/* Ported from CrewLogix_Business.html; brand colors come from the active
   business via the --brand / --accent CSS variables set in switchBusiness(). */
:root {
  --brand: #1f3864;
  --brand-dark: #16294a;
  --accent: #2f6fed;
  --danger: #dc3545;
  --warning: #fd7e14;
  --success: #198754;
  --muted: #6c757d;
  --bg: #f2f4f8;
  --card: #ffffff;
  --border: #e2e6ee;
}
* { box-sizing: border-box; }
body { margin:0; font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Arial,sans-serif; background:var(--bg); color:#222; }

/* ---- auth ---- */
.auth-wrap { min-height:100vh; display:flex; align-items:center; justify-content:center; background:var(--brand-dark); padding:20px; }
.auth-card { background:#fff; border-radius:14px; padding:34px 38px; width:400px; max-width:94vw; box-shadow:0 24px 70px rgba(0,0,0,.45); text-align:center; }
.auth-card h2 { color:var(--brand); margin:8px 0 4px; font-size:20px; }
.auth-card p.sub { color:var(--muted); font-size:13px; margin:0 0 18px; }
.auth-card input { text-align:center; font-size:15px; margin-bottom:10px; }
.auth-card .err { color:var(--danger); font-size:12.5px; min-height:18px; margin-top:8px; }

/* ---- header / nav ---- */
header { background:var(--brand-dark); color:#fff; padding:12px 22px; display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:10px; }
.brand { display:flex; align-items:center; gap:12px; }
.brand img { height:36px; border-radius:6px; background:#fff; }
.brand h1 { font-size:18px; margin:0; font-weight:600; }
.brand small { display:block; font-weight:400; opacity:.75; font-size:12px; }
.hdr-actions { display:flex; gap:8px; align-items:center; }
.biz-switcher { background:rgba(255,255,255,.12); color:#fff; border:1px solid rgba(255,255,255,.3); border-radius:7px; padding:7px 10px; font-size:13.5px; max-width:260px; }
.biz-switcher option { color:#222; }
.user-menu { position:relative; }
.user-drop { position:absolute; right:0; top:110%; background:#fff; border:1px solid var(--border); border-radius:8px; box-shadow:0 10px 30px rgba(0,0,0,.2); z-index:40; min-width:160px; overflow:hidden; }
.user-drop button { display:block; width:100%; text-align:left; background:none; border:none; padding:10px 14px; font-size:13.5px; cursor:pointer; }
.user-drop button:hover { background:#f2f4f8; }
nav { background:var(--brand); display:flex; flex-wrap:wrap; padding:0 14px; }
nav button { background:none; border:none; color:#e6ecf7; padding:12px 15px; font-size:13.5px; cursor:pointer; border-bottom:3px solid transparent; opacity:.85; }
nav button:hover { color:#fff; opacity:1; }
nav button.active { color:#fff; opacity:1; border-bottom-color:var(--accent); font-weight:600; }
main { padding:20px; max-width:1280px; margin:0 auto; }

/* ---- layout bits ---- */
.toolbar { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:10px; margin-bottom:14px; }
.toolbar h2 { margin:0; font-size:20px; color:var(--brand); }
.toolbar .right { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.btn { background:var(--accent); color:#fff; border:none; border-radius:7px; padding:8px 14px; font-size:13.5px; cursor:pointer; }
.btn:hover { filter:brightness(1.08); }
.btn.sm { padding:4px 9px; font-size:12px; }
.btn.ghost { background:#fff; color:var(--brand); border:1px solid var(--border); }
.btn.grey { background:#eef1f6; color:#333; }
.btn.green { background:var(--success); }
.btn.red { background:var(--danger); }
.btn.orange { background:var(--warning); }
.card { background:var(--card); border:1px solid var(--border); border-radius:10px; padding:16px; margin-bottom:16px; }
table { width:100%; border-collapse:collapse; background:#fff; border:1px solid var(--border); border-radius:10px; overflow:hidden; }
th { text-align:left; background:#f7f9fc; color:var(--brand); font-size:12px; text-transform:uppercase; letter-spacing:.4px; padding:9px 12px; border-bottom:1px solid var(--border); }
td { padding:9px 12px; border-bottom:1px solid var(--border); font-size:13.5px; vertical-align:middle; }
tr:last-child td { border-bottom:none; }
tr:hover td { background:#fafbfe; }
td.num, th.num { text-align:right; font-variant-numeric:tabular-nums; }
td.actions { white-space:nowrap; text-align:right; }
.pill { display:inline-block; padding:2.5px 9px; border-radius:20px; font-size:11.5px; font-weight:600; }
.pill.Draft { background:#e9ecef; color:#555; }
.pill.Sent, .pill.Open { background:#dbe7ff; color:#1d4ed8; }
.pill.Accepted, .pill.Paid, .pill.Active, .pill.Received { background:#d1f0e0; color:#0f6c42; }
.pill.Declined, .pill.Void, .pill.Cancelled, .pill.Overdue { background:#fbd9dd; color:#a11525; }
.pill.Converted, .pill.Completed { background:#e3dcfa; color:#5b3fb8; }
.pill.Partial, .pill.Unpaid, .pill.Paused { background:#ffe8cc; color:#ad5b00; }
.pill.PartiallyReceived { background:#ffe8cc; color:#ad5b00; }
.kpis { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:12px; margin-bottom:18px; }
.kpi { background:#fff; border:1px solid var(--border); border-radius:10px; padding:14px 16px; }
.kpi .lbl { font-size:12px; color:var(--muted); text-transform:uppercase; letter-spacing:.4px; }
.kpi .val { font-size:21px; font-weight:700; color:var(--brand); margin-top:4px; font-variant-numeric:tabular-nums; }
.kpi .sub { font-size:12px; color:var(--muted); margin-top:2px; }
.kpi.good .val { color:var(--success); }
.kpi.bad .val { color:var(--danger); }
.grid2 { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
@media (max-width:900px){ .grid2 { grid-template-columns:1fr; } }
.empty { text-align:center; padding:34px 10px; color:var(--muted); font-size:14px; }
input, select, textarea { width:100%; padding:8px 10px; border:1px solid #cfd6e2; border-radius:7px; font-size:13.5px; font-family:inherit; background:#fff; }
input:focus, select:focus, textarea:focus { outline:2px solid #bcd0ff; border-color:var(--accent); }
label { font-size:12.5px; font-weight:600; color:#42506b; display:block; margin-bottom:4px; }
.frow { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-bottom:12px; }
.frow.single { grid-template-columns:1fr; }
.frow.thirds { grid-template-columns:1fr 1fr 1fr; }
.modal-bg { position:fixed; inset:0; background:rgba(15,25,45,.5); display:none; align-items:flex-start; justify-content:center; z-index:50; overflow:auto; padding:38px 14px; }
.modal-bg.open { display:flex; }
.modal { background:#fff; border-radius:12px; width:640px; max-width:100%; padding:22px; box-shadow:0 18px 50px rgba(0,0,0,.25); }
.modal h3 { margin:0 0 16px; color:var(--brand); font-size:17px; }
.modal .mfoot { display:flex; justify-content:flex-end; gap:8px; margin-top:18px; }
.modal.wide { width:820px; }
.search { max-width:230px; }
select.filter { max-width:180px; width:auto; }
#toast { position:fixed; bottom:22px; left:50%; transform:translateX(-50%); background:var(--brand-dark); color:#fff; padding:10px 20px; border-radius:8px; font-size:13.5px; opacity:0; transition:opacity .25s; pointer-events:none; z-index:99; box-shadow:0 6px 18px rgba(0,0,0,.3); }
#toast.show { opacity:1; }
.items-table td { padding:5px 6px; }
.items-table input, .items-table select { padding:6px 8px; }
.link { color:var(--accent); cursor:pointer; text-decoration:underline; background:none; border:none; font-size:inherit; padding:0; }
.subnav { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:16px; }
.subnav button { background:#fff; border:1px solid var(--border); color:#42506b; padding:7px 14px; border-radius:20px; font-size:13px; cursor:pointer; }
.subnav button.active { background:var(--brand); border-color:var(--brand); color:#fff; }
.rep-note { font-size:12.5px; color:var(--muted); margin-top:10px; }
.tot td { font-weight:700; background:#f7f9fc; }
h4.rep { color:var(--brand); margin:18px 0 8px; }
.neg { color:var(--danger); }
.low-badge { display:inline-block; background:#fbd9dd; color:#a11525; font-size:10.5px; font-weight:700; padding:1px 7px; border-radius:10px; margin-left:6px; }
.progress-wrap { background:#eef1f6; border-radius:8px; height:10px; overflow:hidden; }
.progress-bar { background:var(--success); height:100%; }
.access-matrix td, .access-matrix th { padding:5px 8px; font-size:12.5px; }
