:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-soft: #f9fbff;
  --text: #1a2538;
  --muted: #5c6b82;
  --line: #dce4f0;
  --line-strong: #c5d0e0;
  --primary: #1B3A5C;
  --primary-dark: #0f2540;
  --primary-soft: #e8f1ff;
  --gold: #C4963A;
  --gold-light: #fdf3dc;
  --open: #1d4ed8;
  --open-soft: #dbeafe;
  --draft: #b45309;
  --draft-soft: #ffedd5;
  --submit: #15803d;
  --submit-soft: #dcfce7;
  --warning-bg: #fffbeb;
  --warning-border: #fcd34d;
  --warning-text: #78350f;
  --shadow: 0 2px 12px rgba(18, 54, 90, .06);
  --shadow-lg: 0 8px 30px rgba(18, 54, 90, .10);
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }
html {
  min-height: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(27,58,92,.06), transparent 28rem),
    var(--bg);
}
a { color: var(--primary); text-underline-offset: .18em; }
a:hover { color: var(--primary-dark); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, main:focus-visible {
  outline: 3px solid rgba(27, 58, 92, .5);
  outline-offset: 3px;
}

/* Skip link */
.skip-link {
  position: fixed;
  left: 14px;
  top: 10px;
  z-index: 1000;
  transform: translateY(-140%);
  background: var(--surface);
  color: var(--primary-dark);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
}
.skip-link:focus { transform: translateY(0); }

/* ── Compact Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px clamp(16px, 3vw, 40px);
  background: linear-gradient(135deg, #0f2540 0%, #1B3A5C 50%, #234d78 100%);
  color: white;
  flex-wrap: wrap;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.topbar-logo {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}
.topbar-text {
  line-height: 1.15;
}
.topbar-agency {
  margin: 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #9bb5d4;
  font-weight: 700;
}
.topbar-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.01em;
  color: white;
}
.topbar-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-left: auto;
  text-align: right;
  flex-shrink: 0;
}
.topbar-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #9bb5d4;
  font-weight: 700;
}
.topbar-update {
  font-size: 11px;
  color: #bccfe4;
}
.topbar-update strong {
  color: #fcd34d;
  font-weight: 700;
}
.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.top-actions form { margin: 0; }

/* ── Buttons ── */
.button, button {
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary-dark);
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
  text-decoration: none;
  touch-action: manipulation;
}
.button:hover, button:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(10, 31, 61, .14); }
.button:active, button:active { transform: translateY(0); }
.button.secondary { background: rgba(255,255,255,.10); color: white; border: 1px solid rgba(255,255,255,.25); }
.button.secondary:hover { background: rgba(255,255,255,.18); }
.button.refresh { background: #dbeafe; color: #12365a; }
.button.reset { background: var(--surface-soft); border: 1px solid var(--line); color: var(--muted); }

/* ── Shell ── */
.shell { width: min(1200px, calc(100% - 28px)); margin: 18px auto 40px; }
.notice {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--warning-text);
  font-size: 13px;
  margin-bottom: 14px;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0 8px;
  margin: 14px 0 18px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.tabs a {
  min-height: 38px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  touch-action: manipulation;
}
.tabs a.active { color: white; background: var(--primary); border-color: var(--primary); box-shadow: 0 4px 12px rgba(27,58,92,.18); }

/* ── Hero Grid ── */
.hero-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric, .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.metric { padding: 16px 18px; position: relative; overflow: hidden; }
.metric::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--primary); opacity: .85; }
.metric.open::before { background: var(--open); }
.metric.draft::before { background: var(--draft); }
.metric.submit::before { background: var(--submit); }
.metric span { display: block; color: var(--muted); font-weight: 800; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.metric strong { display: block; font-size: clamp(28px, 4vw, 38px); line-height: 1; letter-spacing: -.04em; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.metric small { color: var(--muted); font-size: 12px; }
.metric.open strong, .open { color: var(--open); }
.metric.draft strong, .draft { color: var(--draft); }
.metric.submit strong, .submit { color: var(--submit); }

.highlight { display: grid; grid-template-columns: 220px 1fr; gap: 16px; align-items: center; padding: 18px 20px; margin: 14px 0 20px; }
.highlight h2 { margin: 0; font-size: clamp(22px, 2.5vw, 28px); letter-spacing: -.035em; }

/* ── Progress ── */
.progress { height: 10px; background: #e8eef8; border-radius: 999px; overflow: hidden; }
.progress div { height: 100%; background: linear-gradient(90deg, #22c55e, var(--submit)); border-radius: 999px; transition: width .4s ease; }

/* ── Section ── */
.section-head { display: flex; justify-content: space-between; gap: 14px; align-items: end; margin: 20px 0 10px; }
.section-head h2 { margin: 0; font-size: 18px; letter-spacing: -.03em; }
.section-meta { color: var(--muted); font-weight: 700; font-size: 13px; white-space: nowrap; }
.muted { color: var(--muted); margin-top: -2px; max-width: 70ch; font-size: 13px; }

/* ── Tables ── */
.table-hint { display: none; color: var(--muted); font-size: 12px; margin: 0 0 6px; }
.table-card { overflow: hidden; padding: 12px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 780px; font-size: 14px; }
caption.sr-only, .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1f5f9;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #475569;
  font-weight: 800;
  box-shadow: inset 0 -1px 0 var(--line);
}
tbody tr:nth-child(even) td { background: var(--surface-soft); }
tbody tr:hover td { background: #eef5ff; }

.dt-container { color: var(--text); }
.dt-container .dt-layout-row { margin: 0 0 8px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.dt-container .dt-layout-row:last-child { margin: 8px 0 0; }
.dt-container .dt-length, .dt-container .dt-search, .dt-container .dt-info, .dt-container .dt-paging { color: var(--muted); font-size: 13px; font-weight: 600; }
.dt-container .dt-search label, .dt-container .dt-length label { display: inline-flex; align-items: center; gap: 6px; }
.dt-container .dt-input {
  min-height: 36px;
  border: 1px solid var(--line-strong) !important;
  border-radius: var(--radius-sm) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  padding: 6px 10px !important;
  font-size: 13px;
}
.dt-container .dt-search .dt-input { min-width: min(260px, 55vw); }
.dt-container .dt-scroll { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.dt-container .dt-scroll-body { border-bottom: 0 !important; }
.dt-container .dt-paging .dt-paging-button {
  min-width: 36px;
  min-height: 36px;
  border: 1px solid var(--line) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--primary-dark) !important;
  background: var(--surface) !important;
  margin-left: 3px;
  font-size: 13px;
  font-weight: 700;
  touch-action: manipulation;
}
.dt-container .dt-paging .dt-paging-button.current,
.dt-container .dt-paging .dt-paging-button.current:hover {
  color: white !important;
  background: var(--primary) !important;
  border-color: var(--primary) !important;
}
.dt-container .dt-paging .dt-paging-button.disabled { opacity: .4; cursor: not-allowed !important; }
.dt-container .dt-paging .dt-paging-button:hover { box-shadow: 0 4px 12px rgba(27,58,92,.10); }
.dt-container table.dataTable > thead > tr > th,
.dt-container table.dataTable > thead > tr > td { border-bottom: 1px solid var(--line) !important; }
.dt-container table.dataTable.no-footer { border-bottom: 0 !important; }
.dt-container table.dataTable thead th.dt-orderable-asc span.dt-column-order,
.dt-container table.dataTable thead th.dt-orderable-desc span.dt-column-order { color: var(--muted); }

.num { text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.strong { font-weight: 750; }
.rate-cell { min-width: 140px; }
.rate-cell span { display: block; margin-bottom: 5px; font-weight: 800; font-variant-numeric: tabular-nums; font-size: 13px; }

.status-dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; margin-right: 6px; vertical-align: 1px; }
.dot-open { background: var(--open); }
.dot-draft { background: var(--draft); }
.dot-submit { background: var(--submit); }

.badge { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 800; border: 1px solid transparent; }
.badge-open { background: var(--open-soft); color: #1e3fa8; border-color: #bfdbfe; }
.badge-draft { background: var(--draft-soft); color: #92400e; border-color: #fed7aa; }
.badge-submit { background: var(--submit-soft); color: #166534; border-color: #bbf7d0; }

/* ── Filters ── */
.filters { display: grid; grid-template-columns: minmax(200px, 1.4fr) repeat(4, minmax(150px, 1fr)) auto auto; gap: 8px; margin-bottom: 12px; align-items: end; }
.filters label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 700; }
input, select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(27,58,92,.10); }
.filters button { background: var(--primary); color: white; }
.empty-state { text-align: center; color: var(--muted); padding: 28px; font-size: 14px; }

/* ── Footer ── */
.footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  text-align: center;
  padding: 18px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.footer strong { color: var(--text); }

/* ── Setup ── */
.setup-shell { min-height: 100dvh; display: grid; place-items: center; }
.setup-card { max-width: 760px; padding: 28px; }
.setup-card h1 { margin: 0 0 12px; letter-spacing: -.04em; }
.setup-card h2 { margin-top: 22px; font-size: 16px; }
.setup-list { color: var(--text); font-size: 14px; }
.setup-list li { margin: 8px 0; }
code { background: var(--primary-soft); color: var(--primary-dark); padding: 2px 6px; border-radius: 5px; font-size: .9em; }

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Responsive ── */
@media (max-width: 1040px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters button, .filters .button { width: 100%; }
}
@media (max-width: 800px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 16px; }
  .topbar-info { margin-left: 0; text-align: left; }
  .top-actions { width: 100%; }
  .hero-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .highlight { grid-template-columns: 1fr; }
  .table-hint { display: block; }
}
@media (max-width: 560px) {
  .shell { width: min(100% - 16px, 1200px); }
  .hero-grid, .filters { grid-template-columns: 1fr; }
  .top-actions, .top-actions form, .top-actions .button { width: 100%; }
  .top-actions .button { justify-content: center; }
  .section-head { align-items: flex-start; flex-direction: column; }
}
