/* E-Invoice Desk — local back-office UI.
   One deliberate element: the fiscal strip under the header, which always
   shows where this company stands with Lekuka. Everything else is quiet. */
:root {
  --paper: #f5f7f6;
  --surface: #ffffff;
  --ink: #18212b;
  --muted: #5b6876;
  --line: #d9dfe4;
  --accent: #1b3a8c;          /* overridden per company */
  --ok: #0e6b47;
  --ok-bg: #e6f3ec;
  --wait: #8a5a00;
  --wait-bg: #fbf1dc;
  --bad: #a3231b;
  --bad-bg: #fbe9e7;
  --radius: 6px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --display: "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); line-height: 1.5; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, white); outline-offset: 1px;
}
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.company { padding: 18px 18px 16px; background: var(--accent); color: #fff; }
.company b { display: block; font-family: var(--display); font-size: 1.15rem; line-height: 1.25; font-weight: 650; }
.company small { opacity: .8; font-size: .78rem; }
.nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 1px; }
.nav a { padding: 7px 12px; border-radius: var(--radius); color: var(--ink); text-decoration: none; font-size: .95rem; }
.nav a:hover { background: var(--paper); }
.nav a.on { background: color-mix(in srgb, var(--accent) 10%, white); color: var(--accent); font-weight: 600; }
.nav .sep { height: 1px; background: var(--line); margin: 8px 10px; }
.side-foot { margin-top: auto; padding: 12px 18px 16px; font-size: .82rem; color: var(--muted); border-top: 1px solid var(--line); }
.side-foot form { display: inline; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; }

