/**
 * Travelport Ticket Tracer admin — styles.
 *
 * Self-contained: system font stack, no external fonts/assets. Light theme,
 * dark slate sidebar, white content. Chart colors follow the dataviz method:
 * a single validated accent hue for the carrier bars (magnitude = length,
 * identity = the row label, so one hue is correct), status colors always
 * paired with a text label, values in ink — never in the series color.
 */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #101418;
  --ink-2: #4b5563;
  --muted: #8a8f98;
  --line: #e5e7eb;
  --axis: #c8ccd2;

  --accent: #2a78d6;
  --accent-deep: #1c5cab;
  --accent-tint: #e8f0fb;

  --good: #0ca30c;
  --good-text: #1a6b1a;
  --good-tint: #e6f4e6;
  --warn: #b97e0a;
  --warn-tint: #fdf3d9;
  --warn-line: #f0d48a;
  --warn-text: #7a5200;
  --bad: #d03b3b;
  --bad-text: #a02222;
  --bad-tint: #fbe9e9;

  --slate-900: #16202e;
  --slate-800: #1d2a3a;
  --slate-ink: #b7c3d2;
  --slate-ink-dim: #7d8b9c;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 20, 24, 0.05), 0 1px 3px rgba(16, 20, 24, 0.07);
  --mono: ui-monospace, 'Cascadia Code', Consolas, 'Courier New', monospace;
}

* { box-sizing: border-box }

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

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600 }
h1 { font-size: 20px; letter-spacing: -0.01em }
h2 { font-size: 15px }
button { font: inherit }
a { color: var(--accent-deep) }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------------------------------------------------------------- layout */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  flex: 0 0 224px;
  background: var(--slate-900);
  color: var(--slate-ink);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 18px;
}

.brand-name {
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
}

.brand-sub {
  font-size: 11px;
  color: var(--slate-ink-dim);
  margin-top: 1px;
}

.nav {
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--slate-ink);
  text-decoration: none;
  font-weight: 500;
  border-left: 2px solid transparent;
}

.nav a:hover { background: var(--slate-800); color: #fff }

.nav a.active {
  background: var(--slate-800);
  color: #fff;
  border-left-color: var(--accent);
}

.nav-ico {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  opacity: 0.85;
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px 18px;
  font-size: 11px;
  color: var(--slate-ink-dim);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 28px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.whoami {
  color: var(--ink-2);
  font-size: 13px;
}

.whoami b { color: var(--ink); font-weight: 600 }

.view {
  padding: 26px 32px 48px;
  max-width: 1160px;
  width: 100%;
  margin: 0 auto;
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.view-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-body { padding: 16px 18px }

/* stat tiles — label / value contract from the dataviz skill: sentence-case
   label, semibold proportional-figure value, delta-free */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px 12px;
}

.stat-label {
  font-size: 12px;
  color: var(--ink-2);
}

.stat-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 2px;
  color: var(--ink);
}

.stat-value.range { font-size: 17px; padding: 7px 0 6px }

.stat-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

/* ---------------------------------------------------------------- banner */

.banner {
  border-radius: var(--radius);
  padding: 11px 16px;
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 13px;
}

.banner.warn {
  background: var(--warn-tint);
  border: 1px solid var(--warn-line);
  color: var(--warn-text);
}

.banner b { font-weight: 600 }

/* ------------------------------------------------------- carrier bar list */

.bar-list { display: flex; flex-direction: column }

.bar-row {
  display: grid;
  grid-template-columns: 172px 1fr 90px;
  align-items: center;
  gap: 14px;
  padding: 6px 0;
}

.bar-row:hover { background: #f8fafc }

.bar-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.bar-label .name {
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.carrier-code {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-deep);
  background: var(--accent-tint);
  border-radius: 4px;
  padding: 1px 5px;
  min-width: 26px;
  text-align: center;
}

/* single-series bars: one hue, square at the shared left baseline, 4px
   rounded data-end; the hairline is the baseline axis */
.bar-track {
  border-left: 1px solid var(--axis);
  padding: 2px 0;
  align-self: stretch;
  display: flex;
  align-items: center;
}

.bar-fill {
  height: 12px;
  min-width: 2px;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}

.bar-count {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--ink);
}

/* ---------------------------------------------------------------- tables */

.tbl-wrap { overflow-x: auto }

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

.tbl th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.tbl td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.tbl tbody tr:last-child td { border-bottom: none }
.tbl tbody tr:hover { background: #f8fafc }

.tbl td.num, .tbl th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.tbl .empty {
  color: var(--muted);
  text-align: center;
  padding: 26px;
}

.cell-main { font-weight: 500 }
.cell-sub { font-size: 12px; color: var(--muted) }
.dim { color: var(--muted) }

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge.kind-airline { background: var(--accent-tint); color: var(--accent-deep) }
.badge.kind-agency { background: var(--good-tint); color: var(--good-text) }
.badge.kind-internal { background: #eceef1; color: var(--ink-2) }

.badge.st-active { background: var(--good-tint); color: var(--good-text) }
.badge.st-disabled { background: #eceef1; color: var(--muted) }

.chips { display: flex; flex-wrap: wrap; gap: 4px }

.chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
  background: #f1f3f5;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
}

.chip.scope-air { background: var(--accent-tint); border-color: #cbdff6; color: var(--accent-deep) }

/* status dot — color never carries state alone; always beside its label */
.stdot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
}

.stdot.ok { background: var(--good) }
.stdot.error { background: var(--bad) }
.stdot.running { background: var(--warn) }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  font-size: 13.5px;
  cursor: pointer;
}

.btn:hover { background: #f4f6f8 }
.btn:disabled { opacity: 0.55; cursor: default }

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

.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep) }

.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 6px }

