:root {
  --ink: #102326;
  --muted: #5d7074;
  --line: #d4e2e2;
  --surface: #f4f8f8;
  --panel: #ffffff;
  --primary: #0e7490;
  --primary-dark: #155e75;
  --green: #047857;
  --amber: #a16207;
  --red: #b42318;
  --green-soft: #e2f6ee;
  --amber-soft: #fff3d7;
  --red-soft: #ffe5df;
  --blue-soft: #e7f4fb;
  --shadow: 0 10px 28px rgba(21, 94, 117, 0.08);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface);
  color: var(--ink);
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.loading,
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(560px, 100%);
  display: grid;
  gap: 18px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  max-width: 13ch;
  font-size: clamp(2rem, 6vw, 3.75rem);
  line-height: 0.96;
}

.auth-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.auth-metrics span,
.doc-empty,
.history-item,
.metric-box,
.money-grid span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfb;
}

.auth-metrics span {
  padding: 12px;
  color: var(--muted);
}

.auth-metrics strong {
  display: block;
  color: var(--ink);
  font-size: 1.4rem;
}

.auth-error {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--red-soft);
  color: var(--red);
  font-weight: 700;
}

.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-lockup,
.top-actions,
.toolbar,
.case-title,
.claim-head,
.code-title,
.evidence-row,
.meta-row {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary-dark);
  color: white;
  font-weight: 850;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1.28rem;
}

h2 {
  font-size: 1.8rem;
}

h3 {
  font-size: 1rem;
}

.top-actions {
  gap: 10px;
}

.user-chip {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #f8fbfb;
  font-size: 0.86rem;
}

.primary-button,
.secondary-button,
.segmented button,
.review-button,
.doc-gap,
.gap-chip,
.case-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
}

.primary-button {
  min-height: 44px;
  padding: 0 16px;
  color: white;
  background: var(--green);
  border-color: var(--green);
  font-weight: 800;
}

.primary-button:disabled {
  color: var(--muted);
  background: #edf3f3;
  border-color: var(--line);
  opacity: 1;
}

.primary-button.full {
  width: 100%;
}

.secondary-button {
  min-height: 40px;
  padding: 0 13px;
  font-weight: 750;
}

.workspace {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.toolbar,
.worklist-card,
.case-card,
.claim-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.toolbar {
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: #edf5f5;
}

.segmented button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-weight: 850;
}

.segmented button.active {
  color: var(--ink);
  background: white;
}

.search-box {
  flex: 1;
  min-width: 220px;
  display: grid;
  gap: 4px;
}

.search-box span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.search-box input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfb;
}

.worklist-card {
  overflow: hidden;
}

.table-header,
.case-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) minmax(150px, 1fr) minmax(150px, 1fr) 120px 120px;
  gap: 12px;
  align-items: center;
}

.table-header {
  padding: 10px 14px;
  color: var(--muted);
  background: #edf5f5;
  font-size: 0.75rem;
  font-weight: 850;
  text-transform: uppercase;
}

.case-table {
  display: grid;
}

.case-row {
  width: 100%;
  padding: 13px 14px;
  text-align: left;
  border: 0;
  border-radius: 0;
  border-top: 1px solid var(--line);
}

.case-row.selected {
  background: #eef9f6;
}

.case-row strong,
.case-row small {
  display: block;
}

.case-row small {
  margin-top: 3px;
  color: var(--muted);
}

.case-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  align-items: start;
}

.case-card,
.claim-card {
  padding: 16px;
}

.case-title,
.claim-head {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.meta-row {
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.meta-row span {
  padding: 5px 8px;
  border-radius: 999px;
  background: #edf5f5;
  color: var(--muted);
}

.line-table {
  display: grid;
  gap: 10px;
}

.code-line {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) minmax(230px, 0.7fr) 92px;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.code-line.ready {
  border-left: 5px solid var(--green);
}

.code-line.review {
  border-left: 5px solid var(--amber);
}

.code-line.needs_docs {
  border-left: 5px solid var(--red);
}

.code-cell {
  min-height: 64px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: #0f3d57;
}

.code-cell strong {
  font-size: 1.05rem;
}

.code-cell span {
  font-size: 0.74rem;
  font-weight: 850;
}

.code-main {
  min-width: 0;
}

.code-title {
  justify-content: space-between;
  gap: 10px;
}

.code-main p {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.4;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
  white-space: nowrap;
}

.ready {
  background: var(--green-soft);
  color: var(--green);
}

.review {
  background: var(--amber-soft);
  color: var(--amber);
}

.needs-docs,
.needs_docs {
  background: var(--red-soft);
  color: var(--red);
}

.evidence-row {
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.evidence-chip,
.gap-chip {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  border-radius: 999px;
  background: #edf5f5;
  color: var(--muted);
  font-size: 0.78rem;
}

.gap-chip {
  background: var(--red-soft);
  color: var(--red);
}

.evidence-chip.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.evidence-chip.ok {
  background: var(--green-soft);
  color: var(--green);
}

.money-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.money-grid span {
  min-height: 54px;
  padding: 8px;
}

.money-grid small {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.money-grid strong {
  display: block;
  margin-top: 2px;
}

.review-button {
  min-height: 40px;
  font-weight: 800;
}

.review-button.active {
  color: white;
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.ledger {
  margin: 0;
}

.ledger div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

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

.ledger dd {
  margin: 0;
  font-weight: 850;
}

.doc-panel,
.history-panel {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.doc-gap {
  width: 100%;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  text-align: left;
  background: var(--red-soft);
  color: var(--red);
}

.doc-gap em {
  font-style: normal;
  font-weight: 850;
}

.doc-empty {
  padding: 12px;
  color: var(--green);
  background: var(--green-soft);
}

.history-item {
  display: grid;
  grid-template-columns: 58px 56px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 9px;
  font-size: 0.84rem;
}

.history-item time {
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  min-height: 0;
  max-width: calc(100vw - 36px);
  padding: 10px 12px;
  border: 1px solid #b8e4d3;
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 800;
  line-height: 1.2;
  box-shadow: var(--shadow);
}

.toast:empty {
  display: none;
}

@media (max-width: 1120px) {
  .case-layout {
    grid-template-columns: 1fr;
  }

  .code-line {
    grid-template-columns: 74px minmax(0, 1fr);
  }

  .money-grid,
  .review-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar,
  .toolbar,
  .case-title,
  .claim-head {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace {
    padding: 12px;
  }

  .auth-card {
    padding: 20px;
  }

  .auth-metrics,
  .money-grid {
    grid-template-columns: 1fr;
  }

  .table-header {
    display: none;
  }

  .case-row {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .code-line {
    grid-template-columns: 1fr;
  }

  .code-cell {
    min-height: 48px;
    grid-auto-flow: column;
    justify-content: start;
    padding: 0 12px;
  }
}
