:root {
  --accent: #2563eb;
  --line: #e5e7eb;
  --bg: #f8fafc;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

header {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 56px;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 700;
  font-size: 17px;
  color: var(--accent);
}

nav {
  display: flex;
  gap: 4px;
  flex: 1;
}

nav button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}

nav button:hover {
  background: var(--bg);
  color: var(--text);
}

nav button.active {
  background: var(--accent);
  color: #fff;
}

.status {
  font-size: 13px;
  color: var(--muted);
}
.status.ok {
  color: #16a34a;
}
.status.bad {
  color: #dc2626;
}

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px;
}

h1 {
  font-size: 22px;
  margin: 0 0 16px;
}
h2 {
  font-size: 15px;
  margin: 24px 0 8px;
  color: var(--muted);
}
.muted {
  color: var(--muted);
}
.bad {
  color: #dc2626;
}

table.grid {
  border-collapse: collapse;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
table.grid th,
table.grid td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
table.grid th {
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
}
table.grid tr:last-child td {
  border-bottom: 0;
}
table.grid td.right,
table.grid th.right {
  text-align: right;
}
table.grid td.center,
table.grid th.center {
  text-align: center;
}
tr.archived {
  opacity: 0.5;
}

.row-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.row-form input,
.row-form select {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}
.row-form .chk {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 14px;
}

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}
button:hover {
  border-color: var(--accent);
  color: var(--accent);
}
form button[type='submit'] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
button.primary:hover {
  color: #fff;
  opacity: 0.9;
}
.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}
button.danger {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}
button.danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}
td button {
  padding: 4px 8px;
  font-size: 13px;
  margin-left: 4px;
}
.placeholder p {
  color: var(--muted);
}

.ok-text {
  color: #16a34a;
  font-weight: 600;
}
tr.totals td {
  font-weight: 700;
  border-top: 2px solid var(--line);
  background: var(--bg);
}
.je-row,
.stmt-row {
  cursor: pointer;
}
.je-row:hover td,
.stmt-row:hover td {
  background: var(--bg);
}
.stmt-row.selected td {
  background: #eff6ff;
  box-shadow: inset 3px 0 0 var(--accent);
}
table.grid.sub {
  margin: 4px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
}
table.grid.sub th,
table.grid.sub td {
  padding: 4px 10px;
  font-size: 13px;
}
.je-detail > td {
  padding: 0 12px 8px 24px;
  background: var(--bg);
}

.small {
  font-size: 12px;
}
td.neg {
  color: #dc2626;
}
td.pos {
  color: #16a34a;
}
select {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}
.badge.b-manual {
  background: #ede9fe;
  color: #6d28d9;
}
.badge.b-history {
  background: #dbeafe;
  color: #1d4ed8;
}
.badge.b-claude {
  background: #dcfce7;
  color: #15803d;
}
.badge.b-unsolved {
  background: #fee2e2;
  color: #b91c1c;
}
.badge.b-pending {
  background: var(--bg);
  color: var(--muted);
}

.dropzone {
  border: 2px dashed var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 12px;
}
.dropzone:hover {
  border-color: var(--accent);
}
.dropzone.over {
  border-color: var(--accent);
  background: #eff6ff;
}
.dz-icon {
  font-size: 26px;
  color: var(--accent);
  line-height: 1;
}
.dz-main {
  margin-top: 8px;
  font-weight: 600;
}
.dz-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}
.dz-sub .link {
  color: var(--accent);
  text-decoration: underline;
}

