/* Shared styles for the operator screens (Views/Shared/_Layout.cshtml). */

:root {
  --bg: #f3f5f7; --panel: #ffffff; --border: #e2e6eb; --border-strong: #cdd3db; --text: #14202b; --muted: #5c6878;
  --accent: #0b6b57; --accent-hover: #09594a; --accent-soft: #e4f1ec; --accent-text: #ffffff;
  --danger: #b42318; --credit: #b42318;
  --warn-bg: #fdf6e7; --warn-border: #efd08f; --ok-bg: #ebf6f1; --ok-border: #a9d9c6;
  --bad-bg: #fcecea; --bad-border: #eeb4aa; --row-hover: #f2f5f8;
  --stripe: #fafbfc; --x-attr: #8a4b00; --x-val: #1f5fa8; --x-text: #14202b;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 18px 44px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .06);
  --radius: 12px;
  /* menu */
  --side-bg: #0c2922; --side-bg-2: #0f3a2f; --side-text: #d3e6df; --side-muted: #8db0a3;
  --side-hover: rgba(255, 255, 255, .06); --side-active: rgba(255, 255, 255, .11); --side-accent: #5fd3b0;
  /* charts: validated categorical slots (dataviz reference palette), status palette, chrome */
  --series-1: #2a78d6; --series-2: #eb6834; --gridline: #e7eaee; --axis-base: #c3c8cf;
  --st-good: #0ca30c; --st-warning: #fab219; --st-serious: #ec835a; --st-critical: #d03b3b;
  --up: #006300; --down: #b42318;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1317; --panel: #171c22; --border: #262d36; --border-strong: #37404c; --text: #e7eaef; --muted: #9aa4b2;
    --accent: #3da88c; --accent-hover: #55baa0; --accent-soft: #16302a; --accent-text: #07120f;
    --danger: #f0806f; --credit: #f0806f;
    --warn-bg: #2a2416; --warn-border: #6a5621; --ok-bg: #13261e; --ok-border: #2e6a52;
    --bad-bg: #2d1a17; --bad-border: #7a3a2e; --row-hover: #1e242c;
    --stripe: #1a2027; --x-attr: #e0b36c; --x-val: #8cb8f0; --x-text: #e7eaef;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, .5);
    --side-bg: #0a0f0d; --side-bg-2: #0d1714; --side-text: #cfe0d9; --side-muted: #7f9b91;
    --side-hover: rgba(255, 255, 255, .05); --side-active: rgba(255, 255, 255, .09); --side-accent: #5fd3b0;
    --series-1: #3987e5; --series-2: #d95926; --gridline: #242b33; --axis-base: #3a434e;
    --up: #0ca30c; --down: #f0806f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1317; --panel: #171c22; --border: #262d36; --border-strong: #37404c; --text: #e7eaef; --muted: #9aa4b2;
  --accent: #3da88c; --accent-hover: #55baa0; --accent-soft: #16302a; --accent-text: #07120f;
  --danger: #f0806f; --credit: #f0806f;
  --warn-bg: #2a2416; --warn-border: #6a5621; --ok-bg: #13261e; --ok-border: #2e6a52;
  --bad-bg: #2d1a17; --bad-border: #7a3a2e; --row-hover: #1e242c;
  --stripe: #1a2027; --x-attr: #e0b36c; --x-val: #8cb8f0; --x-text: #e7eaef;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, .5);
  --side-bg: #0a0f0d; --side-bg-2: #0d1714; --side-text: #cfe0d9; --side-muted: #7f9b91;
  --side-hover: rgba(255, 255, 255, .05); --side-active: rgba(255, 255, 255, .09); --side-accent: #5fd3b0;
  --series-1: #3987e5; --series-2: #d95926; --gridline: #242b33; --axis-base: #3a434e;
  --up: #0ca30c; --down: #f0806f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1080px; margin: 0 auto; }
.wrap.wide { max-width: 1320px; }
.wrap.narrow { max-width: 440px; }

h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: -.015em; line-height: 1.2; }
h2 { font-size: 16px; margin: 0 0 14px; }
h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
h3 .hint { text-transform: none; letter-spacing: 0; }
.sub { color: var(--muted); margin: 0 0 22px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; box-shadow: var(--shadow-sm); min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
a { color: var(--accent); }

/* ---------- forms */
label { display: block; font-weight: 600; font-size: 12.5px; margin: 0 0 4px; }
label.inline { display: flex; gap: 8px; align-items: center; font-weight: 500; font-size: 13.5px; }
.hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.req { color: var(--danger); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--panel); color: var(--text); font: inherit; font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=file] { width: 100%; font-size: 13px; color: var(--muted); }
input:disabled, select:disabled { opacity: .6; }
.field { margin-bottom: 13px; }
.input-validation-error { border-color: var(--danger) !important; }
.field-validation-error, .err-text { display: block; color: var(--danger); font-size: 12px; margin-top: 3px; }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }
.validation-summary-valid { display: none; }

