/*
 * systech.css
 * -----------
 * Systech Digital design system for the reporting app (see STYLEGUIDE.md).
 * Loaded after Bootstrap 5.1 by app/Views/template.php, so it restyles the
 * Bootstrap and DataTables components the views already use. Visual only:
 * no class here is selected on by JavaScript.
 */

/* ── Fonts (self-hosted so exports render in Poppins too) ───────────────── */
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/poppins-latin-400.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/poppins-latin-500.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/poppins-latin-600.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/poppins-latin-700.woff2') format('woff2'); }

/* ── 2. Tokens ──────────────────────────────────────────────────────────── */
:root {
  /* Brand */
  --brand-blue:   #456BFF;
  --brand-red:    #F44E42;
  --brand-green:  #15A85E;
  --brand-amber:  #E0A100;
  --brand-black:  #000000;

  /* Primary (interactive) */
  --primary:          #3D5CE0;
  --primary-hover:    #2F4BD9;
  --primary-text:     #2F55E6;
  --primary-tint-50:  #F7F8FF;
  --primary-tint-100: #EEF1FF;
  --primary-tint-200: #C9D3FF;
  --primary-on-tint:  #2F4BD9;

  /* Neutrals */
  --bg:             #F8FAFC;
  --surface:        #FFFFFF;
  --surface-subtle: #F8FAFC;
  --surface-sunken: #F1F5F9;
  --surface-hover:  #F3F5FA;
  --border:         #E2E8F0;
  --border-subtle:  #F1F5F9;

  --text-heading:   #000000;
  --text:           #111111;
  --text-secondary: #475569;
  --text-muted:     #64748B;
  --text-faint:     #94A3B8;

  /* Semantic */
  --success-text: #0F7F48;   --success-bg: #F0FDF4;  --success-border: #BBF7D0;
  --danger-text:  #C9372C;   --danger-bg:  #FEF2F2;  --danger-border:  #FECACA;  --danger-hover-bg: #FEE2E2;
  --warning-text: #B45309;   --warning-bg: #FFFBEB;  --warning-border: #FDE68A;  --warning-strong: #92400E;
  --info-text:    #2F4BD9;   --info-bg:    #EEF1FF;  --info-border:    #C9D3FF;

  /* Typography */
  --font-sans: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Fira Mono', ui-monospace, monospace;
  --fs-2xs: 10px; --fs-xs: 11px; --fs-sm: 12px; --fs-base: 13px;
  --fs-md: 14px;  --fs-lg: 16px; --fs-xl: 20px; --fs-2xl: 22px;
  --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700;
  --tracking-tight: -0.02em;
  --tracking-caps:   0.05em;

  /* Spacing */
  --sp-1: 2px; --sp-2: 4px; --sp-3: 6px; --sp-4: 8px; --sp-5: 10px; --sp-6: 12px;
  --sp-7: 14px; --sp-8: 16px; --sp-10: 20px; --sp-12: 24px; --sp-16: 32px;

  /* Radius */
  --r-xs: 4px; --r-sm: 6px; --r-md: 8px; --r-lg: 10px; --r-xl: 12px; --r-2xl: 16px; --r-full: 999px;

  /* Elevation */
  --shadow-xs:  0 1px 3px rgba(15, 23, 42, .08);
  --shadow-sm:  0 4px 14px rgba(15, 23, 42, .08);
  --shadow-md:  0 12px 32px rgba(15, 23, 42, .14);
  --shadow-lg:  0 16px 48px rgba(15, 23, 42, .18);
  --focus-ring: 0 0 0 3px var(--primary-tint-100);
  --overlay:    rgba(15, 23, 42, .45);

  /* Motion */
  --dur-fast: 120ms; --dur-base: 150ms; --dur-slow: 300ms; --ease: ease;

  /* Layout */
  --nav-h: 52px;
  --container: 1300px;
  --container-wide: 1440px;
  --container-xwide: 1840px;
  --gutter: 16px;

  /* Z-index */
  --z-sticky: 50; --z-nav: 100; --z-dropdown: 500; --z-overlay: 1000; --z-toast: 9999;

  /* Chart surface */
  --chart-muted: #6B7280;
  --chart-grid:  #F0F1F5;

  /* Bootstrap hooks */
  --bs-body-font-family: var(--font-sans);
  --bs-body-color: var(--text);
  --bs-body-bg: var(--bg);
  --bs-font-sans-serif: var(--font-sans);
  --bs-primary: var(--primary);
  --bs-primary-rgb: 61, 92, 224;
}

@media (max-width: 600px) { :root { --gutter: 10px; } }

