/* ─────────────────────────────────────────────────────────────
   USCIS Case Tracker — stylesheet
   Dark is the default; light is applied via [data-theme="light"].
   ───────────────────────────────────────────────────────────── */

:root {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-elev-2: #1c2129;
  --border: #30363d;
  --border-soft: #21262d;
  --text: #e6edf3;
  --text-dim: #9198a1;
  --muted: #8b949e;

  --gold: #d4a843;
  --gold-dim: rgba(212, 168, 67, .16);
  --blue: #58a6ff;
  --blue-dim: rgba(88, 166, 255, .16);
  --green: #3fb950;
  --green-dim: rgba(63, 185, 80, .16);
  --red: #f85149;
  --red-dim: rgba(248, 81, 73, .16);
  --purple: #bc8cff;
  --purple-dim: rgba(188, 140, 255, .16);
  --orange: #f0883e;
  --orange-dim: rgba(240, 136, 62, .16);

  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .18);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-elev: #ffffff;
  --bg-elev-2: #f0f3f6;
  --border: #d0d7de;
  --border-soft: #e4e8ed;
  --text: #1f2328;
  --text-dim: #59636e;
  --muted: #6e7781;

  --gold: #9a6d00;
  --gold-dim: rgba(154, 109, 0, .12);
  --blue: #0969da;
  --blue-dim: rgba(9, 105, 218, .1);
  --green: #1a7f37;
  --green-dim: rgba(26, 127, 55, .1);
  --red: #cf222e;
  --red-dim: rgba(207, 34, 46, .1);
  --purple: #8250df;
  --purple-dim: rgba(130, 80, 223, .1);
  --orange: #bc4c00;
  --orange-dim: rgba(188, 76, 0, .1);

  --shadow: 0 1px 3px rgba(31, 35, 40, .08), 0 8px 24px rgba(31, 35, 40, .06);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}

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

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

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* ── Header ─────────────────────────────────────────────── */
header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(180%) blur(8px);
}

.hdr {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -.2px;
}

.logo-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--gold), var(--orange));
  display: grid; place-items: center;
  font-size: 16px;
  flex: none;
}

.hdr-spacer { flex: 1 1 auto; }

.hdr-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.clock {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev-2);
  white-space: nowrap;
}

select.tz-select {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  max-width: 190px;
}

.icon-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 14px;
  transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: var(--bg); border-color: var(--gold); }
.icon-btn.active { border-color: var(--gold); color: var(--gold); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background .15s, border-color .15s, opacity .15s, transform .06s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--gold); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--gold), #c1922c);
  border-color: transparent;
  color: #1a1204;
}
[data-theme="light"] .btn-primary { color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }

.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Panels & cards ─────────────────────────────────────── */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin: 18px 0;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.panel-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
}

.panel-sub { font-size: 12.5px; color: var(--text-dim); margin: -6px 0 14px; }

.card {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 15px;
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
}

.card-title-icon {
  width: 22px; height: 22px;
  border-radius: 6px;
  display: grid; place-items: center;
  font-size: 12px;
  flex: none;
}

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-soft);
}
.detail-row:last-child { border-bottom: none; }
.detail-key { color: var(--text-dim); font-size: 12.5px; flex: none; }
.detail-val { text-align: right; font-weight: 600; font-size: 13px; word-break: break-word; }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

.badge-blue   { background: var(--blue-dim);   color: var(--blue);   border-color: var(--blue); }
.badge-green  { background: var(--green-dim);  color: var(--green);  border-color: var(--green); }
.badge-red    { background: var(--red-dim);    color: var(--red);    border-color: var(--red); }
.badge-gold   { background: var(--gold-dim);   color: var(--gold);   border-color: var(--gold); }
.badge-purple { background: var(--purple-dim); color: var(--purple); border-color: var(--purple); }
.badge-orange { background: var(--orange-dim); color: var(--orange); border-color: var(--orange); }
.badge-gray   { background: rgba(139,148,158,.14); color: var(--muted); border-color: var(--muted); }

/* ── Connect / fetch panel ──────────────────────────────── */
.connect-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }

.field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