.grid { display: grid; gap: 14px; }
.grid > *, .actions > * { min-width: 0; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 900px) { .g4, .g5 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) { .g2, .g3 { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .g4, .g5 { grid-template-columns: 1fr; } }
.align-end { display: flex; align-items: flex-end; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--accent); color: var(--accent-text); border: 1px solid transparent; padding: 8px 17px;
  border-radius: 8px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
  transition: background-color .15s, border-color .15s, color .15s;
}
/* Filled buttons only: the outlined, link, icon and chip variants keep their own hover. */
button:not(.ghost, .link, .act, .icon-btn, .reveal, .chip):hover:not(:disabled), .button:not(.ghost, .chip):hover { background: var(--accent-hover); }
button:focus-visible, .button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.ghost, .button.ghost { background: var(--panel); color: var(--text); border: 1px solid var(--border-strong); }
button.ghost:hover:not(:disabled), .button.ghost:hover { background: var(--panel); border-color: var(--accent); color: var(--accent); }
button.small, .button.small { padding: 4px 11px; font-size: 12.5px; }
button.block, .button.block { display: flex; width: 100%; }
button.large, .button.large { padding: 11px 18px; font-size: 15px; }
button.busy { opacity: .75; cursor: progress; }
button.link { background: none; color: var(--accent); padding: 2px 6px; font-size: 13px; }
button.link.danger { color: var(--danger); }
.chip {
  display: inline-block; background: none; color: var(--text); border: 1px solid var(--border); padding: 4px 11px;
  font-size: 12.5px; font-weight: 500; border-radius: 99px; text-decoration: none;
}
.chip:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.divider { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.choice { display: grid; gap: 8px; }
.reason { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
          max-width: 280px; margin-top: 4px; font-size: 12px; line-height: 1.35; color: var(--danger); white-space: normal; }
.reason-full { color: var(--danger); white-space: normal; }
td.pending { color: var(--muted); }
.msg.attention span { margin-left: 4px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
pre.mono { white-space: pre-wrap; overflow-wrap: anywhere; padding: 10px 12px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); }

/* ---------- messages */
.msg { padding: 11px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 14px; white-space: pre-wrap; }
.msg.ok { background: var(--ok-bg); border: 1px solid var(--ok-border); }
.msg.warn, .msg.err { background: var(--warn-bg); border: 1px solid var(--warn-border); }
.msg:empty { display: none; }

/* ---------- tables */
.scroll-x { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
th a { color: inherit; text-decoration: none; }
th a:hover { color: var(--text); }
th.num, td.num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: 0; }
td input, td select { padding: 5px 7px; font-size: 13px; }
td.when { white-space: nowrap; }
.neg { color: var(--credit); }
code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
pre { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 12px; max-height: 380px; overflow: auto; font-size: 11.5px; white-space: pre-wrap; overflow-wrap: anywhere; }

dl { display: grid; grid-template-columns: max-content 1fr; gap: 5px 18px; margin: 0; font-size: 13px; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { dl { grid-template-columns: 1fr; gap: 0; } dd { margin-bottom: 8px; } }

.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; border: 1px solid var(--border); white-space: nowrap; }
.tag.good, .tag.on { background: var(--ok-bg); border-color: var(--ok-border); }
.tag.warn { background: var(--warn-bg); border-color: var(--warn-border); }
.tag.bad { background: var(--bad-bg); border-color: var(--bad-border); }
.tag.off { color: var(--muted); }
.tag.big { font-size: 13px; padding: 3px 12px; }
.late { color: var(--danger); font-weight: 700; }
[hidden] { display: none !important; }

/* ---------- report */
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 18px; }
@media (max-width: 1000px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .tiles { grid-template-columns: 1fr; } }
.tile { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; background: var(--bg); }
.tile .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.tile .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; overflow-wrap: anywhere; }
.tile .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.attn { background: var(--bad-bg); border-color: var(--bad-border); }
.split { display: grid; grid-template-columns: 1.2fr 1fr; gap: 22px; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.summary-table tr.net td { font-weight: 700; border-top: 2px solid var(--border); }
.detail > td { background: var(--bg); padding: 16px 18px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr auto; gap: 24px; }
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } }
.qr img { width: 150px; height: 150px; image-rendering: pixelated; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.qr.large img { width: 200px; height: 200px; }

/* ---------- invoice test */
.lines-wrap table { min-width: 860px; }
.totals { display: grid; grid-template-columns: max-content max-content; gap: 4px 24px; justify-content: end; font-size: 14px; margin-top: 12px; }
.totals .big { font-weight: 700; font-size: 16px; }
.result-grid { display: grid; grid-template-columns: 1fr auto; gap: 22px; }
@media (max-width: 760px) { .result-grid { grid-template-columns: 1fr; } }
details summary { cursor: pointer; font-weight: 600; font-size: 13px; margin-bottom: 12px; }

/* ---------- certificates */
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 26px 18px; text-align: center; background: var(--bg); }
.dropzone p { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.files { list-style: none; padding: 0; margin: 14px 0 0; font-size: 12.5px; }
.files li { padding: 3px 0; color: var(--muted); }
.files b { color: var(--text); font-weight: 600; }
.seller { border-top: 1px solid var(--border); margin-top: 20px; padding-top: 18px; }
.seller h3 { font-size: 15px; margin: 0 0 4px; text-transform: none; letter-spacing: 0; color: var(--text); }
.seller .sub { margin-bottom: 16px; font-size: 13px; }

/* ---------- report: the documents grid */
.grid-toolbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 12px; }
.grid-toolbar h2 { margin: 0 0 2px; }
.grid-toolbar h2 .count { color: var(--muted); font-weight: 600; font-size: 13px; margin-left: 4px; }
.grid-toolbar select { width: auto; min-width: 72px; }
/* Scrolls both ways inside the panel, so the header, the totals and the View column stay put. */
.grid-scroll { overflow: auto; max-height: 72vh; border: 1px solid var(--border); border-radius: 8px; }
.datagrid { min-width: 1280px; border-collapse: separate; border-spacing: 0; }
.datagrid th, .datagrid td { border-bottom: 1px solid var(--border); }
.datagrid thead th { position: sticky; top: 0; z-index: 2; background: var(--panel); padding-top: 9px; padding-bottom: 9px; }
.datagrid tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--panel); border-top: 2px solid var(--border); border-bottom: 0; }
.datagrid tbody tr.row > td { background: var(--panel); }
.datagrid tbody tr.row:nth-child(4n+3) > td { background: var(--stripe); }
.datagrid tbody tr.row { cursor: pointer; }
.datagrid tbody tr.row:hover > td, .datagrid tbody tr.row.open > td { background: var(--row-hover); }
.datagrid tbody tr.row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.datagrid td.empty { padding: 22px 12px; text-align: center; }
.datagrid .col-actions { position: sticky; right: 0; z-index: 1; border-left: 1px solid var(--border); width: 1%; white-space: nowrap; }
.datagrid thead th.col-actions, .datagrid tfoot td.col-actions { z-index: 3; }
.row-actions { display: flex; gap: 4px; }
button.act {
  background: var(--panel); color: var(--accent); border: 1px solid var(--border); border-radius: 5px;
  padding: 2px 8px; font-size: 12px; font-weight: 600; line-height: 1.5;
}
button.act:hover:not(:disabled) { border-color: var(--accent); }
button.act:disabled { color: var(--muted); }
button.act.primary { border-color: var(--accent); color: var(--accent); font-weight: 600; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px 16px; margin-top: 12px; font-size: 13px; flex-wrap: wrap; }
.pages { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.pages a, .pages span {
  min-width: 34px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px;
  text-align: center; text-decoration: none; font-weight: 600; font-variant-numeric: tabular-nums;
}
.pages a:hover { border-color: var(--accent); }
.pages .current { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.pages .disabled { color: var(--muted); opacity: .55; }
.pages .gap { border-color: transparent; color: var(--muted); min-width: 0; padding: 4px 2px; }

/* ---------- report: the XML / PDF / QR viewer */
dialog.viewer {
  width: min(1100px, calc(100vw - 32px)); height: min(88vh, 1000px); max-width: none; max-height: none;
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); color: var(--text);
}
dialog.viewer[open] { display: flex; flex-direction: column; }
dialog.viewer::backdrop { background: rgba(8, 11, 16, .55); }
.viewer-head { display: flex; justify-content: space-between; align-items: center; gap: 10px 16px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.viewer-head h2 { margin: 0; }
.viewer-body { flex: 1; min-height: 0; overflow: auto; background: var(--bg); }
.viewer-body[data-kind="pdf"] { overflow: hidden; }
.viewer-body iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.viewer-msg { margin: 0; padding: 22px 18px; font-size: 14px; white-space: pre-wrap; }
.viewer-msg.err { color: var(--danger); }
.qr-view { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 22px; }
.qr-view img { width: min(340px, 100%); height: auto; aspect-ratio: 1; image-rendering: pixelated; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
pre.xml {
  margin: 0; border: 0; border-radius: 0; max-height: none; min-height: 100%; padding: 16px 18px;
  background: none; font-size: 12px; line-height: 1.55; color: var(--x-text); white-space: pre-wrap; overflow-wrap: anywhere;
}
pre.xml .x-tag { color: var(--accent); }
pre.xml .x-attr { color: var(--x-attr); }
pre.xml .x-val { color: var(--x-val); }
pre.xml .x-comment, pre.xml .x-pi { color: var(--muted); }

/* ---------- print (screens mark their filter bars no-print) */
@media print {
  body { background: #fff; color: #000; padding: 0; }
  .sidebar, .appbar, .scrim, .no-print { display: none !important; }
  .content { padding: 0 !important; }
  .panel, .kpi { box-shadow: none; }
}

/* ---------- page headings */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.page-head .sub { margin-bottom: 18px; }
.crumbs { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.crumbs a { text-decoration: none; }
.nowrap { white-space: nowrap; }
tr.muted td, article.muted { opacity: .62; }
.danger-zone { border-style: dashed; }
.filterbar { display: flex; gap: 14px 20px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filterbar select { width: auto; min-width: 220px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip.small { padding: 1px 8px; font-size: 12px; }
.grant-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.tile .v .of { font-size: 13px; font-weight: 500; color: var(--muted); }
.tiles.tiles-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .tiles.tiles-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .tiles.tiles-4 { grid-template-columns: 1fr; } }

/* ---------- dashboard: entity cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card { border: 1px solid var(--border); border-radius: 8px; padding: 14px; background: var(--bg); display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card header { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.card-title { font-weight: 700; font-size: 15px; text-decoration: none; color: var(--text); }
.card-title:hover { color: var(--accent); }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; font-size: 12px; }
.metrics > div { min-width: 0; display: flex; flex-direction: column; justify-content: space-between; }
.metrics dt { color: var(--muted); line-height: 1.25; }
.metrics dd { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@media (max-width: 480px) { .metrics { grid-template-columns: repeat(2, 1fr); } }
.card-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.issues { margin: 0; padding-left: 18px; font-size: 12.5px; }
.issues li.bad { color: var(--danger); }
.issues li.warn { color: var(--text); }
.activity { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.activity li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.activity li:last-child { border-bottom: 0; }

/* ---------- dashboard: chart (one series, recessive grid, hover tooltip) */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--gridline); stroke-width: 1; }
.chart .baseline { stroke: var(--axis-base); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: inherit; font-variant-numeric: tabular-nums; }
.chart .mark { fill: var(--series-1); }
.chart .hit { fill: transparent; }
.chart .bar { outline: none; }
.chart .bar.on .hit, .chart .bar:focus .hit { fill: var(--row-hover); }
.chart .flag { fill: var(--st-critical); stroke: var(--panel); stroke-width: 2; }
.chart-tip { position: absolute; pointer-events: none; background: var(--text); color: var(--panel); font-size: 12px; font-weight: 600; padding: 5px 9px; border-radius: 6px; white-space: nowrap; z-index: 5; box-shadow: var(--shadow-lg); }
.flag-key { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--st-critical); vertical-align: middle; }

/* ---------- users: the privilege matrix */
table.grants th.c, table.grants td.c { text-align: center; width: 16%; }
table.grants th .hint { display: block; text-transform: none; letter-spacing: 0; font-weight: 400; }
table.grants input[type=checkbox] { width: 17px; height: 17px; }

/* ---------- legacy import */
.progress { height: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; padding: 0; }
.progress > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }

/* =====================================================================
   App shell: the menu on the left, the page on the right
   ===================================================================== */
.shell { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 30px 36px 56px; }
.content.bare { padding: 26px 16px; }
.icon { flex: none; display: inline-block; vertical-align: middle; }

.sidebar {
  position: sticky; top: 0; height: 100vh; width: 260px; flex: none; overflow-y: auto;
  display: flex; flex-direction: column; padding: 18px 14px 16px;
  background: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-2) 100%); color: var(--side-text);
}
.brand { display: flex; gap: 11px; align-items: center; color: inherit; text-decoration: none; padding: 4px 8px 14px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; color: #fff;
  background: linear-gradient(135deg, #22a582 0%, #0b6b57 100%); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}
.brand-text b { display: block; font-size: 15.5px; color: #fff; letter-spacing: .01em; line-height: 1.2; }
.brand-text small { display: block; font-size: 11.5px; color: var(--side-muted); }

.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-group { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--side-muted); padding: 16px 10px 6px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px;
  color: var(--side-text); text-decoration: none; font-size: 14px; font-weight: 500;
}
.nav-item .icon { opacity: .75; }
.nav-item:hover { background: var(--side-hover); color: #fff; }
.nav-item.here { background: var(--side-active); color: #fff; font-weight: 600; }
.nav-item.here .icon { opacity: 1; color: var(--side-accent); }
.nav-item.here::before {
  content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--side-accent);
}
.nav-item:focus-visible, .sidebar .icon-btn:focus-visible, .brand:focus-visible { outline: 2px solid var(--side-accent); outline-offset: 1px; }

.side-foot { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .08); }
.me { display: flex; gap: 10px; align-items: center; min-width: 0; }
.me-text { min-width: 0; }
.me-text b { display: block; color: #fff; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { display: block; color: var(--side-muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-actions { display: flex; gap: 6px; }
.me-actions form { margin: 0; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #22a582, #0b6b57); color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .02em;
}
.avatar.small { width: 28px; height: 28px; font-size: 11px; background: var(--accent-soft); color: var(--accent); }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: 9px;
  background: transparent; color: inherit; border: 1px solid transparent; cursor: pointer;
}
.icon-btn:hover { background: var(--row-hover); }
.sidebar .icon-btn { color: var(--side-text); background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .07); }
.sidebar .icon-btn:hover, .sidebar .icon-btn.here { background: rgba(255, 255, 255, .13); color: #fff; }

/* The theme switch shows the moon in light mode and the sun in dark mode. */
.icon.when-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon.when-dark { display: inline-block; }
  :root:not([data-theme="light"]) .icon.when-light { display: none; }
}
:root[data-theme="dark"] .icon.when-dark { display: inline-block; }
:root[data-theme="dark"] .icon.when-light { display: none; }

/* Which ZATCA gateway invoices go to: amber for a test gateway, green for production. */
.env-badge { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; padding: 6px 11px; border-radius: 99px; line-height: 1.3; }
.env-badge .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--st-warning); box-shadow: 0 0 0 3px rgba(250, 178, 25, .22); }
.env-badge.live .dot { background: var(--st-good); box-shadow: 0 0 0 3px rgba(12, 163, 12, .22); }
.sidebar .env-badge { background: rgba(255, 255, 255, .06); color: var(--side-text); align-self: flex-start; }
.env-badge.compact { background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--text); padding: 3px 10px; }
.env-badge.compact.live { background: var(--ok-bg); border-color: var(--ok-border); }

