:root {
  --ink: #15202b;
  --muted: #5f6b76;
  --faint: #87919d;
  --line: #d9e0e7;
  --soft-line: #e8edf2;
  --page: #f7f9fb;
  --surface: #ffffff;
  --band: #f1f5f7;
  --nav: #152638;
  --nav-2: #203447;
  --teal: #087a83;
  --teal-soft: #e7f3f4;
  --amber: #b86b16;
  --amber-soft: #fff4e2;
  --green: #2c7a4b;
  --green-soft: #e8f4ec;
  --red: #a33d3d;
  --red-soft: #f8e9e9;
  --shadow: 0 1px 2px rgba(20, 34, 48, 0.08);
  --radius: 6px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
}

.sidebar {
  background: var(--nav);
  color: #dce6ee;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand {
  padding: 4px 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-title {
  font-weight: 650;
  letter-spacing: 0;
}

.brand-subtitle {
  color: #9fb0bf;
  font-size: 12px;
  margin-top: 4px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav-button {
  background: transparent;
  color: #c5d1dc;
  text-align: left;
  padding: 9px 10px;
  border-radius: var(--radius);
  cursor: pointer;
}

.nav-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.nav-button.active {
  background: var(--nav-2);
  color: #ffffff;
  box-shadow: inset 3px 0 0 var(--teal);
}

.sidebar-note {
  margin-top: auto;
  padding: 10px;
  color: #9fb0bf;
  font-size: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.main {
  min-width: 0;
  padding: 24px 28px 32px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow,
.breadcrumb {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.breadcrumb button {
  color: var(--teal);
  background: transparent;
  padding: 0;
  cursor: pointer;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
  font-weight: 680;
}

h2 {
  font-size: 17px;
  font-weight: 650;
}

h3 {
  font-size: 14px;
  font-weight: 650;
}

.header-meta {
  color: var(--muted);
  margin-top: 5px;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.button {
  border-radius: var(--radius);
  padding: 8px 11px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.button:hover {
  border-color: #b6c2cc;
}

.button.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
}

.button.subtle {
  background: var(--band);
}

.button:disabled {
  color: var(--faint);
  background: #f2f4f6;
  cursor: not-allowed;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 1px;
  border: 1px solid var(--soft-line);
  background: var(--soft-line);
  margin-bottom: 18px;
}

.metric {
  background: var(--surface);
  padding: 12px 14px;
}

.metric-value {
  font-size: 20px;
  font-weight: 680;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
}

.tab {
  padding: 9px 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab.active {
  color: var(--ink);
  border-color: var(--teal);
}

.search {
  width: 270px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: var(--surface);
}

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

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--soft-line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  background: #fafbfd;
}

.sort-button {
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-weight: 600;
}

.sort-button.active {
  color: var(--teal);
}

tr.selected td {
  background: #f4fafb;
}

tr:hover td {
  background: #f8fbfc;
}

.link-button {
  background: transparent;
  color: var(--teal);
  padding: 0;
  cursor: pointer;
}

.link-button + .link-button {
  margin-left: 10px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
  flex: 0 0 auto;
}

.dot.teal {
  background: var(--teal);
}

.dot.green {
  background: var(--green);
}

.dot.amber {
  background: var(--amber);
}

.dot.red {
  background: var(--red);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

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

.grid-3 {
  display: grid;
  grid-template-columns: 1.1fr 1fr 0.9fr;
  gap: 18px;
}

.section {
  background: var(--surface);
  border: 1px solid var(--soft-line);
  padding: 16px;
}

.section + .section {
  margin-top: 18px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--soft-line);
  border-left: 1px solid var(--soft-line);
}

.fact {
  padding: 12px;
  border-right: 1px solid var(--soft-line);
  border-bottom: 1px solid var(--soft-line);
}

.fact-label {
  color: var(--muted);
  font-size: 12px;
}

.fact-value {
  margin-top: 4px;
  font-weight: 620;
}

.list {
  border-top: 1px solid var(--soft-line);
}

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--soft-line);
}

.list-row.compact {
  grid-template-columns: minmax(0, 1fr) auto;
}

.row-title {
  font-weight: 570;
}

.row-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  background: var(--surface);
  color: var(--muted);
}

.pill.green {
  border-color: #b7dac4;
  background: var(--green-soft);
  color: var(--green);
}

.pill.amber {
  border-color: #edd09f;
  background: var(--amber-soft);
  color: var(--amber);
}

.pill.teal {
  border-color: #b3d9dc;
  background: var(--teal-soft);
  color: var(--teal);
}

.notice {
  border-left: 3px solid var(--amber);
  background: #fffaf0;
  padding: 10px 12px;
}

.handoff-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--soft-line);
  padding-top: 12px;
  margin-top: 14px;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(380px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.field-table th,
.field-table td {
  white-space: normal;
}

.evidence-panel {
  position: sticky;
  top: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 16px;
}

.evidence-box {
  margin-top: 12px;
  border: 1px solid var(--line);
  background: #fbfcfd;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #24313d;
}

.highlight-line {
  display: block;
  background: #fff6d6;
  border-left: 2px solid var(--amber);
  padding: 3px 6px;
  margin: 5px 0;
}

.source-viewer {
  margin-top: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.viewer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--soft-line);
}

.viewer-tabs {
  display: flex;
  border-bottom: 1px solid var(--soft-line);
}

.viewer-tabs .tab {
  padding: 7px 10px;
}

.pdf-preview,
.excel-preview,
.file-preview {
  margin: 10px;
  padding: 10px;
  border: 1px solid var(--soft-line);
  background: #fbfcfd;
}

.email-line {
  padding: 7px 0;
  border-bottom: 1px solid var(--soft-line);
}

.page-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.source-highlight,
.cell-highlight {
  background: #fff0b8;
  box-shadow: 0 0 0 2px #f1d36b;
  padding: 1px 3px;
}

.sheet-grid {
  display: grid;
  grid-template-columns: 0.8fr 0.8fr 1.4fr;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  font-size: 12px;
}

.sheet-grid span {
  padding: 7px 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.feedback-panel {
  margin-top: 14px;
  border-top: 1px solid var(--soft-line);
  padding-top: 14px;
}

.feedback-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 12px;
}

.chip {
  border: 1px solid var(--line);
  padding: 5px 8px;
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
}

.chip.active {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-soft);
}

textarea {
  width: 100%;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px;
  resize: vertical;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 26, 38, 0.36);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}

.modal {
  width: min(760px, 96vw);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(15, 34, 52, 0.22);
}

.modal-header,
.modal-footer {
  padding: 16px 18px;
  border-bottom: 1px solid var(--soft-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-footer {
  border-top: 1px solid var(--soft-line);
  border-bottom: 0;
  justify-content: flex-end;
}

.modal-body {
  padding: 18px;
}

.import-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.import-option {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 12px;
  border-radius: var(--radius);
  cursor: pointer;
}

.import-option:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.import-option span {
  display: block;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #10283a;
  color: white;
  padding: 12px 14px;
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(15, 34, 52, 0.25);
}

@media (max-width: 1050px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    flex-direction: row;
    align-items: center;
    overflow: auto;
  }

  .brand,
  .sidebar-note {
    display: none;
  }

  .nav {
    display: flex;
  }

  .metric-row,
  .grid-2,
  .grid-3,
  .detail-layout {
    grid-template-columns: 1fr;
  }

  .facts {
    grid-template-columns: 1fr 1fr;
  }
}