/* ── 3. Base layer ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: var(--font-sans); font-size: var(--fs-md); line-height: 1.5;
  color: var(--text); background: var(--bg); min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 2px; }
::selection { background: var(--primary-tint-100); }
a { color: var(--primary-text); }
a:hover { color: var(--primary-hover); }
h1, h2, h3, h4, h5, h6 { color: var(--text-heading); font-weight: var(--fw-bold); }
code { font-family: var(--font-mono); font-size: .92em; color: var(--text); background: var(--surface-sunken); padding: 1px 5px; border-radius: var(--r-xs); }
pre { font-family: var(--font-mono); font-size: var(--fs-sm); }
hr { border-color: var(--border); opacity: 1; }
.text-muted { color: var(--text-muted) !important; }
.text-success { color: var(--success-text) !important; }
.text-danger { color: var(--danger-text) !important; }
.text-warning { color: var(--warning-text) !important; }
.text-secondary { color: var(--text-secondary) !important; }
small, .small { font-size: var(--fs-sm); }
.num, .table td, .table th { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── 4.1 App shell ──────────────────────────────────────────────────────── */
/* Main navigation is a side menu (4.4 applied to the whole app). */
.app-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.app-sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: var(--z-nav);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 16px; padding: 16px 10px 12px;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 6px 4px; }
/* Mobile-only top bar controls (scoped so the later .btn display doesn't win). */
.sidebar-head .sidebar-toggle, .sidebar-head .sidebar-profile { display: none; }
.sidebar-menu { flex: 1 0 auto; display: flex; flex-direction: column; gap: 16px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-label {
  font-size: var(--fs-2xs); font-weight: var(--fw-semibold); text-transform: uppercase;
  letter-spacing: var(--tracking-caps); color: var(--text-muted); padding: 0 11px 6px;
}
.side-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: var(--r-md);
  color: var(--text-secondary); text-decoration: none; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.side-item svg { width: 17px; height: 17px; flex-shrink: 0; color: var(--text-muted); transition: color var(--dur-fast) var(--ease); }
.side-label { font-size: var(--fs-base); font-weight: var(--fw-medium); color: inherit; line-height: 1.4; }
.side-item:hover { background: #F5F6FA; color: var(--text); }
.side-item:hover svg { color: var(--text); }
.side-item.active { background: var(--primary-tint-100); color: var(--primary-text); }
.side-item.active svg { color: var(--primary-text); }
.side-item.active .side-label { font-weight: var(--fw-semibold); }
.side-item-compact { padding: 7px 11px; }

/* Settings: one item that expands in place (Bootstrap collapse). */
.side-toggle { width: 100%; border: 0; background: transparent; text-align: left; font: inherit; cursor: pointer; }
.side-toggle.has-active, .side-toggle.has-active svg { color: var(--text); }
.side-chevron { margin-left: auto; display: inline-flex; transition: transform var(--dur-base) var(--ease); }
.side-chevron svg { width: 14px; height: 14px; }
.side-toggle[aria-expanded="true"] .side-chevron { transform: rotate(180deg); }
.side-sub { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 4px 19px; padding-left: 8px; border-left: 1px solid var(--border); }
.side-sub .side-item { padding: 6px 10px; }
.side-sub .side-item svg { width: 16px; height: 16px; }
.side-item-danger, .side-item-danger svg { color: var(--danger-text); }
.side-item-danger:hover { background: var(--danger-bg); color: var(--danger-text); }
.side-item-danger:hover svg { color: var(--danger-text); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 4px 11px 8px; min-width: 0; }
.sidebar-user-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sidebar-user-text > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 32px; height: 32px; border-radius: var(--r-full); flex-shrink: 0;
  background: var(--primary); color: #fff; font-size: var(--fs-base); font-weight: var(--fw-bold);
  display: inline-flex; align-items: center; justify-content: center;
}

.app-main {
  width: 100%; max-width: var(--container-wide); margin: 0 auto; padding: 20px var(--gutter) var(--gutter);
  display: flex; flex-direction: column; gap: 14px; min-width: 0;
}
.app-main > .row { margin: 0; }
.app-main > .row > div { padding: 0; }
.app-main .col-12 { display: flex; flex-direction: column; gap: 14px; padding: 0; }

/* Start screen: shown until a service or operator is picked (5.21). */
.start-screen { flex: 1; min-height: calc(100vh - 40px); display: flex; align-items: center; justify-content: center; padding: 24px 0; }
.start-card {
  width: 100%; max-width: 760px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-2xl);
  padding: 32px 28px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
}
.start-icon {
  width: 44px; height: 44px; border-radius: var(--r-full); background: var(--primary-tint-100); color: var(--primary-text);
  display: inline-flex; align-items: center; justify-content: center; margin-bottom: 4px;
}
.start-title { font-size: var(--fs-xl); font-weight: var(--fw-bold); letter-spacing: var(--tracking-tight); color: var(--text-heading); margin: 0; }
.start-text { font-size: var(--fs-base); color: var(--text-muted); margin: 0 0 12px; max-width: 460px; }
.start-card .op-picker, .start-card .svc-picker { justify-content: center; margin: 0; }
.start-card .svc-group { text-align: left; }
/* Start screen keeps the two columns (operator | services) inside the card. */
.start-card .svc-picker-split {
  width: 100%; margin-top: 4px; text-align: left; background: var(--bg);
  justify-content: flex-start; padding: 14px 16px 16px;
}
.start-card .picker-svcs { flex-basis: 260px; }
.start-card .picker-svcs .svc-pills { min-height: 30px; }
.start-card .op-pill { padding: 9px 16px; font-size: var(--fs-base); }
@media (max-width: 900px) { .start-screen { min-height: calc(100vh - 140px); } }
@media (max-width: 600px) { .start-card { padding: 24px 16px; } }

/* Report cards were 70% wide; they now share one centred container. */
.align-center { width: 100%; max-width: var(--container); margin-left: auto; margin-right: auto; }
.page-wide .align-center { max-width: var(--container-wide); }

/* ≤ 900px: the side menu becomes a sticky top bar: menu button · logo · avatar.
   The menu button drops the report links as a panel; the avatar opens a
   dropdown with the user, settings pages, My Account and Logout. */
@media (max-width: 900px) {
  .app-shell { display: block; }
  .app-sidebar {
    height: auto; overflow: visible; gap: 0;
    padding: 8px var(--gutter); border-right: 0; border-bottom: 1px solid var(--border);
  }
  .sidebar-head { padding: 0; min-height: 40px; justify-content: flex-start; }
  .sidebar-head .logo { margin-right: auto; }
  .sidebar-head .sidebar-profile { display: block; }
  .sidebar-head .sidebar-toggle { display: inline-flex; margin-left: -8px; border-color: transparent; background: transparent; }
  .sidebar-toggle:hover { background: var(--surface-sunken); border-color: transparent; }
  .sidebar-toggle-close, .app-sidebar.is-open .sidebar-toggle-open { display: none; }
  .app-sidebar.is-open .sidebar-toggle-close { display: inline-flex; }
  .sidebar-toggle svg { width: 20px; height: 20px; }

  .sidebar-menu {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    max-height: calc(100vh - 57px); max-height: calc(100dvh - 57px); overflow-y: auto; overscroll-behavior: contain;
    background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-md);
    padding: 12px var(--gutter) 16px; gap: 12px;
  }
  .app-sidebar.is-open .sidebar-menu { display: flex; }
  .sidebar-menu .side-item { padding: 11px 11px; }
  .sidebar-foot { display: none; }
  .sidebar-profile .dropdown-item { padding: 10px 10px; }
  body.nav-open { overflow: hidden; }
  .app-main { padding-top: var(--gutter); }
}

