/* størsndr billing — UI stylesheet
   Tokens: paper-cool surfaces, violet (UV light) as the single accent,
   audio-level metaphors for status and thresholds. */

@font-face {
  font-family: "Unbounded";
  src: url("/static/fonts/unbounded-latin.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC;
}
@font-face {
  font-family: "Unbounded";
  src: url("/static/fonts/unbounded-latin-ext.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0;
}

:root {
  --bg: #f2f3f5;
  --surface: #ffffff;
  --ink: #17151f;
  --muted: #6e6c78;
  --line: #e3e4e9;
  --uv: #5b2eff;
  --uv-soft: #eee9ff;
  --ok: #1f7a4d;
  --ok-soft: #e1f2e8;
  --warn: #9a6a00;
  --warn-soft: #f7edd3;
  --bad: #b3372f;
  --bad-soft: #f9e4e1;
  --radius: 12px;
  --pad: 1rem;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: 76px; /* room for the mobile bottom nav */
}

a { color: inherit; }
h1 { font-size: 1.35rem; margin: 0 0 .75rem; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; }

.wrap { max-width: 880px; margin: 0 auto; padding: 1rem var(--pad) 2rem; }

/* --- header / nav ----------------------------------------------------- */
.topbar {
  background: var(--ink);
  color: #fff;
  padding: .7rem var(--pad);
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.wordmark {
  font-family: "Unbounded", sans-serif;
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: .01em;
  text-decoration: none;
  color: #fff;
}
.wordmark .o { color: var(--uv); filter: brightness(1.6); }
.topnav { display: none; gap: .25rem; margin-left: auto; }
.topnav a {
  text-decoration: none;
  color: #cfcdd8;
  padding: .35rem .65rem;
  border-radius: 8px;
  font-size: .92rem;
}
.topnav a.active, .topnav a:hover { color: #fff; background: rgba(255, 255, 255, .12); }
.topnav a.cta { background: var(--uv); color: #fff; font-weight: 600; }

.bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: .3rem .25rem calc(.3rem + env(safe-area-inset-bottom));
  z-index: 10;
}
.bottomnav a {
  text-decoration: none;
  color: var(--muted);
  font-size: .68rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: .25rem .5rem;
  min-width: 56px;
}
.bottomnav a.active { color: var(--ink); font-weight: 600; }
.bottomnav a svg { width: 22px; height: 22px; }
.bottomnav a.newbtn {
  background: var(--uv);
  color: #fff;
  border-radius: 999px;
  width: 52px; height: 52px;
  min-width: 52px;
  justify-content: center;
  margin-top: -18px;
  box-shadow: 0 4px 14px rgba(91, 46, 255, .4);
  font-size: 1.6rem;
  line-height: 1;
}

@media (min-width: 760px) {
  .topnav { display: flex; }
  .bottomnav { display: none; }
  body { padding-bottom: 2rem; }
}

/* --- cards, banners ---------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.banner {
  border-radius: var(--radius);
  padding: .7rem 1rem;
  margin-bottom: 1rem;
  font-size: .95rem;
}
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner.err { background: var(--bad-soft); color: var(--bad); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner a { color: inherit; font-weight: 600; }

.demo-banner {
  background: repeating-linear-gradient(-45deg, #ffe9a8, #ffe9a8 12px, #fff3cd 12px, #fff3cd 24px);
  color: #7a5b00;
  text-align: center;
  font-weight: 600;
  font-size: .85rem;
  padding: .4rem;
}

/* --- status pills (channel LEDs) --------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .8rem;
  font-weight: 600;
  border-radius: 999px;
  padding: .15rem .6rem;
  white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: currentColor; }
.pill.draft { background: #ececf0; color: var(--muted); }
.pill.issued { background: var(--warn-soft); color: var(--warn); }
.pill.paid { background: var(--ok-soft); color: var(--ok); }
.pill.cancelled { background: var(--bad-soft); color: var(--bad); }

/* --- level meter (the signature) --------------------------------------- */
.meter { margin: .75rem 0 .25rem; }
.meter .scale {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(to right, var(--line) 0 100%);
  position: relative;
  overflow: hidden;
}
.meter .scale::before {
  /* segment ticks, like an LED chain */
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(to right, transparent 0 8px, var(--bg) 8px 10px);
  z-index: 2;
}
.meter .fill {
  /* full-width LED gradient, revealed from the left via inline clip-path */
  position: absolute; inset: 0;
  background: linear-gradient(to right, #2fa36b 0 60%, #d99000 60% 85%, #d64545 85% 100%);
  z-index: 1;
}
.meter .labels {
  display: flex;
  justify-content: space-between;
  font-size: .75rem;
  color: var(--muted);
  margin-top: .25rem;
}

.bignum {
  font-variant-numeric: tabular-nums;
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.bignum small { font-size: 1rem; font-weight: 500; color: var(--muted); }

/* --- tables / lists ----------------------------------------------------- */
.rowlist { display: flex; flex-direction: column; gap: .5rem; }
.rowitem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .7rem .9rem;
  text-decoration: none;
}
.rowitem:hover { border-color: var(--uv); }
.rowitem .main { min-width: 0; }
.rowitem .title { font-weight: 600; }
.rowitem .sub { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowitem .amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.rowitem .right { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.items { width: 100%; border-collapse: collapse; font-size: .95rem; min-width: 480px; }
table.items th, table.items td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.items th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
table.items td.num, table.items th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.items tr.total td { border-bottom: none; font-weight: 700; padding-top: .75rem; }
.grand-total {
  display: flex; justify-content: space-between; align-items: baseline;
  border-top: 2px solid var(--ink); margin-top: -1px; padding: .75rem .4rem 0;
  font-size: 1.05rem;
}
.grand-total b { font-variant-numeric: tabular-nums; font-size: 1.2rem; }

/* --- forms -------------------------------------------------------------- */
label.field { display: block; margin-bottom: .9rem; }
label.field span { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: .25rem; }
input[type="text"], input[type="date"], input[type="email"], input[type="number"], input[type="password"], select, textarea {
  width: 100%;
  font: inherit;
  padding: .6rem .7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--uv);
  outline-offset: 1px;
}
textarea { min-height: 84px; resize: vertical; }
.formgrid { display: grid; grid-template-columns: 1fr; gap: 0 1rem; }
@media (min-width: 620px) { .formgrid.two { grid-template-columns: 1fr 1fr; } }

.check { display: flex; align-items: flex-start; gap: .5rem; margin-bottom: .9rem; }
.check input { width: 20px; height: 20px; margin-top: 2px; }
.check .hint { font-size: .8rem; color: var(--muted); }

/* item rows in the wizard: description gets a full line on phones */
.itemrow {
  display: grid;
  grid-template-columns: 96px 1fr 36px;
  grid-template-areas: "desc desc desc" "qty price del";
  gap: .4rem;
  margin-bottom: .75rem;
  align-items: start;
}
.itemrow input[name="item_desc"] { grid-area: desc; }
.itemrow input[name="item_qty"] { grid-area: qty; }
.itemrow input[name="item_price"] { grid-area: price; }
.itemrow .del { grid-area: del; }
.itemhead { display: none; }
@media (min-width: 620px) {
  .itemrow {
    grid-template-columns: 1fr 72px 120px 36px;
    grid-template-areas: "desc qty price del";
    margin-bottom: .5rem;
  }
  .itemhead { display: grid; grid-template-columns: 1fr 72px 120px 36px; }
}
.itemrow input { padding: .55rem .6rem; }
.itemrow .del {
  border: none; background: none; color: var(--muted);
  font-size: 1.2rem; cursor: pointer; padding: .4rem 0; border-radius: 8px;
}
.itemrow .del:hover { color: var(--bad); }
.itemhead { gap: .4rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-bottom: .3rem; }

/* --- buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  font: inherit;
  font-weight: 600;
  padding: .65rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  min-height: 44px;
}
.btn:hover { opacity: .88; }
.btn.primary { background: var(--uv); border-color: var(--uv); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad-soft); }
.btn.small { padding: .35rem .7rem; min-height: 34px; font-size: .85rem; }
.btnrow { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.btnrow form { display: inline; }

.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.pagehead h1 { margin: 0; }

.filters { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filters select { width: auto; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 2.5rem 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  font-size: .95rem;
}
.empty a { color: var(--uv); font-weight: 600; }

.meta-grid { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1.25rem; font-size: .95rem; }
.meta-grid dt { color: var(--muted); font-size: .82rem; padding-top: .12rem; }
.meta-grid dd { margin: 0; }

.hintbox {
  background: var(--uv-soft);
  border-radius: 10px;
  padding: .6rem .8rem;
  font-size: .85rem;
  margin-bottom: .9rem;
}
.hintbox b { color: var(--uv); }

.mehr-list { display: flex; flex-direction: column; gap: .5rem; }

/* --- finances ----------------------------------------------------------- */
.fin-summary { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.fin-summary > div { display: flex; flex-direction: column; }
.fin-label { font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.fin-num { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.fin-num.plus { color: var(--ok); }
.fin-num.minus { color: var(--bad); }

.dropzone {
  display: block;
  border: 2px dashed var(--uv);
  background: var(--uv-soft);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: background .15s;
}
.dropzone:hover, .dropzone.dragging { background: #e2d9ff; }
.dropzone.busy { opacity: .6; pointer-events: none; }
.dz-icon { font-size: 1.8rem; }
.dz-title { font-weight: 700; margin-top: .25rem; }
.dz-sub { font-size: .82rem; color: var(--muted); max-width: 420px; margin: .25rem auto 0; }
.dz-busy { margin-top: .6rem; font-weight: 600; color: var(--uv); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .dz-busy { animation: none; } }

@media (prefers-reduced-motion: no-preference) {
  .meter .fill { transition: width .8s cubic-bezier(.2, .8, .2, 1); }
}
