/* ==========================================================================
   data.css: how data is shown. Tables (and the invoice lines table), type
   badges and dots, status pills, chips, status rows, cards, KPI and stat
   tiles, key-value lists, timeline, lists, bar list and chart, tabs, pager,
   empty states and illustrations, flash messages and callouts, provider
   marks and the column picker.

   Loads after tokens.css, base.css, layout.css and controls.css. Colours,
   spacing and motion come from tokens only, so dark mode needs no rules of
   its own. Hover rules sit inside (hover: hover). Nothing transitions "all".
   ========================================================================== */

/* -- tables ------------------------------------------------------------------------------- */
.table-wrap {
  position: relative;
  overflow-x: auto;
  /* scroll cue: a shadow shows on a side only while content is hidden on that side (local covers hide it at the end) */
  background:
    linear-gradient(to right, var(--surface) 30%, transparent) left center / 40px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 30%, transparent) right center / 40px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--scroll-shadow), transparent) left center / 20px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--scroll-shadow), transparent) right center / 20px 100% no-repeat scroll,
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.card .table-wrap { border: 0; border-radius: 0; box-shadow: none; }

/* long lists: the header stays in view while the rows scroll inside the table */
@media (min-width: 960px) {
  .table-wrap.table-scroll { max-height: calc(100dvh - 260px); min-height: 280px; overflow: auto; }
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--table-font);
  font-variant-numeric: tabular-nums;
}
th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px var(--row-px);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 16px;
  color: var(--muted);
  white-space: nowrap;
}
td {
  padding: var(--row-py) var(--row-px);
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
  color: var(--ink);
}
th:first-child, td:first-child { padding-left: 16px; }
th:last-child, td:last-child { padding-right: 16px; }
tbody tr:last-child > td { border-bottom: 0; }

@media (hover: hover) and (pointer: fine) {
  tbody tr:hover > td { background: var(--row-hover); }
  tr.flagged:hover > td { background: var(--row-flag); }
}

/* a mail that needs a person: the tint and the edge mark the row; the "Needs review" pill says why */
tr.flagged > td { background: var(--row-flag); }
tr.flagged > td:first-child { box-shadow: inset 3px 0 0 var(--warning); }

/* helpers inside cells */
.title { color: var(--ink); font-weight: var(--weight-medium); }
td .title { display: inline-block; min-width: 200px; }
.cell-sub { margin-top: 2px; font-size: var(--text-xs); color: var(--muted); }
.cell-date { white-space: nowrap; }
.cell-date .cell-sub { margin-top: 1px; }
.row-meta { display: none; }
td.row-act, th.row-act {
  width: 1%;
  padding-top: 4px;
  padding-bottom: 4px;
  text-align: right;
  white-space: nowrap;
}
td.empty, .empty { padding: 32px 16px; text-align: center; color: var(--muted); }

