@media screen {
  :root {
    --canvas: #F5F7F5;
    --navy: #173D34;
    --primary: #23634F;
    --brand-gold: #F3C76C;
  }

  :root[data-theme="dark"] {
    color-scheme: dark;
    --canvas: #121A17;
    --surface: #1C2823;
    --ink: #ECF4EF;
    --muted: #B3C4BA;
    --line: #41564A;
    --input: #71887A;
    --primary: #A5DDC0;
    --mint: #294639;
    --good: #A3E5BB;
    --good-bg: #243F32;
    --warn: #FFD393;
    --warn-bg: #47351E;
    --danger: #FFB6B9;
    --danger-bg: #482A30;
    --info: #ACDCEF;
    --info-bg: #253D48;
    --theme-raised: #23342B;
    --theme-selected: #30493C;
    --theme-warm-surface: #49342B;
    --theme-cool-surface: #293E49;
  }

  .theme-control {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--canvas);
  }

  .theme-control:hover { border-color: var(--input); }
  .theme-control:focus-within {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }

  .theme-picker {
    position: relative;
    appearance: none;
    min-height: 40px;
    padding: 6px 27px 6px 39px;
    border: 0;
    border-radius: inherit;
    color: var(--ink);
    background: transparent;
    font-size: 14px;
    cursor: pointer;
  }

  .theme-picker:focus-visible { outline: none; }
  .theme-picker option { color: var(--ink); background: var(--surface); }
  .theme-control-icon, .theme-control-chevron { position: absolute; pointer-events: none; }
  .theme-control-icon {
    left: 5px;
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 7px;
    background: var(--mint);
    color: var(--primary);
  }
  .theme-icon { display: none; width: 16px; height: 16px; }
  [data-theme-preference="system"] .theme-icon[data-theme-mode="system"],
  [data-theme-preference="light"] .theme-icon[data-theme-mode="light"],
  [data-theme-preference="dark"] .theme-icon[data-theme-mode="dark"] { display: block; }
  .theme-control-chevron { right: 8px; width: 13px; height: 13px; color: var(--muted); }

  .brand-mark { background: transparent; flex-shrink: 0; }
  .brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }

  :root[data-theme="dark"] :is(.btn.primary, .comfort-btn.active, .step-strip .current .step-num, .ep-marker.active, .record-tabs button.active, .shift-page-tabs .btn.active) {
    color: #14291F;
  }

  :root[data-theme="dark"] .btn.primary:hover:not(:disabled) {
    background: #BDEBD2;
  }

  :root[data-theme="dark"] :is(.result-document,.sample-label,.patient-ticket,.payment-receipt) {
    --ink: #1E353C;
    --muted: #54676D;
    --line: #DAE3DC;
    --primary: #23634F;
    --surface: #fff;
    color: var(--ink);
  }

  @media (max-width: 700px) {
    .topbar { flex-wrap: wrap; }
    .role-entry-header { flex-wrap: wrap; gap: 8px; }
  }
}

@media screen {
  .sidebar .nav button {
    color: #D0DED8;
  }

  .sidebar .nav button:hover {
    background: rgb(255 255 255 / 5%);
    color: #F5FAF7;
  }

  .sidebar .nav button.active,
  .sidebar .nav button.active:hover {
    background: rgb(255 255 255 / 7%);
    color: #F5FAF7;
    box-shadow: inset 2px 0 0 var(--brand-gold);
  }

  .sidebar .nav button .ico,
  .sidebar .nav button.active .ico {
    color: currentColor;
    stroke-width: 1.6;
    opacity: .86;
  }

  .sidebar .nav button:focus-visible {
    outline-color: var(--brand-gold);
  }

  .btn.record-view-action {
    background: transparent;
    border-color: transparent;
    color: var(--primary);
    font-weight: 500;
  }

  .btn.record-view-action:hover:not(:disabled) {
    background: var(--mint);
    border-color: transparent;
  }

  .btn.record-view-action .ico {
    stroke-width: 1.6;
  }
}