/* ── 5.24 Logo ──────────────────────────────────────────────────────────── */
.logo { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; }
.logo:hover { text-decoration: none; }
.logo-mark { width: 28px; height: 28px; object-fit: contain; display: block; }
.logo-name { font-size: 17px; font-weight: var(--fw-bold); color: var(--text-heading); letter-spacing: -.01em; line-height: 1; white-space: nowrap; }
.logo-stacked { flex-direction: column; gap: 12px; }
.logo-stacked .logo-mark { width: 40px; height: 40px; }
.logo-stacked .logo-name { font-size: var(--fs-2xl); }

/* ── 5.22 Avatar + 5.12 user menu ───────────────────────────────────────── */
.avatar-btn {
  width: 32px; height: 32px; border-radius: var(--r-full); border: 0; padding: 0;
  background: var(--primary); color: #fff; font-size: var(--fs-base); font-weight: var(--fw-bold);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.avatar-btn:hover, .avatar-btn[aria-expanded="true"] { background: var(--primary-hover); }
.avatar-btn.active { box-shadow: 0 0 0 3px var(--primary-tint-200); }

.dropdown-menu {
  --bs-dropdown-min-width: 200px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-md); padding: 6px; min-width: 200px; font-size: var(--fs-base);
  z-index: var(--z-dropdown); margin-top: 6px !important;
}
.dropdown-item {
  display: flex; align-items: center; gap: 9px; border-radius: var(--r-md);
  padding: 7px 10px; font-size: var(--fs-base); color: var(--text);
  transition: background var(--dur-fast) var(--ease);
}
.dropdown-item svg { width: 16px; height: 16px; color: var(--primary-text); flex-shrink: 0; }
.dropdown-item:hover, .dropdown-item:focus-visible { background: var(--surface-hover); color: var(--text); }
.dropdown-item.active, .dropdown-item:active { background: var(--primary-tint-100); color: var(--primary-text); font-weight: var(--fw-semibold); }
.dropdown-item.item-danger, .dropdown-item.item-danger svg { color: var(--danger-text); }
.dropdown-item.item-danger:hover { background: var(--danger-bg); }
.dropdown-divider { border-top-color: var(--border); margin: 4px 0; opacity: 1; }
.dropdown-header { padding: 6px 10px 3px; }
.menu-user { padding: 6px 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.menu-user-name { font-size: var(--fs-base); font-weight: var(--fw-semibold); color: var(--text-heading); }
.menu-user-role, .micro-label {
  font-size: var(--fs-2xs); font-weight: var(--fw-semibold); text-transform: uppercase;
  letter-spacing: var(--tracking-caps); color: var(--text-muted);
}

/* ── 5.3 Chips (range, operator and service pickers) ────────────────────── */
.picker-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.op-picker, .svc-picker {
  max-width: var(--container); width: 100%; margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px;
}
.svc-picker { gap: 10px; }
.svc-group {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 6px;
}
.svc-group-label {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--fs-2xs); font-weight: var(--fw-semibold); text-transform: uppercase;
  letter-spacing: var(--tracking-caps); color: var(--text-muted);
}
.svc-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.svc-pills[hidden] { display: none; }

/* Two-step service filter: operator (left) → its services (right); wraps when narrow. */
.svc-picker-split {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 10px 14px 12px; gap: 10px 0; align-items: stretch; flex-wrap: wrap;
}
.picker-part { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.picker-ops { flex: 0 0 auto; padding-right: 28px; }
.picker-svcs { flex: 1 1 320px; padding-left: 28px; margin-left: -1px; border-left: 1px solid var(--border); }
/* Once the services wrap under the operators there is no column to divide. */
@media (max-width: 600px) { .picker-svcs { padding-left: 0; margin-left: 0; border-left: 0; } }
button.op-pill { cursor: pointer; font-family: inherit; }

.op-pill, .svc-pill, .range-pill {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  padding: 6px 10px; border-radius: var(--r-full);
  border: 1px solid var(--border); background: var(--surface);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); line-height: 1.2; color: var(--text-muted); text-decoration: none;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-base) var(--ease), color var(--dur-fast) var(--ease);
}
.op-pill:hover, .svc-pill:hover, .range-pill:hover {
  color: var(--primary-text); border-color: var(--primary-tint-200); background: var(--primary-tint-100);
}
.op-pill.active, .svc-pill.active, .range-pill.active {
  background: var(--primary-tint-100); border-color: var(--primary-tint-200);
  color: var(--primary-on-tint); font-weight: var(--fw-semibold);
}
/* Tick on the selected operator and service (outline check, same style as the icon set). */
.op-pill.active::after, .svc-pill.active::after {
  content: ""; width: 12px; height: 12px; flex-shrink: 0; margin-left: 1px; background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M20 6 9 17l-5-5'/%3e%3c/svg%3e") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M20 6 9 17l-5-5'/%3e%3c/svg%3e") center / contain no-repeat;
}
.dot, .op-pill .dot, .svc-group-label .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.legacy-links { max-width: var(--container); width: 100%; margin: 0 auto; font-size: var(--fs-base); }
@media (pointer: coarse) { .op-pill, .svc-pill, .range-pill { padding: 10px 12px; } }

