/* ==========================================================================
   BIDIFY ADMIN — Material clean UI, Bidify colors (same tokens as the extension's Options page)
   ========================================================================== */

:root {
  --navy: #0f172a;
  --navy-2: #1e293b;
  --blue: #0088ff;
  --blue-strong: #0070d6;
  --blue-strong-hover: #005bb0;
  --blue-soft: #e0f2fe;
  --blue-ink: #075985;
  --orange: #ff551c;
  --orange-strong: #c2410c;
  --orange-soft: #ffedd5;
  --green-ink: #15803d;
  --green-soft: #dcfce7;
  --red-ink: #b91c1c;
  --red-soft: #fee2e2;
  --red-border: #fecaca;
  --text-primary: #0f172a;
  --text-main: #334155;
  --text-2: #475569;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --row-line: #f1f5f9;
  --surface: #f8fafc;
  --card: #ffffff;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-modal: 0 20px 35px -8px rgba(15, 23, 42, 0.25);
  --focus: 0 0 0 3px rgba(0, 136, 255, 0.45);
  --sidebar-w: 248px;
  --mono: Consolas, "JetBrains Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text-main);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--blue-strong);
}

a:hover {
  color: var(--blue-strong-hover);
}

button,
input,
select,
textarea {
  font-family: inherit;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Line icons (built by ui.js) */
.i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.boot {
  position: fixed;
  inset: 0;
  background: var(--surface);
}

/* ==========================================================================
   SIGN-IN (same look as the extension's Options sign-in)
   ========================================================================== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  overflow-y: auto;
  background: var(--card);
}

.login-brand {
  flex: 1 1 480px;
  padding: 48px 56px 56px;
  background: var(--navy);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.login-truck {
  display: block;
  width: 440px;
  max-width: 100%;
  height: auto;
}

.login-brand-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: #94a3b8;
}

.login-main {
  flex: 1 1 480px;
  padding: 56px 24px;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-panel {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
}

.login-panel h1 {
  margin: 0 0 8px 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.login-hint {
  margin: 0 0 32px 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-2);
}

.google-btn {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 16px;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.google-btn:hover {
  background: var(--surface);
  border-color: var(--blue-strong);
}

.google-btn-icon,
.google-btn-spinner {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.google-btn-label,
.google-btn-waiting {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.google-btn-spinner,
.google-btn-waiting {
  display: none;
}

.google-btn.loading {
  pointer-events: none;
  cursor: progress;
  background: var(--surface);
  border-color: var(--border);
  box-shadow: none;
}

.google-btn.loading .google-btn-icon,
.google-btn.loading .google-btn-label {
  display: none;
}

.google-btn.loading .google-btn-spinner {
  display: block;
  animation: spin 0.8s linear infinite;
}

.google-btn.loading .google-btn-waiting {
  display: inline;
  color: var(--text-2);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.login-notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid #fca5a5;
  border-radius: var(--radius-md);
  background: #fef2f2;
  color: var(--red-ink);
}

.login-notice-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-notice-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.login-notice-text {
  margin: 2px 0 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: #7f1d1d;
}

.login-divider {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: 32px 0 24px 0;
}

.login-security {
  margin: 0;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-2);
}

.login-security svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 2px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 760px) {
  .login-brand {
    flex-basis: 100%;
    padding: 32px 24px 28px;
  }

  .login-truck {
    width: 300px;
  }

  .login-main {
    flex-basis: 100%;
    align-items: flex-start;
    padding: 32px 24px 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .google-btn.loading .google-btn-spinner {
    animation: none;
  }
}

/* ==========================================================================
   APP SHELL: side menu + page
   ========================================================================== */
.app {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  padding: 18px 12px 14px;
  background: var(--navy);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 30;
}

.sidebar-close-row {
  display: none;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 16px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand img {
  display: block;
  width: 184px;
  height: auto;
}

.brand-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: #94a3b8;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  color: #cbd5e1;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.nav:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav .i {
  width: 20px;
  height: 20px;
  color: #94a3b8;
}

.nav.on {
  background: rgba(0, 136, 255, 0.18);
  color: #fff;
  font-weight: 600;
}

.nav.on .i {
  color: #4da9ff;
}

.nav-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
}

.nav-new {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: #fdba74;
  background: rgba(255, 85, 28, 0.2);
  padding: 2px 8px;
  border-radius: 999px;
}

