:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #0f1d33;
  --muted: #637089;
  --line: #dfe6ef;
  --nav: #071a32;
  --nav-2: #082945;
  --green: #16a15f;
  --green-soft: #e0f7ea;
  --blue: #2477e8;
  --blue-soft: #e7f0ff;
  --amber: #f59e0b;
  --amber-soft: #fff5df;
  --red: #ef4444;
  --red-soft: #fee2e2;
  --shadow: 0 10px 28px rgba(15, 29, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 16px 18px;
  background: linear-gradient(180deg, var(--nav), var(--nav-2));
  color: #e7f2ff;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 3px solid #27d18b;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
  font-weight: 900;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 18px;
}

.brand span {
  color: #22d48a;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.nav-groups {
  display: grid;
  gap: 22px;
}

.nav-groups h2 {
  margin: 0 0 8px;
  color: #8ca3bd;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.side-tab {
  width: 100%;
  min-height: 39px;
  display: flex;
  align-items: center;
  margin-bottom: 4px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #dceafa;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  text-align: left;
}

.side-tab::before {
  content: "";
  width: 18px;
  height: 18px;
  margin-right: 12px;
  border: 1.5px solid currentColor;
  border-radius: 5px;
  opacity: 0.9;
}

.side-tab.active,
.side-tab:hover {
  background: rgba(22, 161, 95, 0.28);
  color: #fff;
}

.user-box {
  width: 100%;
  min-height: 64px;
  display: grid;
  grid-template-columns: 38px 1fr;
  column-gap: 10px;
  align-items: center;
  margin-top: auto;
  padding: 11px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  cursor: pointer;
  text-align: left;
}

.user-box span {
  width: 38px;
  height: 38px;
  grid-row: span 2;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #21c56e;
  font-weight: 900;
}

.user-box strong {
  font-size: 15px;
}

.user-box small {
  color: #9db0c6;
}

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

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: #0a1630;
  font-size: 34px;
  line-height: 1.28;
}

.page-head p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  margin-left: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: #0a874b;
  font-size: 12px;
  font-weight: 900;
}

.divider {
  display: inline-block;
  width: 1px;
  height: 14px;
  margin: 0 12px;
  background: var(--line);
  vertical-align: middle;
}

.updated-meta {
  white-space: nowrap;
}

.top-actions,
.command-row,
.ledger-actions,
.page-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-button,
.command,
.table-button,
.state-select,
.page-buttons button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.top-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  white-space: nowrap;
}

.top-button.export {
  min-width: 210px;
  border-color: #0ca966;
  background: #10b86c;
  color: #fff;
}

.command-row {
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.command {
  padding: 0 13px;
  font-size: 13px;
  white-space: nowrap;
}

.command.primary {
  border-color: #0ca966;
  background: #0f9f61;
  color: #fff;
}

.command:disabled,
.top-button:disabled,
.table-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.hidden-file {
  display: none;
}

.notice {
  min-height: 38px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid #badbd0;
  border-radius: 8px;
  background: #e6f7ef;
  color: #116044;
  font-size: 14px;
  font-weight: 800;
}

.collector-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr)) minmax(260px, 1.25fr);
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #cbd8e6;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.collector-card div {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
}

.collector-card span,
.collector-card small {
  display: block;
}

.collector-card span {
  color: #344158;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.collector-card strong {
  display: block;
  margin: 7px 0 3px;
  color: #0f1d33;
  font-size: 18px;
}

.collector-card small {
  color: var(--muted);
  font-size: 12px;
}

.collector-card ul {
  max-height: 96px;
  margin: 0;
  padding: 2px 0 0;
  overflow: auto;
  list-style: none;
  color: var(--muted);
  font-size: 12px;
}

.collector-card li {
  padding: 4px 0;
  border-bottom: 1px solid #edf2f7;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr)) minmax(260px, 1.15fr);
  gap: 14px;
  margin-bottom: 16px;
}

.kpi-card,
.status-card,
.panel,
.ledger-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.kpi-card {
  min-height: 168px;
  min-width: 0;
  padding: 22px;
}

.kpi-card span,
.status-card > span {
  display: block;
  margin-bottom: 18px;
  color: #33415c;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.kpi-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 29px;
  line-height: 1.18;
  white-space: nowrap;
}

.kpi-card small {
  display: block;
  color: #30405b;
  font-size: 13px;
}

.kpi-card.blue strong {
  color: var(--blue);
}

.kpi-card.green strong {
  color: var(--green);
}

.kpi-card.amber {
  border-color: #f5cf8b;
  background: var(--amber-soft);
}

.kpi-card.amber strong {
  color: var(--amber);
}

.kpi-card.cash strong {
  color: #1d56c5;
}

.link-button {
  margin-top: 20px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #0f5fc2;
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
}

.link-button::after {
  content: "  →";
}

.status-card {
  min-height: 168px;
  padding: 22px;
  min-width: 0;
}

.status-body {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
  max-width: 430px;
}

.donut {
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  background: conic-gradient(var(--green) var(--safe-angle), var(--amber) 0 342deg, var(--line) 0);
  position: relative;
}

.donut::after {
  content: "";
  width: 66px;
  height: 66px;
  border-radius: 999px;
  background: #fff;
  position: absolute;
}

