:root {
  --bg: #f6f7f5;
  --panel: #ffffff;
  --ink: #1b2420;
  --muted: #5d6b65;
  --line: #dfe4e0;
  --brand: #1f5f4a;
  --brand-ink: #ffffff;
  --brand-soft: #e3efe9;
  --warn-bg: #fff6e0;
  --warn-ink: #7a5300;
  --bad-bg: #fde8e7;
  --bad-ink: #9b1c16;
  --good-ink: #1f6b3a;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
/* Dark follows the device unless the person picked a theme (html[data-theme]). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111614; --panel: #19201d; --ink: #e6ece9; --muted: #9aa8a2; --line: #2c3632;
    --brand: #4fae8a; --brand-ink: #08130e; --brand-soft: #1d2f28;
    --warn-bg: #3a2f12; --warn-ink: #f2d38a; --bad-bg: #3d1b19; --bad-ink: #ffb4ad; --good-ink: #7fd6a0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111614; --panel: #19201d; --ink: #e6ece9; --muted: #9aa8a2; --line: #2c3632;
  --brand: #4fae8a; --brand-ink: #08130e; --brand-soft: #1d2f28;
  --warn-bg: #3a2f12; --warn-ink: #f2d38a; --bad-bg: #3d1b19; --bad-ink: #ffb4ad; --good-ink: #7fd6a0;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 16px 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.mono, td.num, th.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
td.num, th.num { text-align: right; white-space: nowrap; }

/* layout */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 20px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand img { width: 24px; height: 24px; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 14px; }
.banner { background: var(--warn-bg); color: var(--warn-ink); padding: 8px 20px; font-size: 14px; }
.banner.info { background: var(--brand-soft); color: var(--ink); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 20px; }
.shell { display: grid; grid-template-columns: 210px 1fr; gap: 20px; }
.shell > main { min-width: 0; }
nav.side { display: flex; flex-direction: column; gap: 2px; }
nav.side a {
  padding: 8px 12px; border-radius: 8px; color: var(--ink); text-decoration: none;
}
nav.side a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
nav.side .label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 12px 12px 4px; }
/* The phone menu: a grid of buttons, three to a row, with the rest under More. */
nav.mobile { display: none; }
.banner .short { display: none; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; gap: 12px; }
  nav.side { display: none; }
  nav.mobile { display: block; }
  nav.mobile .tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  nav.mobile .more-tiles { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
  nav.mobile a, nav.mobile button.more {
    position: relative; display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 6px 4px;
    border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink);
    font: inherit; font-size: 14px; font-weight: 500; text-decoration: none; text-align: center; line-height: 1.2; cursor: pointer;
  }
  nav.mobile a.on, nav.mobile button.more.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }
  nav.mobile button.more[aria-expanded=true] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
  nav.mobile .badge { position: absolute; top: -6px; right: -4px; min-width: 18px; line-height: 18px; font-size: 11px; padding: 0 5px; }
  .topbar { gap: 8px; padding: 8px 16px; }
  .topbar .brand span, .topbar .who, .topbar [data-action=theme] { display: none; }
  .topbar select { min-width: 0; flex: 1; }
  .topbar .spacer { display: none; }
  .topbar button { white-space: nowrap; padding: 6px 10px; }
  .banner { padding: 6px 16px; font-size: 13px; }
  .banner .long { display: none; }
  .banner .short { display: inline; }
  .wrap { padding: 12px 16px 16px; }
  .panel { padding: 14px; }
  h1 { font-size: 20px; }
  .head { margin-bottom: 12px; }
  /* Keep the overview's figures in view under the menu. */
  .row.quick { align-items: stretch; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; width: 100%; }
  .row.quick .btn { padding: 8px 4px; font-size: 13px; text-align: center; line-height: 1.2; display: flex; align-items: center; justify-content: center; }
  .cards.kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .card.kpi { padding: 10px 12px; }
  .cards.kpis .kpi .stat { font-size: 18px; }
  .cards.kpis .kpi .hash { font-size: 11px; }
}
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

/* forms */
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; min-width: 0;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
button, .btn {
  font: inherit; font-weight: 600; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-block;
}
button.secondary, .btn.secondary { background: transparent; color: var(--brand); }
button.link { background: none; border: none; color: var(--brand); padding: 0; font-weight: 500; }
button:disabled { opacity: .5; cursor: not-allowed; }
.auth { max-width: 420px; margin: 8vh auto; }
.auth form { display: flex; flex-direction: column; gap: 12px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
td input, td select { width: 100%; }

/* bits */
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); }
.pill.bad { background: var(--bad-bg); color: var(--bad-ink); }
.pill.grey { background: var(--line); color: var(--ink); }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.alert.bad { background: var(--bad-bg); color: var(--bad-ink); }
.alert.warn { background: var(--warn-bg); color: var(--warn-ink); }
.alert.good { background: var(--brand-soft); color: var(--good-ink); }
.entry { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; overflow-x: auto; }
.entry .meta { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.entry table td, .entry table th { border-bottom: none; padding: 4px 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--panel); text-decoration: none; color: var(--ink); display: block; }
.card:hover { border-color: var(--brand); }
.emp { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.stat { font-size: 22px; font-weight: 700; font-family: var(--mono); }
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw;
}
#toast.show { opacity: 1; }
.hash { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* overview */
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--bad-ink); color: var(--panel); font-size: 12px; font-weight: 700; text-align: center; line-height: 20px; }
nav.side a .badge { float: right; }
.hero { border-color: var(--brand); background: var(--brand-soft); }
.kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 16px; }
.kpi .stat { margin: 2px 0; }
.split { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; }
.split > .panel { margin-bottom: 16px; min-width: 0; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } nav.side a .badge { float: none; } }
.todo { list-style: none; margin: 0; padding: 0; }
.todo li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.todo li:last-child { border-bottom: none; }
.todo a { text-decoration: none; color: var(--ink); }
details > summary { cursor: pointer; }

/* invoice and bill documents */
.doc { padding: 28px; }
.doc-title { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
@media print {
  .topbar, .banner, nav.side, nav.mobile, .no-print, #toast { display: none !important; }
  .shell { display: block; }
  .wrap { max-width: none; padding: 0; }
  :root[data-theme], :root:not([data-theme]) { --bg: #fff; --panel: #fff; --ink: #000; --muted: #444; --line: #ccc; --brand: #1f5f4a; color-scheme: light; }
  .panel { border: none; }
}

.stub table { margin-top: 4px; }
@media print {
  .stub { break-after: page; }
  .stub:last-child { break-after: auto; }
}

/* Two-factor setup */
.qr { width: 200px; max-width: 100%; margin: 10px 0; padding: 8px; background: #fff; border-radius: 8px; }
.qr svg { display: block; width: 100%; height: auto; }
.steps li { margin-bottom: 14px; }
pre.recovery { background: var(--bg); border: 1px solid var(--line); padding: 12px; border-radius: 8px; font-size: 15px; line-height: 1.7; }
details { margin-top: 10px; }
details summary { cursor: pointer; color: var(--brand); }

/* Billing */
.banner.bad { background: var(--bad-bg); color: var(--bad-ink); }
.grid.plans { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: 12px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 12px; }
.card.plan { cursor: pointer; display: grid; gap: 6px; }
.card.plan input { justify-self: start; }
.card.plan.on, .card.plan:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.row.seg { gap: 6px; }
.card.plan .plan-price { font-size: 26px; font-weight: 700; }
.card.plan .plan-price .muted { font-size: 14px; font-weight: 400; }
.muted.small { font-size: 13px; }
