/* SubPulse workspace design system.
 * Presentation only: loaded after feature styles; business states stay authoritative.
 * Keep the root type size unchanged so the existing reading preferences still work.
 */
:root {
  --ink: #1e3036;
  --muted: #62737a;
  --line: #e1e7e9;
  --accent: #087f72;
  --paper: #f7f9fa;
  --healthy: #117657;
  --warning: #925e12;
  --critical: #b3343e;
  --sidebar: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f2f6f6;
  --accent-soft: #e7f4f0;
  --control-border: #cbd7db;
  --radius: 10px;
  --shadow-dialog: 0 24px 80px #173c3d24;
}
body { background: var(--paper); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { color: inherit; }
::selection { background: #c9e9df; color: #153c36; }
:where(button, a, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
.skip-link {
  position: fixed; top: 12px; left: 16px; z-index: 1000;
  padding: 10px 18px; background: var(--accent); color: #fff;
  border-radius: 8px; transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }
#main-content:focus { outline: none; }
.app-shell { grid-template-columns: 216px minmax(0, 1fr); }
.sidebar {
  padding: 28px 16px 20px; background: var(--surface);
  color: var(--muted); border-right: 1px solid var(--line);
  height: 100vh; height: 100dvh; overflow-y: auto; z-index: 30;
}
.brand {
  color: #193d39; font-size: 25px; letter-spacing: -1px;
  gap: 10px; margin: 0 8px 36px; font-weight: 750;
}
.brand-mark {
  background: var(--accent); width: 34px; height: 34px; border-radius: 10px;
}
.brand-mark .icon { color: #fff; width: 24px; height: 24px; }
.brand-dot { color: var(--accent); }
.sidebar nav { display: flex; flex-direction: column; gap: 5px; }
.nav-link {
  position: relative; min-height: 46px; padding: 0 13px; gap: 12px;
  margin: 0; border-radius: 8px; font-size: 15px; color: #596d73;
  transition: background 150ms ease, color 150ms ease;
}
.nav-link .icon { width: 19px; height: 19px; stroke-width: 1.7; }
.nav-link:hover { color: #26463f; background: var(--surface-soft); }
.nav-link.active { background: var(--accent-soft); color: #086c5f; font-weight: 650; }
.nav-link.active::before {
  content: ''; position: absolute; left: -16px; top: 12px; bottom: 12px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-count { background: #cbe7dd; color: #175e4c; border-radius: 5px; font-variant-numeric: tabular-nums; }
.sidebar-bottom { padding: 24px 8px 0; }
.version { border-color: var(--line); color: var(--muted); font-size: 12px; letter-spacing: .6px; }
.mobile-nav-toggle { display: none; }
.topbar {
  min-height: 64px; padding: 12px 32px; gap: 16px;
  border-color: var(--line); background: var(--surface);
}
.breadcrumb { gap: 12px; font-size: 13px; color: var(--muted); }
.breadcrumb > span { color: #a6b3b7; }
.breadcrumb strong { color: #354d52; font-weight: 600; }
.topbar-right { gap: 20px; font-size: 13px; }
.connection-status { color: #537267; font-size: 13px; }
.connection-status i { width: 6px; height: 6px; }
.site-link { color: var(--muted); }
.site-link:hover { color: var(--accent); }
.demo-badge { background: #fff8e8; border-color: #efdfb4; color: #865916; border-radius: 5px; font-size: 12px; }
.content { max-width: 1720px; padding: 24px 28px 40px; }
.page-heading { display: flex; margin-bottom: 16px; align-items: center; justify-content: flex-start; flex-wrap: wrap; gap: 12px 20px; }
.page-heading > .button, .page-heading > .quiet-badge { margin-top: 0; }
.page-heading h1, #view-pool .page-heading h1 { font-size: 28px; line-height: 1.4; letter-spacing: -.6px; font-weight: 700; }
.page-heading p { margin-top: 6px; font-size: 14px; color: var(--muted); line-height: 1.7; }
h2 { font-size: 18px; letter-spacing: -.2px; }
h3 { font-size: 16px; }
.heading-actions { gap: 8px; }
.button {
  min-height: 40px; padding: 9px 15px; border-radius: 8px;
  font-size: 14px; line-height: 1.45; font-weight: 600;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.primary:hover:not(:disabled) { background: #06695f; border-color: #06695f; }
.button.secondary { background: var(--surface); border-color: var(--control-border); color: #3a555c; }
.button.secondary:hover:not(:disabled) { background: #f1f7f5; border-color: #a2bdb6; }
.button.small { min-height: 34px; padding: 6px 11px; font-size: 13px; }
.icon-button { border-color: var(--control-border); border-radius: 7px; background: var(--surface); }
.text-link { color: #087367; text-underline-offset: 3px; }
.text-link:hover { text-decoration: underline; }
.text-link.danger-text, .danger-text { color: var(--critical); }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  border: 1px solid var(--control-border); border-radius: 7px;
  background: var(--surface); color: var(--ink);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
input:not([type=checkbox]):not([type=radio]):focus, select:focus, textarea:focus {
  border-color: var(--accent);
}
input::placeholder, textarea::placeholder { color: #71858b; opacity: 1; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
label { color: #3b545b; }
.field-help, .muted { color: var(--muted); }
.banner { border-radius: 8px; }
.freshness-banner { border-color: #e7d6ad; background: #fffaef; color: #7b591d; }
.danger-banner { border-color: #edc3c7; background: #fff1f2; color: #9c3039; }
/* One shared summary strip rather than a mosaic of KPI cards. */
#view-pool .metric-strip, .analytics-metrics {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 24px;
}
#view-pool .metric {
  min-height: 88px; padding: 18px 22px; gap: 16px;
  border-right: 1px solid var(--line); align-items: center; justify-content: space-between;
}
#view-pool .metric > span { color: var(--muted); font-size: 14px; }
#view-pool .metric > strong { font-size: 28px; line-height: 1.2; font-weight: 650; letter-spacing: -.6px; font-variant-numeric: tabular-nums; }
#view-pool .metric-next > strong { font-size: 24px; }
.metric .dot { width: 6px; height: 6px; }
.analytics-metrics > div { padding: 22px 24px; }
.analytics-metrics > div + div { border-color: var(--line); }
.analytics-metrics span { font-size: 14px; color: var(--muted); font-weight: 500; }
.analytics-metrics strong { font-size: clamp(26px, 2.25vw, 36px); color: var(--ink); letter-spacing: -.8px; }
.analytics-metrics > div > small { color: var(--muted); }
/* Tables keep the existing mobile card layout and all operational details. */
.section-heading { align-items: center; gap: 12px; }
#view-pool .accounts-section > .section-heading { margin-bottom: 14px; }
#view-pool .accounts-section > .section-heading h2 { font-size: 17px; }
.subtle-count { background: #e9eff0; color: #526a72; font-size: 12px; font-variant-numeric: tabular-nums; border-radius: 5px; padding: 3px 7px; }
.list-toolbar { gap: 16px; margin-bottom: 10px; align-items: center; }
.filters, .range-presets {
  background: #eaf0f0; padding: 4px; border: 0; border-radius: 8px; gap: 3px;
}
.filter, .range-button { color: #5a6d74; border-radius: 6px; font-size: 14px; min-height: 36px; padding: 8px 14px; }
.filter.active, .range-button.active {
  background: var(--surface); color: #116f60; border-color: transparent;
  box-shadow: 0 1px 3px #173d3712; font-weight: 600;
}
.filter:hover, .range-button:hover { color: var(--accent); }
.search-box { min-height: 42px; border-radius: 8px; border-color: var(--control-border); background: var(--surface); }
.search-box .icon { color: #84969b; width: 18px; height: 18px; }
.search-box input { border: 0 !important; background: transparent !important; box-shadow: none; font-size: 14px; min-width: 0; }
.search-box:focus-within { border-color: var(--accent); outline: 2px solid #b9ded5; outline-offset: 1px; }
.search-box input:focus-visible { outline: none; }
.pool-tools { border-color: var(--line); }
.table-scroll { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { font-variant-numeric: tabular-nums; }
th { background: #f0f4f5; color: #526a72; font-weight: 600; font-size: 13px; border-color: var(--line); }
td { border-color: var(--line); }
tbody tr { transition: background 140ms ease; }
tbody tr:hover { background: #f7fbfa; }
#view-pool .accounts-table td { padding-top: 18px; padding-bottom: 18px; }
.account-name { font-weight: 650; }
.account-sub, .account-meta { color: var(--muted); }
.account-groups > summary { color: #315e55; }
.group-chip { background: #f1f6f4; border-color: #dbe8e2; color: #365f52; }
.table-footer { padding-top: 14px; color: var(--muted); font-size: 13px; gap: 12px; }
.pool-billing-summary { border-color: var(--line); border-radius: 8px; }
.empty-state { padding: 52px 24px; color: var(--muted); }
.empty-state h3 { color: var(--ink); margin-top: 14px; }
.empty-icon { background: var(--accent-soft); color: var(--accent); border-radius: 14px; }
/* Shared section language across analytics, tools, alerts, and settings. */
.analytics-controls { position: relative; border-top: 0; border-color: var(--line); padding: 0 0 12px; margin-bottom: 16px; }
.analytics-query-details { min-width: 0; }
.analytics-controls .range-presets { width: fit-content; }
.analytics-query-details > summary { position: absolute; top: 0; left: 250px; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; cursor: pointer; color: var(--accent); font-weight: 600; list-style: none; }
.analytics-query-details > summary::-webkit-details-marker { display: none; }
.analytics-query-details > summary::after { content: '+'; font-size: 18px; font-weight: 400; }
.analytics-query-details[open] > summary::after { content: '−'; }
.analytics-refresh-row { margin-top: 8px; justify-content: flex-start; flex-wrap: wrap; gap: 8px 24px; }
.analytics-filter-grid { gap: 14px; }
.analytics-filter-grid label { font-size: 13px; }
.analytics-main-grid { gap: 24px; }
.trend-section, .breakdown-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.trend-section .section-heading, .breakdown-section .section-heading { margin-bottom: 18px; }
.breakdown-section { margin-top: 24px; }
.breakdown-section .table-scroll { border-radius: 6px; }
.breakdown-tabs { gap: 8px; }
.breakdown-tab { border-radius: 6px; }
.breakdown-tab.active { color: var(--accent); border-color: var(--accent); }
.daily-forecast { background: #edf6f2; border-color: #d5e6dd; border-radius: 8px; }
.settings-tabs { background: #eaf0f0; border: 0; gap: 4px; padding: 4px; border-radius: 10px; margin-bottom: 16px; }
.settings-tab { min-height: 56px; padding: 8px 14px; border-radius: 7px; }
.settings-tab > span { font-size: 15px; }
.settings-tab > small { color: var(--muted); font-size: 13px; margin-top: 2px; }
.settings-tab[aria-selected="true"] { outline: none; box-shadow: 0 1px 4px #163b3714; color: #116d61; background: var(--surface); }
.settings-tab:hover { background: #f7fbfa; }
.settings-panel .settings-section { grid-template-columns: 220px minmax(0, 1fr); column-gap: 44px; padding: 28px 0; border-color: var(--line); }
.settings-panel .settings-intro h2 { font-size: 18px; }
.settings-intro p { color: var(--muted); font-size: 14px; line-height: 1.8; }
.settings-fields { min-width: 0; }
.settings-fields label { font-size: 14px; }
.settings-fields .field-grid { gap: 18px; }
.settings-disclosure, .compact-disclosure { border-color: var(--line); }
.settings-disclosure > summary, .compact-disclosure > summary { font-size: 15px; min-height: 52px; }
.quiet-details > summary { color: #597078; }
.quiet-details > summary:hover { color: var(--accent); }
.tool-section { border-color: var(--line); padding-top: 24px; padding-bottom: 24px; }
.tool-section h2 { font-size: 18px; }
.notification-strip { border-radius: 8px; border-color: #d5e6dd; background: #edf6f2; }
.quiet-badge { border-radius: 6px; font-size: 13px; }
.incident-section { border-color: var(--line); }
.form-footer, .comm-footer { border-color: var(--line); }
dialog { border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-dialog); }
dialog::backdrop { background: #122e3859; backdrop-filter: blur(3px); }
.dialog-heading, .dialog-header { border-color: var(--line); }
.login-page { min-height: 100vh; min-height: 100dvh; background: var(--paper); display: grid; place-items: center; padding: 32px 20px; }
.login-shell { width: min(100%, 440px); margin: 0; padding: 40px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 36px #173d3709; }
.login-brand { display: inline-block; font-size: 28px; font-weight: 750; color: var(--accent); margin-bottom: 32px; letter-spacing: -1px; }
.login-shell .eyebrow { font-size: 11px; color: var(--muted); letter-spacing: 1.6px; }
.login-shell h1 { font-size: 26px; margin: 8px 0; }
.login-shell > p { color: var(--muted); font-size: 14px; line-height: 1.8; }
.login-shell .detail-form { margin: 28px 0 20px; }
.login-shell .detail-form .button { width: 100%; min-height: 44px; }
.login-shell .field-help { font-size: 12px; }
@media (min-width: 1101px) {
  #view-pool .accounts-table th:nth-child(1) { width: 38px; }
  #view-pool .accounts-table th:nth-child(2) { width: 20%; }
  #view-pool .accounts-table th:nth-child(3) { width: 14%; }
  #view-pool .accounts-table th:nth-child(4) { width: 14%; }
  #view-pool .accounts-table th:nth-child(5) { width: 12%; }
  #view-pool .accounts-table th:nth-child(6) { width: calc(40% - 204px); }
  #view-pool .accounts-table th:nth-child(7) { width: 166px; }
}
@media (max-width: 1200px) and (min-width: 901px) {
  .app-shell { grid-template-columns: 192px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .brand { margin-inline: 4px; font-size: 23px; }
  .content { padding: 24px; }
  .topbar { padding-inline: 24px; }
  #view-pool .metric { padding: 16px; gap: 10px; }
  #view-pool .metric > strong { font-size: 25px; }
  .settings-panel .settings-section { grid-template-columns: 180px minmax(0, 1fr); column-gap: 28px; }
}
@media (max-width: 900px) {
  .app-shell { display: block; }
  .sidebar {
    position: sticky; top: 0; height: auto; max-height: 85dvh; padding: 12px 20px;
    display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between;
    border-right: 0; border-bottom: 1px solid var(--line); overflow: auto;
  }
  .brand { font-size: 23px; margin: 0; gap: 9px; }
  .brand-mark { width: 31px; height: 31px; border-radius: 9px; }
  .sidebar-bottom { display: none; }
  .sidebar nav { flex: 0 0 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; margin-top: 12px; overflow: visible; }
  .sidebar .nav-link { min-height: 44px; font-size: 14px; white-space: normal; }
  .nav-link.active::before { display: none; }
  .design-ready .mobile-nav-toggle { display: inline-flex; min-height: 40px; padding: 8px 12px; gap: 7px; }
  .design-ready .sidebar:not(.nav-open) nav { display: none; }
  .topbar { min-height: 52px; padding: 12px 20px; flex-wrap: wrap; gap: 10px 16px; }
  .topbar-right { gap: 12px; flex-wrap: wrap; }
  .content { padding: 24px 20px 36px; }
  .page-heading h1, #view-pool .page-heading h1 { font-size: 25px; }
  .page-heading { margin-bottom: 16px; }
  #view-pool .metric { padding: 16px; min-height: 76px; }
  #view-pool .metric > strong { font-size: 25px; }
  .settings-panel .settings-section { display: block; padding: 24px 0; }
  .settings-intro { margin-bottom: 20px; }
  .settings-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .sidebar { padding: 10px 16px; }
  .topbar { padding: 10px 16px; }
  .topbar-right { font-size: 12px; gap: 10px; }
  .content { padding: 22px 16px 32px; }
  .page-heading { align-items: flex-start; flex-wrap: wrap; gap: 14px; }
  .page-heading h1, #view-pool .page-heading h1 { font-size: 24px; }
  .heading-actions { gap: 8px; flex-wrap: wrap; }
  .heading-actions .button { min-height: 42px; }
  #view-pool .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 22px; }
  #view-pool .metric { min-height: 78px; padding: 16px; border-right: 0; border-top: 0; border-bottom: 1px solid var(--line); }
  #view-pool .metric:nth-child(odd) { border-right: 1px solid var(--line); }
  #view-pool .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  #view-pool .metric:nth-child(n+3) { border-bottom: 0; }
  #view-pool .metric > span { font-size: 13px; }
  #view-pool .metric > strong { font-size: 25px; }
  #view-pool .metric-next > strong { font-size: 22px; }
  .list-toolbar { align-items: stretch; gap: 12px; }
  .filters { width: 100%; display: flex; gap: 2px; }
  .filter { flex: 1; padding: 8px 6px; font-size: 13px; min-height: 40px; }
  .search-box { width: 100%; }
  .search-box input { font-size: 16px; }
  .mobile-nav-toggle, .button { min-height: 44px; }
  .analytics-query-details { border-bottom: 1px solid var(--line); margin-top: 4px; }
  .analytics-query-details > summary { position: static; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; min-height: 44px; cursor: pointer; color: #315e55; font-size: 14px; font-weight: 600; list-style: none; }
  .analytics-query-details > summary::-webkit-details-marker { display: none; }
  .analytics-query-details > summary::after { content: '+'; font-size: 18px; font-weight: 400; }
  .analytics-query-details[open] > summary::after { content: '−'; }
  .analytics-query-details > summary > span { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 400; }
  .analytics-query-details[open] .analytics-filter-grid { margin-top: 2px; }
  #view-pool .accounts-table { border: 0; border-radius: 0; background: transparent; }
  #view-pool .accounts-table tbody tr { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin-bottom: 14px; }
  #view-pool .accounts-table td { padding-top: 11px; padding-bottom: 11px; }
  .analytics-metrics > div { padding: 18px 16px; }
  .analytics-metrics strong { font-size: 26px; }
  .trend-section, .breakdown-section { padding: 18px 14px; }
  .settings-tab { padding: 8px 12px; min-height: 56px; }
  .settings-fields input:not([type=checkbox]):not([type=radio]), .settings-fields select { min-height: 44px; }
  dialog { max-width: calc(100vw - 24px); border-radius: 12px; }
  .login-shell { padding: 30px 24px; }
}
/* Keep the first screen focused on content and nearby actions. */
.page-heading h1 { margin: 0; }
.page-heading h1 .subtle-count { vertical-align: middle; letter-spacing: 0; }
.group-list-toolbar { justify-content: flex-start; flex-wrap: wrap; gap: 12px; }
.group-list-toolbar > .search-box { order: 0; margin-left: 0; width: 280px; max-width: 100%; }
.group-list-toolbar > label:not(.search-box) { display: flex; align-items: center; gap: 8px; }
.group-sync-time { font-size: 13px; }
#view-pool .metric-strip { margin-bottom: 16px; }
#view-pool .metric { min-height: 76px; padding-block: 12px; }
#view-alerts .notification-strip { padding: 10px 14px; margin-bottom: 12px; gap: 12px; justify-content: flex-start; }
#view-alerts .notification-strip p { margin: 3px 0 0; }
#care-freshness:empty, #intelligence-notice:empty { display: none; }
#intelligence-workspace { padding: 12px 0; }
#intelligence-notice { margin: 0 0 12px; }
#quality-board { margin: 0 0 20px; }
.quality-toolbar { justify-content: flex-start; gap: 12px 24px; }
.quality-toolbar h2 { margin: 0; font-size: 18px; }
.quality-toolbar p { margin: 4px 0 0; }
.quality-toolbar .heading-actions { align-items: center; flex-wrap: wrap; }
.quality-toolbar .quality-concurrency { width: auto; grid-template-columns: auto 80px; margin-left: 4px; }
.quality-concurrency select { width: 80px; min-height: 40px; padding-inline: 12px; }
.quality-live { margin: 12px 0; padding: 10px 14px; }
@media (max-width: 600px) {
  .group-list-toolbar > .search-box { width: 100%; }
  .group-list-toolbar { display: flex; flex-direction: row; align-items: center; }
  .group-sync-time { flex: 1; }
  .quality-toolbar .heading-actions { gap: 8px; }
  #view-alerts .notification-strip { flex-wrap: wrap; align-items: flex-start; }
}
@media (prefers-reduced-motion: no-preference) {
  .view:not([hidden]) { animation: workspace-enter 180ms ease-out; }
  .design-ready .sidebar.nav-open nav { animation: workspace-enter 140ms ease-out; }
  @keyframes workspace-enter { from { opacity: .5; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
@media print {
  .sidebar, .topbar, .skip-link, .mobile-nav-toggle { display: none !important; }
  .app-shell { display: block; }
  .content { max-width: none; padding: 0; }
  body { background: #fff; }
}
