:root {
  --zb-shell-height: 48px;
}

body.zb-shell-mounted {
  padding-top: var(--zb-shell-height) !important;
}

.zb-shell-tabs {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  height: var(--zb-shell-height);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: #10161d;
  border-bottom: 1px solid rgba(180, 197, 216, 0.18);
  color: #f1f6fb;
  font-family: "Segoe UI", system-ui, sans-serif;
}

.zb-shell-brand {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 10px;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
  gap: 7px;
}

.zb-shell-brand-logo { width:28px; height:28px; object-fit:contain; flex-shrink:0; background:transparent; }

/* Keep the dark strokes readable within the existing logo footprint. */
:root:not([data-theme="light"]) .zb-shell-brand-logo {
  background: #eef4f8;
  border-radius: 4px;
}

.zb-shell-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.zb-shell-tab[hidden] { display: none !important; }

.zb-shell-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 11px;
  color: #c7d5e4;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 0.86rem;
  white-space: nowrap;
}

.zb-shell-tab:hover {
  border-color: var(--color-active-border, #2e92ec);
  color: var(--button-active-text, #fff);
  background: var(--color-active, #075eaf);
}

.zb-shell-tab.is-active {
  border-color: var(--color-active-border, #2e92ec);
  color: var(--button-active-text, #ffffff);
  background: var(--color-active, #075eaf);
}

.zb-shell-spacer {
  flex: 1 1 auto;
}

.zb-shell-role {
  color: #91a6bb;
  font-size: 0.78rem;
  white-space: nowrap;
}

.zb-shell-signout {
  appearance: none;
  border: 1px solid var(--color-border-strong, rgba(77, 163, 255, 0.24));
  background: var(--accent-soft, rgba(77, 163, 255, 0.1));
  color: #f1f6fb;
  border-radius: 999px;
  min-height: 32px;
  padding: 0 12px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.zb-shell-signout:hover {
  border-color: var(--color-primary, #4da3ff);
  background: var(--color-active, #075eaf);
  color: var(--button-active-text, #fff);
}

.control-drop {
  display: none !important;
}

:root[data-theme="light"] .zb-shell-signout {
  color: var(--color-text);
  background: var(--accent-soft);
  border-color: var(--color-border-strong);
}

/* Shared light-mode palette. Keep dark mode page-specific, but make light mode consistent. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef2f6;
  --bg-2: #f8fafc;
  --panel: #ffffff;
  --panel-2: #f4f7fb;
  --panel-3: #e8eef6;
  --line: rgba(20, 37, 56, 0.12);
  --line-strong: rgba(20, 37, 56, 0.2);
  --text: #142033;
  --muted: #62748a;
  --accent: var(--color-primary, #005fbd);
  --accent-2: var(--color-secondary, #007aa8);
  --accent-strong: var(--color-primary-hover, #004996);
  --accent-soft: color-mix(in srgb, var(--color-primary, #005fbd) 12%, transparent);
  --success: #166534;
  --good: #166534;
  --ok: #166534;
  --danger: #b42318;
  --bad: #b42318;
  --warning: #b45309;
  --warn: #b45309;
  --gold: #b45309;
  --red-row: #fecaca;
  --green-row: #bbf7d0;
  --manual-row: #fde68a;
  --shadow: 0 18px 42px rgba(20, 37, 56, 0.1);
}

:root[data-theme="light"] body {
  background: #eef2f6 !important;
  color: var(--text);
}

:root[data-theme="light"] .app-shell,
:root[data-theme="light"] .app-shell-home.settings-mode {
  background: #eef2f6 !important;
}

:root[data-theme="light"] .settings-view,
:root[data-theme="light"] #settingsView {
  background: #eef2f6 !important;
}

:root[data-theme="light"] .metric-card,
:root[data-theme="light"] .panel,
:root[data-theme="light"] .settings-card,
:root[data-theme="light"] .landing-card,
:root[data-theme="light"] .login-card,
:root[data-theme="light"] .card,
:root[data-theme="light"] .detail-panel,
:root[data-theme="light"] .table-panel,
:root[data-theme="light"] .filter-panel,
:root[data-theme="light"] .queue-panel,
:root[data-theme="light"] .stack-panel {
  background: #ffffff !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
}

:root[data-theme="light"] .btn-primary {
  background: var(--color-primary) !important;
  color: #ffffff !important;
  border-color: var(--color-primary) !important;
  box-shadow: 0 10px 22px color-mix(in srgb, var(--color-primary) 20%, transparent);
}

:root[data-theme="light"] .btn-primary:hover {
  background: var(--color-primary-hover) !important;
}

:root[data-theme="light"] .btn-ghost,
:root[data-theme="light"] .filter-button,
:root[data-theme="light"] .filter-action,
:root[data-theme="light"] .icon-button,
:root[data-theme="light"] .route-select,
:root[data-theme="light"] .mini-select,
:root[data-theme="light"] .type-chip,
:root[data-theme="light"] .meta-chip,
:root[data-theme="light"] .status-pill.idle {
  background: #f4f7fb !important;
  color: #24364a !important;
  border-color: var(--line) !important;
}

:root[data-theme="light"] .btn-ghost.is-active,
:root[data-theme="light"] .btn.is-active,
:root[data-theme="light"] .filter-button.active,
:root[data-theme="light"] .filter-button:hover,
:root[data-theme="light"] .account-card.is-active,
:root[data-theme="light"] .queue-card.is-active,
:root[data-theme="light"] .vehicle-card.is-active,
:root[data-theme="light"] .metric-card.is-active,
:root[data-theme="light"] .metric-filter.active,
:root[data-theme="light"] .case-item.active,
:root[data-theme="light"] .location-tile.active,
:root[data-theme="light"] .location-tile:hover {
  background: var(--color-active) !important;
  background-image: none !important;
  color: var(--button-active-text) !important;
  border-color: var(--color-active-border) !important;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-active-ring) 16%, transparent), var(--shadow) !important;
}

:root[data-theme="light"] input,
:root[data-theme="light"] select,
:root[data-theme="light"] textarea,
:root[data-theme="light"] .scan-input,
:root[data-theme="light"] .search-input {
  background: #ffffff !important;
  border-color: rgba(20, 37, 56, 0.16) !important;
  color: var(--text) !important;
}

:root[data-theme="light"] input::placeholder,
:root[data-theme="light"] textarea::placeholder {
  color: #7a8da1 !important;
}

:root[data-theme="light"] thead th,
:root[data-theme="light"] .planning-table th,
:root[data-theme="light"] .table-header,
:root[data-theme="light"] .column-menu-head,
:root[data-theme="light"] .filter-panel-head,
:root[data-theme="light"] .filter-panel-actions {
  background: #e8eef6 !important;
  color: #24364a !important;
  border-color: var(--line) !important;
}

:root[data-theme="light"] tbody td,
:root[data-theme="light"] th,
:root[data-theme="light"] td {
  border-color: rgba(20, 37, 56, 0.09) !important;
}

:root[data-theme="light"] tbody tr:hover {
  background: #f8fafc !important;
}

:root[data-theme="light"] .badge,
:root[data-theme="light"] .pill,
:root[data-theme="light"] .mini-pill,
:root[data-theme="light"] .case-status-badge {
  background: #eef2f6 !important;
  color: #24364a !important;
}

:root[data-theme="light"] .badge.good,
:root[data-theme="light"] .pill.ok,
:root[data-theme="light"] .case-status-badge.good,
:root[data-theme="light"] .status-pill.live,
:root[data-theme="light"] .status-pill.yes {
  background: #86efac !important;
  color: #111827 !important;
}

:root[data-theme="light"] .badge.warn,
:root[data-theme="light"] .pill.warn,
:root[data-theme="light"] .case-status-badge.warn {
  background: #fde68a !important;
  color: #111827 !important;
}

:root[data-theme="light"] .badge.danger,
:root[data-theme="light"] .pill.danger,
:root[data-theme="light"] .case-status-badge.danger,
:root[data-theme="light"] .status-pill.error,
:root[data-theme="light"] .status-pill.no {
  background: #fca5a5 !important;
  color: #111827 !important;
}

:root[data-theme="light"] .badge.info,
:root[data-theme="light"] .case-status-badge.info {
  background: #93c5fd !important;
  color: #111827 !important;
}

:root[data-theme="light"] .badge.muted,
:root[data-theme="light"] .case-status-badge.muted {
  background: #d1d5db !important;
  color: #111827 !important;
}

:root[data-theme="light"] .status-pill.idle {
  background: #b42318 !important;
  color: #ffffff !important;
  border-color: #b42318 !important;
}

:root[data-theme="light"] .case-status-badge,
:root[data-theme="light"] .status-badge,
:root[data-theme="light"] .status-chip {
  color: #111827 !important;
}

:root[data-theme="light"] .ok,
:root[data-theme="light"] .feedback.ok,
:root[data-theme="light"] .component-seen {
  color: #166534 !important;
}

:root[data-theme="light"] .warn,
:root[data-theme="light"] .feedback.warn {
  color: #92400e !important;
}

:root[data-theme="light"] .error,
:root[data-theme="light"] .feedback.error {
  color: #991b1b !important;
}

:root[data-theme="light"] tbody tr.row-pending,
:root[data-theme="light"] tbody tr.missing,
:root[data-theme="light"] #expeditedTable tbody tr.expedited-row-missing > td,
:root[data-theme="light"] .expedite-row:not(.is-complete) {
  background: #fecaca !important;
  color: #111827 !important;
}

:root[data-theme="light"] tbody tr.row-complete,
:root[data-theme="light"] tbody tr.row-manual,
:root[data-theme="light"] tbody tr.available,
:root[data-theme="light"] #expeditedTable tbody tr.expedited-row-complete > td,
:root[data-theme="light"] .expedite-row.is-complete {
  background: #bbf7d0 !important;
  color: #111827 !important;
}

:root[data-theme="light"] .row-has-swap {
  background: #e0f2f1 !important;
}

:root[data-theme="light"] .row-has-move {
  background: #fef3c7 !important;
}

:root[data-theme="light"] .location-ready,
:root[data-theme="light"] .done-check {
  background: #22c55e !important;
  color: #111827 !important;
  border-color: rgba(17, 24, 39, 0.18) !important;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18) !important;
}

:root[data-theme="light"] .row-b2b {
  box-shadow: inset 4px 0 0 #b45309 !important;
}

:root[data-theme="light"] .column-menu,
:root[data-theme="light"] .column-filter-menu {
  background: #ffffff !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}

:root[data-theme="light"] .column-toggle,
:root[data-theme="light"] .filter-value,
:root[data-theme="light"] .unexpected-item,
:root[data-theme="light"] .component-list li,
:root[data-theme="light"] .rule-row {
  background: #f8fafc !important;
  color: var(--text) !important;
}

@media (max-width: 860px) {
  .zb-shell-tabs {
    gap: 4px;
    padding-inline: 8px;
  }

  .zb-shell-brand,
  .zb-shell-role {
    display: none;
  }
}

/* Compact reporting preference beside the signed-in user. */
.zb-shell-tabs .zb-shell-site {
  appearance: none; box-sizing: border-box; flex: 0 0 auto; min-width: 0; min-height: 0;
  margin: 0; padding: 0 26px 0 10px; border: 1px solid rgba(180,197,216,.24);
  border-radius: 6px; color: inherit; background-color: #192431;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='m3 4.5 3 3 3-3' fill='none' stroke='%2391a6bb' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; cursor: pointer;
}
.zb-shell-tabs .zb-shell-site:focus-visible { outline: 2px solid #4ecabc; outline-offset: 2px; }
:root[data-theme="light"] .zb-shell-tabs .zb-shell-site { background-color: #f4f7fb; color: #142033; border-color: rgba(20,37,56,.2); }

/* This sheet loads after the theme, so keep the two-row mobile shell height here. */
@media(max-width:640px) { :root { --zb-shell-height:88px; } }

.zb-shell-tabs .zb-shell-role { display:inline-flex!important;align-items:center;gap:7px;position:relative;min-height:30px;padding:0 10px;font:inherit;font-size:13px;border:1px solid var(--color-border,rgba(180,197,216,.24));border-radius:6px;background:var(--color-surface-alt,#192431);color:var(--color-text,#f3f7fc);cursor:pointer;white-space:nowrap; }
.zb-shell-role:focus-visible { outline:2px solid var(--color-primary);outline-offset:2px; }
.zb-notification-count { position:absolute;top:-6px;right:-6px;min-width:20px;height:20px;padding:0 4px;border:2px solid var(--color-surface,#121a24);border-radius:999px;background:#d52b36;color:#fff;font-size:11px;font-weight:800;line-height:1;display:grid;place-items:center;pointer-events:none; }
.zb-notification-count[hidden], .zb-notifications[hidden] { display:none!important; }
.zb-notifications { position:absolute;top:calc(100% + 7px);right:10px;width:min(410px,calc(100vw - 20px));color:var(--color-text,#edf4fc);background:rgb(var(--surface-raised-rgb,23,35,50));border:1px solid var(--color-border-strong,#40526a);border-radius:var(--card-radius,14px);box-shadow:0 15px 45px #0005;font-size:13px;overflow:hidden;z-index:10070; }
.zb-notifications > header { display:flex;align-items:center;gap:10px;padding:15px 16px;border-bottom:1px solid var(--color-border); }
.zb-notifications h2 { margin:0;flex:1;font-size:15px; }
.zb-notifications button { cursor:pointer;color:inherit;background:transparent;border:1px solid var(--color-border);border-radius:6px;min-height:28px;padding:4px 8px;font:inherit; }
.zb-notifications button:disabled { opacity:.5;cursor:default; }
.zb-notifications button:focus-visible,.zb-notifications a:focus-visible { outline:2px solid var(--color-primary);outline-offset:2px; }
.zb-notifications-close { font-size:20px!important;line-height:1; }
.zb-notifications-status { margin:0;padding:0 16px;color:var(--color-text-muted); }
.zb-notifications-status:empty { display:none; }
.zb-notifications-list { max-height:min(460px,60vh);overflow-y:auto;overscroll-behavior:contain; }
.zb-notification { display:flex;gap:12px;padding:15px 16px;border-bottom:1px solid var(--color-border); }
.zb-notification[data-read="false"] { border-left:3px solid var(--color-primary);padding-left:13px; }
.zb-notification > div { flex:1;min-width:0; }
.zb-notification strong { font-size:13px;line-height:1.4; }
.zb-notification p { margin:6px 0;color:var(--color-text-muted);line-height:1.5;overflow-wrap:anywhere; }
.zb-notification time { display:block;font-size:11px;color:var(--color-text-muted); }
.zb-notifications a { color:var(--color-primary);text-decoration:none; }
.zb-notification a { display:inline-block;margin-top:9px;font-size:12px; }
.zb-notification-dismiss { align-self:flex-start; }
.zb-notifications-empty { text-align:center;padding:35px 20px;color:var(--color-text-muted); }
.zb-notifications > footer { display:flex;justify-content:space-between;padding:12px 16px;font-size:11px;color:var(--color-text-muted); }
@media(max-width:640px) { .zb-shell-tabs {gap:4px!important;} .zb-shell-tabs .zb-shell-role {padding:0 7px;} .zb-shell-user-name {display:none;} body.zb-dashboard-system .zb-shell-brand {font-size:12px;} .zb-shell-tabs .zb-shell-site {max-width:122px;} .zb-shell-signout {padding:0 7px!important;font-size:11px!important;} }
body.zb-dashboard-system .zb-shell-tabs .zb-shell-role {background:var(--color-surface-alt);color:var(--color-text);border-color:var(--color-border);box-shadow:none;}

/* Keep dashboard tabs visible; narrower displays use a second tab row. */
.zb-shell-tabs > .zb-shell-menu { display:none!important; }
.zb-shell-tabs > .zb-shell-nav { display:flex!important; }
.zb-shell-tabs > .zb-shell-nav .zb-shell-tab { flex-shrink:0; }
@media(max-width:1580px) {
  :root { --zb-shell-height:88px; }
  .zb-shell-tabs { flex-wrap:wrap; gap:4px 8px; padding:6px 12px; }
  .zb-shell-tabs > .zb-shell-brand { display:inline-flex; }
  .zb-shell-tabs > .zb-shell-nav { order:10; width:100%; flex:0 0 100%; padding-bottom:2px; }
  .zb-shell-tabs > .zb-shell-spacer { flex:1 1 0; }
  .zb-shell-tabs > .zb-shell-role,.zb-shell-tabs > .zb-shell-site,.zb-shell-tabs > .zb-shell-signout { flex-shrink:0; }
}
@media(max-width:380px) {
  .zb-shell-tabs { padding-inline:8px!important; }
  .zb-shell-tabs > .zb-shell-brand { padding:0!important; gap:4px; font-size:11px!important; }
  .zb-shell-brand-logo { width:20px; height:20px; }
  .zb-shell-tabs .zb-shell-site { max-width:90px; padding-left:7px; }
  .zb-shell-tabs .zb-shell-role { gap:4px; padding:0 5px; }
}

/* The name remains a clear notification target on phones without a bell. */
@media(max-width:640px) {
  .zb-shell-tabs .zb-shell-user-name { display:block;max-width:100px;overflow:hidden;text-overflow:ellipsis; }
}
@media(max-width:380px) {
  .zb-shell-tabs .zb-shell-user-name { max-width:62px;font-size:11px; }
}

/* Keep phone account controls on one row; tabs own the second row. A flexible
   site/name cell can shrink without pushing Sign Out below the fixed header. */
@media(max-width:640px) {
  body.zb-dashboard-system .zb-shell-tabs {
    display:grid;grid-template-columns:auto minmax(0,1fr) minmax(0,auto) auto;
    grid-template-rows:36px minmax(0,1fr);gap:4px;padding:6px 10px;
  }
  .zb-shell-tabs > .zb-shell-spacer { display:none; }
  .zb-shell-tabs > .zb-shell-brand { grid-column:1;grid-row:1; }
  body.zb-dashboard-system .zb-shell-tabs > .zb-shell-brand { font-size:12px; }
  .zb-shell-tabs > .zb-shell-site { grid-column:2;grid-row:1;justify-self:end;width:100%!important;max-width:122px; }
  body.zb-dashboard-system .zb-shell-tabs > .zb-shell-role { grid-column:3;grid-row:1;min-width:0;padding:0 7px;font-size:12px; }
  .zb-shell-tabs > .zb-shell-signout { grid-column:4;grid-row:1; }
  .zb-shell-tabs > .zb-shell-nav { grid-column:1/-1;grid-row:2;min-width:0;width:100%; }
  .zb-shell-tabs .zb-shell-user-name { min-width:0; }
}
@media(max-width:420px) {
  .zb-shell-tabs .zb-shell-user-name { max-width:72px; }
}
@media(max-width:380px) {
  body.zb-dashboard-system .zb-shell-tabs > .zb-shell-role { padding:0 5px; }
  .zb-shell-tabs .zb-shell-user-name { max-width:62px; }
}

/* Match all account controls, including borders and inherited button rules. */
body.zb-dashboard-system .zb-shell-tabs .zb-shell-site,
body.zb-dashboard-system .zb-shell-tabs .zb-shell-role,
body.zb-dashboard-system .zb-shell-tabs .zb-shell-signout {
  box-sizing:border-box!important;height:32px!important;min-height:32px!important;max-height:32px!important;
  margin:0!important;padding-top:0!important;padding-bottom:0!important;line-height:1!important;align-self:center;
}