@media screen {
  .header-controls {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: auto;
    flex-shrink: 0;
  }
  .header-clock, .staff-trigger, .staff-dropdown-identity {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .header-clock { color: var(--muted); white-space: nowrap; }
  .header-clock .ico { width: 17px; height: 17px; color: var(--primary); }
  .header-clock strong, .staff-trigger strong { display: block; color: var(--ink); font-size: 14px; font-weight: 620; }
  .header-clock small, .staff-trigger small, .staff-dropdown-identity small {
    display: block;
    color: var(--muted);
    font-size: 12px;
  }
  .header-clock time { font-variant-numeric: tabular-nums; }
  .staff-menu { position: relative; }
  .staff-trigger {
    padding: 5px 7px 5px 5px;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    list-style: none;
  }
  .staff-trigger::-webkit-details-marker { display: none; }
  .staff-trigger:hover, .staff-menu[open] .staff-trigger { background: var(--canvas); border-color: var(--line); }
  .staff-trigger:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
  .staff-trigger-copy { min-width: 0; max-width: 175px; }
  .staff-trigger-copy strong, .staff-trigger-copy small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .staff-avatar {
    display: inline-grid;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    place-items: center;
    overflow: hidden;
    border-radius: 50%;
    background: var(--mint);
    color: var(--primary);
    font-size: 14px;
    font-weight: 650;
  }
  .staff-avatar img { width: 100%; height: 100%; object-fit: cover; }
  .staff-chevron { width: 14px; height: 14px; color: var(--muted); }
  .staff-dropdown {
    position: absolute;
    z-index: 20;
    top: calc(100% + 9px);
    right: 0;
    width: min(290px, calc(100vw - 26px));
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 12px 30px rgb(0 0 0 / 16%);
  }
  .staff-dropdown-identity, .staff-dropdown-theme { padding: 13px; border-bottom: 1px solid var(--line); }
  .staff-dropdown-identity strong, .staff-dropdown-identity small { overflow-wrap: anywhere; }
  .staff-dropdown-theme { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .staff-dropdown-actions { display: grid; gap: 2px; padding: 6px; }
  .staff-dropdown-actions .btn { justify-content: flex-start; min-height: 40px; border-color: transparent; background: transparent; }
  .staff-dropdown-actions .staff-signout { color: var(--danger); }
  @media (max-width: 920px) {
    .header-controls { gap: 8px; }
    .staff-trigger-copy { display: none; }
  }
  @media (max-width: 620px) {
    .topbar .global-search { min-width: 0; }
    .header-clock { gap: 3px; }
    .header-clock .ico { display: none; }
    .header-clock strong { font-size: 11px; }
    .header-clock small { font-size: 10px; }
  }
}

@media screen {
  .doctor-queue-record-row { cursor: pointer; }
  .doctor-queue-record-row:hover td { background: var(--mint); }
  .btn.doctor-queue-record-link {
    min-height: auto;
    padding: 2px 0;
    border: 0;
    background: transparent;
    color: var(--primary);
    text-align: left;
    justify-content: flex-start;
  }
  .btn.doctor-queue-record-link:hover:not(:disabled) {
    background: transparent;
    text-decoration: underline;
  }
  .record-back-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
}

@media screen {
  .account-profile-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(270px, 1fr); gap: 20px; align-items: start; }
  .account-profile-hero { display: flex; align-items: center; gap: 18px; padding: 24px; background: var(--mint); }
  .account-profile-hero .staff-avatar { flex-basis: 66px; width: 66px; height: 66px; font-size: 22px; background: var(--surface); }
  .account-profile-body { padding: 24px; }
  .account-profile-fields { display: grid; gap: 16px; margin: 0; }
  .account-profile-fields div { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
  .account-profile-fields dt { color: var(--muted); font-size: 13px; }
  .account-profile-fields dd { margin: 3px 0 0; overflow-wrap: anywhere; }
  .account-photo-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
  .account-photo-button { position: relative; cursor: pointer; }
  .account-photo-button input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
  .account-photo-button:focus-within { outline: 2px solid var(--primary); outline-offset: 3px; }
  @media (max-width: 820px) { .account-profile-grid { grid-template-columns: minmax(0, 1fr); } }
}

@media screen {
  .record-back-bar { flex-wrap: wrap; }
  .record-queue-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-left: auto; }
}

@media screen {
  .platform-filters { align-items: end; }
  .platform-filters .searchbox { flex: 2 1 240px; }
  .platform-filters .field { flex: 1 1 170px; }
  .platform-roles { padding-top: 0; }
  .platform-staff-bar p { flex: 1 1 220px; margin: 0; }
  .platform-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 20px; }
  .platform-info { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 24px; margin: 0; }
  .platform-info dt { color: var(--muted); font-size: 13px; }
  .platform-info dd { margin: 3px 0 0; overflow-wrap: anywhere; }
  .platform-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
  .platform-fieldset { min-width: 0; margin: 24px 0 0; padding: 14px 16px 16px; border: 1px solid var(--line); border-radius: 10px; }
  .platform-fieldset legend { padding: 0 6px; font-size: 14px; font-weight: 600; }
  .trend-summary { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
  .trend-summary strong { margin-right: 4px; color: var(--ink); font-size: 20px; font-variant-numeric: tabular-nums; }
  .trend { display: flex; align-items: flex-end; gap: 2px; height: 170px; border-bottom: 1px solid var(--line); }
  .trend.dense { gap: 1px; }
  .trend-col { position: relative; display: flex; flex: 1 1 0; align-items: flex-end; justify-content: center; height: 100%; }
  .trend-col i { display: block; width: 100%; max-width: 24px; border-radius: 4px 4px 0 0; background: var(--primary); }
  .trend.dense .trend-col i { border-radius: 2px 2px 0 0; }
  .trend-col:hover { background: var(--mint); }
  .trend-col:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; z-index: 2; padding: 5px 9px; border-radius: 6px; background: var(--ink); color: var(--surface); font-size: 12px; white-space: nowrap; translate: -50%; pointer-events: none; }
  .trend-col:nth-child(-n + 4):hover::after { left: 0; translate: none; }
  .trend-col:nth-last-child(-n + 4):hover::after { right: 0; left: auto; translate: none; }
  .trend-axis { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
  .trend-table { margin-top: 12px; }
  .trend-table summary { width: fit-content; padding: 11px 0; color: var(--primary); font-size: 14px; font-weight: 600; cursor: pointer; }
  .trend-table .table-wrap { max-height: 320px; margin-top: 4px; border: 1px solid var(--line); border-radius: 10px; }
  .trend-table table { min-width: 0; }
  .share-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) minmax(120px, auto); align-items: center; gap: 12px; padding: 9px 0; font-size: 14px; }
  .share-row > :last-child { text-align: right; font-variant-numeric: tabular-nums; }
  .share-bar { height: 8px; overflow: hidden; border-radius: 4px; background: var(--mint); }
  .share-bar i { display: block; height: 100%; border-radius: 4px; background: var(--primary); }
  @media (max-width: 1000px) {
    .platform-grid { grid-template-columns: minmax(0, 1fr); }
    .platform-info { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media (max-width: 560px) {
    .platform-info { grid-template-columns: minmax(0, 1fr); }
    .share-row { grid-template-columns: minmax(0, 1fr) auto; }
    .share-bar { grid-row: 2; grid-column: 1 / -1; }
    .trend { height: 140px; }
  }
}