/* ── 5.8 Card ───────────────────────────────────────────────────────────── */
.card {
  --bs-card-border-color: var(--border);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  overflow: hidden; box-shadow: none;
}
.app-main .card.mb-4 { margin-bottom: 0 !important; }
.card-header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 12px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
}
.card-header:first-child { border-radius: 0; }
.card:not(:has(.card-body)) > .card-header { border-bottom: 0; }
.card-header > * { float: none !important; margin: 0 !important; }
.card-header > div[style*="clear"] { display: none; }
.card-header > .card-title { margin-right: auto !important; }
.card-header .chart-toggle { order: 2; }
.card-header .report-export { order: 3; } /* Export sits at the far right, after Table | Graph */
.card-header:has(> .picker-bar) > .card-title { margin-right: 6px !important; }
.card-header > .picker-bar { margin-right: auto !important; }
.card-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 10px 16px; background: var(--primary-tint-50); border-bottom: 1px solid var(--border);
}

/* 5.20 Spinner */
.spinner {
  display: inline-block; width: 13px; height: 13px; vertical-align: middle;
  border: 2px solid var(--border); border-top-color: var(--brand-blue); border-radius: 50%;
  animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.card-title, .card-header h5 {
  font-size: var(--fs-base); font-weight: var(--fw-bold); color: var(--text-heading);
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px; line-height: 1.4;
}
.card-title b { font-weight: inherit; }
.card-title > i.fas { display: none; }
.card-title small, .card-header small { font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--text-muted); }
.card-body { padding: 14px 16px; }
.card-body > .table-responsive:only-child, .card-body > .chart-table-view > .table-responsive { margin: -14px -16px; width: auto; }
.card-body > .chart-table-view > .table-responsive .dt-container { padding: 12px 16px; }
@media (max-width: 600px) {
  .card-body { padding: 10px 12px; }
  .card-body > .table-responsive:only-child, .card-body > .chart-table-view > .table-responsive { margin: -10px -12px; }
}
.page-title-card .card-title { font-size: var(--fs-lg); letter-spacing: var(--tracking-tight); }