.donut strong {
  z-index: 1;
  font-size: 22px;
}

.status-card ul {
  flex: 0 0 210px;
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.status-card li {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 8px;
  align-items: center;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

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

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

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

.dot.partial {
  background: #94a3b8;
}

.status-card small {
  display: block;
  margin-top: 14px;
  color: var(--muted);
}

.content-grid {
  display: grid;
  grid-template-columns: 315px minmax(0, 1fr);
  gap: 16px;
}

.insights {
  display: grid;
  gap: 14px;
  align-content: start;
}

.panel {
  padding: 18px 20px;
}

.panel h2,
.ledger-head h2 {
  color: #344158;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.summary-line {
  width: 100%;
  min-height: 33px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 0;
  background: transparent;
  color: #22324c;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.summary-line.safe {
  color: var(--green);
}

.summary-line.review {
  color: var(--amber);
}

.summary-line.critical {
  color: var(--red);
}

.summary-line.partial {
  color: #64748b;
}

.exception-list {
  margin-top: 16px;
}

.exception-item {
  padding: 0 0 13px;
  border-bottom: 1px solid var(--line);
}

.exception-item strong,
.exception-item span,
.exception-item small {
  display: block;
}

.exception-item span {
  margin-top: 4px;
  color: #344158;
  font-size: 13px;
  font-weight: 800;
}

.exception-item small {
  margin-top: 6px;
  color: var(--muted);
}

.exception-item em {
  float: right;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.panel-link {
  margin-top: 12px;
}

.panel-help {
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.work-status-list {
  display: grid;
  gap: 8px;
}

.work-status {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.work-status span {
  font-size: 14px;
  font-weight: 900;
}

.work-status em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.work-status strong {
  grid-row: 1 / span 2;
  grid-column: 2;
  min-width: 24px;
  color: #0f1d33;
  font-size: 18px;
  text-align: right;
}

.work-status[data-work-status="needs-review"] strong,
.work-status[data-work-status="needs-review"] span {
  color: var(--amber);
}

.work-status[data-work-status="failed"] strong,
.work-status[data-work-status="failed"] span {
  color: var(--red);
}

.work-status[data-work-status="ready"] strong,
.work-status[data-work-status="ready"] span {
  color: var(--blue);
}

.work-status[data-work-status="received"] span {
  color: var(--green);
}

.sources {
  display: grid;
  gap: 12px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
}

.sources li {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sources strong {
  color: var(--green);
  font-size: 12px;
}

.sources em {
  color: #94a3b8;
  font-style: normal;
}

.ledger-card {
  min-width: 0;
  overflow: hidden;
}

.ledger-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.ledger-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.ledger-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search {
  position: relative;
  width: 350px;
}

.search span {
  position: absolute;
  width: 1px;
  height: 1px;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
}

.search input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
}

.table-button,
.state-select {
  padding: 0 15px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  background: #f8fafc;
  color: #39465d;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

tbody tr.needs-review-row {
  background: #fff8ea;
  outline: 1px solid #f2c572;
}

.badge {
  display: inline-flex;
  min-width: 90px;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
}

.badge.safe {
  background: var(--green-soft);
  color: #0a874b;
}

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

.badge.critical {
  background: var(--red-soft);
  color: var(--red);
}

.badge.partial {
  background: #e9eef5;
  color: #64748b;
}

.customer-main {
  display: block;
  font-weight: 900;
}

.evidence,
.resolved {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.resolved {
  color: var(--green);
  font-weight: 900;
}

.money {
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.negative {
  color: var(--red);
}

.evidence-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 190px;
}

.file-chip {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 7px;
  align-items: center;
  color: #31435e;
  font-size: 12px;
  line-height: 1.15;
}

.file-chip i {
  width: 24px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid #ff8b8b;
  border-radius: 5px;
  color: #ef4444;
  font-size: 9px;
  font-style: normal;
  font-weight: 900;
}

.file-chip.processor i {
  border-color: #70a8ff;
  color: var(--blue);
}

.row-menu {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: #27415d;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.empty {
  padding: 40px;
  color: var(--muted);
  text-align: center;
}

.pager {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 22px;
  color: var(--muted);
  font-size: 13px;
}

.page-buttons button {
  min-width: 34px;
  min-height: 34px;
}

.page-buttons button.active {
  border-color: #cfe1ff;
  background: #eaf2ff;
  color: var(--blue);
}

.pager select {
  min-height: 34px;
  margin-left: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

@media (max-width: 1500px) {
  .app-frame {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .kpi-grid {
    grid-template-columns: repeat(4, minmax(180px, 1fr));
  }

  .status-card {
    grid-column: 1 / -1;
  }

  .content-grid {
    grid-template-columns: 290px minmax(0, 1fr);
  }

  .main {
    padding: 22px 20px 28px;
  }
}

@media (max-width: 1180px) {
  .kpi-grid,
  .content-grid,
  .collector-card {
    grid-template-columns: 1fr 1fr;
  }

  .status-card,
  .ledger-card {
    grid-column: 1 / -1;
  }

  .insights {
    display: grid;
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    min-height: auto;
  }

  .page-head,
  .ledger-head,
  .pager {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .ledger-actions,
  .insights {
    display: grid;
    grid-template-columns: 1fr;
  }

  .search {
    width: 100%;
  }
}