.appbar { display: none; }
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(6, 10, 14, .5); }

@media (max-width: 960px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%);
    transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .appbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30;
    padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--border);
  }
  .appbar-title { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .content { padding: 20px 16px 44px; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
body.nav-locked { overflow: hidden; }

/* =====================================================================
   Sign-in and first-time setup
   ===================================================================== */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 1fr) minmax(420px, 1.05fr); }
.auth-brand {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  padding: 44px 54px; color: #d9ebe4;
  background:
    radial-gradient(900px 520px at -10% -10%, rgba(34, 165, 130, .35), transparent 60%),
    linear-gradient(160deg, #0b261f 0%, #0c3a2e 55%, #0f4d3d 100%);
}
/* Quiet concentric rings in the corner, echoing a stamp. */
.auth-brand::after {
  content: ""; position: absolute; right: -90px; bottom: -90px; width: 340px; height: 340px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .09);
  box-shadow: 0 0 0 44px rgba(255, 255, 255, .025), 0 0 0 88px rgba(255, 255, 255, .02);
  pointer-events: none;
}
.brand.large { padding: 0; }
.brand.large .brand-mark { width: 44px; height: 44px; border-radius: 13px; }
.brand.large .brand-text b { font-size: 17px; }
.auth-org { margin: 0 0 14px; font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #8fd9bf; }
.auth-pitch h1 { max-width: 500px; margin: 0 0 30px; font-size: 31px; line-height: 1.25; color: #fff; }
.auth-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 20px; max-width: 470px; }
.auth-points li { display: flex; gap: 14px; align-items: flex-start; }
.auth-points .icon {
  width: 38px; height: 38px; padding: 9px; box-sizing: border-box; border-radius: 11px;
  color: #6fe0bd; background: rgba(255, 255, 255, .07);
}
.auth-points span { font-size: 13.5px; line-height: 1.5; color: #b7d3c8; }
.auth-points b { display: block; font-size: 14.5px; color: #fff; }
.env-badge.on-brand { position: relative; z-index: 1; align-self: flex-start; background: rgba(255, 255, 255, .08); color: #d9ebe4; }

.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 40px 24px; }
.auth-card {
  width: 100%; max-width: 430px; padding: 34px 32px 30px; border-radius: 18px;
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.auth-title { margin: 0 0 6px; font-size: 24px; letter-spacing: -.01em; }
.auth-card .sub { margin-bottom: 24px; }
.auth-card .field { margin-bottom: 16px; }
.auth-card label { font-size: 13px; }
.auth-card input[type=text], .auth-card input[type=password] { padding-top: 10px; padding-bottom: 10px; font-size: 15px; }
.auth-card button[type=submit] { margin-top: 6px; }
.auth-help { margin: 20px 0 0; text-align: center; }
.auth-foot { max-width: 380px; margin: 0; font-size: 12px; color: var(--muted); text-align: center; }

.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 38px !important; }
.input-icon.has-action input { padding-right: 44px !important; }
.reveal {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%); display: grid; place-items: center;
  padding: 7px; border-radius: 7px; background: none; border: 0; color: var(--muted);
}
.reveal:hover { color: var(--text); background: var(--row-hover); }
.reveal .when-shown { display: none; }
.reveal[aria-pressed="true"] .when-shown { display: inline-block; }
.reveal[aria-pressed="true"] .when-hidden { display: none; }
.caps-hint { display: block; margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--x-attr); }

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { gap: 20px; padding: 26px 22px 30px; }
  .auth-pitch h1 { margin: 0; font-size: 21px; }
  .auth-points, .auth-brand .env-badge { display: none; }
  .auth-main { justify-content: flex-start; padding: 24px 16px 40px; }
  .auth-card { padding: 26px 20px 22px; }
}