.account {
  margin-top: auto;
  padding: 12px 0 0 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.account-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(0, 136, 255, 0.22);
  color: #cfe6ff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.account-text {
  flex: 1;
  min-width: 0;
}

.account-caption {
  font-size: 11.5px;
  color: #94a3b8;
}

.account-email {
  font-size: 13px;
  color: #e2e8f0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--row-line);
  color: var(--text-primary);
}

.account-signout,
.sidebar-close,
.topbar-btn {
  color: #94a3b8;
}

.account-signout {
  width: 36px;
  height: 36px;
}

.account-signout:hover,
.sidebar-close:hover,
.topbar-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.topbar {
  display: none;
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 25;
}

.page {
  margin-left: var(--sidebar-w);
  min-width: 0;
  padding: 28px 32px 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  outline: none;
}

/* The page area gets focus after navigation (for screen readers), without a visible ring */
.page:focus,
.page:focus-visible {
  box-shadow: none;
}

/* Phone and small tablet: top bar + drawer */
@media (max-width: 899px) {
  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 4px;
    height: 56px;
    padding: 0 12px 0 6px;
    background: var(--navy);
    color: #f8fafc;
  }

  .topbar-btn {
    width: 48px;
    height: 48px;
  }

  .topbar-btn .i {
    width: 24px;
    height: 24px;
  }

  .topbar-title {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Closed drawer: off screen, no shadow, and not reachable with Tab */
  .sidebar {
    width: 300px;
    max-width: 86vw;
    padding-top: 12px;
    transform: translateX(-100%);
    visibility: hidden;
    transition:
      transform 0.22s cubic-bezier(0.4, 0, 0.2, 1),
      visibility 0.22s;
  }

  .sidebar.open {
    transform: translateX(0);
    visibility: visible;
    box-shadow: 0 20px 35px -8px rgba(15, 23, 42, 0.4);
  }

  .sidebar-close-row {
    display: flex;
    justify-content: flex-end;
  }

  .sidebar-close {
    width: 44px;
    height: 44px;
  }

  .page {
    margin-left: 0;
    padding: 16px 16px 40px;
    gap: 14px;
  }

  .page-head h1 {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}

/* ==========================================================================
   PAGE PARTS
   ========================================================================== */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.page-head h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-sub {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--text-muted);
}

