:root {
  --bg: #0b0f17;
  --surface: #121826;
  --surface-2: #182133;
  --border: #253149;
  --text: #e6edf7;
  --muted: #93a4bf;
  --accent: #4f9cff;
  --accent-soft: rgba(79, 156, 255, 0.14);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.14);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.14);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.14);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 15, 23, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 20px;
  font-weight: 700;
  border: 1px solid rgba(79, 156, 255, 0.35);
}

.brand-name {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 6px;
  background: var(--surface);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tab:hover {
  color: var(--text);
}
.tab.active {
  background: var(--accent);
  color: #07111f;
}

.container {
  max-width: 1480px;
  margin: 0 auto;
  padding: 20px 24px 64px;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kpi-val {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.kpi-lbl {
  font-size: 12px;
  color: var(--muted);
}

.view {
  display: none;
}
.view.active {
  display: block;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.search-input {
  flex: 1 1 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #07111f;
}
.btn-primary:hover {
  filter: brightness(1.08);
}
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
}
.btn-secondary:hover {
  background: #22304a;
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}
.btn-ghost:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}
.btn-full {
  width: 100%;
  padding: 11px;
  font-size: 14px;
}

.hint-line {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 12px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  max-height: 72vh;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 1280px;
}

.matrix-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface-2);
  color: var(--muted);
  text-align: left;
  padding: 10px 11px;
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}

.matrix-table td {
  padding: 9px 11px;
  border-bottom: 1px solid rgba(37, 49, 73, 0.65);
  vertical-align: top;
}

.sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  min-width: 215px;
  border-right: 1px solid var(--border);
}
.matrix-table th.sticky-col {
  z-index: 4;
  background: var(--surface-2);
}

.law-title {
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.law-cite {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.badge-live {
  background: var(--green-soft);
  color: var(--green);
}
.badge-static {
  background: var(--accent-soft);
  color: var(--accent);
}
.badge-pending {
  background: var(--amber-soft);
  color: var(--amber);
}
.badge-red {
  background: var(--red-soft);
  color: var(--red);
}

.cell-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  line-height: 1.38;
}
.cell-btn:hover {
  background: var(--accent-soft);
  border-color: rgba(79, 156, 255, 0.45);
}
.cell-muted {
  color: var(--muted);
}
.cell-strong {
  font-weight: 600;
}

/* Planner */
.planner-grid {
  display: grid;
  grid-template-columns: minmax(340px, 430px) 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 960px) {
  .planner-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.card-header h2 {
  margin: 0;
  font-size: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

label > span,
.section-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}

input[type="date"],
input[type="number"],
select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13px;
}

.form-section {
  margin-bottom: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(37, 49, 73, 0.7);
}

.section-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.section-head > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.inline-add {
  display: grid;
  grid-template-columns: 1fr 90px auto;
  gap: 6px;
}

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

.state-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 12.5px;
}
.state-chip button {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0 2px;
}
.state-chip button:hover {
  color: var(--red);
}

.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
}
.check input {
  accent-color: var(--accent);
}

.sec-mat-wrap {
  display: block;
  margin-top: 10px;
}
.hidden {
  display: none !important;
}

.plan-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.timeline-item {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.timeline-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.due-pill {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
}
.due-pill.urgent {
  background: var(--red-soft);
  color: var(--red);
}

.quote-box {
  margin-top: 8px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.25);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: 12.5px;
  color: #cbd7ea;
  white-space: pre-wrap;
}

.quote-highlight {
  background: rgba(251, 191, 36, 0.28);
  color: #fff8dc;
  padding: 1px 2px;
  border-radius: 3px;
}

.warn-banner {
  background: var(--amber-soft);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fde68a;
  padding: 8px 11px;
  border-radius: 7px;
  font-size: 12.5px;
  margin: 8px 0;
}

/* MCP & Watcher */
.mcp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 960px) {
  .mcp-grid {
    grid-template-columns: 1fr;
  }
}

.muted {
  color: var(--muted);
  font-size: 13.5px;
}

.tool-list {
  padding-left: 18px;
  font-size: 13.5px;
}
.tool-list li {
  margin-bottom: 8px;
}

.code-block {
  background: #070a10;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  overflow-x: auto;
  color: #c7d6ee;
}

.watcher-list {
  max-height: 400px;
  overflow-y: auto;
  margin-top: 12px;
  border-top: 1px solid var(--border);
}

.watcher-row {
  padding: 8px 0;
  border-bottom: 1px solid rgba(37, 49, 73, 0.5);
  font-size: 12.5px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

/* Provenance Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  z-index: 40;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(560px, 95vw);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.drawer-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.drawer-header h2 {
  margin: 4px 0 0;
  font-size: 17px;
}

.drawer-kicker {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.drawer-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}

.drawer-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
  font-size: 12.5px;
}

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

.check-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
}

.status-select {
  width: auto !important;
  min-width: 170px;
}

.checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin: 12px 0 16px;
}

.checklist-item {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 7px;
  padding: 9px 11px;
  font-size: 12.5px;
}

.checklist-item strong {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 3px;
}

.account-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.tier-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--amber);
}
.tier-dot.paid {
  background: var(--green);
}

.plan-cards {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.paywall-box {
  border: 1px solid rgba(79, 156, 255, 0.45);
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
}

.hero-card {
  background: linear-gradient(135deg, rgba(79, 156, 255, 0.12), rgba(19, 25, 38, 0.96));
  border: 1px solid rgba(79, 156, 255, 0.35);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.hero-copy {
  max-width: 780px;
}
.hero-kicker {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 6px;
}
.hero-card h1 {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.25;
}
.hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.claim-banner {
  border: 1px solid rgba(52, 211, 153, 0.5);
  background: var(--green-soft);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

.footer {
  border-top: 1px solid var(--border);
  padding: 18px 24px;
  color: var(--muted);
  font-size: 12.5px;
}
.footer-inner {
  max-width: 1480px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.footer-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.print-watermark {
  display: none;
}

@media print {
  .topbar,
  .hero-card,
  .kpi-strip,
  .planner-form,
  .footer,
  .btn {
    display: none !important;
  }
  body.tier-free .print-watermark {
    display: block;
    border: 2px dashed #b45309;
    color: #92400e;
    padding: 8px 12px;
    margin-bottom: 12px;
    font-weight: 700;
    text-align: center;
  }
  body {
    background: #fff;
    color: #000;
  }
  .card,
  .timeline-item {
    border-color: #ccc;
    background: #fff;
    color: #000;
  }
}