/* =====================================================================
   Dashboard
   ===================================================================== */
.eyebrow { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.dash-head { align-items: flex-end; }
.dash-head .actions { margin-bottom: 20px; }

.filterbar { margin-bottom: 18px; }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 10px; background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.segmented a { padding: 5px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none; white-space: nowrap; }
.segmented a:hover { color: var(--text); background: var(--row-hover); }
.segmented a.on { background: var(--accent); color: var(--accent-text); }

.attention { margin-bottom: 18px; padding: 14px 18px; border-radius: var(--radius); background: var(--warn-bg); border: 1px solid var(--warn-border); }
.attention-title { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; font-weight: 700; }
.attention-title .icon { color: var(--x-attr); }
.attention ul { margin: 0; padding-left: 26px; font-size: 14px; }
.attention li { margin: 3px 0; }
.all-clear {
  display: flex; gap: 10px; align-items: center; margin-bottom: 18px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--ok-bg); border: 1px solid var(--ok-border); font-size: 14px; font-weight: 500;
}
.all-clear .icon { color: var(--up); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
@media (max-width: 1150px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .kpis { grid-template-columns: 1fr; } }
.kpi {
  display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 18px 18px 16px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.kpi-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1.15; letter-spacing: -.015em; overflow-wrap: anywhere; }
.kpi-value small { margin-right: 2px; font-size: 13px; font-weight: 600; letter-spacing: 0; color: var(--muted); }
.kpi-foot { margin-top: auto; font-size: 12.5px; color: var(--muted); }
.delta { font-size: 12.5px; font-weight: 700; }
.delta.good { color: var(--up); }
.delta.bad { color: var(--down); }
.delta.flat, .delta.none { font-weight: 500; color: var(--muted); }
.delta .vs { font-weight: 500; color: var(--muted); }
.spark { display: block; width: 100%; height: auto; margin-top: auto; overflow: visible; }
.spark-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark-area { fill: var(--series-1); opacity: .1; }
.spark-dot { fill: var(--series-1); stroke: var(--panel); stroke-width: 2; }

/* A meter's unfilled track is a lighter step of its own fill. */
.meter { height: 8px; border-radius: 99px; overflow: hidden; background: rgba(12, 163, 12, .16); }
.meter > span { display: block; height: 100%; border-radius: 99px; background: var(--st-good); }
.meter.warning { background: rgba(250, 178, 25, .22); }
.meter.warning > span { background: var(--st-warning); }
.meter.critical { background: rgba(208, 59, 59, .16); }
.meter.critical > span { background: var(--st-critical); }
.meter.empty { background: var(--border); }
.meter-row { display: flex; gap: 12px; align-items: center; }
.meter-row .meter { flex: 1; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 0 18px; }
.dash-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1150px) { .dash-grid, .dash-grid.three { grid-template-columns: minmax(0, 1fr); } }
.panel-head .hint { display: block; }
.panel-head.tight { margin-bottom: 8px; }
.subsection { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.subsection h3 { margin: 0; }

.chart-empty { display: grid; place-items: center; align-content: center; gap: 6px; min-height: 220px; color: var(--muted); text-align: center; }
.chart-empty p { margin: 0; }
.table-view { margin-top: 10px; }
.table-view summary { margin-bottom: 8px; }

/* Part-to-whole bars: segments separated by a 2px gap, rounded only at the two ends. */
.stack { position: relative; display: flex; gap: 2px; height: 14px; margin: 4px 0 14px; }
.stack .seg { min-width: 4px; height: 100%; }
.stack .seg:first-child { border-top-left-radius: 4px; border-bottom-left-radius: 4px; }
.stack .seg:last-of-type { border-top-right-radius: 4px; border-bottom-right-radius: 4px; }
.stack .seg:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.stack .seg.on { filter: brightness(1.08); }
.stack-empty { flex: 1; border-radius: 4px; background: var(--border); }

.status-good { background: var(--st-good); }
.status-warning { background: var(--st-warning); }
.status-serious { background: var(--st-serious); }
.status-critical { background: var(--st-critical); }
.series-1 { background: var(--series-1); }
.series-2 { background: var(--series-2); }

.legend-rows { list-style: none; margin: 0; padding: 0; }
.legend-rows li {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto 42px; gap: 10px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px;
}
.legend-rows li:last-child { border-bottom: 0; }
.legend-rows li.zero { opacity: .55; }
.legend-rows .name small { display: block; font-size: 12px; color: var(--muted); }
.legend-rows .val { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.legend-rows .pct { font-size: 12.5px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.key { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; color: #fff; }
.key.status-warning { color: #3b2a00; }
.key.swatch { width: 12px; height: 12px; border-radius: 3px; justify-self: center; }

dl.figures { display: block; margin: 0; font-size: 14px; }
dl.figures > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
dl.figures > div:last-child { border-bottom: 0; }
dl.figures dt { color: var(--muted); }
dl.figures dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
dl.figures .total dt { color: var(--text); font-weight: 700; }
dl.figures .total dd { font-size: 16px; font-weight: 800; }
dl.figures .muted-row dd { color: var(--muted); }

.ready-list { list-style: none; margin: 0; padding: 0; }
.ready-list li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.ready-list li:last-child { border-bottom: 0; }
.ready-list a { color: var(--text); text-decoration: none; }
.ready-list a:hover { color: var(--accent); }
.ready-list small { display: block; font-size: 12.5px; color: var(--muted); }

.empty-state { padding: 48px 20px; text-align: center; }
.empty-state .icon { color: var(--muted); margin-bottom: 8px; }
table.list tbody tr:hover > td { background: var(--row-hover); }
.tag { padding: 2px 9px; font-weight: 600; }