/* numbers, amounts and codes */
th.num, td.num { text-align: right; }
.amount { font-variant-numeric: tabular-nums; font-weight: var(--weight-medium); white-space: nowrap; }
.cur { margin-left: 4px; font-size: var(--text-xs); font-weight: var(--weight-regular); color: var(--muted); }
.code {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  background: var(--surface-3);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.78125rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
/* opt-in for a long free value in running text (an otpauth link, a command): it wraps inside the page. Codes in
   tables and chips (PNR, GSTIN, flight and ticket numbers, setup key groups) keep .code and never break. */
.code-wrap {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}
/* the setup key: its 4-character groups are the only places it wraps (at the spaces), never inside a group */
.code.code-groups {
  max-width: 100%;
  white-space: normal;
}
.code-big {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.06em;
}
.action-tag {
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  background: var(--surface-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

/* a wide table on a phone: the row keeps its date and title, the rest moves under the title */
@media (max-width: 959.98px) {
  .table-wrap table { min-width: 720px; }
}
@media (max-width: 639.98px) {
  .table-wrap table.stack { min-width: 0; }
  table.stack .col-wide { display: none; }
  table.stack td:nth-child(2) { overflow-wrap: anywhere; }
  table.stack .title { min-width: 0; }
  table.stack th:nth-child(2) { width: 100%; }
  table.stack .row-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    margin-top: 8px;
  }
  /* on a phone the row's buttons (Check, Approve as is) stack at the end of the row and fit 390px.
     The cell stays a table cell; its children are stacked, right-aligned, 6px apart. */
  table.stack td.row-act > * {
    display: flex;
    width: max-content;
    margin-left: auto;
  }
  table.stack td.row-act > * + * {
    margin-top: 6px;
  }
}

/* a table as cards on a phone (Team, Audit log): each row is a card, its cells flow inside it; a cell with
   data-label shows that label in front of its value. The header row stays for screen readers only. */
@media (max-width: 639.98px) {
  .table-wrap table.cards { min-width: 0; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; }
  table.cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  table.cards tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 14px 16px; border-bottom: 1px solid var(--hairline); }
  table.cards tbody tr:last-child { border-bottom: 0; }
  table.cards td { min-width: 0; padding: 0; border: 0; }
  table.cards td.card-main, table.cards td.card-full { flex: 1 1 100%; }
  table.cards td[data-label]::before { content: attr(data-label) " "; color: var(--muted); font-size: var(--text-xs); }
  table.cards td.row-act { width: auto; margin-left: auto; padding: 0; }
  /* a labelled cell (Last login, IP) is a quiet last line of the card: label, then the value on the same line */
  table.cards td[data-label] { order: 1; flex: 1 1 100%; color: var(--muted); font-size: var(--text-sm); }
  table.cards td[data-label] .cell-date, table.cards td[data-label] .cell-date > .cell-sub { display: inline; margin: 0; font-size: inherit; color: inherit; }
  table.cards td[data-label] .cell-date > .cell-sub::before { content: ", "; }
  /* a card table does not scroll sideways, so the scroll-edge fade (further down) would only fade the card's right edge */
  .table-wrap:has(> table.cards), .table-wrap:has(> table.cards.sticky-first) { mask-image: none; animation: none; }
  /* a cell that is nowrap on the desktop table may not run off a card: it wraps instead */
  table.cards td.nowrap { white-space: normal; overflow-wrap: anywhere; }
}

/* laptop widths (960-1439px): cell padding 4px tighter on each side (8px at comfortable density, still
   tighter than the 10px of compact), so the Review flag and Excel columns of the mails table fit the card;
   the airline name may wrap in that table only */
@media (min-width: 960px) and (max-width: 1439.98px) {
  th, td {
    padding-left: calc(var(--row-px) - 4px);
    padding-right: calc(var(--row-px) - 4px);
  }
  table[aria-label="Mails"] .airline { white-space: normal; }
}

/* wide tables (.sticky-first): the first column stays in view while the rest scrolls, from 640px up
   (phones keep their card layout). Every cell is opaque: the surface, then the row state, layered over it. */
@media (min-width: 640px) {
  table.sticky-first th:first-child,
  table.sticky-first td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: linear-gradient(var(--surface), var(--surface)), var(--surface);
    box-shadow: inset -1px 0 0 var(--hairline);
  }
  table.sticky-first th:first-child {
    z-index: 3;
    background: linear-gradient(var(--surface-2), var(--surface-2)), var(--surface-2);
  }
  table.sticky-first tr.flagged > td:first-child {
    background: linear-gradient(var(--row-flag), var(--row-flag)), var(--surface);
    box-shadow: inset 3px 0 0 var(--warning), inset -1px 0 0 var(--hairline);
  }
}
@media (hover: hover) and (pointer: fine) and (min-width: 640px) {
  table.sticky-first tbody tr:hover > td:first-child {
    background: linear-gradient(var(--row-hover), var(--row-hover)), var(--surface);
  }
  table.sticky-first tbody tr.flagged:hover > td:first-child {
    background: linear-gradient(var(--row-flag), var(--row-flag)), var(--surface);
  }
  /* row actions (the Excel link) appear on hover or focus within the row; on touch and phones they always show */
  table.sticky-first td.row-act > * {
    opacity: 0;
    transition: opacity var(--dur-2) var(--ease-out), background-color var(--dur-1) ease, color var(--dur-1) ease, transform var(--dur-2) var(--ease-out);
  }
  table.sticky-first tbody tr:hover td.row-act > *,
  table.sticky-first tbody tr:focus-within td.row-act > * {
    opacity: 1;
  }
}

