:root {
  --bg: #0e1420;
  --panel: #171f2e;
  --panel2: #1d2739;
  --line: #2a3650;
  --text: #e8edf6;
  --muted: #8b97ad;
  --accent: #4fa3ff;
  --green: #3ecf8e;
  --red: #ff6b6b;
  --amber: #ffb454;
  --radius: 12px;
  font-size: 15px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
}

/* auth gate */
.auth-gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 48px 56px; text-align: center; }
.auth-logo { font-size: 3rem; }
.auth-card h1 { margin: 8px 0 4px; }
.auth-card button { margin-top: 22px; }

header {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }

.ws-switch { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.ws-switch button {
  background: none; border: none; color: var(--muted); padding: 6px 14px;
  border-radius: 8px; cursor: pointer; font-size: .92rem; font-weight: 600;
}
.ws-switch button.active { background: var(--accent); color: #06121f; }
.ws-switch button:not(.active):hover { color: var(--text); }

nav { display: flex; gap: 2px; flex-wrap: wrap; }
nav button {
  background: none; border: none; color: var(--muted);
  padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: .93rem;
}
nav button:hover { color: var(--text); background: var(--panel2); }
nav button.active { color: var(--text); background: var(--panel2); box-shadow: inset 0 -2px 0 var(--accent); }
.header-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }

main { max-width: 1200px; margin: 0 auto; padding: 22px; }

button.primary, button.ghost, button.danger {
  border-radius: 8px; padding: 8px 14px; cursor: pointer; font-size: .92rem; border: 1px solid transparent;
}
button.primary { background: var(--accent); color: #06121f; font-weight: 600; }
button.primary:hover { filter: brightness(1.1); }
button.ghost { background: transparent; border-color: var(--line); color: var(--text); }
button.ghost:hover { background: var(--pan2, var(--panel2)); }
button.danger { background: transparent; border-color: var(--red); color: var(--red); }
button.small { padding: 4px 10px; font-size: .82rem; }

.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; } }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.card h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.big { font-size: 1.7rem; font-weight: 700; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.warn { color: var(--amber); }
.sub { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.section-gap { margin-top: 16px; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid rgba(42,54,80,.5); }
tr:hover td { background: rgba(79,163,255,.05); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

select, input, textarea {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 7px 10px; font-size: .92rem; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); }
label { font-size: .85rem; color: var(--muted); display: block; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem;
  background: var(--panel2); border: 1px solid var(--line); color: var(--muted);
}
.pill.demo { color: var(--amber); border-color: var(--amber); }
.pill.cloud { color: var(--green); border-color: #2f7d5c; }
.acct-pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; background: var(--panel2); border: 1px solid #2c5c8f; color: #8ec9ff; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bar-label { width: 170px; font-size: .88rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 18px; background: var(--panel2); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 5px; }
.bar-val { width: 90px; text-align: right; font-size: .88rem; font-variant-numeric: tabular-nums; }

.progress-wrap { background: var(--panel2); border-radius: 10px; height: 26px; overflow: hidden; margin: 10px 0; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #2f9e6e, var(--green)); display: flex; align-items: center; justify-content: flex-end; padding-right: 10px; color: #06121f; font-weight: 700; font-size: .85rem; }

.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 40px; text-align: center;
  color: var(--muted); transition: all .15s; cursor: pointer;
}
.dropzone.drag { border-color: var(--accent); background: rgba(79,163,255,.06); color: var(--text); }

.chart-scroll { overflow-x: auto; }
svg text { fill: var(--muted); font-size: 11px; font-family: inherit; }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--accent); color: var(--text);
  border-radius: 10px; padding: 10px 18px; opacity: 0; pointer-events: none; transition: opacity .25s;
  z-index: 50; max-width: 80vw;
}
#toast.show { opacity: 1; }

.bulk-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: rgba(79,163,255,.08); border: 1px solid #2c5c8f; border-radius: 8px;
  padding: 8px 12px; margin-bottom: 12px;
}
.month-nav { display: inline-flex; align-items: center; gap: 4px; margin-left: 10px; font-size: 1rem; font-weight: 400; color: var(--muted); }
.month-nav button[disabled] { opacity: .35; cursor: default; }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

.status-chip { font-size: .78rem; padding: 2px 8px; border-radius: 99px; }
.status-paid { background: rgba(62,207,142,.15); color: var(--green); }
.status-due, .status-sent { background: rgba(255,180,84,.15); color: var(--amber); }
.status-late, .status-overdue { background: rgba(255,107,107,.15); color: var(--red); }
.status-draft { background: rgba(139,151,173,.15); color: var(--muted); }
.creep { color: var(--amber); font-size: .8rem; }
.muted { color: var(--muted); }
.mt { margin-top: 12px; }
h2 { margin-bottom: 14px; font-size: 1.25rem; }

/* invoice print view */
#printHost { display: none; }
@media print {
  body > *:not(#printHost) { display: none !important; }
  #printHost { display: block; background: #fff; color: #111; }
  .inv-sheet { max-width: 720px; margin: 0 auto; padding: 40px; font-size: 14px; }
  .inv-sheet h1 { font-size: 26px; margin-bottom: 2px; }
  .inv-sheet table { width: 100%; border-collapse: collapse; margin-top: 18px; }
  .inv-sheet th, .inv-sheet td { border-bottom: 1px solid #ccc; padding: 8px 6px; text-align: left; }
  .inv-sheet .num { text-align: right; }
  .inv-head { display: flex; justify-content: space-between; margin-bottom: 24px; }
  .inv-total { font-size: 18px; font-weight: 700; }
}