.btn-danger { color: var(--bad-text) }
.btn-danger:hover { background: var(--bad-tint) }

.row-actions { display: flex; gap: 6px; justify-content: flex-end }

/* ----------------------------------------------------------------- forms */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}

.form-grid .full { grid-column: 1 / -1 }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 4px;
}

.field .hint {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
}

input[type='text'],
input[type='password'],
select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #d4d8dd;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

input:focus, select:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-tint);
}

/* segmented kind toggle */
.seg {
  display: inline-flex;
  border: 1px solid #d4d8dd;
  border-radius: 8px;
  overflow: hidden;
}

.seg button {
  padding: 7px 18px;
  border: none;
  background: var(--surface);
  color: var(--ink-2);
  font-weight: 500;
  cursor: pointer;
}

.seg button + button { border-left: 1px solid #d4d8dd }

.seg button.on {
  background: var(--accent-tint);
  color: var(--accent-deep);
  font-weight: 600;
}

.seg button:disabled { cursor: default; opacity: 0.7 }

/* scrolling checkbox lists (cities, grants) */
.checklist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 2px 12px;
  max-height: 190px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.checklist label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 400;
  color: var(--ink);
  padding: 3px 2px;
  margin: 0;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.checklist label.special { font-weight: 600 }
.checklist label .count { color: var(--muted); font-size: 12px }
.checklist label.off { color: var(--muted) }

.radio-row {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 4px 0;
}

.radio-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  font-size: 13px;
  margin: 0;
  cursor: pointer;
}

.form-error {
  color: var(--bad-text);
  font-size: 13px;
  min-height: 18px;
}

.form-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
}

.form-foot .spacer { flex: 1 }

/* preview result */
.preview-box {
  background: var(--accent-tint);
  border: 1px solid #cbdff6;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13.5px;
}

.preview-box .headline { font-weight: 600; color: var(--accent-deep) }

.preview-box table {
  margin-top: 8px;
  border-collapse: collapse;
  font-size: 12.5px;
  width: 100%;
}

.preview-box th, .preview-box td {
  text-align: left;
  padding: 2px 12px 2px 0;
  color: var(--ink-2);
}

.preview-box th {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.preview-box td.num, .preview-box th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------- one-time password */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 20, 24, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(16, 20, 24, 0.25);
  width: min(440px, calc(100vw - 40px));
  padding: 22px 24px;
}

.modal h2 { margin-bottom: 4px }

.modal .modal-sub { color: var(--ink-2); font-size: 13px; margin-bottom: 14px }

.otp-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--warn-tint);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.otp-box code {
  flex: 1;
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0.04em;
  color: var(--ink);
  user-select: all;
  word-break: break-all;
}

.otp-note {
  color: var(--warn-text);
  font-size: 12.5px;
  font-weight: 600;
  margin-top: 8px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

/* ----------------------------------------------------------------- login */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1000px 500px at 80% -10%, rgba(42, 120, 214, 0.12), transparent 60%),
    var(--slate-900);
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.35);
  width: min(380px, 100%);
  padding: 30px 30px 26px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.login-card h1 { font-size: 19px }

.login-sub {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 20px;
}

.login-card .field { margin-bottom: 14px }

.login-error {
  min-height: 20px;
  font-size: 13px;
  color: var(--bad-text);
  margin-bottom: 8px;
}

.login-error.throttle { color: var(--warn-text) }

.login-card .btn-primary {
  width: 100%;
  justify-content: center;
  padding: 9px 14px;
}

.login-foot {
  text-align: center;
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 16px;
}

/* ----------------------------------------------------------------- toast */

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: var(--slate-900);
  color: #fff;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  z-index: 60;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show { opacity: 1; transform: none }
.toast.error { background: #7c1d1d }

.loading {
  color: var(--muted);
  padding: 30px 0;
  text-align: center;
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 900px) {
  .sidebar { flex-basis: 64px }
  .brand-name, .brand-sub, .nav a span, .sidebar-foot { display: none }
  .nav a { justify-content: center; padding: 10px }
  .view { padding: 20px 16px 40px }
  .form-grid { grid-template-columns: 1fr }
  .bar-row { grid-template-columns: 120px 1fr 76px }
}