/* -- lines table (the invoice's own tables on a mail page) -------------------------------- */
.lines-panel { margin: 4px 0 18px; }
.lines-panel[aria-busy="true"] { opacity: 0.6; cursor: progress; }
.lines-block + .lines-block { margin-top: 20px; }
.lines-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 8px;
}
.lines-title { font-size: var(--text-base); font-weight: var(--weight-semibold); color: var(--ink); }
.lines-sub { margin-top: 2px; font-size: var(--text-xs); color: var(--muted); }
.lines-wrap { border-radius: var(--radius-md); }

table.lines-table, table.by-rate { font-size: var(--text-sm); }
table.lines-table th, table.lines-table td,
table.by-rate th, table.by-rate td { padding: 7px 10px; }
table.lines-table th {
  min-width: 64px;
  vertical-align: bottom;
  white-space: normal;
  font-size: var(--text-xs);
  line-height: 1.3;
}
table.lines-table td { white-space: nowrap; }
table.lines-table th:first-child,
table.lines-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 160px;
  white-space: normal;
  background: var(--surface);
  box-shadow: inset -1px 0 0 var(--border);
}
table.lines-table thead th:first-child { background: var(--surface-2); }
table.lines-table tr.row-total > td { background: var(--surface-2); font-weight: var(--weight-semibold); }
table.lines-table tr.row-total > td:first-child { background: var(--surface-2); }
table.lines-table tr.row-line-zero > td.cell { color: var(--muted); }
table.by-rate tr.row-muted > td { color: var(--muted); }
table.lines-table td.line-check { min-width: 240px; max-width: 380px; white-space: normal; }
td.line-check .chk { margin: 0; }

/* the cells a person can change (app.js): one click or tap to edit */
[data-editable] td.cell { cursor: cell; }
[data-editable].tap-edit td.cell { cursor: text; }
@media (hover: hover) and (pointer: fine) {
  [data-editable].tap-edit td.cell:hover { text-decoration: underline dashed var(--muted); text-underline-offset: 3px; }
}
td.cell:focus { outline: none; }
td.cell:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
table.lines-table td.cell.is-changed {
  background: var(--accent-soft);
  color: var(--accent-soft-ink);
  font-weight: var(--weight-semibold);
}
table.lines-table td.cell.is-bad {
  background: var(--critical-soft);
  color: var(--critical-ink);
  font-weight: var(--weight-semibold);
}
table.lines-table td.cell.is-editing {
  padding: 3px 4px;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.lines-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
  font-size: var(--text-sm);
  color: var(--accent-soft-ink);
}
.lines-status:empty { display: none; }
.lines-status .i { width: 14px; height: 14px; }
.lines-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--warning-line);
  border-radius: var(--radius-md);
  background: var(--warning-soft);
  color: var(--warning-ink);
  font-size: var(--text-sm);
}
.lines-note .i { flex: none; width: 15px; height: 15px; margin-top: 1px; }
.lines-problems {
  display: grid;
  gap: 4px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  color: var(--warning-ink);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.45;
}
.lines-problems li { display: flex; align-items: flex-start; gap: 6px; }
.lines-problems .i { flex: none; width: 13px; height: 13px; margin-top: 2px; }
.lines-sub-title {
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}
.lines-sub-title .muted {
  font-weight: var(--weight-medium);
  letter-spacing: 0;
  text-transform: none;
}

/* the totals box under the lines: five across on a wide split page, two across on a phone */
@media (min-width: 1100px) {
  .split-wide .totals-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 639.98px) {
  table.lines-table th:first-child, table.lines-table td:first-child { min-width: 112px; }
  .form-grid.totals-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* -- badges + dots (mail type: a neutral badge with a coloured dot) ------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1;
  white-space: nowrap;
}
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--t-other);
}
.dot-invoice { background: var(--t-invoice); }
.dot-credit_note { background: var(--t-credit_note); }
.dot-e_ticket { background: var(--t-e_ticket); }
.dot-schedule_change { background: var(--t-schedule_change); }
.dot-cancellation { background: var(--t-cancellation); }
.dot-refund { background: var(--t-refund); }
.dot-check_in { background: var(--t-check_in); }
.dot-other { background: var(--t-other); }

