/* GLACXYSTEM console — no build step needed. Tenant colours arrive as --brand / --brand-2. */
:root {
  --ink: #102a33;
  --ink-2: #4a6470;
  --ink-3: #7d939c;
  --ice: #edf3f5;
  --frost: #dfe9ed;
  --surface: #ffffff;
  --line: #d3e0e5;
  --brand: #0e7490;
  --brand-2: #22a6c3;
  --late: #b42318;
  --late-soft: #fdecea;
  --old: #7a1a12;
  --soon: #a15c07;
  --soon-soft: #fdf3e2;
  --ok: #08704a;
  --ok-soft: #e4f5ec;
  --radius: 10px;
  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--ice); font-feature-settings: "tnum" 1; }
a { color: var(--brand); }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 26px; line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 15px; margin: 0 0 6px; font-weight: 650; }
p { margin: 0 0 10px; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Shell */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--ink) 236px, transparent 236px); }
.side { background: var(--ink); color: #cfe0e6; padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; color: #fff; text-decoration: none; }
.brand img { max-height: 36px; max-width: 150px; background: #fff; border-radius: 6px; padding: 3px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; }
.brand-name { font-weight: 700; line-height: 1.15; font-size: 15px; }
.nav a { display: flex; align-items: center; gap: 10px; color: #cfe0e6; text-decoration: none; padding: 9px 10px; border-radius: 8px; font-size: 14.5px; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.on { background: var(--brand); color: #fff; }
.nav .group { margin: 16px 10px 6px; font-size: 12.5px; color: #8fb0bb; }
.side-foot { margin-top: 22px; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; }
.side-foot button { background: none; border: 0; color: #cfe0e6; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; }
.main { padding: 26px 32px 60px; max-width: 1240px; width: 100%; }
.topbar { display: none; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.head .sub { color: var(--ink-2); margin-top: 4px; }

/* Blocks */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush > h2 { padding: 16px 20px 0; }
.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; }

/* The aging strip: the one bold element of the console. */
.aging { margin: 4px 0 18px; }
.aging-total { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.aging-total .big { font-size: 40px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.strip { display: flex; height: 18px; border-radius: 9px; overflow: hidden; background: var(--frost); }
.strip span { display: block; min-width: 3px; }
.b-overdue_older { background: var(--old); }
.b-overdue { background: var(--late); }
.b-due_today { background: var(--soon); }
.b-due_week { background: #d99a2b; }
.b-upcoming { background: var(--brand-2); }
.legend { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 12px; }
.legend a { text-decoration: none; color: var(--ink); padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.legend a:hover { border-color: var(--ink-3); }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
.legend .amt { display: block; font-weight: 650; font-size: 17px; margin-top: 2px; }
.legend .cnt { color: var(--ink-2); font-size: 13px; }

.stat { padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.stat .v { font-size: 22px; font-weight: 700; }
.stat .l { color: var(--ink-2); font-size: 13.5px; }
.meter { height: 6px; border-radius: 3px; background: var(--frost); margin-top: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--ok); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 13px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #f7fafb; white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--frost); vertical-align: top; }
td.r, td.num { white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
tbody tr:hover { background: #f6fafb; }
.who { font-weight: 600; }
.who a { color: var(--ink); text-decoration: none; }
.who a:hover { text-decoration: underline; }
.empty { padding: 26px 20px; color: var(--ink-2); }

/* Status chips */
.chip { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.chip.unpaid, .chip.due { background: var(--soon-soft); color: var(--soon); }
.chip.late { background: var(--late-soft); color: var(--late); }
.chip.paid, .chip.active, .chip.online { background: var(--ok-soft); color: var(--ok); }
.chip.void, .chip.written_off, .chip.closed, .chip.ended, .chip.unknown { background: var(--frost); color: var(--ink-2); }
.chip.suspended, .chip.offline { background: var(--late-soft); color: var(--late); }

/* Forms */
form.inline { display: inline; }
.form { display: grid; gap: 14px; }
.form .row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form .row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 5px; }
.hint { font-weight: 400; color: var(--ink-3); font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid #b9cbd2; border-radius: 8px; padding: 9px 11px;
}
input[type=color] { width: 56px; height: 40px; border: 1px solid #b9cbd2; border-radius: 8px; padding: 2px; background: #fff; }
textarea { min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; font-size: 14.5px; border-radius: 8px; padding: 9px 16px; border: 1px solid transparent; cursor: pointer; text-decoration: none; background: var(--brand); color: #fff; }
.btn:hover { filter: brightness(1.08); color: #fff; }
.btn.ghost { background: #fff; color: var(--ink); border-color: #b9cbd2; }
.btn.ghost:hover { border-color: var(--ink-2); color: var(--ink); }
.btn.danger { background: #fff; color: var(--late); border-color: #e9b7b1; }
.btn.small { padding: 5px 11px; font-size: 13.5px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { width: auto; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: 14px; }
.tabs a.on { background: var(--ink); color: #fff; }
.tabs a:hover:not(.on) { background: var(--frost); color: var(--ink); }

/* Messages */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.errors { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; background: var(--late-soft); color: var(--late); }
.errors ul { margin: 0; padding-left: 18px; }
.field-error { color: var(--late); font-size: 13px; margin-top: 4px; }

/* Receipt / invoice */
.doc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.doc-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid var(--brand); padding-bottom: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.doc-amount { font-size: 34px; font-weight: 700; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--frost); position: relative; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand-2); }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--ink); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; padding: 30px; }
.auth-card .brand { color: var(--ink); padding: 0 0 18px; }

.pager { padding: 12px 20px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.pager a, .pager span { padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line); text-decoration: none; }
.pager span.cur { background: var(--ink); color: #fff; border-color: var(--ink); }

details.more summary { cursor: pointer; font-weight: 600; color: var(--brand); }

@media (max-width: 980px) {
  .grid2 { grid-template-columns: 1fr; }
  .legend { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; background: none; }
  td, th { padding: 9px 10px; }
  table { font-size: 14px; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 20; transform: translateX(-105%); transition: transform .2s; height: 100%; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(16,42,51,.45); }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 10; }
  .topbar button { background: none; border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: 8px; padding: 6px 10px; font: inherit; }
  .main { padding: 18px 16px 50px; }
  .grid3, .form .row, .form .row3 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 6px; }
  .aging-total .big { font-size: 32px; }
  h1 { font-size: 22px; }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }
@media print {
  .side, .topbar, .no-print { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  .main { padding: 0; }
}

/* New client form */
.client-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; display: grid; gap: 14px; }
.step-head { display: flex; align-items: center; gap: 12px; }
.step-no { width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.step-head h2 { margin: 0; }
.step-head p { margin: 0; color: var(--ink-2); font-size: 13.5px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.plan-card { position: relative; display: block; border: 1.5px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; background: #fff; font-weight: 400; margin: 0; }
.plan-card input { position: absolute; opacity: 0; pointer-events: none; }
.plan-card .pn { font-weight: 650; display: block; }
.plan-card .pp { font-size: 20px; font-weight: 700; margin-top: 4px; display: block; }
.plan-card .ps { color: var(--ink-2); font-size: 13px; }
.plan-card:hover { border-color: var(--ink-3); }
.plan-card:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.plan-card:has(input:focus-visible) { outline: 3px solid var(--brand-2); outline-offset: 2px; }
.inline-field { display: flex; gap: 8px; }
.inline-field input { flex: 1; }
.summary { position: sticky; top: 20px; background: var(--ink); color: #dbe8ec; border-radius: var(--radius); padding: 20px; }
.summary h2 { color: #fff; }
.summary dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; font-size: 14px; }
.summary dt { color: #8fb0bb; }
.summary dd { margin: 0; text-align: right; color: #fff; overflow-wrap: anywhere; }
.summary .total { border-top: 1px solid rgba(255,255,255,.15); margin-top: 14px; padding-top: 14px; display: flex; justify-content: space-between; align-items: baseline; }
.summary .total strong { font-size: 24px; color: #fff; }
.summary .btn { width: 100%; justify-content: center; margin-top: 16px; background: var(--brand-2); }
.summary .faint { color: #8fb0bb; }

/* Client profile */
.profile-head { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; }
.profile-head h1 { margin-bottom: 4px; }
.profile-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--ink-2); font-size: 14px; }
.paid-through { text-align: right; }
.paid-through .big { font-size: 26px; font-weight: 700; display: block; line-height: 1.1; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; grid-column: 1 / -1; border-top: 1px solid var(--frost); padding-top: 14px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); margin-right: 5px; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--late); }
@media (max-width: 980px) {
  .client-layout { grid-template-columns: 1fr; }
  .summary { position: static; }
  .profile-head { grid-template-columns: 1fr; }
  .paid-through { text-align: left; }
}
.step .row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 760px) { .step .row { grid-template-columns: 1fr; } }
