/* ITB e-Invoicing portal. One stylesheet, no framework: tokens first, then layout, then components. */

:root {
  --bg: #f3f5f8; --panel: #ffffff; --ink: #1a2330; --ink-2: #3b4857; --muted: #66758a; --line: #dfe4ea; --line-2: #eceff3;
  --brand: #123f6d; --brand-2: #1b5a99; --brand-soft: #e8f0fa; --focus: #9cc0ee;
  --ok: #157347; --ok-soft: #e3f3ea; --bad: #b3261e; --bad-soft: #fcebe9; --warn: #9a5b00; --warn-soft: #fff3dc;
  --wait: #245db8; --wait-soft: #e6eefb; --neutral-soft: #eceff3;
  --radius: 6px; --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: Consolas, "Cascadia Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html { height: 100%; }
body { margin: 0; min-height: 100%; display: flex; flex-direction: column; font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--line-2); padding: 1px 5px; border-radius: 4px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }

/* ---------- header, main, footer ---------- */
header.top { display: flex; align-items: center; gap: 20px; padding: 0 24px; height: 56px; background: var(--brand); color: #fff; }
header.top .brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; font-size: 16px; white-space: nowrap; }
header.top .brand:hover { text-decoration: none; }
header.top .mark { width: 26px; height: 26px; border-radius: 7px; background: #fff; color: var(--brand); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; }
header.top nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
header.top nav::-webkit-scrollbar { display: none; }
header.top nav a { color: #d9e4f1; padding: 7px 11px; border-radius: 6px; white-space: nowrap; font-weight: 500; }
header.top nav a:hover { background: rgba(255, 255, 255, .12); color: #fff; text-decoration: none; }
header.top nav a.active { background: rgba(255, 255, 255, .18); color: #fff; }
header.top .who { display: flex; align-items: center; gap: 12px; font-size: 13px; white-space: nowrap; }
header.top .who .name { color: #d9e4f1; }
header.top select { height: 32px; font: inherit; font-size: 13px; padding: 0 8px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .12); color: #fff; }
header.top select option { color: var(--ink); }
header.top button.link { background: none; border: 0; color: #d9e4f1; padding: 6px 8px; cursor: pointer; border-radius: 6px; font: inherit; font-size: 13px; }
header.top button.link:hover { background: rgba(255, 255, 255, .12); color: #fff; }
main { flex: 1; width: 100%; max-width: 1440px; margin: 0 auto; padding: 22px 24px 40px; }
footer { color: var(--muted); font-size: 12px; text-align: center; padding: 14px 24px 20px; }

/* ---------- page head and text ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin: 0 0 18px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
h1 { font-size: 22px; font-weight: 600; line-height: 1.25; margin: 0 0 16px; letter-spacing: -.01em; }
h1 .badge { vertical-align: 3px; margin-left: 6px; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; color: var(--ink); }
h2 .count { color: var(--muted); font-weight: 400; margin-left: 6px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.note { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; max-width: 90ch; }
.errors { color: var(--bad); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.section { margin-top: 22px; }
.section > h2 { margin-bottom: 10px; }

/* ---------- panels and cards ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; min-width: 0; }
.panel > h2:first-child { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; align-items: start; }
.grid > .panel { margin-bottom: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; }
.card.warn { border-left-color: var(--warn); }
.card.bad { border-left-color: var(--bad); }
.card.plain { border-left-color: var(--line); }
.card .card-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card .card-title strong { font-size: 15px; }
.card .card-title .muted { font-size: 12.5px; }
.card .headline { display: flex; align-items: baseline; gap: 8px; margin: 6px 0 10px; }
.card .headline .value { font-size: 28px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.card .headline .value.bad { color: var(--bad); }
.card .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 10px; font-size: 12.5px; }
.card .stats span { color: var(--muted); }
.card .stats b { font-weight: 600; font-variant-numeric: tabular-nums; }
.card .foot { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line-2); font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }

/* ---------- key/value lists ---------- */
dl.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 7px 18px; margin: 0; }
dl.kv dt { color: var(--muted); white-space: nowrap; }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 18px; white-space: nowrap; background: var(--neutral-soft); color: var(--ink-2); vertical-align: middle; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.wait { background: var(--wait-soft); color: var(--wait); }
.badge.held { background: var(--warn-soft); color: var(--warn); }
.badge.ready { background: var(--brand-soft); color: var(--brand-2); }
.badge.muted { color: var(--muted); }
.badge.plain::before { display: none; }

/* ---------- toolbar (filters) ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; margin-bottom: 16px; }
.toolbar label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); min-width: 0; }
.toolbar label > input, .toolbar label > select { min-width: 150px; }
.toolbar .check { padding-bottom: 7px; }
.toolbar .spacer { flex: 1; }
.toolbar .clear { font-size: 12.5px; padding-bottom: 8px; }

/* ---------- forms ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=date], input[type=number], input[type=email], input[type=password], input[type=search], select, textarea {
  height: 34px; padding: 0 10px; border: 1px solid #c7d0db; border-radius: var(--radius); background: #fff; min-width: 0; width: 100%; color: var(--ink);
}
textarea { height: auto; min-height: 72px; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(27, 90, 153, .18); outline: none; }
input::placeholder { color: #98a4b3; }
input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: var(--brand-2); flex: none; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; cursor: pointer; line-height: 18px; }
.check.block { display: flex; }
.form-grid label.check, .toolbar label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
.toolbar label.check > input { min-width: 0; width: 16px; }
td.status-cell { min-width: 180px; }
td.status-cell .sub { max-width: 46ch; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px 18px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.form-grid label > input, .form-grid label > select { color: var(--ink); }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .check { color: var(--ink); font-size: 13px; }
.form-grid .checks { display: flex; flex-direction: column; gap: 8px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }
.validation { color: var(--bad); font-size: 12.5px; }
.validation ul { margin: 0 0 10px; padding-left: 18px; }
.validation:empty { display: none; }
.help { font-size: 12.5px; color: var(--muted); }
.field-row { display: flex; align-items: center; gap: 8px; }
.field-row input, .field-row select { width: auto; }

/* ---------- buttons ---------- */
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; line-height: 1; }
button:hover, .btn:hover { background: var(--brand-2); border-color: var(--brand-2); text-decoration: none; color: #fff; }
button.secondary, .btn.secondary { background: #fff; border-color: #c7d0db; color: var(--ink); }
button.secondary:hover, .btn.secondary:hover { background: #f4f6f9; border-color: #aab6c5; color: var(--ink); }
button.danger, .btn.danger { background: #fff; border-color: #e3a19b; color: var(--bad); }
button.danger:hover, .btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
button.small, .btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; }
button.wide, .btn.wide { width: 100%; }
button:disabled { opacity: .55; cursor: default; }
form.inline { display: inline; }

/* ---------- flash messages ---------- */
.flash { display: flex; gap: 10px; align-items: flex-start; background: var(--ok-soft); border: 1px solid #bfe3cd; border-left: 4px solid var(--ok); color: #0f4a2c; padding: 11px 14px; border-radius: var(--radius); margin-bottom: 16px; line-height: 1.5; }
.flash.error { background: var(--bad-soft); border-color: #f0c2bd; border-left-color: var(--bad); color: #6e1a14; }
.flash.key { background: var(--brand-soft); border-color: #bcd3ec; border-left-color: var(--brand-2); color: var(--ink); }
.flash.key code { font-size: 13px; background: #fff; padding: 4px 8px; border: 1px solid #bcd3ec; border-radius: 4px; overflow-wrap: anywhere; }
.flash .text { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* ---------- tables ---------- */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; margin-bottom: 16px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
thead th { position: sticky; top: 0; z-index: 1; background: #f8fafc; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.nowrap, th.nowrap { white-space: nowrap; }
td.wrap { min-width: 280px; max-width: 520px; }
td.ellipsis { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td .sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
td.empty, .empty { color: var(--muted); text-align: center; padding: 28px 16px; }
td.actions { white-space: nowrap; }
td.actions .actions { gap: 6px; }
table.compact th, table.compact td { padding: 6px 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12.5px; }
.chips span { color: var(--muted); }
.chips b { font-weight: 600; font-variant-numeric: tabular-nums; }
.chips b.bad { color: var(--bad); }
.chips b.held { color: var(--warn); }

/* ---------- pager ---------- */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }

/* ---------- code and details ---------- */
pre.code { margin: 0; background: #f7f9fb; border: 1px solid var(--line); color: var(--ink); padding: 12px 14px; border-radius: var(--radius); overflow: auto; max-height: 440px; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
details.call { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: 8px; }
details.call > summary { cursor: pointer; padding: 10px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; list-style: none; }
details.call > summary::-webkit-details-marker { display: none; }
details.call > summary::before { content: "\25B8"; color: var(--muted); font-size: 12px; }
details[open].call > summary::before { content: "\25BE"; }
details.call > summary .url { font-family: var(--mono); font-size: 12px; color: var(--ink-2); overflow-wrap: anywhere; }
details.call .body { padding: 0 14px 14px; display: grid; gap: 10px; }
details.call .body h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 6px 0 0; }
details.plain summary { cursor: pointer; color: var(--brand-2); }

/* ---------- action rows (document commands) ---------- */
.action-row { display: grid; grid-template-columns: auto minmax(200px, 1fr); gap: 8px 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line-2); }
.action-row:first-of-type { border-top: 0; padding-top: 0; }
.action-row .check { grid-column: 2; }
.action-row .explain { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }

/* ---------- login ---------- */
.login-wrap { max-width: 380px; margin: 56px auto 0; }
.login-wrap .brand-block { text-align: center; margin-bottom: 18px; }
.login-wrap .brand-block .mark { width: 44px; height: 44px; border-radius: 12px; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 22px; margin-bottom: 8px; }
.login-wrap .brand-block h1 { margin: 0; font-size: 20px; }
.login-wrap .brand-block p { color: var(--muted); margin: 4px 0 0; }
.login-wrap form { display: grid; gap: 14px; }
.login-wrap label:not(.check) { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }

/* ---------- status strip (system page) ---------- */
.status-list { display: grid; gap: 8px; }
.status-list .item { display: grid; grid-template-columns: 70px 1fr; gap: 12px; align-items: baseline; }
.status-list .item .badge { justify-self: start; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  header.top { flex-wrap: wrap; height: auto; padding: 8px 14px; gap: 8px 14px; }
  header.top nav { order: 3; flex-basis: 100%; flex-wrap: wrap; overflow: visible; }
  header.top .who { margin-left: auto; }
  header.top .who .name { display: none; }
  main { padding: 14px 14px 32px; }
  .page-head { align-items: flex-start; }
  .toolbar label { flex: 1 1 140px; }
  .toolbar label > input, .toolbar label > select { min-width: 0; }
  .card .stats { grid-template-columns: repeat(3, 1fr); }
  .action-row { grid-template-columns: 1fr; }
  .action-row .check { grid-column: 1; }
  dl.kv { grid-template-columns: 1fr; gap: 2px 0; }
  dl.kv dt { margin-top: 8px; }
}