/* -- pills (state: soft background, icon and text, so colour is never the only signal) ---- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1;
  white-space: nowrap;
}
.pill .i { width: 13px; height: 13px; stroke-width: 2; }
.pill-good { background: var(--good-soft); color: var(--good-ink); border-color: var(--good-line); }
.pill-warning { background: var(--warning-soft); color: var(--warning-ink); border-color: var(--warning-line); }
.pill-critical { background: var(--critical-soft); color: var(--critical-ink); border-color: var(--critical-line); }
.pill-info { background: var(--info-soft); color: var(--info-ink); border-color: var(--info-line); }
.pill-muted { background: var(--neutral-soft); color: var(--neutral-ink); border-color: var(--neutral-line); }
.pill-ai { background: var(--violet-soft); color: var(--violet-ink); border-color: var(--violet-line); }

/* -- chips (topbar AI status, rules label) ------------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1;
  white-space: nowrap;
}
.chip .i { width: 14px; height: 14px; }
.chip-ai { background: var(--violet-soft); color: var(--violet-ink); }
.chip-ai .i { color: var(--violet-ink); }
.chip-rules { background: var(--neutral-soft); color: var(--neutral-ink); }
.chip-rules .i { color: var(--muted); }
.chip-label {
  font-size: var(--text-2xs);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}
@media (hover: hover) and (pointer: fine) {
  a.chip:hover { color: var(--ink); text-decoration: none; }
}
@media (max-width: 639.98px) {
  .chip-label { display: none; }
  .chip { padding: 0 9px; }
}

/* -- status rows (system checks: one line per check, with a mark) ------------------------- */
/* a row lays itself out: the round mark on the left (its 1px top margin centres it on the first text line),
   the text block on the right, 12px between; a hairline between rows, none under the last one */
.status-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding-top: var(--list-py);
  padding-bottom: var(--list-py);
  border-bottom: 1px solid var(--hairline);
}
.status-row:last-child { border-bottom: 0; }
.status-row .status-mark { margin-top: 1px; }
.status-row .item-title { white-space: normal; }
.status-text {
  margin-top: 2px;
  color: var(--ink-2);
  font-size: var(--text-base);
  line-height: 1.5;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.status-text.muted { color: var(--muted); }
.status-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border: 1px solid var(--neutral-line);
  border-radius: 50%;
  background: var(--neutral-soft);
  color: var(--neutral-ink);
}
.status-mark .i { width: 12px; height: 12px; stroke-width: 2.4; }
.status-ok { background: var(--good-soft); color: var(--good-ink); border-color: var(--good-line); }
.status-bad { background: var(--critical-soft); color: var(--critical-ink); border-color: var(--critical-line); }

/* the icon tile at the start of a list row (mail type, upload file) */
.type-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-3);
}
.type-icon .i { color: var(--muted); }
.type-icon .dot { width: 9px; height: 9px; }

/* -- cards -------------------------------------------------------------------------------- */
.card {
  min-width: 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-highlight), var(--shadow-sm);
}
.card[id] { scroll-margin-top: calc(var(--topbar-h) + 16px); }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  min-height: 28px;
  margin-bottom: 12px;
}
.card-head h2, .head-title h2 {
  margin: 0;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: 22px;
}
.head-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.head-sub { margin-top: 2px; color: var(--muted); font-size: var(--text-sm); }
.card-desc { margin: 0 0 12px; color: var(--muted); font-size: var(--text-sm); }
.meta { color: var(--muted); font-size: var(--text-xs); }
.card-body { padding: 16px; }
.card-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--hairline);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* a flush card: its content touches the edges; the head and foot keep their own rules */
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head {
  min-height: 56px;
  margin: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--hairline);
}
.card.flush .card-body { padding: 16px; }
.card.flush > .card-foot { border-radius: 0; }
.card.flush > .empty-state { padding: 40px 24px; }
.card.flush > .tabs { margin: 0; padding: 0 12px; }
.card.flush > .pager { padding: 12px 16px; border-top: 1px solid var(--hairline); }

