/* ============================================================
   style-41-next-service.css — FEAT-161 Next Service standalone page
   Prefix: .ns-*
   ============================================================ */

/* ── Page shell ────────────────────────────────────────────── */
.ns-page {
    padding: 20px 24px;
    min-height: 100vh;
    font-family: inherit;
}

/* ── Header ────────────────────────────────────────────────── */
.ns-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}
.ns-header-left  { display: flex; flex-direction: column; gap: 4px; }
.ns-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

.ns-page-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}
body[data-theme="dark"]  .ns-page-title { color: #e8edf3; }
body[data-theme="light"] .ns-page-title { color: #1a1f2e; }

.ns-page-subtitle {
    font-size: 0.8rem;
    opacity: 0.6;
}

.ns-as-of {
    font-size: 0.78rem;
    opacity: 0.65;
}

.ns-refresh-btn {
    padding: 6px 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    transition: background 0.15s;
}
body[data-theme="dark"]  .ns-refresh-btn { background: #2e3447; color: #c8d4e8; }
body[data-theme="light"] .ns-refresh-btn { background: #e8ecf2; color: #2a3245; }
.ns-refresh-btn:hover { opacity: 0.82; }

/* ── Content area ──────────────────────────────────────────── */
.ns-content {
    margin-top: 4px;
}

.ns-tables-area {
    margin-top: 4px;
}

/* ── Clickable cards ───────────────────────────────────────── */
.ns-card-clickable {
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.ns-card-clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}
.ns-card-active {
    border-color: #4a9eff !important;
    box-shadow: 0 0 0 2px rgba(74,158,255,0.35);
}
body[data-theme="light"] .ns-card-active {
    border-color: #2a7de1 !important;
    box-shadow: 0 0 0 2px rgba(42,125,225,0.25);
}

/* ── PnL Group filter row (always visible) ─────────────────── */
.ns-pnl-filter-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 10px;
}
.ns-pnl-filter-label {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    color: #8b9ab1;
}
.ns-pnl-filter-dd {
    min-width: 220px;
    max-width: 380px;
    flex: 0 0 auto;
    font-size: 0.82rem;
}
.svc-ns-pnl-unassigned { color: #6b7280; }
body[data-theme="light"] .svc-ns-pnl-unassigned { color: #9aa3b5; }

/* ── Hide-already-booked toggle (FEAT-294) ─────────────────── */
.ns-hide-booked-toggle {
    margin-left: auto;
    font-size: 0.82rem;
    flex-shrink: 0;
}
.ns-hide-booked-toggle label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}
body[data-theme="dark"]  .ns-hide-booked-toggle label { color: #c8d4e8; }
body[data-theme="light"] .ns-hide-booked-toggle label { color: #2a3245; }
@media (max-width: 430px) { .ns-hide-booked-toggle { margin-left: 0; } }

/* ── Filter bar (show-all affordance) ──────────────────────── */
.ns-filter-bar {
    margin: 0 0 12px;
    align-items: center;
    gap: 8px;
}

.ns-show-all-btn {
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(74,158,255,0.5);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 500;
    transition: background 0.15s;
}
body[data-theme="dark"]  .ns-show-all-btn { background: rgba(74,158,255,0.12); color: #4a9eff; }
body[data-theme="light"] .ns-show-all-btn { background: rgba(42,125,225,0.08); color: #2a7de1; border-color: rgba(42,125,225,0.4); }
.ns-show-all-btn:hover { opacity: 0.8; }

/* ── Tabs ──────────────────────────────────────────────────── */
.ns-tabs {
    margin-top: 4px;
}

.ns-tab {
    background: #1e2537 !important;
    color: #9aa3b5 !important;
    border: 1px solid #2d3548 !important;
    border-radius: 4px 4px 0 0 !important;
    padding: 8px 20px !important;
}

.ns-tab--selected {
    background: #252b3b !important;
    color: #e8eaf0 !important;
    border-bottom-color: #252b3b !important;
    font-weight: 600 !important;
}

body[data-theme="light"] .ns-tab {
    background: #f0f2f5 !important;
    color: #6b7280 !important;
    border-color: #d1d5db !important;
}

body[data-theme="light"] .ns-tab--selected {
    background: #ffffff !important;
    color: #1a202c !important;
    border-bottom-color: #ffffff !important;
}

/* ── Trends tab ────────────────────────────────────────────── */
.ns-trend-container {
    padding: 16px 0 8px;
}

.ns-trend-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.ns-trend-label {
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0.75;
}

.ns-trend-dropdown {
    min-width: 240px;
    max-width: 340px;
}

.ns-trend-caption {
    font-size: 0.78rem;
    opacity: 0.55;
    margin-bottom: 12px;
}

.ns-trend-charts-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ns-trend-chart-block {
    border-radius: 6px;
    padding: 12px 14px 6px;
}
body[data-theme="dark"]  .ns-trend-chart-block { background: #1a2035; }
body[data-theme="light"] .ns-trend-chart-block { background: #f7f9fc; border: 1px solid #e5e8ef; }

.ns-trend-chart-title {
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 4px;
    opacity: 0.8;
}

.ns-trend-graph {
    width: 100%;
}

.ns-trend-empty {
    padding: 48px 0;
    text-align: center;
    font-size: 0.88rem;
    opacity: 0.55;
}

/* ── Branch count drill buttons (FEAT-210) ─────────────────── */
.ns-branch-count-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.12s, opacity 0.12s;
    line-height: 1;
}
.ns-branch-count-btn:hover {
    opacity: 0.75;
}
body[data-theme="dark"]  .ns-branch-count-btn { color: inherit; }
body[data-theme="dark"]  .ns-branch-count-btn:hover { background: rgba(255,255,255,0.07); }
body[data-theme="light"] .ns-branch-count-btn { color: inherit; }
body[data-theme="light"] .ns-branch-count-btn:hover { background: rgba(0,0,0,0.06); }

/* ── Branch drill panel ─────────────────────────────────────── */
.ns-branch-drill-panel {
    margin-bottom: 6px;
}

/* ── Expiry drill panel (FEAT-211) — inherits drill-section styles ── */
.ns-expiry-drill-panel {
    margin-top: 8px;
}

.ns-branch-drill-section {
    border-radius: 6px;
    padding: 12px 14px 10px;
    margin-bottom: 12px;
}
body[data-theme="dark"]  .ns-branch-drill-section { background: #1a2035; border: 1px solid #2d3e5a; }
body[data-theme="light"] .ns-branch-drill-section { background: #f0f5ff; border: 1px solid #c8d6ee; }

.ns-branch-drill-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.ns-branch-drill-title {
    font-size: 0.85rem;
    font-weight: 600;
    flex: 1;
}
body[data-theme="dark"]  .ns-branch-drill-title { color: #c8d4e8; }
body[data-theme="light"] .ns-branch-drill-title { color: #1a2a4a; }

.ns-branch-drill-count {
    font-size: 0.78rem;
    opacity: 0.65;
    white-space: nowrap;
}

.ns-branch-drill-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
    opacity: 0.55;
    transition: opacity 0.12s;
    margin-left: auto;
}
.ns-branch-drill-close-btn:hover { opacity: 1; }
body[data-theme="dark"]  .ns-branch-drill-close-btn { color: #c8d4e8; }
body[data-theme="light"] .ns-branch-drill-close-btn { color: #1a2a4a; }

/* ── Export buttons ────────────────────────────────────────── */
.ns-export-btn {
    padding: 5px 11px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.12);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 500;
    transition: background 0.15s;
}
body[data-theme="dark"]  .ns-export-btn { background: #2a3245; color: #c8d4e8; }
body[data-theme="light"] .ns-export-btn { background: #e8ecf2; color: #2a3245; border-color: rgba(0,0,0,0.12); }
.ns-export-btn:hover { opacity: 0.82; }

/* ── BUG-313: mobile header button wrap (@390px) ───────────── */
@media (max-width: 430px) {
    .ns-page { padding: 14px 12px; }
    .ns-header-right { flex-shrink: 1; width: 100%; justify-content: flex-start; }
    .ns-as-of { width: 100%; }
}

/* ═══════════════════════════════════════════════════════════════
   FEAT-215: Executive Layer — KPI cards + Group Health league
   ═══════════════════════════════════════════════════════════════ */

/* ── Executive layer container ─────────────────────────────── */
.ns-exec-layer { margin-bottom: 20px; }
.ns-exec-layer-inner { display: flex; flex-direction: column; gap: 16px; }
.ns-exec-section-title {
    font-size: 0.82rem;
    font-weight: 600;
    opacity: 0.75;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── KPI card row ──────────────────────────────────────────── */
.ns-exec-kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.ns-exec-kpi-card {
    border-radius: 6px;
    padding: 12px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
body[data-theme="dark"]  .ns-exec-kpi-card { background: #1a2035; border: 1px solid #2d3548; }
body[data-theme="light"] .ns-exec-kpi-card { background: #f7f9fc; border: 1px solid #e5e8ef; }

.ns-exec-kpi-top {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.ns-exec-kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}
body[data-theme="dark"]  .ns-exec-kpi-value { color: #e8edf3; }
body[data-theme="light"] .ns-exec-kpi-value { color: #1a1f2e; }

.ns-exec-kpi-label {
    font-size: 0.75rem;
    font-weight: 500;
    opacity: 0.6;
    white-space: nowrap;
}

.ns-exec-kpi-sparkline {
    margin-top: 2px;
    height: 40px;
    overflow: hidden;
}

/* ── Delta chip ─────────────────────────────────────────────── */
.ns-delta-chip {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 10px;
    white-space: nowrap;
}
.ns-delta-good    { background: rgba(39,174,96,0.18);  color: #27ae60; }
.ns-delta-bad     { background: rgba(231,76,60,0.18);  color: #e74c3c; }
.ns-delta-neutral { background: rgba(128,128,128,0.15); color: inherit; opacity: 0.6; }
body[data-theme="light"] .ns-delta-good    { background: rgba(39,174,96,0.12);  color: #1e8449; }
body[data-theme="light"] .ns-delta-bad     { background: rgba(231,76,60,0.12);  color: #c0392b; }

/* ── Group Health league table ─────────────────────────────── */
.ns-exec-league-section { }

.ns-league-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.ns-league-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    table-layout: auto;
}

.ns-league-th {
    font-size: 0.75rem;
    font-weight: 600;
    text-align: left;
    padding: 6px 10px;
    white-space: nowrap;
    opacity: 0.65;
    border-bottom-width: 1px;
    border-bottom-style: solid;
}
body[data-theme="dark"]  .ns-league-th { border-bottom-color: #2d3548; }
body[data-theme="light"] .ns-league-th { border-bottom-color: #e0e4ed; }

.ns-league-th.ns-league-num,
.ns-league-td.ns-league-num { text-align: right; }

.ns-league-td {
    padding: 7px 10px;
    vertical-align: middle;
    border-bottom-width: 1px;
    border-bottom-style: solid;
}
body[data-theme="dark"]  .ns-league-td { border-bottom-color: #212840; }
body[data-theme="light"] .ns-league-td { border-bottom-color: #eef0f5; }

.ns-league-group { font-weight: 500; }
body[data-theme="dark"]  .ns-league-group { color: #c8d4e8; }
body[data-theme="light"] .ns-league-group { color: #1a2a4a; }

/* Clickable rows */
.ns-league-tr {
    cursor: pointer;
    transition: background 0.1s;
}
.ns-league-tr:hover td {
    background: rgba(74,158,255,0.06);
}
body[data-theme="light"] .ns-league-tr:hover td {
    background: rgba(42,125,225,0.05);
}

/* Currently-selected row */
.ns-league-tr--selected td {
    background: rgba(74,158,255,0.1);
}
body[data-theme="light"] .ns-league-tr--selected td {
    background: rgba(42,125,225,0.08);
}

/* Due≤7 drill button */
.ns-league-due7-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    color: #f39c12;
    transition: background 0.12s;
    line-height: 1;
}
.ns-league-due7-btn:hover {
    background: rgba(243,156,18,0.15);
}
body[data-theme="light"] .ns-league-due7-btn { color: #d68910; }

/* ── Status pills ────────────────────────────────────────────── */
.ns-status-pill {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}
.ns-status-worsening { background: rgba(231,76,60,0.18);  color: #e74c3c; }
.ns-status-improving { background: rgba(39,174,96,0.18);  color: #27ae60; }
.ns-status-stable    { background: rgba(128,128,128,0.15); color: inherit; opacity: 0.7; }
body[data-theme="light"] .ns-status-worsening { background: rgba(231,76,60,0.12);  color: #c0392b; }
body[data-theme="light"] .ns-status-improving { background: rgba(39,174,96,0.12);  color: #1e8449; }

/* ── Mobile: KPI cards 2×2 + league table scroll (@430px) ─── */
@media (max-width: 430px) {
    .ns-exec-kpi-row { grid-template-columns: repeat(2, 1fr); }
    .ns-league-table-wrapper { overflow-x: auto; }
}

/* FEAT-293-P4b: Fitness filter + column chip ───────────────────────────────── */
.ns-fitness-filter-dd {
    min-width: 130px;
    max-width: 160px;
}
.ns-fitness-chip {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 9px;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.ns-fitness-chip--allow  { background: #d1fae5; color: #065f46; }
.ns-fitness-chip--warn   { background: #fff7ed; color: #c2410c; }
.ns-fitness-chip--block  { background: #fee2e2; color: #991b1b; }
.ns-fitness-chip--nodata { background: #f3f4f6; color: #6b7280; }

body[data-theme="dark"] .ns-fitness-chip--allow  { background: #064e3b; color: #6ee7b7; }
body[data-theme="dark"] .ns-fitness-chip--warn   { background: #431407; color: #fdba74; }
body[data-theme="dark"] .ns-fitness-chip--block  { background: #450a0a; color: #fca5a5; }
body[data-theme="dark"] .ns-fitness-chip--nodata { background: #1f2937; color: #9ca3af; }
