:root {
  --ink: #0f172a; --muted: #64748b; --line: #e2e8f0; --bg: #f6f8fa; --card: #fff;
  --brand: #0f766e; --brand-dark: #115e59; --brand-soft: #e6f4f2;
  --red: #b91c1c; --red-soft: #fee2e2; --amber: #b45309; --amber-soft: #fef3c7;
  --blue: #1d4ed8; --blue-soft: #dbeafe; --gray-soft: #f1f5f9;
  --radius: 10px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 1px 8px rgba(15,23,42,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* Buttons and inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--gray-soft); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--red); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: #334155; }
input, select, textarea { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
input[type=checkbox] { width: auto; }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* App shell */
.topbar { background: var(--ink); color: #fff; }
.topbar-inner { max-width: 1180px; margin: auto; padding: 10px 18px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo { font-weight: 800; font-size: 18px; color: #fff; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.logo-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--brand); display: grid; place-items: center; font-size: 14px; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { color: #cbd5e1; text-decoration: none; padding: 6px 12px; border-radius: 7px; font-weight: 600; font-size: 14px; }
.nav a.active, .nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.ws-pill { font-size: 13px; color: #cbd5e1; display: flex; align-items: center; gap: 8px; }
.plan { font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; background: #334155; color: #e2e8f0; }
.plan.pro { background: var(--brand); color: #fff; }
main { max-width: 1180px; margin: auto; padding: 22px 18px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.5rem; margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .num { font-size: 28px; font-weight: 800; }
.stat .lbl { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat.red .num { color: var(--red); } .stat.amber .num { color: var(--amber); } .stat.blue .num { color: var(--blue); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f8fafc; }
.sub { font-size: 12px; color: var(--muted); }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.b-red { background: var(--red-soft); color: var(--red); }
.b-amber { background: var(--amber-soft); color: var(--amber); }
.b-blue { background: var(--blue-soft); color: var(--blue); }
.b-gray { background: var(--gray-soft); color: #475569; }
.b-green { background: var(--brand-soft); color: var(--brand-dark); }

.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (max-width: 760px) { .filters { grid-template-columns: 1fr 1fr; } }

/* Spend bars */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-fill { width: 100%; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-lbl { font-size: 11px; color: var(--muted); margin-top: 4px; }
.bar-val { font-size: 10px; color: var(--muted); margin-bottom: 2px; white-space: nowrap; }

.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }
.list-plain li:last-child { border-bottom: 0; }

.locked { position: relative; background: linear-gradient(135deg, #f0fdfa, #fff); border: 1px dashed #99d5cc; }
.locked ul { margin: 8px 0 14px; padding-left: 20px; }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: flex-start; justify-content: center; padding: 30px 12px; overflow-y: auto; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 760px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.section-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--brand-dark); margin: 16px 0 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.note { font-size: 13px; background: var(--amber-soft); color: #78350f; padding: 8px 12px; border-radius: 8px; margin: 8px 0; }
.x { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; background: var(--gray-soft); padding: 4px; border-radius: 9px; }
.tabs button { flex: 1; border: 0; background: none; padding: 7px; border-radius: 7px; font: inherit; font-weight: 600; cursor: pointer; color: var(--muted); }
.tabs button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.msg { padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 12px; }
.msg.err { background: var(--red-soft); color: var(--red); }
.msg.ok { background: var(--brand-soft); color: var(--brand-dark); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 9px; z-index: 100; font-size: 14px; max-width: 90vw; }
.toast.err { background: var(--red); }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.person-card h3 { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* Print (offboarding checklist) */
#print-area { display: none; }
@media print {
  body.printing > *:not(#print-area) { display: none !important; }
  body.printing #print-area { display: block; font-size: 13px; }
  #print-area h1 { font-size: 20px; }
  #print-area li { margin: 6px 0; }
}

/* Layout fixes */
.list-plain li { align-items: flex-start; }
.list-plain li .badge { white-space: normal; border-radius: 6px; text-align: right; max-width: 60%; }
.table-wrap table { min-width: 620px; }
@media (max-width: 640px) {
  .topbar-inner { gap: 8px; }
  .nav { order: 3; flex-basis: 100%; }
  .ws-pill { margin-left: auto; }
  main { padding: 16px 12px 50px; }
  .card { padding: 14px; }
}
.list-plain li > span:first-child { flex: 1; min-width: 0; }
