/* BARB Office — off-white and gold. Layout: sidebar on desktop, scrolling tab bar on phones. */
:root {
  --bg: #f6f3ec;
  --surface: #fffdf8;
  --surface-2: #f0ebe0;
  --ink: #26221c;
  --muted: #776e60;
  --line: #e2d9c8;
  --gold: #9c7633;
  --gold-strong: #7f5e22;
  --gold-soft: #efe3c8;
  --good: #3b7550;  --good-soft: #e1eee4;
  --warn: #a5701a;  --warn-soft: #f6ead2;
  --bad:  #a63f37;  --bad-soft:  #f6e1de;
  --info: #3e6688;  --info-soft: #e0e9f1;
  --display: "Cormorant Garamond", "Cormorant", Georgia, "Times New Roman", serif;
  --body: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(60, 45, 20, .06), 0 4px 16px rgba(60, 45, 20, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15130f; --surface: #1e1b15; --surface-2: #27231b; --ink: #eee7da; --muted: #a59b89;
    --line: #363024; --gold: #d3ad62; --gold-strong: #e6c47f; --gold-soft: #3a3020;
    --good: #7cc191; --good-soft: #1f3326; --warn: #e2b05a; --warn-soft: #3a2e17;
    --bad: #e58b82; --bad-soft: #3d2220; --info: #8fb6d6; --info-soft: #1d2b37;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15130f; --surface: #1e1b15; --surface-2: #27231b; --ink: #eee7da; --muted: #a59b89;
  --line: #363024; --gold: #d3ad62; --gold-strong: #e6c47f; --gold-soft: #3a3020;
  --good: #7cc191; --good-soft: #1f3326; --warn: #e2b05a; --warn-soft: #3a2e17;
  --bad: #e58b82; --bad-soft: #3d2220; --info: #8fb6d6; --info-soft: #1d2b37;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--body); -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gold-strong); }
.num, td.num, .money { font-variant-numeric: tabular-nums; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.15; margin: 0; text-wrap: balance; }
h1 { font-size: 2rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden, [hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }
.shell > div, .main { min-width: 0; }
.side {
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 22px 14px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { text-align: center; padding: 4px 6px 14px; border-bottom: 1px solid var(--line); }
.brand .word { font-family: var(--display); font-size: 1.9rem; letter-spacing: .32em; padding-left: .32em; color: var(--gold-strong); }
.brand .sub { font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); }
.nav a.on { background: var(--gold-soft); color: var(--gold-strong); }
.nav .badge { background: var(--gold); color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 7px; line-height: 1.5; }
.side .who { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; font-size: .875rem; }
.main { padding: 28px clamp(16px, 4vw, 44px) 60px; max-width: 1180px; width: 100%; }
.topbar { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .topbar {
    display: block; position: sticky; top: 0; z-index: 20;
    background: var(--surface); border-bottom: 1px solid var(--line);
  }
  .topbar .row1 { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px 4px; }
  .topbar .word { font-family: var(--display); font-size: 1.35rem; letter-spacing: .28em; color: var(--gold-strong); }
  .tabs { display: flex; gap: 4px; overflow-x: auto; padding: 4px 12px 8px; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a {
    flex: none; padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--ink);
    font-size: .9rem; font-weight: 500; border: 1px solid var(--line); background: var(--surface);
  }
  .tabs a.on { background: var(--gold); border-color: var(--gold); color: #fff; }
  .tabs .badge { background: var(--gold); color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 6px; margin-left: 6px; }
  .tabs a.on .badge { background: #fff; color: var(--gold-strong); }
  .main { padding: 18px 16px 80px; }
  h1 { font-size: 1.65rem; }
}

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head .lede { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: .925rem;
  text-decoration: none; min-height: 38px;
}
.btn:hover { border-color: var(--gold); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.primary:hover { background: var(--gold-strong); border-color: var(--gold-strong); }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.bad { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--gold-strong); padding-inline: 8px; }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: .85rem; }
.btn[disabled] { opacity: .55; cursor: wait; }

label.f { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; font-weight: 600; color: var(--muted); }
label.f > span em { font-style: normal; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=month], select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 1rem; font-weight: 400; min-height: 42px;
}
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
input[type=file] { font-size: .9rem; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 560px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; padding: 3px; background: var(--surface-2); }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--gold-strong); box-shadow: var(--shadow); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-width: 140px; min-height: 38px; padding: 6px 10px; font-size: .925rem; }

/* ---------- Cards, tiles, tables ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card h2, .card h3 { margin-bottom: 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .k { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.tile .v { font-family: var(--display); font-size: 1.85rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 2px; }
.tile .s { font-size: .82rem; color: var(--muted); }
.tile.link { text-decoration: none; color: inherit; display: block; }
.tile.link:hover { border-color: var(--gold); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .925rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
tfoot td { font-weight: 700; background: var(--surface-2); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }

.list { display: flex; flex-direction: column; gap: 10px; }
.item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; align-items: start; }
.item .t { font-weight: 600; }
.item .meta { font-size: .85rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.item .amt { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.item .row-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.item.stripe-pending { border-left: 4px solid var(--warn); }
.item.stripe-approved { border-left: 4px solid var(--info); }
.item.stripe-paid { border-left: 4px solid var(--good); }
.item.stripe-rejected { border-left: 4px solid var(--bad); }

.pill { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.pending { background: var(--warn-soft); color: var(--warn); }
.pill.approved { background: var(--info-soft); color: var(--info); }
.pill.paid, .pill.received, .pill.staff { background: var(--good-soft); color: var(--good); }
.pill.rejected, .pill.inactive { background: var(--bad-soft); color: var(--bad); }
.pill.due { background: var(--warn-soft); color: var(--warn); }
.pill.owner { background: var(--gold-soft); color: var(--gold-strong); }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface); }
.note { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); font-size: .9rem; }
.note.warn { background: var(--warn-soft); color: var(--ink); }
.note.bad { background: var(--bad-soft); }

/* Turnover meter */
.meter { position: relative; height: 14px; background: var(--surface-2); border-radius: 999px; margin: 26px 0 30px; }
.meter .fill { position: absolute; inset: 0 auto 0 0; background: var(--gold); border-radius: 999px; }
.meter .mark { position: absolute; top: -6px; bottom: -6px; width: 2px; background: var(--ink); opacity: .55; }
.meter .mark span { position: absolute; top: 22px; left: 50%; transform: translateX(-50%); font-size: .72rem; white-space: nowrap; color: var(--muted); }
.meter .mark span.up { top: -20px; }

/* Bars in project table */
.bar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 6px; min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--gold); }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(20, 16, 10, .45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 12px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; width: min(620px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.25); border: 1px solid var(--line); }
.modal.wide { width: min(860px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal .body { padding: 18px 20px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal .x { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 9px; z-index: 80; font-weight: 600; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.toast.err { background: var(--bad); color: #fff; }

/* ---------- Auth ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: min(400px, 100%); padding: 28px; }
.auth .brand { border: 0; margin-bottom: 8px; }

/* ---------- Letterhead (payslip) ---------- */
.lh { background: #fff; color: #1d1a15; padding: 34px 36px; border: 1px solid #ddd; font-family: var(--body); }
.lh .lh-head { text-align: center; border-bottom: 1.5px solid #1d1a15; padding-bottom: 12px; margin-bottom: 18px; }
.lh .lh-name { font-family: var(--display); font-size: 1.9rem; font-weight: 600; letter-spacing: .16em; }
.lh .lh-line { font-size: .78rem; letter-spacing: .05em; color: #555; }
.lh .lh-title { text-align: center; font-family: var(--display); font-size: 1.3rem; letter-spacing: .2em; margin: 6px 0 18px; }
.lh .box { background: #eeeeec; border-radius: 4px; padding: 10px 12px; }
.lh .box .k { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #666; font-weight: 700; }
.lh .box .v { font-weight: 600; }
.lh .boxes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.lh table { font-size: .9rem; }
.lh th { background: #eeeeec; color: #444; }
.lh td, .lh th { border-bottom: 1px solid #ddd; }
.lh .netrow td { font-size: 1.05rem; background: #eeeeec; font-weight: 700; }
.lh .foot { margin-top: 26px; font-size: .75rem; color: #666; text-align: center; }
@media (max-width: 560px) { .lh { padding: 20px 16px; } .lh .boxes { grid-template-columns: 1fr 1fr; } .lh .lh-name { font-size: 1.35rem; } }

@media print {
  body { background: #fff; }
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block !important; position: static; }
  .print-area .lh { border: 0; padding: 0; }
}
.print-area { display: none; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
