:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --ink: #0a0a0a;
  --ink-2: #404040;
  --muted: #737373;
  --line: #e7e7e7;
  --line-2: #f1f1f1;
  --accent: #0a0a0a;
  --accent-ink: #ffffff;
  --good: #15803d;
  --good-bg: #ecfdf3;
  --warn: #a16207;
  --warn-bg: #fefce8;
  --bad: #b91c1c;
  --bad-bg: #fef2f2;
  --info-bg: #f4f4f5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 1px 1px rgba(0, 0, 0, .02);
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 16px; }
.mt-s { margin-top: 8px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.stack > * + * { margin-top: 16px; }
.pre { white-space: pre-wrap; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--ink) 248px, transparent 248px); }
.sidebar { background: var(--ink); color: #d4d4d4; padding: 22px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: baseline; gap: 8px; padding: 0 10px 22px; color: #fff; text-decoration: none; }
.brand b { font-size: 20px; font-weight: 800; letter-spacing: .18em; }
.brand span { font-size: 11px; color: #a3a3a3; letter-spacing: .04em; }
.nav-group { margin-bottom: 18px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: #737373; padding: 0 10px 6px; font-weight: 700; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: #d4d4d4; font-weight: 600; font-size: 13.5px; }
.nav a:hover { background: #1f1f1f; color: #fff; }
.nav a.active { background: #fff; color: var(--ink); }
.nav a .count { margin-left: auto; background: #fff; color: #000; font-size: 11px; border-radius: 99px; padding: 0 7px; font-weight: 800; }
.nav a.active .count { background: #000; color: #fff; }
.nav svg { width: 17px; height: 17px; flex: none; }
.side-foot { margin-top: auto; border-top: 1px solid #262626; padding-top: 14px; }
.me-chip { display: flex; gap: 10px; align-items: center; padding: 6px 10px; text-decoration: none; color: #fff; border-radius: 8px; }
.me-chip:hover { background: #1f1f1f; }
.me-chip .who { min-width: 0; }
.me-chip .who div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; font-size: 13px; }
.me-chip .who small { color: #a3a3a3; font-size: 11.5px; }
.linkbtn { background: none; border: 0; color: #a3a3a3; font: inherit; font-size: 12.5px; cursor: pointer; padding: 6px 10px; }
.linkbtn:hover { color: #fff; }

.main { min-width: 0; }
.topbar { display: none; }
.content { max-width: 1180px; margin: 0 auto; padding: 32px 36px 64px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line-2); gap: 10px; }
.card-body { padding: 16px 20px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }

.stat { padding: 18px 20px; text-decoration: none; display: block; }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.stat .value { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; margin-top: 4px; }
.stat .sub { color: var(--muted); font-size: 12px; }
a.stat:hover { border-color: var(--ink); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--ink); background: var(--ink); color: var(--accent-ink); font: inherit; font-weight: 700; font-size: 13.5px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #262626; }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.danger { background: var(--surface); color: var(--bad); border-color: #f3c4c4; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 7px; }
.btn.block { width: 100%; }
.btn svg { width: 16px; height: 16px; }
form.inline { display: inline; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; background: var(--info-bg); color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.approved, .badge.active, .badge.paid { background: var(--good-bg); color: var(--good); }
.badge.pending, .badge.submitted, .badge.invited { background: var(--warn-bg); color: var(--warn); }
.badge.rejected, .badge.offboarded { background: var(--bad-bg); color: var(--bad); }
.badge.cancelled { background: var(--info-bg); color: var(--muted); }
.badge.plain::before { display: none; }
.badge.dark { background: var(--ink); color: #fff; }

.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; flex: none; letter-spacing: .02em; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.avatar.light { background: #fff; color: #000; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; }
.person .name { font-weight: 700; }
.person .meta { color: var(--muted); font-size: 12.5px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fcfcfc; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.link:hover { background: #fafafa; cursor: pointer; }
.table-wrap { overflow-x: auto; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 700; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-color: var(--ink); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pills a { padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); text-decoration: none; font-weight: 600; font-size: 12.5px; background: var(--surface); }
.pills a.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Forms */
label { display: block; font-weight: 700; font-size: 12.5px; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=tel], input[type=month], input[type=file], select, textarea {
  width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 9px; padding: 0 12px; font: inherit; background: var(--surface); color: var(--ink);
}
input[type=file] { padding: 8px 12px; height: auto; }
textarea { height: auto; min-height: 110px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: -1px; border-color: var(--ink); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; }
.check input { width: 16px; height: 16px; accent-color: #000; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 12px; padding: 0; }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-weight: 600; border: 1px solid; }
.alert.success { background: var(--good-bg); color: var(--good); border-color: #bbf7d0; }
.alert.error { background: var(--bad-bg); color: var(--bad); border-color: #fecaca; }
.alert.info { background: var(--info-bg); color: var(--ink-2); border-color: var(--line); }

.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 12px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.list li:last-child { border-bottom: 0; }

.progress { height: 6px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--ink); border-radius: 99px; }

.balance { padding: 16px 18px; }
.balance .num { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; }
.balance .of { color: var(--muted); font-weight: 600; font-size: 13px; }

.announce { padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.announce:last-child { border-bottom: 0; }
.announce h3 { margin-bottom: 4px; }
.announce .body { color: var(--ink-2); white-space: pre-wrap; }

/* Checklist */
.checklist li { justify-content: flex-start; }
.tick { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid #cfcfcf; background: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; flex: none; }
.tick.done { background: var(--ink); border-color: var(--ink); color: #fff; }
.tick svg { width: 14px; height: 14px; }
.tick[disabled] { cursor: default; opacity: .6; }
.done-text { text-decoration: line-through; color: var(--muted); }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal .dow { padding: 8px; font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fcfcfc; }
.cal .day { min-height: 96px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; font-size: 12px; }
.cal .day.weekend { background: #fafafa; }
.cal .day.blank { background: #f6f6f6; }
.cal .day .n { font-weight: 800; font-size: 12px; color: var(--muted); }
.cal .day.today .n { background: var(--ink); color: #fff; border-radius: 99px; padding: 1px 7px; }
.cal .chip { display: block; background: var(--ink); color: #fff; border-radius: 5px; padding: 1px 6px; margin-top: 3px; font-weight: 600; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .chip.pending { background: #fff; color: var(--ink); border: 1px dashed var(--ink); }
.cal .hol { display: block; color: var(--bad); font-weight: 700; font-size: 11px; margin-top: 3px; }

/* Invoice items */
.items td { padding: 6px 6px; }
.items input { height: 36px; }
.items .amt { font-weight: 700; text-align: right; white-space: nowrap; }
.total-row { display: flex; justify-content: flex-end; gap: 24px; padding: 14px 6px; font-size: 18px; font-weight: 800; }

.kv { display: grid; grid-template-columns: 170px 1fr; gap: 10px 16px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }

.profile-head { display: flex; gap: 18px; align-items: center; }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: var(--ink); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side .brand { padding: 0; }
.auth-side h2 { font-size: 40px; font-weight: 800; line-height: 1.08; letter-spacing: -0.04em; max-width: 440px; }
.auth-side p { color: #a3a3a3; max-width: 420px; font-size: 15px; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: #fff; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); margin-bottom: 24px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 18px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.gbtn { background: #fff; color: var(--ink); border-color: var(--line); }
.gbtn:hover { background: #fafafa; border-color: var(--ink); }

.notif { display: flex; gap: 12px; align-items: flex-start; }
.notif .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); margin-top: 7px; flex: none; }
.notif .dot.read { background: var(--line); }

.callout { border: 1px dashed #cfcfcf; border-radius: 10px; padding: 14px 16px; background: #fcfcfc; }
.copy { display: flex; gap: 8px; }
.copy input { font-family: ui-monospace, monospace; font-size: 12px; }

details.drop > summary { list-style: none; cursor: pointer; }
details.drop > summary::-webkit-details-marker { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .4); }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 40; }
  .topbar .brand { padding: 0; }
  .topbar button { background: none; border: 0; color: #fff; padding: 6px; cursor: pointer; display: flex; }
  .topbar svg { width: 24px; height: 24px; }
  .content { padding: 20px 16px 48px; }
  h1 { font-size: 22px; }
  .g2, .g3, .form-grid { grid-template-columns: 1fr; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 10px; }
  .cal .day { min-height: 64px; padding: 4px; }
  .cal .chip { font-size: 10px; padding: 0 4px; }
  .hide-sm { display: none; }
}
@media (max-width: 480px) {
  .g4 { grid-template-columns: 1fr 1fr; }
  .stat .value { font-size: 22px; }
}

/* Radio pills (invoice cut-off) */
.pill-radio { display: inline-flex; margin: 0; font-weight: 600; cursor: pointer; }
.pill-radio input { position: absolute; opacity: 0; pointer-events: none; }
.pill-radio span { padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; }
.pill-radio input:checked + span { background: var(--ink); color: #fff; border-color: var(--ink); }
.pill-radio input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
details.drop[open] > summary { display: none !important; }
.sync { font-size: 12px; }