/* -- KPI tiles (dashboard) ---------------------------------------------------------------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.kpi {
  --kpi-tone: var(--border-strong);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-highlight), var(--shadow-sm);
  color: inherit;
  text-decoration: none;
}
/* 2px status rule along the top edge; overflow hidden clips it to the tile's radius */
.kpi::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--kpi-tone);
  pointer-events: none;
}
.kpi.kpi-tone-neutral { --kpi-tone: var(--border-strong); }
.kpi.kpi-tone-good { --kpi-tone: var(--good); }
.kpi.kpi-tone-warning { --kpi-tone: var(--warning); }
.kpi.kpi-tone-danger { --kpi-tone: var(--danger); }
a.kpi { transition: border-color var(--dur-1) ease, box-shadow var(--dur-1) ease; }
@media (hover: hover) and (pointer: fine) {
  a.kpi:hover { border-color: var(--border-strong); box-shadow: var(--card-highlight), var(--shadow-md); }
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi .label { color: var(--muted); font-size: var(--text-sm); font-weight: var(--weight-medium); }
.kpi-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent-icon);
}
.kpi-icon .i { width: 16px; height: 16px; }
.kpi-icon.good { background: var(--good-soft); color: var(--good-ink); }
.kpi-icon.warn { background: var(--warning-soft); color: var(--warning-ink); }
.kpi-icon.violet { background: var(--violet-soft); color: var(--violet-ink); }
.kpi .value {
  color: var(--ink);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.kpi .note { color: var(--muted); font-size: var(--text-xs); }
.kpi.attention {
  border-color: var(--warning-line);
  background: linear-gradient(180deg, var(--warning-soft), var(--surface) 75%);
}
.kpi.attention .value { color: var(--warning-ink); }
.kpi.attention .note { color: var(--warning-ink); font-weight: var(--weight-medium); }
@media (max-width: 639.98px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 12px 14px; }
  .kpi .value { font-size: 24px; }
}

/* -- stat tiles (settings usage) ---------------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.stat {
  min-width: 0;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.stat-label { color: var(--muted); font-size: var(--text-xs); }
.stat-value {
  margin-top: 2px;
  color: var(--ink);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  font-variant-numeric: tabular-nums;
}
.stat-note { color: var(--muted); font-size: var(--text-xs); }
/* the "Day by day" fold under the usage tiles: 12px below them */
.stat-grid + details.form-fold { margin-top: var(--space-3); }

/* -- key-value lists (invoice details, a mail's facts, audit details) --------------------- */
dl.kv {
  display: grid;
  grid-template-columns: minmax(110px, max-content) minmax(0, 1fr);
  gap: 10px 16px;
  margin: 0;
}
dl.kv dt { color: var(--muted); font-size: var(--text-sm); }
dl.kv dd {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-base);
  overflow-wrap: anywhere;
}
@media (max-width: 639.98px) {
  dl.kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  dl.kv dt { font-size: var(--text-xs); }
  dl.kv dd { margin-bottom: 10px; }
}

/* the invoice's own "label : value" lines, in a grid of pairs */
dl.printed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px 24px;
  margin: 0;
  padding: 16px;
}
dl.printed > div { min-width: 0; }
dl.printed dt { margin-bottom: 2px; color: var(--muted); font-size: var(--text-xs); }
dl.printed dd {
  margin: 0;
  color: var(--ink);
  font-weight: var(--weight-medium);
  overflow-wrap: anywhere;
}

/* audit details: small, with the values in mono */
.detail-kv {
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.detail-kv .muted { font-family: var(--font-sans); }

/* -- timeline (a booking's or a mail's history) ------------------------------------------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 18px;
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  top: 22px;
  bottom: 0;
  left: 9.5px;
  width: 1px;
  background: var(--border);
}
.timeline li:last-child::before { display: none; }
.tl-mark {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
}
.tl-mark .i { width: 12px; height: 12px; color: var(--muted); }
.tl-mark .dot { width: 8px; height: 8px; }
.tl-body { min-width: 0; }
.tl-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  color: var(--ink);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 20px;
}
.tl-title a { color: var(--ink); font-weight: var(--weight-medium); }
.tl-detail { color: var(--muted); font-size: var(--text-sm); }
.timeline .when {
  color: var(--muted);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

/* -- lists (activity, mailboxes, changes) ------------------------------------------------- */
.list { margin: 0; padding: 0; list-style: none; }
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: var(--list-py) 16px;
  border-bottom: 1px solid var(--hairline);
  color: inherit;
  text-decoration: none;
}
.list-item:last-child { border-bottom: 0; }
@media (hover: hover) and (pointer: fine) {
  a.list-item:hover { background: var(--row-hover); }
}
.list-item .grow { flex: 1; min-width: 0; }
/* a list row with buttons (Reports > Scheduled email reports): on a phone the buttons move under the text and line
   up with it (32px icon + 12px gap), so the text keeps the row's width */
