@font-face { font-family: "Space Grotesk"; font-weight: 700; src: url("fonts/space-grotesk-latin-700-normal.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); font-display: swap; }

:root {
  --bg: #0b0e14; --panel: #111521; --card: #161b29; --line: #232a3d; --line2: #2e3750;
  --text: #e7eaf3; --soft: #aab1c3; --muted: #8b93a7;
  --accent: #37e2c4; --accent-ink: #06201b; --amber: #f5b84a; --red: #ff8a80; --blue: #9fb4ff;
  --display: "Space Grotesk", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: #8af3e0; }
h1, h2, h3 { font-family: var(--display); margin: 0; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.soft { color: var(--soft); }

/* buttons & fields */
.btn { display: inline-block; padding: 11px 16px; border-radius: 8px; border: 1px solid var(--line2); background: transparent;
  color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-align: center; }
.btn:hover { border-color: var(--accent); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); color: var(--accent-ink); }
.btn.link { border: none; padding: 0; color: var(--soft); font-weight: 400; }
.btn.danger { border-color: #6b3530; color: var(--red); }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--soft); }
input[type=email], input[type=password], input[type=text], input[type=search], input[type=date], input:not([type]), select, textarea {
  padding: 11px 12px; border-radius: 8px; border: 1px solid var(--line2); background: var(--bg); color: var(--text); font: inherit; font-size: 15px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--soft); }
.error { background: #2a1416; border: 1px solid #6b3530; color: #ffb3ab; border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.info { background: #11231f; border: 1px solid #2c6b62; color: #9ff0e0; border-radius: 8px; padding: 10px 12px; font-size: 13px; }

/* sign-in pages */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 32px;
  display: flex; flex-direction: column; gap: 16px; }
.auth-card.wide { max-width: 880px; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.brand img { width: 52px; height: 55px; }
.brand span { font-family: var(--display); font-size: 20px; }
.code-input { font-family: var(--mono) !important; font-size: 26px !important; letter-spacing: 0.35em; text-align: center; }
.fine { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.5; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.step { background: #0f1320; border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.step .num { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; color: var(--accent); }
.step p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.qr { background: #fff; border-radius: 8px; padding: 8px; width: 176px; height: 176px; }
.qr svg { width: 100%; height: 100%; display: block; }
.key { font-family: var(--mono); color: var(--soft); font-size: 13px; word-break: break-all; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 28px; font-family: var(--mono); font-size: 18px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 20px 24px; }
.warnbox { border: 1px solid #6b5220; background: #1a1610; border-radius: 12px; padding: 16px 18px; color: #f3d9a4; line-height: 1.5; }

/* app shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  padding: 20px 14px; gap: 4px; position: sticky; top: 0; height: 100vh; }
.sidebar .logo { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; color: var(--text); }
.sidebar .logo img { width: 30px; height: 32px; }
.sidebar .logo b { font-family: var(--display); font-size: 15px; display: block; }
.sidebar .logo small { font-size: 12px; color: var(--muted); }
.sidebar nav a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--soft); }
.sidebar nav a:hover { background: #161d2c; color: var(--text); }
.sidebar nav a.on { background: #1b2233; color: var(--text); font-weight: 600; }
.sidebar .spacer { flex-grow: 1; }
.sidebar .who { padding: 10px 12px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 8px; }
.main { flex-grow: 1; padding: 28px 36px; display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat .v { font-family: var(--mono); font-size: 24px; }
.alert { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: #1a1610; border: 1px solid #6b5220;
  color: #f3d9a4; border-radius: 10px; padding: 10px 14px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 8px 6px; border-bottom: 1px solid var(--line); }
td { padding: 9px 6px; border-bottom: 1px solid #1d2335; }
.ok { color: var(--accent); } .bad { color: var(--red); }

@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .main { padding: 20px 16px; }
  .grid4, .steps { grid-template-columns: 1fr; }
}
@media print {
  :root { color-scheme: light; }
  .no-print { display: none !important; }
  body, .auth-card, .codes { background: #fff !important; color: #000 !important; border-color: #999 !important; }
}

/* ===== stage 2: lists, editors ===== */
.main.split { flex-direction: row; padding: 0; gap: 0; }
.listpane { width: 330px; flex-shrink: 0; border-right: 1px solid var(--line); padding: 24px 18px; display: flex; flex-direction: column; gap: 12px;
  height: 100vh; overflow-y: auto; position: sticky; top: 0; }
.detail { flex-grow: 1; padding: 24px 28px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line2); color: var(--soft); font-size: 12px; }
.pill.on { border-color: var(--accent); background: #1f2a3d; color: var(--text); }
.item { display: flex; flex-direction: column; gap: 4px; padding: 11px 12px; border-radius: 10px; background: #121726; border: 1px solid var(--line); color: var(--text); }
.item:hover { border-color: var(--line2); color: var(--text); }
.item.on { background: #1b2233; border-color: var(--accent); }
.item .row { font-size: 12px; }
.st { font-size: 12px; font-weight: 600; }
.st-draft, .st-void { color: var(--muted); } .st-sent { color: var(--blue); } .st-paid, .st-accepted { color: var(--accent); }
.st-overdue, .st-declined { color: var(--red); } .st-expired { color: var(--amber); }
.fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.fields.f3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fields.f2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label.field input, label.field select, label.field textarea { font-size: 14px; padding: 9px 10px; width: 100%; }
textarea { resize: vertical; }
.lines-table { width: 100%; border-collapse: collapse; }
.lines-table th { padding: 6px 6px 8px; }
.lines-table td { padding: 6px; border-bottom: 1px solid #1d2335; vertical-align: top; }
.lines-table input, .lines-table textarea { width: 100%; font-size: 14px; padding: 8px 9px; }
.lines-table .num input { text-align: right; font-family: var(--mono); }
.lines-table .amt { text-align: right; font-family: var(--mono); padding-top: 14px; white-space: nowrap; }
.x { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 6px 8px; }
.x:hover { color: var(--red); }
.totals { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-family: var(--mono); }
.totals .grand { font-size: 20px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sendbox { background: #111a1c; border: 1px solid #2c6b62; border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.sendbox b { color: var(--accent); }
.locked { background: #161b29; border: 1px dashed var(--line2); border-radius: 10px; padding: 12px 14px; color: var(--soft); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label.field { min-width: 140px; }
@media (max-width: 1100px) { .main.split { flex-direction: column; } .listpane { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--line); } .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
