/* =====================================================================
   Midwood Money — design system
   Matches the ops portal Inventory Import look: warm off-white, white
   cards, single gold accent, airy 14px type, restrained color.
   ===================================================================== */

:root {
  --bg:            #f8f7f4;
  --surface:       #ffffff;
  --surface-soft:  #faf9f6;
  --border:        #ece7da;
  --border-strong: #d6cfbd;
  --text:          #1a1a1a;
  --text-muted:    #6b6b6b;
  --text-subtle:   #9a9a9a;
  --gold:          #b07525;
  --gold-light:    #d4a864;
  --gold-tint:     #fbf3e3;
  --green:         #2e6a3f;  --green-bg: #e9f2ec;
  --red:           #8b2c2c;  --red-bg:   #f7e9e9;
  --yellow:        #8a6d1a;  --yellow-bg:#f7f1dd;
  --blue:          #2e4866;  --blue-bg:  #e8eef5;
  --purple:        #5b3f80;  --purple-bg:#ece5f3;
  --mono: ui-monospace, Menlo, monospace;
  --radius: 7px;
  --radius-lg: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* === App shell ====================================================== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex; align-items: center; gap: 6px;
  height: 54px;
}
.topbar .wordmark {
  font-weight: 700; font-size: 14px; letter-spacing: 0.02em;
  margin-right: 18px; white-space: nowrap;
}
.topbar .wordmark .sep { color: var(--gold); padding: 0 4px; font-weight: 400; }
.topbar nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.topbar nav a {
  padding: 7px 13px; border-radius: 999px;
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  transition: all 0.15s; white-space: nowrap;
}
.topbar nav a:hover { background: var(--gold-tint); color: var(--text); }
.topbar nav a.active { background: var(--gold-tint); color: var(--gold); }
.topbar .user { font-size: 12px; color: var(--text-subtle); white-space: nowrap; }

.main { max-width: 1280px; margin: 0 auto; padding: 24px 32px 64px; }
.page-title { font-size: 22px; font-weight: 600; margin: 0 0 4px; }
.page-sub { color: var(--text-muted); font-size: 13px; margin: 0 0 20px; }

/* === Cards ========================================================== */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
}
.section-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.section-header h2 { font-size: 15px; font-weight: 600; margin: 0; }
.section-body { padding: 20px; }
.section-body.flush { padding: 0; }

/* === Stats ========================================================== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 20px;
}
.stat-card .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-subtle); font-weight: 600; }
.stat-card .value { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat-card .value.warn { color: var(--red); }
.stat-card .value.ok { color: var(--green); }

/* === Buttons ======================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: all 0.15s;
}
.btn-primary { background: var(--gold); color: #fff; }
.btn-primary:hover { background: #9a6520; }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--gold); color: var(--gold); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* === Tables ========================================================= */
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  padding: 9px 14px; text-align: left;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-subtle); font-weight: 600;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
}
table.data td { padding: 9px 14px; font-size: 13.5px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:hover td { background: var(--surface-soft); }
table.data tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.amount-in { color: var(--green); font-weight: 600; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }

/* === Badges ========================================================= */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap;
}
.badge.business { color: var(--green); background: var(--green-bg); }
.badge.personal { color: var(--purple); background: var(--purple-bg); }
.badge.mixed    { color: var(--blue); background: var(--blue-bg); }
.badge.unreviewed { color: var(--text-subtle); background: var(--surface-soft); border: 1px dashed var(--border-strong); }
.badge.fishy   { color: var(--red); background: var(--red-bg); }
.badge.followup{ color: var(--yellow); background: var(--yellow-bg); }
.badge.pending { color: var(--text-subtle); background: var(--surface-soft); }
.badge.gold    { color: var(--gold); background: var(--gold-tint); }
.badge.ok      { color: var(--green); background: var(--green-bg); }
.badge.err     { color: var(--red); background: var(--red-bg); }

/* Review action chips */
.chip-row { display: inline-flex; gap: 4px; }
.chip {
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  border: 1px solid var(--border-strong); background: var(--surface);
  cursor: pointer; transition: all 0.15s; color: var(--text-muted);
}
.chip:hover { border-color: var(--gold); color: var(--gold); }
.chip.on-business { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.chip.on-personal { background: var(--purple-bg); border-color: var(--purple); color: var(--purple); }
.chip.on-fishy    { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.chip.on-followup { background: var(--yellow-bg); border-color: var(--yellow); color: var(--yellow); }

/* === Forms ========================================================== */
.input, input[type="text"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
  padding: 8px 12px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  font-size: 14px; transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-tint);
}
label.field-label {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-subtle); font-weight: 600; margin: 0 0 4px;
}
.form-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.form-row > div { display: flex; flex-direction: column; }

/* === Misc =========================================================== */
.empty-state { padding: 36px 20px; text-align: center; color: var(--text-subtle); font-size: 13px; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(8px);
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; opacity: 0; transition: all 0.18s;
  pointer-events: none; z-index: 1000; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); }
.overlay {
  position: fixed; inset: 0; background: rgba(26,26,26,0.4);
  display: none; align-items: flex-start; justify-content: center;
  z-index: 200; padding: 24px; overflow-y: auto;
}
.overlay.show { display: flex; }
.overlay-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px;
  width: min(560px, 100%); margin: 40px auto;
  box-shadow: 0 32px 80px rgba(26,26,26,0.18);
}
.overlay-panel h2 { margin: 0 0 4px; font-size: 18px; }
.overlay-panel .sub { color: var(--text-muted); font-size: 13px; margin: 0 0 16px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs button {
  background: none; border: none; padding: 9px 16px; font-size: 14px; font-weight: 500;
  color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--gold); border-bottom-color: var(--gold); }

@media (max-width: 720px) {
  .main { padding: 16px 14px 48px; }
  .topbar { padding: 0 12px; }
}
