/* Shared interface refinement. Existing routes and application behavior are preserved. */
@media screen {
  :root {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-2: #edf1f7;
    --surface-3: #e2e8f0;
    --border: #dce3ed;
    --border-strong: #b9c6d8;
    --text: #182438;
    --text-2: #526078;
    --text-3: #65738a;
    --accent: #315fc4;
    --accent-hover: #234ba5;
    --accent-soft: #e6edfc;
    --warn: #89500f;
    --warn-soft: #fff3df;
    --info-soft: #edf1f7;
    --shadow: none;
    --r-sm: 8px;
    --r: 10px;
    --r-lg: 14px;
    --sidebar: 248px;
  }
  body { line-height: 1.5; }
  a { text-underline-offset: 3px; }
  input, textarea { caret-color: var(--accent); }
  h1 { font-size: 24px; letter-spacing: -.025em; }
  h2 { font-size: 18px; }
  h3 { font-size: 15px; }
  .sidebar { z-index: 30; background: var(--bg); padding: 20px 14px 12px; gap: 7px; }
  .brand { gap: 12px; padding: 2px 10px 20px; font-size: 17px; letter-spacing: -.025em; }
  .brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--accent-text); font-size: 15px; }
  .switcher { padding: 12px; min-height: 64px; margin-bottom: 7px; }
  .switcher-name { margin-top: 2px; }
  .nav-item { min-height: 40px; padding: 9px 12px; gap: 12px; }
  .nav-item.active { background: var(--accent-soft); }
  .nav-sep { margin: 10px 8px; }
  .sidebar-foot { padding-top: 16px; border-top: 1px solid var(--border); gap: 4px; }
  .collapsed .brand { padding: 2px 4px 20px; }
  .collapsed .switcher { min-height: 48px; justify-content: center; padding: 8px; }
  .collapsed .sidebar { padding-inline: 10px; }
  .context-bar { min-height: 84px; padding: 18px 32px; gap: 12px; background: var(--surface); backdrop-filter: none; }
  .context-bar .page-title { font-size: 20px; letter-spacing: -.025em; font-weight: 650; }
  .context-bar > .small { font-size: 12px; }
  .content { padding: 28px 32px 48px; }
  .btn { height: 38px; padding: 0 14px; gap: 8px; }
  .btn.sm { height: 32px; padding: 0 10px; }
  .btn.icon { width: 38px; }
  .btn.sm.icon { width: 32px; }
  .btn:active:not(:disabled) { background: var(--surface-3); }
  .btn.primary:active:not(:disabled) { background: var(--accent-hover); }
  .seg { padding: 3px; gap: 2px; background: var(--surface-2); border-color: transparent; }
  .seg button { height: 32px; padding: 0 12px; border-radius: 6px; }
  .seg button + button { border-left: 0; }
  .seg button[aria-pressed=true] { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgb(24 36 56 / 10%); }
  input, select { min-height: 38px; }
  textarea { padding: 10px 12px; }
  label.field { gap: 7px; font-size: 13px; }
  .field-row { gap: 16px; }
  input[type=checkbox], input[type=radio] { min-height: 0; }
  .card { box-shadow: none; }
  .card-pad { padding: 22px; }
  .card-head { padding: 18px 22px; }
  .card-head h2, .card-head h3 { font-size: 15px; }
  .section { margin-top: 28px; }
  .section-title { margin-bottom: 16px; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .kpi { min-height: 154px; padding: 21px 22px 18px; gap: 12px; border-radius: var(--r-lg); }
  .kpi-name { font-size: 13px; font-weight: 550; line-height: 1.4; }
  .kpi-value { font-size: 30px; letter-spacing: -.03em; font-weight: 650; }
  .kpi-value.unknown { font-size: 19px; color: var(--text-2); font-weight: 500; }
  .kpi-foot { gap: 8px; line-height: 1.5; flex-wrap: wrap; }
  button.kpi:hover { border-color: var(--accent); }
  .kpi:not(button) { cursor: default; }
  .kpi:focus-visible { outline-offset: 3px; }
  .kpi[aria-pressed=true] { box-shadow: none; background: var(--accent-soft); }
  .badge { min-height: 22px; height: auto; padding: 2px 8px; line-height: 1.35; }
  .badge.outline { border-color: var(--border-strong); }
  .table-toolbar { padding: 14px 16px; gap: 8px; }
  table.dt { font-size: 13px; }
  table.dt th { background: var(--surface-2); color: var(--text-2); font-weight: 600; font-size: 12px; }
  table.dt th, table.dt td { padding: 13px 16px; }
  table.dt.compact th, table.dt.compact td { padding: 8px 12px; }
  table.dt tbody tr:last-child td { border-bottom: 0; }
  table.dt .sticky-col { min-width: 190px; }
  table.dt td.na, table.dt .faint { color: var(--text-3); }
  .notice { padding: 14px 16px; line-height: 1.6; }
  .empty { padding: 52px 24px; gap: 12px; }
  .empty h3 { font-size: 17px; }
  .empty p { max-width: 56ch; }
  .tabs { gap: 8px; margin-bottom: 20px; }
  .tab { padding: 12px 14px; }
  .popover { padding: 8px; }
  .menu-item { min-height: 38px; padding: 9px 12px; }
  .modal-head, .drawer-head { padding: 20px 24px; }
  .modal-body { padding: 22px 24px; gap: 16px; }
  .modal-foot { padding: 16px 24px; }
  .drawer-body { padding: 22px 24px 32px; }
  .list-row { padding: 14px 20px; }
  .login-wrap { padding: 32px 20px; }
  .login-card { width: min(440px, 100%); padding: 36px; }
  .login-card .brand { padding: 0 0 24px; gap: 14px; }
  .login-card .brand-mark { width: 42px; height: 42px; font-size: 20px; border-radius: 12px; }
  .login-card h1 { font-size: 26px; }
  .login-card .small { font-size: 14px; line-height: 1.7; }
  .login-card .field { margin-top: 20px; }
  .login-card input { height: 46px; padding-inline: 12px; font-size: 16px; }
  .login-card .btn.primary { height: 46px; font-size: 15px; font-weight: 600; margin-top: 8px; }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme=light]) {
      --bg: #121923; --surface: #192230; --surface-2: #222e40; --surface-3: #2d3b50;
      --border: #314057; --border-strong: #52647f; --text: #edf2fa; --text-2: #b6c2d5;
      --text-3: #a1b1c9; --accent: #94b4ff; --accent-hover: #b4cbff; --accent-soft: #263a60;
      --warn: #efb86d; --warn-soft: #352a1a; --info-soft: #222e40;
    }
  }
  :root[data-theme=dark] {
    --bg: #121923; --surface: #192230; --surface-2: #222e40; --surface-3: #2d3b50;
    --border: #314057; --border-strong: #52647f; --text: #edf2fa; --text-2: #b6c2d5;
    --text-3: #a1b1c9; --accent: #94b4ff; --accent-hover: #b4cbff; --accent-soft: #263a60;
    --warn: #efb86d; --warn-soft: #352a1a; --info-soft: #222e40;
  }
  @media (min-width: 1600px) { .kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
  @media (max-width: 1100px) {
    .content { padding: 24px; }
    .context-bar { padding: 16px 24px; }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi { padding: 18px; min-height: 148px; }
  }
  @media (max-width: 760px) {
    .sidebar { width: min(290px, 85vw); }
    .context-bar { padding: 14px 16px 14px 52px; min-height: 76px; gap: 10px; }
    .context-bar .page-title { font-size: 18px; }
    .context-bar .seg { max-width: 100%; }
    .context-bar:has(> .seg) { padding-left: 16px; }
    .context-bar:has(> .seg) .page-title { margin-left: 36px; }
    .context-bar:has(> .seg) > .grow { display: none; }
    .context-bar:has(> .seg) > .btn.primary { margin-left: auto; }
    .list-row:has(> select) { flex-wrap: wrap; }
    .list-row:has(> select) > .grow { flex-basis: 100%; }
    .list-row .tiny { overflow-wrap: anywhere; }
    .seg button { padding-inline: 9px; }
    .content { padding: 20px 16px 36px; }
    .kpis { gap: 10px; }
    .kpi { min-height: 144px; padding: 16px 14px; gap: 10px; }
    .kpi-name { font-size: 12px; }
    .kpi-value { font-size: 26px; }
    .kpi-value.unknown { font-size: 17px; }
    .kpi-foot { font-size: 11.5px; }
    .table-toolbar { padding: 12px; }
    .table-toolbar .btn { min-height: 36px; }
    .table-wrap { max-width: 100%; }
    table.dt .sticky-col { min-width: 156px; max-width: 200px; }
    .card-pad { padding: 18px; }
    .section-title { flex-wrap: wrap; }
    .field-row { grid-template-columns: 1fr; }
    .health-grid { min-width: 760px; }
    .card:has(> .health-grid) { overflow-x: auto; }
    .toast-stack { width: calc(100% - 32px); }
    .toast { max-width: 100%; }
    .overlay { padding: 24px 12px; }
    .login-card { padding: 28px 24px; }
    .login-card h1 { font-size: 24px; }
    .login-card .brand { gap: 12px; }
  }
  @media (prefers-reduced-motion: no-preference) {
    .btn, .nav-item, .switcher, .kpi, input, select, textarea {
      transition: background-color 160ms ease-out, border-color 160ms ease-out, color 160ms ease-out;
    }
  }
}