input[type="text"], textarea, input[type="password"] {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:focus, textarea:focus, input[type="password"]:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}
textarea { font-family: var(--mono); font-size: 12px; resize: vertical; min-height: 130px; line-height: 1.5; }

#receiptInput { font-family: var(--mono); letter-spacing: 1px; font-weight: 700; text-transform: uppercase; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > .grow { flex: 1 1 240px; min-width: 0; }

/* ── Step list (bookmarklet instructions) ───────────────── */
.steps { counter-reset: step; margin: 0; padding: 0; list-style: none; }
.steps li {
  counter-increment: step;
  position: relative;
  padding: 0 0 14px 34px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 1px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--gold-dim);
  color: var(--gold);
  font-weight: 700;
  font-size: 11px;
  display: grid; place-items: center;
  border: 1px solid var(--gold);
}
.steps li strong { color: var(--text); }
.steps li:last-child { padding-bottom: 0; }

.bookmarklet {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--gold), var(--orange));
  color: #1a1204;
  font-weight: 800;
  font-size: 13px;
  text-decoration: none;
  border: none;
  cursor: grab;
  box-shadow: var(--shadow);
  user-select: all;
}
[data-theme="light"] .bookmarklet { color: #fff; }
.bookmarklet:active { cursor: grabbing; }

/* ── Status / alerts ────────────────────────────────────── */
.alert {
  border-radius: 8px;
  padding: 10px 13px;
  font-size: 13px;
  display: none;
  align-items: flex-start;
  gap: 9px;
  margin-top: 12px;
  border: 1px solid transparent;
  line-height: 1.5;
}
.alert.show { display: flex; }
.alert-err  { background: var(--red-dim);   border-color: var(--red);   color: var(--red); }
.alert-ok   { background: var(--green-dim); border-color: var(--green); color: var(--green); }
.alert-info { background: var(--blue-dim);  border-color: var(--blue);  color: var(--blue); }
.alert-warn { background: var(--orange-dim);border-color: var(--orange);color: var(--orange); }
.alert strong { font-weight: 800; }

.spinner {
  width: 13px; height: 13px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex: none;
  margin-top: 2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tabs ───────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ── Stat bar ───────────────────────────────────────────── */
.stat-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.stat-pill {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-pill-val { font-size: 24px; font-weight: 800; color: var(--gold); font-family: var(--mono); line-height: 1.1; }
.stat-pill-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; margin-top: 5px; font-weight: 600; }

/* ── Timeline ───────────────────────────────────────────── */
.tl-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.tl-controls input[type="text"] { flex: 1 1 200px; }

.chip {
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--gold-dim); color: var(--gold); border-color: var(--gold); }

.timeline-item { display: flex; gap: 14px; align-items: stretch; }

.tl-date { width: 110px; flex: none; text-align: right; padding-top: 1px; }
.tl-date-main { font-size: 12.5px; font-weight: 700; font-family: var(--mono); }
.tl-date-time { font-size: 10.5px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }

.tl-spine { width: 14px; flex: none; display: flex; flex-direction: column; align-items: center; }
.tl-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2.5px solid var(--muted);
  background: var(--bg);
  flex: none;
  margin-top: 4px;
}
.tl-line { flex: 1; width: 2px; background: var(--border); margin: 4px 0 0; min-height: 18px; }

.tl-content { flex: 1; padding-bottom: 20px; min-width: 0; }
.tl-content-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.tl-event-name { font-size: 13.5px; font-weight: 700; }
.tl-event-code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--gold);
  background: var(--gold-dim);
  padding: 1px 7px;
  border-radius: 5px;
  border: 1px solid var(--gold);
  flex: none;
  font-weight: 700;
}
.tl-badges { margin: 6px 0; display: flex; gap: 6px; flex-wrap: wrap; }
.tl-event-desc { font-size: 12.5px; color: var(--text-dim); line-height: 1.6; }
.tl-event-id { font-size: 10.5px; color: var(--muted); font-family: var(--mono); margin-top: 6px; word-break: break-word; }
.tl-gap {
  font-size: 10.5px;
  color: var(--muted);
  font-style: italic;
  margin-top: 5px;
}

