@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --ink: #172420;
  --paper: #F1EEE3;
  --panel: #FDFCF7;
  --line: #DAD5C4;
  --muted: #6B6459;
  --kelp: #2B6E5B;
  --kelp-dark: #1F5346;
  --clay: #B85C2E;
  --clay-dark: #96491F;
  --amber: #C98A1D;
  --green: #3B8F63;
  --red: #B23A3A;
  --radius: 6px;
  --accent: var(--kelp);
  --accent-dark: var(--kelp-dark);
}
body[data-business="clicksandco"] { --accent: var(--clay); --accent-dark: var(--clay-dark); }
body[data-business="studiokelp"] { --accent: var(--kelp); --accent-dark: var(--kelp-dark); }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
h1, h2, h3, .display {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}
h1 { font-size: 28px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
a { color: inherit; }

/* ---- Auth screen ---- */
.auth-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 36px 32px;
}
.auth-brand { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.auth-brand .mark { color: var(--kelp); font-size: 22px; }
.auth-sub { color: var(--muted); margin: 6px 0 24px; font-size: 13.5px; }
.tabbar { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.tabbar button {
  flex: 1; background: none; border: none; padding: 10px 4px;
  font: inherit; font-weight: 600; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabbar button.active { color: var(--ink); border-bottom-color: var(--accent); }
.role-pick { display: flex; gap: 8px; margin-bottom: 18px; }
.role-pick button {
  flex: 1; padding: 9px; border: 1px solid var(--line); background: var(--panel);
  border-radius: var(--radius); font: inherit; font-weight: 500; cursor: pointer; color: var(--muted);
}
.role-pick button.active { border-color: var(--ink); color: var(--ink); background: #fff; }

/* ---- Form elements ---- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input, select, textarea {
  width: 100%; font: inherit; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
textarea { resize: vertical; min-height: 60px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

button.btn {
  font: inherit; font-weight: 600; padding: 10px 16px; border-radius: var(--radius);
  border: 1px solid var(--accent-dark); background: var(--accent); color: #fff; cursor: pointer;
}
button.btn:hover { background: var(--accent-dark); }
button.btn:disabled { opacity: 0.55; cursor: default; }
button.btn.full { width: 100%; }
button.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
button.btn.ghost:hover { background: #fff; }
button.btn.danger { background: var(--red); border-color: #8f2e2e; }
button.btn.danger:hover { background: #8f2e2e; }
button.btn.small { padding: 6px 11px; font-size: 12.5px; }

.msg { padding: 10px 12px; border-radius: var(--radius); font-size: 13px; margin-bottom: 14px; }
.msg.error { background: #F8E9E5; color: #7A2E17; border: 1px solid #E3B9A6; }
.msg.ok { background: #E7F1EA; color: #1F5346; border: 1px solid #B9D8C4; }

/* ---- App shell ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--ink); color: #EDEAE0;
  padding: 24px 18px; display: flex; flex-direction: column;
}
.sidebar .brand { font-family: 'Fraunces', serif; font-size: 18px; margin-bottom: 2px; }
.sidebar .brand-sub { font-size: 12px; color: #A9A296; margin-bottom: 28px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav button {
  text-align: left; background: none; border: none; color: #D8D4C6; font: inherit;
  padding: 9px 10px; border-radius: var(--radius); cursor: pointer; font-weight: 500;
}
.sidebar nav button.active { background: rgba(255,255,255,0.1); color: #fff; }
.sidebar nav button:hover:not(.active) { background: rgba(255,255,255,0.05); }
.sidebar .who { font-size: 12px; color: #A9A296; padding: 10px; border-top: 1px solid rgba(255,255,255,0.12); margin-top: 12px; }
.sidebar .who strong { color: #EDEAE0; display: block; font-size: 13px; margin-bottom: 6px; }

.main { flex: 1; padding: 32px 40px; max-width: 1040px; }
.main-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 10px; }
.main-head p { color: var(--muted); margin: 4px 0 0; }

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

/* ---- Cards / stats ---- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 26px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
}
.stat .label { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.stat .value { font-family: 'Fraunces', serif; font-size: 24px; }
.stat.balance .value { color: var(--accent-dark); }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 22px;
}
.panel-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.panel-body { padding: 18px; }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: none; }
td.amount, th.amount { text-align: right; font-variant-numeric: tabular-nums; }
.empty-row td { color: var(--muted); text-align: center; padding: 26px; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge.pending .dot { background: var(--amber); }
.badge.pending { color: #8a611a; }
.badge.approved .dot { background: var(--green); }
.badge.approved { color: var(--green); }
.badge.rejected .dot { background: var(--red); }
.badge.rejected { color: var(--red); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 100px; background: #EDEAE0; font-size: 12px; color: var(--muted); }
.actions-cell { display: flex; gap: 6px; }

.filter-bar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-bar button { font: inherit; font-size: 12.5px; font-weight: 600; padding: 6px 12px; border-radius: 100px; border: 1px solid var(--line); background: #fff; color: var(--muted); cursor: pointer; }
.filter-bar button.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(23, 36, 32, 0.45); display: none;
  align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal-backdrop.active { display: flex; }
.modal {
  background: var(--panel); border-radius: var(--radius); border: 1px solid var(--line);
  width: 100%; max-width: 440px; padding: 24px; max-height: 90vh; overflow-y: auto;
}
.modal-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); }

.logout-link { background: none; border: none; color: #D8D4C6; font: inherit; font-size: 12px; cursor: pointer; padding: 0; text-decoration: underline; }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; flex-direction: row; align-items: center; padding: 14px 18px; }
  .sidebar .brand-sub, .sidebar .who { display: none; }
  .sidebar nav { flex-direction: row; flex: 1; overflow-x: auto; }
  .main { padding: 22px 18px; }
  .stat-row { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
}
