:root {
  color-scheme: light;
  --ink: #1a1d29;
  --muted: #6b7280;
  --line: #e5e7eb;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --surface-soft-2: #f3f4f6;
  --navy: #0f172a;
  --navy-2: #1e293b;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #eff6ff;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --green: #059669;
  --green-soft: #ecfdf5;
  --purple: #7c3aed;
  --purple-soft: #f5f3ff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.10);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-width: 320px;
  background: var(--surface-soft);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: none; background: none; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

a { color: var(--blue); text-decoration: none; }

.topbar {
  min-height: 60px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  background: var(--navy);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #fff, #e2e8f0);
  color: var(--navy);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.topbar-copy { display: flex; flex-direction: column; min-width: 0; }
.topbar-copy strong { font-size: 13px; color: #f1f5f9; }
.topbar-copy span { color: #94a3b8; font-size: 11px; }

.tab-nav {
  display: flex;
  gap: 2px;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.tab-button {
  padding: 7px 16px;
  border-radius: var(--radius-xs);
  color: #94a3b8;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tab-button:hover { color: #e2e8f0; background: rgba(255,255,255,0.06); }
.tab-button.active {
  background: #fff;
  color: var(--navy);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
}
.tab-button.active .tab-badge { background: var(--navy); }

.connection-panel {
  width: min(1050px, calc(100% - 40px));
  margin: 0 auto;
  min-height: calc(100vh - 60px);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: 72px;
  padding: 70px 0;
}

.connection-copy h1 {
  margin: 8px 0 18px;
  font-size: clamp(36px, 5.5vw, 64px);
  line-height: 0.98;
  letter-spacing: -0.055em;
  color: var(--ink);
}

.connection-copy > p:last-child {
  max-width: 620px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}

.eyebrow, .step {
  margin: 0;
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

.connection-form { padding: 32px; }

.stack-form { display: flex; flex-direction: column; gap: 16px; }

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #374151;
  font-size: 12px;
  font-weight: 700;
}

label small { color: var(--muted); font-weight: 500; }

input, select, textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  font-size: 13px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

textarea { resize: vertical; line-height: 1.5; }

input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

::placeholder { color: #9ca3af; }

.button, .icon-button {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 13px;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.button { min-height: 40px; padding: 9px 16px; }
.button:not(:disabled):active { transform: translateY(1px); }

.button-primary { background: var(--blue); color: #fff; }
.button-primary:hover:not(:disabled) { background: var(--blue-dark); box-shadow: 0 4px 12px rgba(37,99,235,0.25); }

.button-quiet { background: transparent; color: #4b5563; border-color: #d1d5db; }
.button-quiet:hover:not(:disabled) { background: var(--surface-soft-2); border-color: #9ca3af; }

.button-review { background: var(--amber-soft); border-color: #fcd34d; color: #92400e; }
.button-review:hover:not(:disabled) { background: #fef3c7; }

.button-danger { background: var(--red-soft); border-color: #fca5a5; color: #991b1b; }
.button-danger:hover:not(:disabled) { background: #fee2e2; }

.icon-button {
  width: 36px;
  height: 36px;
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}
.icon-button:hover:not(:disabled) { background: var(--surface-soft-2); }

.form-note { margin: 10px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.workspace {
  min-height: calc(100vh - 60px);
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
}

.case-sidebar {
  padding: 24px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  max-height: calc(100vh - 60px);
}

.sidebar-heading, .case-list-heading, .section-heading, .case-header,
.audit-actions, .report-actions, .case-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.sidebar-heading strong { display: block; margin-top: 4px; font-size: 14px; }
.sidebar-heading span { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }

.permission-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 20px; }

.permission-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 10px;
  background: var(--blue-soft);
  color: #1e40af;
  font-size: 10px;
  font-weight: 700;
}

.create-case {
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}
.create-case summary {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.create-case summary::before { content: '+'; font-size: 16px; font-weight: 300; color: var(--blue); }
.create-case[open] summary::before { content: '\2013'; }
.create-case summary::-webkit-details-marker { display: none; }
.create-case form { padding: 0 14px 14px; }

.case-list-heading { margin-bottom: 12px; }
.case-list-heading h2 { margin: 0; font-size: 15px; }
.case-list-heading span { color: var(--muted); font-size: 12px; }

.case-list { display: flex; flex-direction: column; gap: 8px; }

.case-item {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  text-align: left;
  transition: all var(--transition);
}
.case-item:hover { border-color: #93c5fd; background: var(--blue-soft); }
.case-item[aria-current="true"] {
  border-color: var(--blue);
  background: var(--blue-soft);
  box-shadow: 0 0 0 1px rgba(37,99,235,0.15);
}
.case-item strong { display: block; font-size: 13px; }
.case-item span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }

.case-workspace {
  min-width: 0;
  padding: 32px;
  overflow-y: auto;
  max-height: calc(100vh - 60px);
}

.empty-state {
  min-height: 60vh;
  display: grid;
  place-content: center;
  text-align: center;
}
.empty-state h2 { margin: 0; font-size: 26px; letter-spacing: -0.03em; }
.empty-state p { color: var(--muted); margin-top: 8px; font-size: 14px; }

.case-header { align-items: flex-start; margin-bottom: 24px; }
.case-header h1 { margin: 5px 0; font-size: clamp(26px, 4vw, 40px); letter-spacing: -0.04em; }
.case-header p:last-child { margin: 0; color: var(--muted); }
.case-actions { flex-wrap: wrap; justify-content: flex-end; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.metric {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: box-shadow var(--transition);
}
.metric:hover { box-shadow: var(--shadow-sm); }
.metric span { display: block; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.metric strong { display: block; margin-top: 8px; font-size: 22px; letter-spacing: -0.02em; }

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

.workflow-card, .audit-card, .report-card, .trail-card { padding: 24px; }

.section-heading { align-items: flex-start; margin-bottom: 18px; }
.section-heading h2 { margin: 4px 0 0; font-size: 18px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 700;
  background: var(--surface-soft-2);
  color: #4b5563;
}

.rule-description {
  min-height: 52px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.file-label input { padding: 8px; background: var(--surface-soft); }

.audit-card, .report-card, .trail-card { margin-top: 18px; }
.audit-card > p { color: var(--muted); line-height: 1.6; font-size: 13px; }
.audit-actions { justify-content: flex-start; margin-top: 16px; }
.status-text { color: var(--muted); font-size: 12px; }

.report-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

.summary-chip { padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-soft); font-size: 11px; }
.summary-chip strong { margin-left: 5px; }

.warning-list { display: grid; gap: 8px; margin: 12px 0; }
.warning-item {
  padding: 10px 14px;
  border-left: 3px solid var(--amber);
  background: var(--amber-soft);
  color: #78350f;
  font-size: 12px;
  line-height: 1.5;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.finding-list { display: grid; gap: 10px; }
.finding-item {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: box-shadow var(--transition);
}
.finding-item:hover { box-shadow: var(--shadow-sm); }
.finding-item header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.finding-item h3 { margin: 0; font-size: 14px; }
.finding-item p { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.finding-meta { margin-top: 10px; color: #4b5563; font-size: 10px; word-break: break-word; }

.report-actions { justify-content: flex-start; flex-wrap: wrap; margin-top: 18px; }

.trail-list { display: grid; gap: 8px; }
.trail-event {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.trail-event:last-child { border-bottom: 0; }
.trail-event time { color: var(--muted); font-size: 10px; }
.trail-event strong { display: block; font-size: 12px; }
.trail-event span { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; word-break: break-word; }

.discovery-panel { padding: 32px; overflow-y: auto; max-height: calc(100vh - 60px); }

.discovery-header { margin-bottom: 24px; }
.discovery-header h1 { font-size: clamp(26px, 4vw, 40px); letter-spacing: -0.04em; margin-bottom: 8px; }
.discovery-header p { color: var(--muted); font-size: 14px; max-width: 600px; line-height: 1.6; }

.discovery-import-zone {
  margin: 24px 0;
  padding: 40px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
  background: var(--surface);
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
}
.discovery-import-zone:hover, .discovery-import-zone.dragover {
  border-color: var(--blue);
  background: var(--blue-soft);
}
.discovery-import-zone h3 { font-size: 16px; margin-bottom: 8px; }
.discovery-import-zone p { color: var(--muted); font-size: 13px; }
.discovery-import-zone .import-icon { font-size: 32px; margin-bottom: 12px; opacity: 0.4; }

.discovery-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.discovery-stat {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  text-align: center;
  transition: box-shadow var(--transition);
}
.discovery-stat:hover { box-shadow: var(--shadow-sm); }
.discovery-stat .stat-value { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.discovery-stat .stat-label {
  font-size: 10px; color: var(--muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; margin-top: 6px;
}

.discovery-filters {
  display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center;
}
.discovery-filters input[type="text"] { flex: 1; min-width: 200px; }

.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff;
  font-size: 11px; font-weight: 700; color: #4b5563;
  cursor: pointer; transition: all var(--transition);
}
.filter-chip:hover { border-color: #9ca3af; }
.filter-chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.discovery-list { display: grid; gap: 12px; }

.property-card {
  padding: 20px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff;
  transition: all var(--transition);
}
.property-card:hover { box-shadow: var(--shadow); border-color: #d1d5db; }

.property-card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 14px;
}
.property-card-header h3 { font-size: 15px; letter-spacing: -0.01em; }
.property-card-header .apn { color: var(--muted); font-size: 12px; margin-top: 3px; }

.classification-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 999px;
  font-size: 10px; font-weight: 800; letter-spacing: 0.02em; white-space: nowrap;
}
.classification-badge.confirmed-government-taking {
  background: var(--red-soft); color: #991b1b; border: 1px solid #fca5a5;
}
.classification-badge.tax-sale-after-code-enforcement {
  background: var(--amber-soft); color: #92400e; border: 1px solid #fcd34d;
}
.classification-badge.possible-pressured-sale {
  background: var(--purple-soft); color: #6b21a8; border: 1px solid #c4b5fd;
}
.classification-badge.ownership-change-after-notice-cause-unknown {
  background: var(--surface-soft-2); color: #4b5563; border: 1px solid var(--line);
}
.classification-badge.owner-retained-property {
  background: var(--green-soft); color: #065f46; border: 1px solid #6ee7b7;
}

.property-meta {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px; margin-bottom: 14px;
}
.property-meta-item { font-size: 11px; }
.property-meta-item .meta-label {
  color: var(--muted); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; font-size: 9px; margin-bottom: 3px;
}
.property-meta-item .meta-value { color: var(--ink); font-weight: 600; }

.property-reasoning {
  padding: 10px 12px; background: var(--surface-soft);
  border-radius: var(--radius-sm); font-size: 11px;
  color: var(--muted); line-height: 1.5; margin-bottom: 14px;
}

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

.notice {
  position: fixed; right: 24px; bottom: 24px; z-index: 100;
  max-width: 420px; padding: 14px 16px;
  border-radius: var(--radius); background: var(--navy); color: #fff;
  box-shadow: var(--shadow-lg); font-size: 13px; line-height: 1.5;
  animation: notice-in 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes notice-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.notice[data-tone="error"] { background: var(--red); }
.notice[data-tone="success"] { background: var(--green); }

.loading-skeleton { display: grid; gap: 12px; padding: 20px; }
.skeleton-bar {
  height: 14px; border-radius: var(--radius-xs);
  background: linear-gradient(90deg, var(--surface-soft-2) 25%, var(--surface-soft) 50%, var(--surface-soft-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

[hidden] { display: none !important; }

@media (max-width: 980px) {
  .connection-panel { grid-template-columns: 1fr; gap: 32px; padding: 40px 0; }
  .workspace { grid-template-columns: 280px minmax(0, 1fr); }
  .workflow-grid { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .discovery-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .property-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .topbar { grid-template-columns: 1fr auto; padding-inline: 14px; gap: 12px; }
  .topbar-copy { display: none; }
  .tab-nav { order: 3; width: 100%; grid-column: 1 / -1; overflow-x: auto; }
  .workspace { display: block; }
  .case-sidebar, .case-workspace { max-height: none; }
  .case-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .case-header { display: block; }
  .case-actions { justify-content: flex-start; margin-top: 14px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .case-workspace { padding: 18px 14px 36px; }
  .trail-event { grid-template-columns: 1fr; gap: 3px; }
  .discovery-panel { padding: 18px 14px 36px; }
  .discovery-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .property-meta { grid-template-columns: 1fr; }
  .property-card-header { flex-direction: column; }
}