/* ── 5.1 Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 6px 12px; min-height: 32px; border-radius: var(--r-md);
  font-size: var(--fs-base); font-weight: var(--fw-medium); line-height: 1.4;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  box-shadow: none !important;
  transition: background var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease), color var(--dur-base) var(--ease);
}
.btn .me-1, .btn .me-2 { margin-right: 0 !important; }
.btn:hover { background: var(--surface-sunken); border-color: var(--border); color: var(--text); }
.btn:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 2px; }
.btn:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: auto; }
.btn:disabled:hover { background: var(--surface); }

.btn-secondary, .btn-outline-secondary, .btn-default, .btn-light, .btn-warning, .btn-outline-primary {
  background: var(--surface); border-color: var(--border); color: var(--text);
}
.btn-secondary:hover, .btn-outline-secondary:hover, .btn-default:hover, .btn-light:hover, .btn-warning:hover, .btn-outline-primary:hover,
.btn-outline-secondary:active, .btn-outline-secondary.active {
  background: var(--surface-sunken); border-color: var(--border); color: var(--text);
}

.btn-primary, .btn-success { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover, .btn-success:hover, .btn-primary:active, .btn-success:active,
.btn-primary:focus, .btn-success:focus { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-primary:disabled:hover, .btn-success:disabled:hover { background: var(--primary); }

.btn-danger, .btn-outline-danger { background: var(--surface); border-color: var(--danger-border); color: var(--danger-text); }
.btn-danger:hover, .btn-outline-danger:hover, .btn-danger:active { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.btn-danger:disabled:hover { background: var(--surface); }
/* Filled red only for the confirm button inside a delete dialog. */
.btn-danger-solid { background: var(--danger-text); border-color: var(--danger-text); color: #fff; }
.btn-danger-solid:hover { background: #B42F25; border-color: #B42F25; color: #fff; }

.btn-sm { padding: 4px 10px; min-height: 28px; font-size: var(--fs-sm); border-radius: var(--r-md); }
.btn-icon { width: 32px; height: 32px; min-height: 32px; padding: 0; }
.btn-sm.btn-icon { width: 28px; height: 28px; min-height: 28px; }
.btn-icon svg { width: 16px; height: 16px; }
@media (pointer: coarse) { .btn { min-height: 40px; } .btn-sm.btn-icon, .btn-icon { width: 40px; height: 40px; } }
.row-actions { display: inline-flex; gap: 4px; justify-content: center; align-items: center; }
.row-actions form { display: inline-flex; }

/* ── 5.2 Segmented control (Table | Graph) ────────────────────────────── */
.seg { display: inline-flex; align-items: center; gap: 3px; padding: 3px; background: var(--surface-sunken); border-radius: var(--r-md); }
.seg-item {
  display: inline-flex; align-items: center; gap: 5px; border: 0; background: transparent; cursor: pointer;
  padding: 3px 10px; min-height: 24px; border-radius: var(--r-sm);
  font-family: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-secondary);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.seg-item svg { width: 14px; height: 14px; }
.seg-item:hover { background: rgba(255, 255, 255, .7); color: var(--text); }
.seg-item.active { background: var(--surface); color: var(--primary-text); font-weight: var(--fw-semibold); box-shadow: var(--shadow-xs); }
.seg-item:disabled { opacity: .4; cursor: not-allowed; }
@media (max-width: 600px) { .seg-item { padding: 4px 7px; font-size: var(--fs-2xs); } }
@media (pointer: coarse) { .seg-item { min-height: 34px; } }

/* ── 5.6 Form fields ────────────────────────────────────────────────────── */
.form-label {
  font-size: var(--fs-2xs); font-weight: var(--fw-semibold); text-transform: uppercase;
  letter-spacing: var(--tracking-caps); color: var(--text-muted); margin-bottom: 5px;
}
.modal .form-label { font-size: var(--fs-sm); font-weight: var(--fw-medium); text-transform: none; letter-spacing: 0; color: #374151; }
.form-control, .form-select {
  background-color: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 7px 10px; font-size: var(--fs-base); color: var(--text); min-height: 36px;
  transition: border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.form-select {
  padding-right: 32px; background-position: right 10px center; background-size: 12px 12px;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='m6 9 6 6 6-6'/%3e%3c/svg%3e");
}
.form-control-sm, .form-select-sm { padding-top: 5px; padding-bottom: 5px; min-height: 32px; font-size: var(--fs-sm); border-radius: var(--r-md); }
.form-control:focus, .form-select:focus { border-color: var(--brand-blue); box-shadow: var(--focus-ring); outline: none; }
.form-control:disabled, .form-select:disabled, .form-control[readonly] { background-color: var(--surface-subtle); opacity: .6; }
.form-control::placeholder { color: var(--text-faint); }
.modal .form-control, .modal .form-select { padding-top: 9px; padding-bottom: 9px; }
input[type="number"].form-control { text-align: right; }
input[type="date"].form-control { font-size: var(--fs-base); }
.form-text { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 4px; line-height: 1.5; }
.form-check-label { font-size: var(--fs-base); color: var(--text); }
.form-check-input { border-color: #CBD5E1; }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-input:focus { border-color: var(--brand-blue); box-shadow: var(--focus-ring); }
.inline-field { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-muted); }
.inline-field .form-control { width: 90px; min-width: 0; }

/* Filter forms: fields bottom-aligned (4.3). */
.filter-form { align-items: flex-end; }
.filter-form .btn { min-height: 36px; }

/* ── 5.11 Tables ────────────────────────────────────────────────────────── */
.table {
  --bs-table-bg: transparent;
  --bs-table-striped-bg: transparent;
  --bs-table-hover-bg: var(--surface-subtle);
  --bs-table-active-bg: var(--surface-subtle);
  --bs-table-striped-color: var(--text);
  --bs-table-hover-color: var(--text);
  color: var(--text); font-size: var(--fs-base); margin-bottom: 0; border-color: var(--border-subtle);
}
.table > :not(:first-child) { border-top: 0; }
.table > thead > tr > th, .table > tr > th:only-child, .table thead th {
  font-size: var(--fs-2xs); font-weight: var(--fw-semibold); text-transform: uppercase;
  letter-spacing: var(--tracking-caps); color: var(--text-muted);
  background: var(--surface-subtle); border-bottom: 1px solid var(--border);
  padding: 9px 14px; white-space: nowrap; vertical-align: middle;
}
.table > tbody > tr > td, .table > tfoot > tr > td, .table > tr > td { padding: 9px 14px; vertical-align: middle; border-bottom-color: var(--border-subtle); }
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table-sm > :not(caption) > * > * { padding: 7px 12px; }
.table-sm > thead > tr > th { padding: 8px 12px; }
.table-hover > tbody > tr:hover > * { background: var(--surface-subtle); }
.table th .bi { color: var(--text-faint); font-size: 11px; margin-left: 2px; }

/* Numeric report tables: first column is the label, every other column a number. */
.table-num th:not(:first-child), .table-num td:not(:first-child) { text-align: right; }
.table-num td:not(:first-child) { white-space: nowrap; }

/* Totals (subtotal / grand total). */
.table tr.row-subtotal > td { font-weight: var(--fw-semibold); background: #FAFBFC; border-bottom: 2px solid var(--border); }
.table tfoot tr > td, .table tr.row-total > td {
  font-weight: var(--fw-bold); background: var(--surface-sunken); border-top: 2px solid var(--border); border-bottom: 0;
}
.table tr.row-group > td { background: var(--surface-subtle); font-weight: var(--fw-bold); font-size: var(--fs-sm); padding-top: 12px; }
.table tr.row-child > td { background: #FAFBFC; font-size: var(--fs-sm); }
.table tr.row-child > td:first-child { padding-left: 32px; }
.op-cell { display: inline-flex; align-items: center; gap: 7px; }

/* Key/value detail tables (account, audit entry). */
.table-kv > tbody > tr > th, .table-kv > tr > th {
  width: 200px; font-size: var(--fs-2xs); font-weight: var(--fw-semibold); text-transform: uppercase;
  letter-spacing: var(--tracking-caps); color: var(--text-muted); background: transparent; border-bottom: 1px solid var(--border-subtle);
  padding: 10px 14px 10px 0; white-space: nowrap;
}
.table-kv > tbody > tr > td, .table-kv > tr > td { padding: 10px 0; }
.table-kv tr:last-child > * { border-bottom: 0; }
.mono { font-family: var(--font-mono); font-size: var(--fs-sm); }

/* Empty-state row */
.table td.empty-cell { text-align: center; color: var(--text-muted); padding: 24px 14px; }

/* ── DataTables 2 controls ──────────────────────────────────────────────── */
body div.dt-container { font-size: var(--fs-sm); color: var(--text-muted); }
body div.dt-container .dt-layout-row { margin: 0 0 10px; }
body div.dt-container .dt-layout-row.dt-layout-table { margin: 0 -16px; }
body div.dt-container .dt-layout-row:last-child { margin: 10px 0 0; }
body div.dt-container .dt-search input, body div.dt-container .dt-input {
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface);
  padding: 5px 9px; font-size: var(--fs-sm); color: var(--text); min-height: 32px;
}
body div.dt-container .dt-search input:focus, body div.dt-container .dt-input:focus { border-color: var(--brand-blue); box-shadow: var(--focus-ring); outline: none; }
body div.dt-container select.dt-input { padding-right: 24px; }
body div.dt-container .dt-paging .dt-paging-button {
  border: 1px solid transparent !important; border-radius: var(--r-md) !important; background: transparent !important;
  color: var(--text-secondary) !important; padding: 4px 10px !important; min-width: 30px; font-size: var(--fs-sm);
}
body div.dt-container .dt-paging .dt-paging-button:hover { background: var(--surface-sunken) !important; color: var(--text) !important; }
body div.dt-container .dt-paging .dt-paging-button.current, body div.dt-container .dt-paging .dt-paging-button.current:hover {
  background: var(--primary-tint-100) !important; border-color: var(--primary-tint-200) !important;
  color: var(--primary-on-tint) !important; font-weight: var(--fw-semibold);
}
body div.dt-container .dt-paging .dt-paging-button.disabled { opacity: .4; }
body table.dataTable thead > tr > th.dt-orderable-asc:hover, body table.dataTable thead > tr > th.dt-orderable-desc:hover { outline: none; color: var(--text); }
body table.dataTable > thead > tr > th, body table.dataTable > thead > tr > td { border-bottom: 1px solid var(--border) !important; }
body table.dataTable.table-striped > tbody > tr:nth-child(odd) > * { box-shadow: none; }
body table.dataTable > tbody > tr.selected > * { box-shadow: none; }
body table.dataTable.table > tbody > tr > td, body table.dataTable.table > thead > tr > th { padding: 9px 14px; }
body table.dataTable th.dt-type-numeric, body table.dataTable td.dt-type-numeric { text-align: right; }

/* ── 5.9 Stat tiles ─────────────────────────────────────────────────────── */
.ads-tile, .stat-tile {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 12px 14px; height: 100%;
}
.ads-tile .lbl, .stat-tile .lbl {
  font-size: var(--fs-2xs); font-weight: var(--fw-semibold); text-transform: uppercase;
  letter-spacing: var(--tracking-caps); color: var(--text-muted);
}
.ads-tile .val, .stat-tile .val {
  font-size: clamp(17px, 1.6vw, 22px); font-weight: var(--fw-bold); color: var(--text-heading);
  letter-spacing: var(--tracking-tight); font-variant-numeric: tabular-nums; line-height: 1.1;
  overflow-wrap: anywhere; margin-top: 4px;
}
.ads-tile .val small, .stat-tile .val small { font-size: var(--fs-xs) !important; font-weight: var(--fw-medium); letter-spacing: 0; }
.ads-tile .sub, .stat-tile .sub { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.ads-tile .sub .text-success, .ads-tile .sub .text-danger { font-weight: var(--fw-semibold); white-space: nowrap; }
/* Metric colours (2.3) for KPI tiles: --metric = mark (accent, icon),
   --metric-text = a shade of it that passes 4.5:1 for the value. Metrics the
   guide doesn't colour (clicks, CTR, ARPU, ROAS, …) get no class and stay neutral. */
.metric-base  { --metric: #8A5CF6; --metric-text: #7044E8; } /* total subscribers / subscriber base */
.metric-new   { --metric: #456BFF; --metric-text: #2F55E6; } /* new subscribers */
.metric-cpa   { --metric: #456BFF; --metric-text: #2F55E6; }
.metric-churn { --metric: #F44E42; --metric-text: #C9372C; }
.metric-paid  { --metric: #E0A100; --metric-text: #B45309; }
.metric-spend { --metric: #E0A100; --metric-text: #B45309; }
.metric-rev   { --metric: #0F766E; --metric-text: #0F766E; }
.metric-net   { --metric: #E36FB0; --metric-text: #B8357F; }

/* Stat tiles with a metric: 3px top accent + coloured value. */
.stat-tile[class*="metric-"], .ads-tile[class*="metric-"] { position: relative; overflow: hidden; }
.stat-tile[class*="metric-"]::before, .ads-tile[class*="metric-"]::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--metric);
}
.stat-tile[class*="metric-"] .val, .ads-tile[class*="metric-"] .val { color: var(--metric-text); }

/* 5.10 Scoreboard tiles (Today Summary): one per KPI, coloured by metric (2.3). */
.scoreboard { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.score-tile {
  position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-2xl);
  padding: 16px 16px 14px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0;
}
.score-tile::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--metric); }
.score-icon {
  width: 34px; height: 34px; border-radius: var(--r-full); display: inline-flex; align-items: center; justify-content: center;
  color: var(--metric); background: color-mix(in srgb, var(--metric) 12%, #FFFFFF); margin-bottom: 6px;
}
.score-label { font-size: var(--fs-base); font-weight: var(--fw-medium); color: var(--text-secondary); line-height: 1.3; }
.score-value {
  font-size: clamp(20px, 1.9vw, 26px); font-weight: var(--fw-bold); color: var(--metric-text);
  letter-spacing: var(--tracking-tight); line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.score-value small { font-size: var(--fs-xs); font-weight: var(--fw-semibold); letter-spacing: 0; color: var(--text-muted); }
.score-delta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; font-size: var(--fs-xs); margin-top: 2px; }
.score-prev { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.delta { font-weight: var(--fw-semibold); white-space: nowrap; font-variant-numeric: tabular-nums; }
.delta.good { color: var(--success-text); }
.delta.bad  { color: var(--danger-text); }
.delta.flat { color: var(--text-muted); }
/* Change line under a table figure (vs previous day / month / yesterday). */
.cell-delta { display: block; font-size: var(--fs-2xs); line-height: 1.3; margin-top: 1px; }
@media (max-width: 1100px) { .scoreboard { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px)  { .scoreboard { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .score-tile { padding: 14px 12px 12px; } }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat-grid .stat-tile[title] { cursor: help; }
.section-subtitle { font-size: var(--fs-base); font-weight: var(--fw-bold); color: var(--text-heading); margin: 16px 0 8px; }
@media (max-width: 600px) { .ads-tile .val, .stat-tile .val { font-size: 18px; } }

/* ── 5.16 Badges ────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-2xs); font-weight: var(--fw-semibold); line-height: 1.4;
  padding: 2px 8px; border-radius: var(--r-full); white-space: nowrap; letter-spacing: 0;
}
.badge.bg-success { background: #DCFCE7 !important; color: #166534 !important; }
.badge.bg-warning { background: #FEF3C7 !important; color: #92400E !important; }
.badge.bg-danger  { background: var(--danger-bg) !important; color: var(--danger-text) !important; }
.badge.bg-info    { background: var(--info-bg) !important; color: var(--info-text) !important; }
.badge.bg-secondary { background: var(--surface-sunken) !important; color: var(--text-muted) !important; }
.badge.bg-dark    { background: var(--surface-sunken) !important; color: #334155 !important; }
.badge.bg-primary { background: var(--primary-tint-100) !important; color: var(--primary-on-tint) !important; }
.badge.mono, .perm-badge, .audit-action { font-family: var(--font-mono); font-size: var(--fs-2xs); font-weight: var(--fw-medium); }
.perm-badge { margin: 0 4px 4px 0; }
.badge.bg-success::before, .badge.bg-warning::before, .badge.bg-danger::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor;
}
.badge.perm-badge::before { content: none; }

/* ── 5.15 Alerts ────────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--r-md); padding: 12px 16px; font-size: var(--fs-sm); line-height: 1.6;
  border: 1px solid var(--border); max-width: var(--container); width: 100%; margin-left: auto; margin-right: auto;
}
.alert a { color: inherit; text-decoration: underline; }
.alert code { background: rgba(255, 255, 255, .6); color: inherit; }
.alert-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-strong); }
.alert-danger  { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.alert-info    { background: var(--info-bg); border-color: var(--info-border); color: var(--info-text); }
.alert-secondary { background: var(--surface-subtle); border-color: var(--border); color: var(--text-secondary); }
.modal .alert { max-width: none; }

/* ── 5.13 Modal ─────────────────────────────────────────────────────────── */
.modal-backdrop.show { background: var(--overlay); opacity: 1; }
.modal-content {
  background: var(--surface); border: 0; border-radius: var(--r-2xl); box-shadow: var(--shadow-lg);
  padding: 24px 28px; gap: 16px;
}
.modal-header, .modal-body, .modal-footer { padding: 0; border: 0; }
.modal-title { font-size: var(--fs-lg); font-weight: var(--fw-bold); color: var(--text-heading); letter-spacing: var(--tracking-tight); }
.modal-footer { justify-content: flex-end; gap: 8px; }
.modal-footer > * { margin: 0; }
.modal-body hr { margin: 8px 0 16px; }
.btn-close { width: 32px; height: 32px; padding: 0; border-radius: var(--r-md); background-size: 12px; opacity: .55; }
.btn-close:hover { background-color: var(--surface-sunken); opacity: .9; }
.btn-close:focus { box-shadow: none; }
.btn-close:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 2px; }
@media (max-width: 600px) { .modal-content { padding: 20px 18px; } }

/* 5.7 Option cards (role permissions) */
.option-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.option-card {
  display: flex; gap: 8px; align-items: flex-start; margin: 0;
  border: 1px solid var(--border); border-radius: var(--r-md); padding: 7px 9px; cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-base) var(--ease);
}
.option-card .form-check-input { margin: 3px 0 0; flex-shrink: 0; float: none; }
.option-card .form-check-label { cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.option-card code { background: transparent; padding: 0; font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.option-card small { font-size: var(--fs-xs); }
.option-card:has(.form-check-input:checked) { background: var(--primary-tint-100); border-color: var(--primary-tint-200); }
.option-card:has(.form-check-input:disabled) { cursor: not-allowed; }

/* ── Pagination ─────────────────────────────────────────────────────────── */
.pagination { gap: 4px; flex-wrap: wrap; }
.page-link {
  border: 1px solid var(--border) !important; border-radius: var(--r-md) !important; background: var(--surface);
  color: var(--text-secondary); font-size: var(--fs-sm); padding: 4px 10px; min-width: 30px; text-align: center;
}
.page-link:hover { background: var(--surface-sunken); color: var(--text); }
.page-link:focus { box-shadow: var(--focus-ring); }
.page-item.active .page-link { background: var(--primary-tint-100); border-color: var(--primary-tint-200) !important; color: var(--primary-on-tint); font-weight: var(--fw-semibold); }
.page-item.disabled .page-link { opacity: .45; background: var(--surface); }
.table-footer { padding: 12px 16px; border-top: 1px solid var(--border); }

/* ── Code / payload blocks ──────────────────────────────────────────────── */
.code-block {
  background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 12px; overflow-x: auto; font-size: var(--fs-sm); margin: 0;
}

/* ── Charts (6) ─────────────────────────────────────────────────────────── */
.chart-box { position: relative; height: 280px; }
.chart-box + .chart-box { margin-top: 24px; }
.chart-box[hidden] { display: none; }

/* Graph date range (time-series cards): chips + From/To, default year to date. */
.chart-range {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--border);
}
.chart-range .inline-field .form-control { width: 150px; }
.chart-type { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; }
.chart-range-empty { text-align: center; color: var(--text-muted); font-size: var(--fs-base); padding: 24px 0; margin: 0; }
.chart-graph-view canvas, .chart-box canvas { outline: none; }
@media (max-width: 600px) { .chart-box { height: 230px; } }

/* Hour-of-day heatmap */
.heat { border-collapse: separate !important; border-spacing: 2px; }
.heat td, .heat th {
  font-size: var(--fs-2xs); padding: 4px 2px !important; text-align: center; min-width: 26px;
  border: 0 !important; border-radius: 3px; font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums;
}
.heat thead th { background: transparent !important; color: var(--chart-muted); font-weight: var(--fw-medium); text-transform: none; letter-spacing: 0; }
.heat th:first-child, .heat td:first-child { text-align: left; min-width: 36px; font-weight: var(--fw-medium); color: var(--text-secondary); background: transparent; }

/* Back link */
.back-link {
  display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-base); font-weight: var(--fw-medium);
  text-decoration: none; max-width: var(--container); width: 100%; margin: 0 auto;
}
.back-link svg { width: 15px; height: 15px; }
.meta-line { font-size: var(--fs-sm); color: var(--text-muted); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.meta-line b { color: var(--text); font-weight: var(--fw-semibold); }

/* ── 5.23 Login ─────────────────────────────────────────────────────────── */
.login-page { background: var(--surface-sunken); display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border-radius: var(--r-2xl);
  box-shadow: var(--shadow-sm); padding: 36px 32px; display: flex; flex-direction: column; gap: 18px;
}
.login-card .logo { align-self: center; }
.login-card h2 { font-size: var(--fs-lg); text-align: center; margin: 0; letter-spacing: var(--tracking-tight); color: var(--text-heading); }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form .field { display: flex; flex-direction: column; gap: 5px; }
.login-form label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: #374151; }
.login-form input {
  width: 100%; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface);
  padding: 9px 11px; font-size: var(--fs-md); color: var(--text);
  transition: border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.login-form input:focus { border-color: var(--brand-blue); box-shadow: var(--focus-ring); outline: none; }
.login-form button {
  width: 100%; padding: 11px; border: 1px solid var(--primary); border-radius: var(--r-md);
  background: var(--primary); color: #fff; font-size: var(--fs-md); font-weight: var(--fw-semibold); cursor: pointer;
  transition: background var(--dur-base) var(--ease);
}
.login-form button:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.login-error { background: var(--danger-bg); border: 1px solid var(--danger-border); color: var(--danger-text); border-radius: var(--r-md); padding: 12px 16px; font-size: var(--fs-sm); }
.login-footer { text-align: center; font-size: var(--fs-xs); color: var(--text-faint); }
@media (max-width: 600px) { .login-card { padding: 28px 20px; } }

/* ── Misc ───────────────────────────────────────────────────────────────── */
.day-cell { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; }
.day-name { text-align: left; color: var(--text-muted); font-size: var(--fs-sm); }
.day-date { text-align: right; }
[data-toggle="tooltip"] { cursor: help; }
details summary { cursor: pointer; }

/* ── Fixes found in the page review ─────────────────────────────────────── */
hr { background-color: var(--border); color: var(--border); height: 1px; border: 0; opacity: 1; }
.btn-primary:disabled, .btn-primary.disabled, .btn-success:disabled, .btn-success.disabled {
  background: var(--primary); border-color: var(--primary); color: #fff; opacity: .5;
}
.btn-danger:disabled, .btn-danger.disabled { background: var(--surface); border-color: var(--danger-border); color: var(--danger-text); opacity: .5; }
.table a { text-decoration: none; font-weight: var(--fw-medium); }
.table a:hover { text-decoration: underline; }
body div.dt-container .dt-layout-row.dt-layout-table { width: calc(100% + 32px); }
body div.dt-container .dt-layout-row.dt-layout-table .dt-layout-cell { padding: 0; }
@media (max-width: 600px) {
  .card-body > .chart-table-view > .table-responsive .dt-container { padding: 10px 12px; }
  body div.dt-container .dt-layout-row.dt-layout-table { margin: 0 -12px; width: calc(100% + 24px); }
}
/* A title card whose title is empty (no service picked yet) shows nothing. */
.card-header:has(> .card-title > b:empty):not(:has(> small, > div, > .btn)) { display: none; }
.card:has(> .card-header:first-child > .card-title > b:empty) > .card-header:not(:has(> small, > div, > .btn)) + .card-body { border-top: 0; }
/* Tables scroll inside their wrapper instead of squashing on phones (5.11). */
.table-responsive > .table, .table-responsive .dt-container .table { min-width: 560px; }
.table-responsive > .table-kv { min-width: 0; }

/* ── Mobile (2.5) ───────────────────────────────────────────────────────── */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.alert { overflow-wrap: anywhere; }

/* < 768px (Bootstrap md): fields are 16px so iOS doesn't zoom in on focus;
   filter forms pair short fields two-up and the submit button spans the row. */
@media (max-width: 767.98px) {
  .form-control, .form-select, input[type="date"].form-control,
  body div.dt-container .dt-search input, body div.dt-container .dt-input, .login-form input { font-size: 16px; }
  .filter-form > [class*="col-md-"]:has(> input[type="date"], > select, > input[type="number"], > .form-check) { width: 50%; }
  .filter-form > [class*="col-md-"] > .btn[type="submit"] { width: 100%; }
  .filter-form .form-check { margin-bottom: 0 !important; padding-bottom: 0 !important; min-height: 36px; display: flex; align-items: center; gap: 8px; }
  .filter-form .form-check .form-check-input { margin: 0; float: none; }
}

@media (max-width: 600px) {
  /* Denser table cells so more columns fit before the table scrolls. */
  .table > thead > tr > th, .table thead th,
  .table > tbody > tr > td, .table > tfoot > tr > td,
  body table.dataTable.table > tbody > tr > td, body table.dataTable.table > thead > tr > th { padding: 8px 10px; }
  .table tr.row-child > td:first-child { padding-left: 20px; }

  /* Key/value tables stack: label above value. */
  .table-kv, .table-kv > tbody, .table-kv > tbody > tr,
  .table-kv > tbody > tr > th, .table-kv > tbody > tr > td { display: block; width: auto; }
  .table-kv > tbody > tr > th { padding: 10px 0 2px; border-bottom: 0; white-space: normal; }
  .table-kv > tbody > tr > td { padding: 0 0 10px; border-bottom: 1px solid var(--border-subtle); overflow-wrap: anywhere; }
  .table-kv > tbody > tr:last-child > td { border-bottom: 0; }

  /* Chart range bar: From/To share a row, chart type gets its own. */
  .chart-range { gap: 8px 10px; }
  .chart-range > .inline-field { flex: 1 1 140px; }
  .chart-range > .inline-field .form-control { width: auto; flex: 1; min-width: 0; }
  .chart-type { margin-left: 0; width: 100%; justify-content: space-between; }

  .card-header { padding: 10px 12px; gap: 8px; }
  .card-toolbar { padding: 8px 12px; justify-content: flex-start; }
  .picker-ops { padding-right: 0; }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer > .btn { flex: 1 1 auto; }
}