@media (max-width: 639.98px) {
  .list-item:has(> .actions) { flex-wrap: wrap; row-gap: 8px; }
  .list-item > .actions { flex: 1 1 100%; width: auto; margin-left: 0; padding-left: 44px; }
}
.item-title {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  text-overflow: ellipsis;
  white-space: nowrap;
}
a.item-title { color: var(--ink); }
.item-title.multiline { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
.item-sub {
  overflow: hidden;
  color: var(--muted);
  font-size: var(--text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-side {
  margin-left: auto;
  padding-left: 12px;
  color: var(--muted);
  font-size: var(--text-xs);
  text-align: right;
  white-space: nowrap;
}
.grow { flex: 1; min-width: 0; }
.link-more {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--link);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.link-more .i { width: 14px; height: 14px; }

/* a short list of ticks: what a feature gives, what a check passed */
.check-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.check-list li { display: flex; align-items: flex-start; gap: 8px; }
.check-list .i { flex: none; margin-top: 2px; color: var(--good-ink); }

/* -- bar list + column chart (dashboard) -------------------------------------------------- */
.bars {
  display: grid;
  grid-template-columns: max-content minmax(60px, 1fr) max-content;
  align-items: center;
  gap: 12px 14px;
}
.bars .name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: var(--text-sm);
  white-space: nowrap;
}
.bars svg { display: block; width: 100%; height: 8px; overflow: visible; }
.bars .track { fill: var(--seq-track); }
.bars .bar { fill: var(--seq); }
.bars .val {
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.chart-plot { position: relative; height: 170px; margin-top: 8px; }
.chart-plot svg {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.chart .grid-line { stroke: var(--hairline); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .base-line { stroke: var(--border); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart .bar { fill: var(--seq); transition: fill var(--dur-1) ease; }
@media (hover: hover) and (pointer: fine) {
  .chart .col:hover .bar { fill: var(--accent-hover); }
  .chart .col:hover .hit { fill: var(--accent-soft); }
}
.chart-y {
  position: absolute;
  top: -9px;
  left: 0;
  padding-right: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: var(--text-2xs);
  font-variant-numeric: tabular-nums;
  line-height: 18px;
}
.chart-x {
  display: grid;
  grid-template-columns: repeat(30, minmax(0, 1fr));
  margin-top: 8px;
  color: var(--muted);
  font-size: var(--text-2xs);
}
.chart-x span { overflow: visible; text-align: center; white-space: nowrap; }
.chart-x span:last-child { display: flex; justify-content: flex-end; }
.chart-total { display: flex; align-items: baseline; gap: 8px; }
.chart-total .big {
  color: var(--ink);
  font-size: var(--text-3xl);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tighter);
  font-variant-numeric: tabular-nums;
}

/* -- tabs (quick filters, booking status) ------------------------------------------------- */
.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 16px;
  overflow-x: auto;
  /* scroll cue, same technique as .table-wrap; tabs sit inside .card.flush (surface) */
  background:
    linear-gradient(to right, var(--surface) 30%, transparent) left center / 40px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 30%, transparent) right center / 40px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--scroll-shadow), transparent) left center / 20px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--scroll-shadow), transparent) right center / 20px 100% no-repeat scroll,
    var(--surface);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
