/* hands thinking brand: Space Navy, Royal Blue -> Lavender gradient, Comfortaa + Montserrat. */
@font-face { font-family: "Comfortaa"; src: url("fonts/comfortaa.ttf") format("truetype"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "Montserrat"; src: url("fonts/montserrat.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }

:root {
  color-scheme: dark;
  --navy: rgba(20, 27, 56, 1);
  --blue: #5866ef;
  --lavender: #b389f0;
  --gradient: linear-gradient(45deg, var(--blue), var(--lavender));
  --surface: #1d2649;
  --surface-2: #252f58;
  --border: #333e6c;
  --text: #ffffff;
  --muted: #b3badb;
  --ok: #6fe3b4;
  --warn: #ffd37a;
  --info: #a9b3ff;
  --bad: #ff9aae;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--navy); color: var(--text); font: 400 14px/1.55 "Montserrat", system-ui, sans-serif; min-height: 100vh; }
h1, h2, h3, .wordmark { font-family: "Comfortaa", "Montserrat", sans-serif; font-weight: 700; line-height: 1.25; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 2rem 0 .75rem; }
a { color: var(--lavender); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--lavender); outline-offset: 2px; }

/* Header */
.topbar { display: flex; align-items: center; flex-wrap: wrap; gap: 1rem 2rem; padding: .9rem clamp(1rem, 4vw, 2.5rem); position: relative; }
.topbar::after { content: ""; position: absolute; inset: auto 0 0; height: 2px; background: linear-gradient(90deg, var(--blue), var(--lavender)); }
.brand { display: flex; align-items: center; gap: .75rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { width: 40px; height: 40px; }
.wordmark { display: block; font-size: 1.15rem; }
.product { display: block; font-size: .72rem; color: var(--muted); }
nav { display: flex; gap: .35rem; }
nav a { padding: .45rem .9rem; border-radius: 999px; color: var(--muted); font-weight: 600; }
nav a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.account { margin-left: auto; display: flex; align-items: center; gap: .8rem; color: var(--muted); }
.account strong { color: var(--text); }

main { max-width: 1280px; margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 2.5rem) 3rem; }
.subtitle { color: var(--muted); margin: 0 0 1.5rem; }

/* Controls */
input, select { font: inherit; color: var(--text); background: var(--navy); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .7rem; min-width: 0; }
input:not([type="checkbox"]), select { height: 2.5rem; }
input::placeholder { color: var(--muted); }
input[type="checkbox"] { accent-color: var(--blue); }
.btn { font: 600 .85rem "Montserrat", sans-serif; display: inline-block; border: 0; border-radius: 999px; padding: .55rem 1.15rem; cursor: pointer; color: #fff; background: linear-gradient(90deg, var(--blue), #8b6cee); }
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--lavender); }
form { margin: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.25rem; }
.notice { border: 1px solid var(--border); border-left: 4px solid var(--lavender); background: var(--surface); border-radius: 8px; padding: .75rem 1rem; margin-bottom: 1.25rem; }
.notice-warn { border-left-color: var(--warn); }
.notice-bad { border-left-color: var(--bad); }
.notice strong { display: block; }
.notice span { overflow-wrap: anywhere; }

/* Summary tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.tile { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: .9rem 1.1rem; color: var(--muted); }
.tile:hover { border-color: var(--lavender); text-decoration: none; }
.tile b { display: block; font: 700 1.8rem "Comfortaa", sans-serif; color: var(--text); }
.tile.bad b { color: var(--bad); }

.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; margin-bottom: 1.25rem; }
.field { display: flex; flex-direction: column; gap: .25rem; font-size: .75rem; color: var(--muted); }
.field > input, .field > select { font-size: .875rem; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .75rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.nowrap { white-space: nowrap; }
td.wrap { overflow-wrap: anywhere; }
td.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }

/* Status pills */
.status { --c: var(--info); display: inline-flex; align-items: center; gap: .45rem; padding: .2rem .65rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); background: color-mix(in srgb, var(--c) 14%, transparent); }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-error { --c: var(--bad); }
.status-invoice_uploaded, .status-uploaded { --c: var(--ok); }
.status-received, .status-parsed, .status-pending, .status-invoice_pending { --c: var(--warn); }

/* Detail pages */
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin: .75rem 0 1.25rem; }
.title-row h1 { margin: 0; }
.title-row form { margin-left: auto; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin: 0 0 1.25rem; }
.facts dt { font-size: .75rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
pre { margin: 0; max-height: 28rem; overflow: auto; background: #0e1430; color: #dde1ff; border: 1px solid var(--border); border-radius: 12px; padding: 1rem; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Forms: sign in, users */
.login { max-width: 380px; margin: 8vh auto 0; text-align: center; }
.login img { width: 96px; height: 96px; }
.login .wordmark { font-size: 1.7rem; margin-top: .75rem; }
.login .card { margin-top: 1.5rem; text-align: left; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack .btn { align-self: stretch; padding: .7rem; }
.row-form { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.add-user { align-items: end; }
.row-form input[type="password"][placeholder] { width: 17rem; max-width: 100%; }
.check { display: inline-flex; align-items: center; gap: .35rem; }

@media (max-width: 640px) { .account { margin-left: 0; } .title-row form { margin-left: 0; } }