.head-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.updated {
  font-size: 13px;
  color: var(--text-muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-width: 0;
}

.card-pad {
  padding: 20px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-sub {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.link {
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: var(--blue-strong);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.link:hover {
  color: var(--blue-strong-hover);
  text-decoration: underline;
}

.row-flex {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

.mono {
  font-family: var(--mono);
  font-size: 13px;
}

.empty {
  padding: 28px 20px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

.loading-line {
  padding: 28px 20px;
  font-size: 14px;
  color: var(--text-muted);
}

/* KPI cards */
.kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.kpi {
  flex: 1 1 190px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  color: inherit;
}

a.kpi:hover {
  border-color: var(--border-strong);
}

.kpi-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.kpi-note {
  font-size: 13px;
  color: var(--text-muted);
}

.kpi-note.warn {
  color: var(--orange-strong);
  font-weight: 600;
}

.tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.tile-stat {
  flex: 1 1 150px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tile-stat .k {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.tile-stat .v {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.15;
}

.tile-stat .s {
  font-size: 12.5px;
  color: var(--text-muted);
}

@media (max-width: 599px) {
  .kpis {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .kpi {
    padding: 14px;
  }

  .kpi-value {
    font-size: 24px;
  }

  .tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
}

/* Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.chip-ok {
  background: var(--green-soft);
  color: var(--green-ink);
}

.chip-off {
  background: var(--row-line);
  color: var(--text-2);
}

.chip-bad {
  background: var(--red-soft);
  color: var(--red-ink);
}

.chip-new {
  background: var(--orange-soft);
  color: var(--orange-strong);
}

.chip-info {
  background: var(--blue-soft);
  color: var(--blue-ink);
}

/* Avatars */
.av {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--blue-soft);
  color: #0369a1;
}

.av.grey {
  background: var(--row-line);
  color: var(--text-2);
}

.av.big {
  width: 48px;
  height: 48px;
  font-size: 15px;
}

/* Lists inside cards */
.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-top: 1px solid var(--row-line);
}

.list-row.wrap {
  flex-wrap: wrap;
}

.list-main {
  flex: 1 1 260px;
  min-width: 0;
}

.list-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.list-line {
  font-size: 13.5px;
  color: var(--text-main);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-ic {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tile-ic .i {
  width: 20px;
  height: 20px;
}

.tile-ic.orange {
  background: var(--orange-soft);
  color: var(--orange-strong);
}

.tile-ic.blue {
  background: var(--blue-soft);
  color: #0369a1;
}

.tile-ic.green {
  background: var(--green-soft);
  color: var(--green-ink);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  font: 600 14px "Inter", system-ui, sans-serif;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text-main);
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface);
  color: var(--text-primary);
}

.btn .i {
  width: 18px;
  height: 18px;
}

.btn-sm {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-primary {
  background: var(--blue-strong);
  border-color: var(--blue-strong);
  color: #fff;
}

.btn-primary:hover {
  background: var(--blue-strong-hover);
  border-color: var(--blue-strong-hover);
  color: #fff;
}

.btn-danger {
  color: var(--red-ink);
  border-color: var(--red-border);
}

.btn-danger:hover {
  background: #fef2f2;
  color: var(--red-ink);
}

.btn-danger-filled {
  background: var(--red-ink);
  border-color: var(--red-ink);
  color: #fff;
}

.btn-danger-filled:hover {
  background: #991b1b;
  border-color: #991b1b;
  color: #fff;
}

.btn:disabled,
.btn[disabled] {
  background: var(--border);
  border-color: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn.busy {
  pointer-events: none;
  opacity: 0.75;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn-row.between {
  justify-content: space-between;
}

/* Filters and fields */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.field {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text-muted);
}

.field:focus-within {
  border-color: var(--blue-strong);
  box-shadow: 0 0 0 3px rgba(0, 136, 255, 0.16);
}

.field input,
.field select {
  border: 0;
  outline: 0;
  background: transparent;
  font: 500 13.5px "Inter", system-ui, sans-serif;
  color: var(--text-primary);
  min-width: 0;
}

.field input {
  flex: 1;
  font-weight: 400;
}

.field select {
  cursor: pointer;
  max-width: 260px;
}

.field.search {
  flex: 1 1 260px;
  max-width: 420px;
}

.input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font: 500 14px "Inter", system-ui, sans-serif;
  color: var(--text-primary);
  background: #fff;
  min-width: 0;
}

.input:focus,
textarea.input:focus {
  outline: none;
  border-color: var(--blue-strong);
  box-shadow: 0 0 0 3px rgba(0, 136, 255, 0.16);
}

textarea.input {
  height: auto;
  min-height: 96px;
  padding: 10px 12px;
  line-height: 1.5;
  resize: vertical;
  font-weight: 400;
}

textarea.input.code {
  font-family: var(--mono);
  font-size: 12.5px;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #fff;
  font: 500 13px "Inter", system-ui, sans-serif;
  color: var(--text-main);
  cursor: pointer;
}

.filter-pill.on {
  background: var(--blue-soft);
  border-color: #7dd3fc;
  color: var(--blue-ink);
  font-weight: 600;
}

/* Segmented buttons */
.seg {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #fff;
  flex-shrink: 0;
}

.seg-btn {
  height: 38px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  font: 500 13.5px "Inter", system-ui, sans-serif;
  color: var(--text-main);
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
}

.seg-btn:last-child {
  border-right: 0;
}

.seg-btn.on {
  background: var(--blue-soft);
  color: var(--blue-ink);
  font-weight: 600;
}

.seg.small .seg-btn {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}

.tab {
  height: 44px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 500 14px "Inter", system-ui, sans-serif;
  color: var(--text-2);
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  cursor: pointer;
}

.tab.on {
  color: var(--blue-strong);
  font-weight: 600;
  border-bottom-color: var(--blue);
}

.tab .chip {
  height: 20px;
  font-size: 11px;
  padding: 0 8px;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.tbl th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.tbl td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--row-line);
  white-space: nowrap;
  color: var(--text-2);
}

.tbl .num {
  text-align: right;
}

.tbl .strong {
  font-weight: 600;
  color: var(--text-primary);
}

.tbl tr.sel td {
  background: #f0f9ff;
}

.tbl tbody tr:hover td {
  background: #f8fbff;
}

.tbl tbody tr.sel:hover td {
  background: #f0f9ff;
}

.tbl tfoot td {
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 0;
  border-top: 1px solid var(--border);
}

.tbl .ellipsis {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pick {
  all: unset;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  font-weight: 600;
  color: var(--text-primary);
  max-width: 340px;
}

.pick:focus-visible {
  box-shadow: var(--focus);
  border-radius: var(--radius-sm);
}

.pick-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.pick.mono-pick {
  display: block;
  line-height: 40px;
  font-family: var(--mono);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lane {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.lane .i {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

/* Horizontal bars (layers, error types) */
.hbar {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 56px;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
  min-height: 32px;
}

.hbar-track {
  height: 12px;
  background: var(--row-line);
  border-radius: 0 4px 4px 0;
}

.hbar-fill {
  display: block;
  height: 12px;
  border-radius: 0 4px 4px 0;
  background: var(--blue);
}

.hbar-fill.grey {
  background: var(--text-muted);
}

.hbar-val {
  text-align: right;
  font-weight: 600;
  color: var(--text-primary);
}

/* Bar chart (one series, Bidify blue) */
.chart {
  display: flex;
  gap: 10px;
}

.chart-y {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 24px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
}

.chart-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chart-plot {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  border-bottom: 1px solid var(--border-strong);
}

.chart-grid {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed var(--border);
  pointer-events: none;
}

.chart-col {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  cursor: default;
}

.chart-col:hover .chart-bar,
.chart-col:focus-visible .chart-bar {
  background: #0070d6;
}

.chart-col:focus-visible {
  box-shadow: none;
  outline: 2px solid rgba(0, 136, 255, 0.45);
  outline-offset: 1px;
}

.chart-bar {
  width: 100%;
  max-width: 28px;
  background: var(--blue);
  border-radius: 4px 4px 0 0;
}

.chart-peak {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-main);
}

.chart-x {
  display: flex;
  gap: 2px;
}

.chart-x span {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: visible;
}

.chart-tip {
  position: fixed;
  z-index: 80;
  pointer-events: none;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--navy);
  color: #f8fafc;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 8px 18px -6px rgba(15, 23, 42, 0.35);
}

/* Split view: list + details */
.split {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}

.split-list {
  flex: 999 1 560px;
  min-width: 0;
}

.split-detail {
  flex: 1 1 380px;
  min-width: 0;
}

.detail-back-row {
  display: none;
}

.strong {
  font-weight: 600;
  color: var(--text-primary);
}

.chip-row {
  margin-top: 8px;
}

/* Phone: list first, tap opens details full width with a Back button */
@media (max-width: 719px) {
  .split.show-detail .split-list,
  .page:has(.split.show-detail) .split-hide-on-detail {
    display: none;
  }

  .split:not(.show-detail) .split-detail {
    display: none;
  }

  .detail-back-row {
    display: block;
    padding: 12px 16px 0;
  }

  .tbl .hide-sm {
    display: none;
  }

  .pick {
    max-width: 210px;
  }
}

.detail {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-main);
}

.detail-sec {
  padding: 16px 20px;
  border-top: 1px solid var(--row-line);
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-main);
}

.tbl .lane {
  flex-wrap: nowrap;
}

.set .muted {
  font-size: 13.5px;
}

.sec-title {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kv {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 8px;
  font-size: 13.5px;
  padding: 7px 0;
  border-bottom: 1px solid var(--row-line);
}

.kv > span:first-child {
  color: var(--text-muted);
}

.kv > span:last-child {
  word-break: break-word;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
  min-height: 28px;
}

.kv-row .val {
  display: flex;
  align-items: center;
  gap: 14px;
}

.kv-row .link {
  white-space: nowrap;
  flex-shrink: 0;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mini {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.mini .k {
  font-size: 12px;
  color: var(--text-muted);
}

.mini .v {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.detail-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  word-break: break-word;
}

.detail-title.mono {
  font-family: var(--mono);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.5;
}

.stack {
  margin: 0;
  padding: 12px 14px;
  background: var(--navy);
  color: #e2e8f0;
  border-radius: var(--radius-md);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
}

.mail-frame {
  width: 100%;
  min-height: 260px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
}

.user-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px;
}

.user-head .email {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   SETTINGS
   ========================================================================== */
.settings {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
}

.settings-nav {
  flex: 1 1 200px;
  max-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-body {
  flex: 999 1 520px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sm {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  font: 500 14px "Inter", system-ui, sans-serif;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
}

.sm .i {
  color: var(--text-muted);
}

.sm:hover {
  background: var(--row-line);
}

.sm.on {
  background: var(--blue-soft);
  color: var(--blue-ink);
  font-weight: 600;
}

.sm.on .i {
  color: var(--blue-strong);
}

@media (max-width: 719px) {
  .settings-nav {
    max-width: none;
    flex-direction: row;
    overflow-x: auto;
    flex-basis: 100%;
  }

  .sm {
    flex-shrink: 0;
  }
}

.set-title {
  margin: 0;
  padding: 18px 20px 4px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.set-intro {
  margin: 0;
  padding: 0 20px 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.set {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 16px 20px;
  border-top: 1px solid var(--row-line);
}

.set-text {
  flex: 1 1 260px;
  min-width: 0;
}

.set-text b {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.set-text span {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.45;
}

.set-extra {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-left: 60px;
  font-size: 13.5px;
  color: var(--text-main);
}

@media (max-width: 599px) {
  .set-extra {
    padding-left: 0;
  }
}

.set-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.switch {
  flex-shrink: 0;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.switch .knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.25);
  transition: left 0.15s ease;
}

.switch.on {
  background: var(--blue-strong);
}

.switch.on .knob {
  left: 21px;
}

.email-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 6px 0 12px;
  border-radius: 999px;
  background: var(--row-line);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.email-chip button {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
}

.email-chip button:hover {
  background: var(--border);
}

.email-chip .i {
  width: 14px;
  height: 14px;
}

.choice {
  flex: 1 1 180px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.choice.on {
  border: 2px solid var(--blue);
  padding: 11px 13px;
  background: #f0f9ff;
}

.choice b {
  font-size: 14px;
  color: var(--text-primary);
}

.choice span {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ==========================================================================
   DIALOG (confirmation popups), SIDE PANEL (data editor), SNACKBAR
   ========================================================================== */
.dialog-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 120px 16px 16px;
  overflow-y: auto;
}

.dialog-scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}

.dialog {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dialog.wide {
  max-width: 720px;
}

.dialog-ic {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dialog-ic .i {
  width: 22px;
  height: 22px;
}

.dialog-ic.red {
  background: var(--red-soft);
  color: var(--red-ink);
}

.dialog-ic.blue {
  background: var(--blue-soft);
  color: var(--blue-strong);
}

.dialog h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  word-break: break-word;
}

.dialog-body {
  margin: 0;
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.55;
}

.dialog-quote {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  word-break: break-word;
}

.dialog-note {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.dialog-note.red {
  color: var(--red-ink);
}

.dialog-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: #fef2f2;
  color: var(--red-ink);
  font-size: 13px;
  font-weight: 500;
}

.dialog-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 4px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.dialog-text {
  max-height: 60vh;
  overflow: auto;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 599px) {
  .dialog-layer {
    align-items: center;
    padding: 16px;
  }

  .dialog {
    padding: 20px;
  }

  .dialog-actions .btn {
    flex: 1;
  }
}

.panel-layer {
  position: fixed;
  inset: 0;
  z-index: 55;
}

.panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 100%;
  background: #fff;
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 12px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  flex: 1;
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.panel-item {
  all: unset;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--row-line);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
}

.panel-item:hover {
  background: var(--surface);
}

.panel-item.on {
  background: #f0f9ff;
  font-weight: 600;
}

.panel-item .i {
  margin-left: auto;
  color: var(--text-muted);
}

.panel-form {
  padding: 16px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.snackbar {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  background: var(--navy);
  color: #f8fafc;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 12px 28px -6px rgba(15, 23, 42, 0.24);
  max-width: calc(100vw - 48px);
}

.snackbar .i {
  color: #86efac;
}

.snackbar.error {
  background: var(--red-ink);
}

.snackbar.error .i {
  color: #fff;
}

@media (min-width: 900px) {
  .snackbar {
    left: calc(var(--sidebar-w) + 32px);
  }
}