/* last tab not flush with the phone edge; .card.flush > .tabs sets its own padding, so match its specificity */
@media (max-width: 639.98px) {
  .tabs { padding-right: 16px; }
  .card.flush > .tabs { padding-right: 16px; }
}
/* scroll-driven edge fade (browsers with scroll timelines): the content itself fades at an edge while more is hidden on that side; the background cue above is the fallback */
@property --fade-start { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --fade-end { syntax: "<length>"; inherits: false; initial-value: 0px; }
@keyframes edge-fade {
  0%   { --fade-start: 0px;  --fade-end: 36px; }
  8%   { --fade-start: 36px; --fade-end: 36px; }
  92%  { --fade-start: 36px; --fade-end: 36px; }
  100% { --fade-start: 36px; --fade-end: 0px; }
}
@supports (animation-timeline: scroll()) {
  .table-wrap, .tabs {
    mask-image: linear-gradient(to right, transparent, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent);
    animation: edge-fade linear both;
    animation-timeline: scroll(self inline);
  }
  /* a sticky first column does not scroll away, so only the right edge fades */
  .table-wrap:has(> table.sticky-first) {
    mask-image: linear-gradient(to right, #000 calc(100% - var(--fade-end)), transparent);
  }
}
@media print {
  .table-wrap, .tabs { background: none; mask-image: none; }
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  margin-bottom: -1px;
  padding: 0 10px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--dur-1) ease, border-color var(--dur-1) ease;
}
.tab .dot { width: 7px; height: 7px; }
.tab .i { width: 14px; height: 14px; }
@media (hover: hover) and (pointer: fine) {
  .tab:hover { color: var(--ink); }
}
@media (pointer: coarse) {
  .tab { height: 44px; }
}
.tab.active, .tab[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* -- pager -------------------------------------------------------------------------------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
}
.pager .pages { font-variant-numeric: tabular-nums; }
.pager .pager-btns { display: flex; gap: 8px; }

/* -- empty states + illustrations --------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 40px 24px;
  color: var(--muted);
  text-align: center;
}
.empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 6px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  color: var(--muted);
}
.empty-icon .i { width: 20px; height: 20px; }
.empty-icon.good { background: var(--good-soft); color: var(--good-ink); }
.empty-icon.accent { background: var(--accent-soft); color: var(--accent-soft-ink); }
.empty-state :is(h2, h3), .empty-title {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}
.empty-state p {
  max-width: 46ch;
  margin: 0;
  color: var(--muted);
  font-size: var(--text-base);
}
.empty-state .cluster { justify-content: center; margin-top: 10px; }
/* actions under an empty state: .actions carries margin-left:auto for page headers, which would push them right;
   here they centre, wrap on phones and keep 12px above */
.empty-state .actions { justify-content: center; margin: var(--space-3) auto 0; }
.empty-state .form-actions { justify-content: center; }
.empty-art { width: 160px; max-width: 100%; margin: 0 auto 8px; }
.empty-art svg { display: block; width: 100%; height: auto; }

/* -- flash messages + callouts ------------------------------------------------------------ */
.flashes { display: grid; gap: 8px; margin-bottom: 16px; }
.flash, .flash-ok {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--good-line);
  border-radius: var(--radius-md);
  background: var(--good-soft);
  color: var(--ink);
  font-size: var(--text-base);
  overflow-wrap: anywhere;
}
.flash > .i { width: 16px; height: 16px; margin-top: 2px; color: var(--good-ink); }
.flash-warn { border-color: var(--warning-line); background: var(--warning-soft); }
.flash-warn > .i { color: var(--warning-ink); }
.flash-error { border-color: var(--critical-line); background: var(--critical-soft); }
.flash-error > .i { color: var(--critical-ink); }
.flash-text { flex: 1; min-width: 0; }
.flash .flash-close { width: 28px; height: 28px; margin: -4px -4px -4px auto; }
.flash .flash-close .i { width: 15px; height: 15px; }
/* the verify-email banner (partials/verify_banner.html): a warning flash with a Resend button. From 640px up the
   text and the button share one row; on a phone the button sits under the text, lined up with it. */
.main > .flash { margin-bottom: 16px; }
.flash:has(> form.inline) { align-items: center; }
.flash:has(> form.inline) > .i { margin-top: 0; }
.flash > form.inline { flex: none; }
@media (max-width: 639.98px) {
  .flash:has(> form.inline) { flex-wrap: wrap; align-items: flex-start; row-gap: 8px; }
  .flash:has(> form.inline) > .i { margin-top: 2px; }
  .flash > form.inline { flex: 1 1 100%; padding-left: 26px; }  /* 16px icon + 10px gap */
}
/* the flash close button: a 44px hit box on touch screens, same look (the negative margin keeps the row height) */
@media (pointer: coarse) {
  .flash .flash-close { width: 44px; height: 44px; margin: -12px -12px -12px auto; }
}

