:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #eef3f6;
  --ink: #17202a;
  --muted: #64748b;
  --line: #d7dee8;
  --accent: #1d6f8f;
  --accent-2: #3a7d44;
  --warn: #a7662f;
  --danger: #a23b3b;
  --review: #6d5bd0;
  --shadow: 0 12px 32px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.auth-required {
  overflow: hidden;
}

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

button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover { border-color: var(--accent); }

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f5f7fa;
}

.auth-gate[hidden] {
  display: none;
}

.auth-card {
  width: min(100%, 380px);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  margin-bottom: 14px;
}

.auth-card h1 {
  margin-bottom: 18px;
  font-size: 30px;
}

.sidebar {
  min-height: 100vh;
  padding: 18px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
}

.brand {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  margin-bottom: 18px;
}

.brand img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.brand strong {
  display: block;
  font-size: 17px;
}

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

nav {
  display: grid;
  gap: 6px;
  margin-bottom: 22px;
}

.nav-button {
  width: 100%;
  text-align: left;
  background: transparent;
  border-color: transparent;
}

.nav-button.active {
  background: #e8f4f7;
  border-color: #b7d9e4;
  color: #155873;
  font-weight: 700;
}

.doc-link {
  display: block;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  margin: 10px 0;
}

.app-shell {
  min-width: 0;
  padding: 22px 28px 36px;
}

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

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  font-weight: 800;
}

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

h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 40px);
}

h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
  min-height: 118px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
  line-height: 1;
}

.metric em {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
}

.workspace,
.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 420px));
  gap: 14px;
  align-items: start;
}

.workspace > div,
.panel {
  padding: 16px;
}

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

.panel-heading h2 {
  margin: 0;
}

.wide {
  grid-column: 1 / -1;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.list-item strong {
  display: block;
  margin-bottom: 4px;
}

.list-item span,
td small {
  color: var(--muted);
  font-size: 12px;
}

form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.form-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

a {
  color: var(--accent);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 8px 10px;
}

textarea { resize: vertical; }

form button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 800;
}

.wide { min-width: 0; }
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.paid,
.succeeded,
.verified,
.card_paid,
.ach_settled {
  background: #e7f6ec;
  color: var(--accent-2);
}

.pending,
.ach_pending_manual_approval,
.issued,
.open,
.unsigned_local_dev {
  background: #fff2df;
  color: var(--warn);
}

.failed,
.disputed,
.not_ready {
  background: #fde9e9;
  color: var(--danger);
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 14px;
}

.report {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.report ul {
  margin: 0;
  padding-left: 18px;
  color: #334155;
  line-height: 1.6;
}

.setup-panel {
  max-width: 760px;
}

.checklist {
  display: grid;
  gap: 10px;
}

.checklist label {
  grid-template-columns: 20px 1fr;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.checklist input {
  width: 16px;
  height: 16px;
  min-height: 16px;
}

@media (max-width: 960px) {
  body { grid-template-columns: 1fr; }

  .sidebar {
    position: static;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .workspace,
  .split,
  .metric-grid,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .app-shell {
    padding: 18px 16px 30px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