main { min-width: 0; }
.content { padding: 24px 32px 48px; max-width: 1180px; }
h1 { font-family: var(--display); font-weight: 650; font-size: 1.6rem; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 28px 0 10px; }
.lede { color: var(--muted); margin: 0 0 20px; max-width: 70ch; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.head .lede { margin: 0; }

/* ---- the fiscal strip */
.strip { display: flex; flex-wrap: wrap; align-items: stretch; background: var(--ink); color: #e8edf2; font-size: .86rem; }
.strip > div { padding: 9px 18px; border-right: 1px solid #2f3b47; }
.strip .k { color: #9aa8b6; margin-right: 6px; }
.strip .v { font-variant-numeric: tabular-nums; font-weight: 600; color: #fff; }
.strip .state { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.strip .dot { width: 9px; height: 9px; border-radius: 50%; background: #7c8a98; }
.strip .dot.ok { background: #3ccf8e; } .strip .dot.wait { background: #f1b434; } .strip .dot.bad { background: #ff6b5e; }
.strip .grow { flex: 1; border-right: 0; }
.strip a { color: #fff; }

/* ---- surfaces */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.panel + .panel { margin-top: 16px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 20px; }
.figures > div { padding: 14px 18px; border-right: 1px solid var(--line); }
.figures > div:last-child { border-right: 0; }
.figures .n { font-family: var(--display); font-size: 1.45rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.figures .l { color: var(--muted); font-size: .85rem; }

/* ---- tables */
table.t { width: 100%; border-collapse: collapse; background: var(--surface); }
.t th { text-align: left; font-weight: 600; font-size: .82rem; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fafbfb; }
.t td { padding: 9px 10px; border-bottom: 1px solid #edf0f2; vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover td { background: #fafcfd; }
.tablewrap { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; background: var(--surface); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---- status chips */
.chip { display: inline-block; font-size: .78rem; padding: 1px 8px; border-radius: 999px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.wait { background: var(--wait-bg); color: var(--wait); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.draft { background: #eef1f4; color: var(--muted); border-color: var(--line); }

/* ---- forms */
form.stack { display: grid; gap: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 18px; }
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 4px; }
.hint { font-weight: 400; color: var(--muted); font-size: .82rem; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; font: inherit; padding: 7px 10px; border: 1px solid #b9c3cc; border-radius: var(--radius); background: #fff; color: var(--ink);
}
textarea { min-height: 70px; }
input:disabled, select:disabled { background: #f0f2f4; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; padding: 7px 15px; border-radius: var(--radius);
  border: 1px solid #b9c3cc; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; }
.btn:hover { background: #f3f5f7; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: #e2b4af; }
.btn.small { padding: 3px 10px; font-size: .85rem; }
.inline { display: inline; }

/* ---- invoice editor */
.lines th, .lines td { padding: 6px 6px; }
.lines input, .lines select { padding: 5px 7px; }
.lines .c-name { width: 24%; } .lines .c-ltype { width: 8%; } .lines .c-kind { width: 8%; } .lines .c-code { width: 8%; }
.lines .c-qty { width: 6%; } .lines .c-price { width: 9%; } .lines .c-tax { width: 12%; } .lines .c-total { width: 9%; }
.lines .c-levy { width: 10%; } .lines .c-fixed { width: 12%; }
.lines td.c-fixed { display: flex; gap: 4px; } .lines td.c-fixed select { flex: 1 1 60%; } .lines td.c-fixed .units { flex: 1 1 40%; min-width: 3.5em; }
.totals { margin-left: auto; width: min(360px, 100%); margin-top: 12px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 2px; font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 8px; font-size: 1.15rem; font-weight: 700; }
.ref { border-left: 4px solid var(--accent); }

/* ---- messages */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid; }
.flash.success { background: var(--ok-bg); border-color: #b5dcc6; color: #0b4f35; }
.flash.error { background: var(--bad-bg); border-color: #efc1bb; color: #7a1a14; }
.flash.info { background: #e9f0fb; border-color: #c4d4ee; color: #1d3a6b; }
.banner { padding: 10px 32px; font-size: .92rem; }
.banner.warn { background: var(--wait-bg); color: #5f3e00; border-bottom: 1px solid #ecd7a6; }
.banner.bad { background: var(--bad-bg); color: #7a1a14; border-bottom: 1px solid #efc1bb; }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
code, .mono { font-family: Consolas, "Cascadia Mono", ui-monospace, monospace; font-size: .86em; overflow-wrap: anywhere; }
details summary { cursor: pointer; font-weight: 600; }
pre.mail { white-space: pre-wrap; background: #fafbfb; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; font: .88rem/1.5 Consolas, ui-monospace, monospace; }

/* ---- single-card pages (login, setup) */
.solo { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.solo .card { width: min(560px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 28px 30px; }
.solo .card.wide { width: min(760px, 100%); }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; color: var(--muted); font-size: .9rem; }
.brand .mark { width: 14px; height: 14px; background: var(--accent); border-radius: 3px; }
.steps { display: flex; gap: 6px; margin-bottom: 20px; }
.steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.steps span.done { background: var(--accent); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .content { padding: 18px 16px 40px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
}
@media print { .side, .strip, .actions, .banner { display: none; } .shell { display: block; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.mt { margin-top: 14px; }
.logo-preview { max-width: 220px; max-height: 110px; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; background: #fff; }
.panel > h2:first-child, details.panel > summary + h2 { margin-top: 0; }
.cols > .panel { margin-top: 0; }
#t-taxes { display: block; padding: 0; }
.bigkey { font-size: 1.25rem; padding: 6px 10px; background: #f3f5f7; border-radius: 6px; display: inline-block; letter-spacing: .04em; }
.panel > input[type=hidden] + h2, .panel > input[type=hidden] + input[type=hidden] + h2 { margin-top: 0; }

/* debug page */
pre.code { white-space: pre-wrap; word-break: break-all; background: #fafbfb; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; font: .8rem/1.45 Consolas, ui-monospace, monospace; max-height: 520px; overflow: auto; margin: 0 0 8px; }
.wrap { word-break: break-all; }
td.small { font-size: .78rem; }
tr.bad td { background: #fff3f2; }
.narrow { max-width: 460px; }

/* certificate renewal progress */
.renew-status { display: flex; gap: 14px; align-items: center; }
.renew-msg { font-weight: 600; margin: 0; }
.renew-count { margin: 2px 0 0; color: var(--muted, #667); }
.spinner { width: 28px; height: 28px; border: 3px solid #d7dde0; border-top-color: var(--accent, #1f6f8b); border-radius: 50%; animation: spin 0.9s linear infinite; flex: none; }
.spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 6px; background: #eef1f2; border-radius: 3px; margin: 14px 0; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--accent, #1f6f8b); transition: width 0.9s linear; }
#renewal[data-state="failed"] .renew-msg { color: #b42318; }
#renewal[data-state="done"] .renew-msg { color: #1a7f37; }
.renew-log { font-size: .85rem; margin: 0 0 12px 1.2em; padding: 0; }

small.rslcode { font-size: .72rem; opacity: .7; margin-left: .4em; white-space: nowrap; font-family: Consolas, ui-monospace, monospace; }