.callout {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--warning-line);
  border-radius: var(--radius-lg);
  background: var(--warning-soft);
  color: var(--ink);
}
.callout-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--warning) 16%, transparent);
  color: var(--warning-ink);
}
.callout-icon .i { width: 18px; height: 18px; }
.callout-body { flex: 1; min-width: 0; }
.callout-body strong { display: block; margin-bottom: 2px; }
/* a bold date or name inside a sentence stays inline; only a bold heading line of the callout is a block */
.callout-body p > strong { display: inline; margin: 0; }
.callout ul { margin: 6px 0 0; padding-left: 18px; color: var(--ink-2); }
.callout li + li { margin-top: 2px; }
.callout-warning { border-color: var(--warning-line); background: var(--warning-soft); }
.callout-info { border-color: var(--info-line); background: var(--info-soft); }
.callout-info .callout-icon { background: color-mix(in srgb, var(--info) 14%, transparent); color: var(--info-ink); }
.callout-critical { border-color: var(--critical-line); background: var(--critical-soft); }
.callout-critical .callout-icon { background: color-mix(in srgb, var(--critical) 14%, transparent); color: var(--critical-ink); }
.callout-good { border-color: var(--good-line); background: var(--good-soft); }
.callout-good .callout-icon { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good-ink); }
.callout-muted { border-color: var(--border); background: var(--surface-2); }
.callout-muted .callout-icon { background: var(--surface-3); color: var(--muted); }

/* -- marks: airline initials, provider tiles ---------------------------------------------- */
.airline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.airline-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.02em;
}
.provider-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  color: var(--ink-2);
}
.provider-mark .i, .provider-mark .brand-logo { width: 18px; height: 18px; }
.provider-mark.small { width: 24px; height: 24px; border-radius: 6px; }
.provider-mark.small .i, .provider-mark.small .brand-logo { width: 14px; height: 14px; }
.provider-demo { border-color: var(--violet-line); background: var(--violet-soft); color: var(--violet-ink); }
.provider-imap { border-color: var(--info-line); background: var(--accent-soft); color: var(--accent-soft-ink); }
.provider-upload { border-color: var(--info-line); background: var(--accent-soft); color: var(--accent-soft-ink); }

/* -- column picker (reports: choose and order the Excel columns) -------------------------- */
.colpick { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.colpick-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}
.colpick-legend .i { width: 16px; height: 16px; color: var(--muted); }
.colpick-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 8px; }
.colpick-find { flex: 1 1 160px; min-width: 0; max-width: 260px; }
.colpick-count {
  margin-right: auto;
  color: var(--muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}
.colpick-list {
  max-height: 440px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.colpick-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--hairline);
}
.colpick-item:last-child { border-bottom: 0; }
.colpick-item[hidden] { display: none; }
@media (hover: hover) and (pointer: fine) {
  .colpick-item:hover { background: var(--row-hover); }
}
.colpick-item .check { flex: 1; min-width: 0; align-items: center; padding: 8px 0; }
.colpick-item .check input[type="checkbox"] { margin: 0; }
.colpick-item .check span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.colpick-item:has(input:not(:checked)) .check span { color: var(--muted); font-weight: var(--weight-regular); }
.colpick-group {
  flex: none;
  color: var(--muted);
  font-size: var(--text-2xs);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  white-space: nowrap;
  margin-left: auto;
}
.colpick-move .icon-btn { width: 26px; height: 26px; }
.colpick-move .icon-btn .i { width: 16px; height: 16px; }
@media (pointer: coarse) {
  .colpick-move .icon-btn { width: 44px; height: 44px; }
}
/* the reorder buttons, the search box, the Excel-order note and the bar's buttons need the script (app.js) */
.colpick-move, .colpick-js, .colpick-bar .btn, .colpick-find { display: none; }
.colpick[data-ready] .colpick-move { display: inline-flex; flex: none; }
.colpick[data-ready] .colpick-js { display: inline; }
.colpick[data-ready] .colpick-bar .btn { display: inline-flex; }
.colpick[data-ready] .colpick-find { display: block; }
@media (max-width: 639.98px) {
  .colpick-group { display: none; }
}