ul.queue {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}
ul.queue li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 6px;
  background: var(--panel);
  font-size: 14px;
}
ul.queue .q-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
ul.queue .q-state {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
ul.queue li.working {
  border-color: var(--accent);
}
ul.queue li.working .q-state {
  color: var(--accent);
}
ul.queue li.ok .q-state {
  color: #16a34a;
}
ul.queue li.dup {
  border-color: #fde68a;
  background: #fffbeb;
}
ul.queue li.dup .q-state {
  color: #b45309;
  white-space: normal;
}
ul.queue li.err {
  border-color: #fecaca;
}

a.dl {
  display: inline-block;
  padding: 7px 12px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}
a.dl:hover {
  background: var(--accent);
  color: #fff;
}

.nowrap {
  white-space: nowrap;
}
tr.audit-fail td {
  background: #fff7ed;
}

nav button.has-badge {
  color: #b91c1c;
  font-weight: 600;
}
.q-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 12px 14px;
  margin-bottom: 12px;
}
.q-head {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.q-thread {
  margin: 8px 0;
}
.note {
  padding: 7px 10px;
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 14px;
  max-width: 70ch;
}
.note.from-firm {
  background: #eff6ff;
}
.note.from-client {
  background: var(--bg);
}
.note-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}
.q-reply {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.q-reply textarea {
  flex: 1;
  min-width: 260px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.badge.b-transfer {
  background: #e0e7ff;
  color: #3730a3;
}
.split-view div {
  font-size: 13px;
}
.split-box {
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.split-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 6px 0;
  flex-wrap: wrap;
}
.split-row .sp-amt {
  width: 110px;
}
.split-row input,
.split-row select {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}
.split-total {
  margin: 6px 0;
  font-size: 13px;
}
.split-box button {
  margin-right: 6px;
}

table.grid.selfcheck {
  max-width: 460px;
  margin: 10px 0;
}
table.grid.selfcheck td {
  padding: 6px 12px;
}

.acting-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  background: #fef3c7;
  color: #92400e;
  border-bottom: 1px solid #fcd34d;
  font-size: 14px;
}
.acting-bar button {
  padding: 3px 10px;
  font-size: 13px;
}

button.link-btn {
  border: 0;
  background: none;
  color: var(--muted);
  padding: 2px 0;
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}
button.link-btn:hover {
  color: var(--accent);
}
.dup-toggle {
  margin-top: 4px;
  font-size: 12px;
  padding: 3px 8px;
}
tr.dup-line td {
  background: #fffbeb;
  color: #92400e;
  text-decoration: line-through;
  text-decoration-color: #d9a441;
}
tr.dup-line td:last-child {
  text-decoration: none;
}
tr.subtotal td {
  background: var(--bg);
  font-weight: 600;
  border-top: 1px solid var(--line);
}
ul.queue li.err .q-state {
  color: #dc2626;
  white-space: normal;
}

.cards {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.card {
  flex: 1;
  min-width: 90px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  text-align: center;
}
.card-n {
  font-size: 26px;
  font-weight: 700;
}
.card-l {
  font-size: 12px;
  color: var(--muted);
  text-transform: capitalize;
}
.card.b-manual {
  border-color: #ddd6fe;
}
.card.b-history {
  border-color: #bfdbfe;
}
.card.b-claude {
  border-color: #bbf7d0;
}
.card.b-unsolved {
  border-color: #fecaca;
}

/* ---- Budget ---- */
.scrollx { overflow-x: auto; }
table.budget input { width: 74px; text-align: right; }
table.budget input.by { width: 92px; font-weight: 600; }
table.budget td.bud-name { white-space: nowrap; }
tr.bud-group td { font-weight: 700; padding-top: 14px; border-bottom: 2px solid var(--line, #d8dee6); }
tr.bud-total td { font-weight: 700; border-top: 2px solid var(--line, #d8dee6); }
td.num, th.num { text-align: right; }
.badge.b-under { background: #e6f6ea; color: #1b7e3c; }
.badge.b-near { background: #fff4d6; color: #8a6400; }
.badge.b-over { background: #fdeaea; color: #b42318; }

/* ---- Oversight: client picker, review banner, overview tiles ---- */
.client-pick {
  font: inherit;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--line, #d8dee6);
  margin-right: 10px;
  max-width: 220px;
}
.review-bar {
  background: #fff4d6;
  color: #6b4e00;
  border-bottom: 1px solid #f0d68a;
  padding: 6px 14px;
  font-size: 13px;
  text-align: center;
}
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 14px 0 22px;
}
.tile {
  background: #fff;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.tile-v { font-size: 22px; font-weight: 700; }
.tile-l { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: #64748b; margin-top: 2px; }
.tile-n { font-size: 11px; color: #94a3b8; margin-top: 4px; }
.tile.warn { border-color: #f0d68a; background: #fffdf5; }
.tile.bad { border-color: #fca5a5; background: #fff6f6; }
.tile.bad .tile-v { color: #b42318; }