/* ── Notices ────────────────────────────────────────────── */
.notice-item {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 13px;
  margin-bottom: 10px;
}
.notice-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.notice-type { font-weight: 700; font-size: 13px; }
.notice-date { font-size: 11.5px; color: var(--text-dim); font-family: var(--mono); }
.notice-appt {
  margin-top: 8px;
  padding: 7px 10px;
  background: var(--gold-dim);
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--gold);
  font-weight: 600;
}
.notice-meta { margin-top: 7px; font-size: 11px; color: var(--muted); font-family: var(--mono); }

/* ── Summary narrative ──────────────────────────────────── */
.sum-title { font-size: 16px; font-weight: 800; margin-bottom: 12px; }
.sum-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 14px 0; }
.sum-stat { background: var(--bg-elev-2); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 11px; text-align: center; }
.sum-stat-val { font-size: 19px; font-weight: 800; font-family: var(--mono); color: var(--gold); }
.sum-stat-lbl { font-size: 10.5px; color: var(--text-dim); margin-top: 3px; text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }
.sum-body p { font-size: 13.5px; line-height: 1.7; margin: 11px 0; color: var(--text-dim); }
.sum-body p strong { color: var(--text); }
.sum-body .hl { color: var(--gold); font-weight: 700; }

.callout {
  border-radius: var(--radius);
  padding: 13px 15px;
  margin: 14px 0;
  border: 1px solid;
  font-size: 13.5px;
  line-height: 1.65;
}
.callout-green  { background: var(--green-dim);  border-color: var(--green);  }
.callout-gold   { background: var(--gold-dim);   border-color: var(--gold);   }
.callout-red    { background: var(--red-dim);    border-color: var(--red);    }
.callout-blue   { background: var(--blue-dim);   border-color: var(--blue);   }
.callout-purple { background: var(--purple-dim); border-color: var(--purple); }
.callout-title { font-weight: 800; margin-bottom: 5px; display: flex; align-items: center; gap: 7px; }

/* ── Saved cases ────────────────────────────────────────── */
.case-chips { display: flex; gap: 8px; flex-wrap: wrap; }

.case-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  font-size: 12px;
  font-family: var(--mono);
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
}
.case-chip:hover { border-color: var(--gold); }
.case-chip.active { background: var(--gold-dim); border-color: var(--gold); color: var(--gold); }
.case-chip .x {
  width: 17px; height: 17px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.case-chip .x:hover { background: var(--red-dim); color: var(--red); }

/* ── Diff / change log ──────────────────────────────────── */
.diff-item {
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--bg-elev-2);
  border-left: 3px solid var(--green);
  margin-bottom: 8px;
  font-size: 12.5px;
}
.diff-item.removed { border-left-color: var(--red); }
.diff-when { font-size: 10.5px; color: var(--muted); font-family: var(--mono); }

/* ── Empty state ────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-dim);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: .55; }
.empty h3 { color: var(--text); margin: 0 0 7px; font-size: 16px; }
.empty p { margin: 0 auto; max-width: 460px; font-size: 13px; }

/* ── Details/summary disclosure ─────────────────────────── */
details.disclose {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  background: var(--bg-elev-2);
  margin-top: 12px;
  overflow: hidden;
}
details.disclose > summary {
  cursor: pointer;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 700;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
details.disclose > summary::-webkit-details-marker { display: none; }
details.disclose > summary::before { content: '▸'; color: var(--gold); transition: transform .18s; display: inline-block; }
details.disclose[open] > summary::before { transform: rotate(90deg); }
details.disclose > .disclose-body { padding: 0 14px 14px; }

/* ── Footer ─────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  margin-top: 40px;
  padding: 24px 0 40px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}
footer strong { color: var(--text-dim); }

.url-preview {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
  margin-top: 6px;
  display: none;
}
.url-preview.visible { display: block; }

.hide { display: none !important; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 720px) {
  .wrap { padding: 0 14px; }
  .tl-date { width: 78px; }
  .tl-date-main { font-size: 11px; }
  .panel { padding: 14px; }
  .hdr { gap: 9px; }
  .logo { font-size: 14px; }
  .stat-pill-val { font-size: 20px; }
  select.tz-select { max-width: 130px; }
}

@media print {
  header, footer, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .panel { break-inside: avoid; box-shadow: none; }
}
