:root {
  /* ALTN official palette (Brand Standards, Feb 2024, p.9) */
  --altn-lyons: #015871;     /* Lyons Blue */
  --altn-mandarin: #EC6A37;  /* Mandarin Orange */
  --altn-jasmine: #7FC844;   /* Jasmine Green */
  --altn-blithe: #0084BD;    /* Blithe */
  --altn-atlantis: #00AF9F;  /* Atlantis */
  --altn-abundant: #006339;  /* Abundant Green */
  --altn-scuba: #00ABC0;     /* Scuba Blue */
  --altn-mosaic: #00758F;    /* Mosaic Blue */
  --altn-ink: #0B5369;       /* Ink Blue */
  --bg: var(--altn-ink);
  --panel: #ffffff;
  --ink: #1a2230;
  --muted: #6b7684;
  --line: #e4e8ee;
  --brand: var(--altn-lyons);
  --brand-dark: var(--altn-ink);
  --accent: var(--altn-blithe);
  --accent-dark: var(--altn-mosaic);
  --accent-bg: rgba(0, 132, 189, 0.10);
  --brand-bg: rgba(1, 88, 113, 0.07);
  --brand-line: rgba(1, 88, 113, 0.22);
  /* Errors keep a red: the ALTN palette has no red, and danger vs warning rows rely on color. */
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --danger-line: #f3b9b9;
  --success: var(--altn-abundant);
  --success-bg: rgba(0, 99, 57, 0.08);
  --success-line: rgba(0, 99, 57, 0.25);
  /* Mandarin Orange is too light for small text on white (3.1:1): use it for borders/fills, ink for text. */
  --warn: var(--altn-mandarin);
  --warn-ink: var(--ink);
  --warn-bg: rgba(236, 106, 55, 0.12);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 8px 24px rgba(16, 24, 40, 0.06);
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: linear-gradient(180deg, #eef2f6 0%, #e7edf3 100%);
  color: var(--ink);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.45;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 24px;
  background: var(--altn-lyons);
  color: #fff; box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { display: block; height: 36px; width: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 16px; }
.brand-sub { font-size: 12px; opacity: .85; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.loc-badge {
  background: #fff; color: var(--altn-lyons); font-weight: 700;
  padding: 4px 12px; border-radius: 999px; font-size: 13px;
}
.demo-tag {
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  opacity: .8; border: 1px solid rgba(255,255,255,.4); padding: 3px 8px; border-radius: 999px;
}

/* ---------- Step tracker ---------- */
.steps {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  padding: 14px 24px; max-width: 1100px; margin: 0 auto;
}
.step {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; color: var(--muted);
}
.step .dot {
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  background: var(--line); color: #fff; font-size: 11px; font-weight: 700;
}
.step.done { color: var(--ink); border-color: var(--success); }
.step.done .dot { background: var(--success); }
.step.active { color: var(--ink); border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,132,189,.15); }
.step.active .dot { background: var(--accent); }

/* ---------- Layout / cards ---------- */
.layout {
  max-width: 1100px; margin: 0 auto; padding: 8px 20px 60px;
  display: grid; gap: 20px;
}
.card {
  background: var(--panel); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; border: 1px solid var(--line);
}
.card-head { padding: 20px 24px 10px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0 0 4px; font-size: 19px; display: flex; align-items: center; gap: 10px; }
.card-head p { margin: 0; color: var(--muted); font-size: 13.5px; max-width: 760px; }
.num {
  display: inline-grid; place-items: center; width: 28px; height: 28px;
  border-radius: 8px; background: var(--brand); color: #fff; font-size: 15px;
}
.card-body { padding: 18px 24px 24px; }
.subhead { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 22px 0 10px; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: 10px;
  padding: 10px 16px; cursor: pointer; transition: transform .05s, filter .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--altn-mosaic); color: #fff; } /* Mosaic, not Blithe: white on Blithe is 4.2:1 (< WCAG AA 4.5) */
.btn-primary:hover { background: var(--altn-ink); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--altn-ink); }
.btn-success:disabled { background: rgba(0, 99, 57, 0.35); cursor: not-allowed; filter: none; }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.5); color: inherit; }
.card .btn-ghost { border-color: var(--line); color: var(--ink); background: #fff; }
.btn-small { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

/* ---------- Part 1 ---------- */
.feed-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: #f6f9fb; border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; flex-wrap: wrap;
}
.stat { display: flex; flex-direction: column; }
.stat-num { font-size: 32px; font-weight: 800; color: var(--brand); line-height: 1; }
.stat-label { font-size: 13px; color: var(--muted); }
.import-summary { margin: 14px 0 0; display: flex; gap: 10px; flex-wrap: wrap; }
.pill { font-size: 12.5px; padding: 5px 11px; border-radius: 999px; font-weight: 600; }
.pill.success { background: var(--success-bg); color: var(--success); }
.pill.duplicate { background: var(--warn-bg); color: var(--warn-ink); box-shadow: inset 0 0 0 1px var(--warn); }
.pill.failure { background: var(--danger-bg); color: var(--danger); }
.pill.rejected { background: var(--line); color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th, .data-table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table th { background: #f6f9fb; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.row-failure { background: var(--danger-bg); }
.data-table tr.row-duplicate { background: var(--warn-bg); }
.data-table tr.row-rejected { background: var(--line); color: var(--muted); }
.data-table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.empty { color: var(--muted); font-style: italic; padding: 16px; text-align: center; }

.badge { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .4px; }
.badge.success { background: var(--success-bg); color: var(--success); }
.badge.duplicate { background: var(--warn-bg); color: var(--warn-ink); box-shadow: inset 0 0 0 1px var(--warn); }
.badge.failure { background: var(--danger-bg); color: var(--danger); }
.badge.rejected { background: var(--line); color: var(--muted); }

/* ---------- Part 2 cash ---------- */
.cash-grid { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(300px, 1.1fr); gap: 28px; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); flex: 1; }
select, input, textarea {
  font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--ink); font-weight: 500;
}
select:focus, input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.denoms { display: grid; gap: 7px; margin: 16px 0; }
.denom {
  display: grid; grid-template-columns: 1fr 86px 92px; align-items: center; gap: 10px;
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfe;
}
.denom .d-label { font-size: 13.5px; font-weight: 600; }
.denom input { width: 100%; text-align: right; padding: 7px 9px; }
.denom .d-amount { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13.5px; }
.cash-total {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; background: var(--brand-bg); border: 1px solid var(--brand-line); border-radius: 10px; margin-bottom: 14px;
  font-weight: 700;
}
.cash-total .money { font-size: 22px; color: var(--brand-dark); font-variant-numeric: tabular-nums; }
.entry-list { display: flex; flex-direction: column; gap: 10px; max-height: 520px; overflow-y: auto; }
.entry {
  border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; background: #fff;
}
.entry.correction { border-left: 4px solid var(--warn); }
.entry-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.entry-type { font-weight: 700; text-transform: capitalize; }
.entry-type .tag { font-size: 11px; font-weight: 700; margin-left: 6px; padding: 2px 7px; border-radius: 999px; }
.tag.open { background: var(--accent-bg); color: var(--altn-lyons); }
.tag.close { background: var(--brand-bg); color: var(--altn-ink); box-shadow: inset 0 0 0 1px var(--brand-line); }
.entry .amt { font-weight: 800; color: var(--brand-dark); font-variant-numeric: tabular-nums; }
.entry .meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.entry .link-note { font-size: 12px; color: var(--warn-ink); margin-top: 4px; }
.entry .counts { font-size: 12px; color: var(--muted); margin-top: 6px; font-family: ui-monospace, monospace; }
.lock { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: 0; text-transform: none; }

/* ---------- Part 3 closeout ---------- */
.closeout-summary { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.c-stat { flex: 1; min-width: 120px; border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; background: #fbfcfe; }
.c-stat .n { font-size: 26px; font-weight: 800; line-height: 1; }
.c-stat .l { font-size: 12px; color: var(--muted); }
.c-stat.flagged .n { color: var(--danger); }
.c-stat.paid .n { color: var(--success); }
.flag-list { display: flex; flex-direction: column; gap: 10px; }
.flag {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--danger); background: var(--danger-bg);
}
.flag.resolved { border-color: var(--success-line); background: var(--success-bg); }
.flag .flag-icon { font-size: 22px; }
.flag .flag-body { flex: 1; }
.flag .flag-msg { font-weight: 600; }
.flag .flag-expl { font-size: 12.5px; color: var(--altn-abundant); margin-top: 4px; }
.flag .flag-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.flag .resolved-tag { font-size: 12px; font-weight: 700; color: var(--success); }
.all-clear { padding: 18px; text-align: center; background: var(--success-bg); border: 1px solid var(--success-line); border-radius: 12px; color: var(--altn-abundant); font-weight: 600; }
.finalize-bar { display: flex; align-items: flex-end; gap: 14px; margin-top: 18px; flex-wrap: wrap; }
.finalize-bar label { flex: 0 0 200px; }

.hint { font-size: 13px; margin: 10px 0 0; min-height: 18px; }
.hint.error { color: var(--danger); }
.hint.ok { color: var(--success); }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(11,83,105,.55); display: grid; place-items: center; z-index: 50; padding: 16px;
}
.modal { background: #fff; border-radius: 16px; padding: 24px; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 6px; }
.modal-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; }
.modal label { margin-bottom: 14px; color: var(--ink); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px;
  box-shadow: var(--shadow); z-index: 60; font-size: 14px; max-width: 90vw;
}
.toast.err { background: var(--danger); }

.footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 0 20px 30px; }

@media (max-width: 760px) {
  .cash-grid { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
  .topbar { padding: 12px 14px; flex-wrap: wrap; }
  .topbar-right, .auth-in { flex-wrap: wrap; }
  .layout { padding: 8px 12px 50px; }
}

/* ---------- Part 4: forensic look-back (PHI-safe) ---------- */
.phi-safe {
  display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px; vertical-align: middle;
  color: var(--success); background: var(--success-bg);
  padding: 3px 9px; border-radius: 999px;
}
.period-list { display: flex; flex-direction: column; gap: 10px; }
.period-total {
  font-size: 14px; color: var(--ink); padding: 10px 14px; margin-bottom: 4px;
  background: #fbfcfe; border: 1px solid var(--line); border-radius: 11px;
}
.period { border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; background: #fff; }
.period-head { display: flex; justify-content: space-between; align-items: baseline; }
.period-name { font-weight: 700; font-variant-numeric: tabular-nums; }
.period-head .amt { font-weight: 800; color: var(--brand-dark); font-variant-numeric: tabular-nums; }
.period-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- Phase B1: auth bar, roles, ledger integrity, audit ---------- */
.authbar { display: flex; align-items: center; }
.auth-out { display: flex; align-items: center; gap: 6px; }
.auth-out select, .auth-out input {
  font-size: 13px; padding: 6px 8px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink);
}
.auth-out input { width: 78px; }
.auth-in { display: flex; align-items: center; gap: 8px; }
.auth-in .who { font-size: 13px; color: var(--ink); }
.topbar .auth-in .who { color: #fff; }
.role-tag {
  display: inline-block; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; padding: 2px 7px; border-radius: 999px; vertical-align: middle;
}
.role-tag.manager { color: var(--altn-lyons); background: #fff; box-shadow: inset 0 0 0 1px var(--altn-lyons); }
.role-tag.staff { color: var(--altn-ink); background: var(--accent-bg); }

.ledger-status {
  font-size: 14px; color: var(--ink); padding: 10px 14px; margin-bottom: 12px;
  background: #fbfcfe; border: 1px solid var(--line); border-radius: 11px;
}
.ledger-status.ok { background: var(--success-bg); border-color: var(--success-line); }
.ledger-status.bad { background: var(--danger-bg); border-color: var(--danger-line); }
.led-badge {
  display: inline-block; font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .5px; padding: 3px 9px; border-radius: 999px; margin-right: 8px;
}
.led-badge.ok { color: var(--success); background: #fff; }
.led-badge.bad { color: var(--danger); background: #fff; }
.led-badge.neutral { color: var(--muted); background: #fff; }
.ledger-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.ledger-bar .headhash { color: var(--muted); font-size: 12px; }
.hashcell { font-size: 12px; color: var(--brand-dark); }
.corr-note { display: block; color: var(--muted); font-size: 11px; }

@media (max-width: 760px) {
  .auth-out input { width: 60px; }
  .demo-tag { display: none; }
}

/* Phase B2 — Poynt card-batch + amber near-miss tables */
#poyntTable td .flag-expl,
#amberTable td { font-size: 13px; }
#poyntTable .money, #amberTable .money { white-space: nowrap; }
#amberTable td:last-child { white-space: nowrap; }
#amberTable td:last-child .btn + .btn { margin-left: 6px; }
#poyntTable .flag-expl { margin-top: 4px; color: var(--muted); font-style: italic; }

/* Phase B3 — three-way agreement badge + Daily Close Report */
.tw-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; justify-content: space-between; margin-bottom: 16px; }
.tw-bar label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.tw-bar select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; min-width: 280px; }
.tw-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.daily-report { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; background: #fff; }
.report-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 2px solid var(--line); padding-bottom: 14px; margin-bottom: 14px; }
.report-title { font-size: 22px; font-weight: 800; color: var(--ink); }
.report-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.demo-tag2 { font-style: italic; }

.tw-badge { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px; font-weight: 800; font-size: 15px; border: 2px solid; }
.tw-badge .tw-icon { font-size: 18px; line-height: 1; }
.tw-badge.agreed { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.tw-badge.blocked { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.tw-badge.unverified { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn); }
.tw-badge.neutral { background: #eef2f6; color: var(--muted); border-color: var(--line); }

.tw-legs { display: grid; gap: 8px; margin-bottom: 8px; }
.tw-leg { padding: 8px 12px; border-radius: 8px; font-size: 14px; border-left: 4px solid var(--line); background: #f8fafc; }
.tw-leg .leg-ico { font-weight: 800; margin-right: 6px; }
.tw-leg .leg-meta { color: var(--muted); font-size: 12px; margin-left: 6px; }
.tw-leg.ok { border-left-color: var(--success); }
.tw-leg.bad { border-left-color: var(--danger); }
.tw-leg.warn { border-left-color: var(--warn); }
.tw-leg.neutral { border-left-color: var(--line); }

.report-section { margin-top: 16px; }
.report-section h4 { margin: 0 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .4px; color: var(--brand-dark); }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 10px; }
.report-grid > div { display: flex; flex-direction: column; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.report-grid .l { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .3px; }
.report-grid .v { font-size: 16px; font-weight: 700; }
.blocker-list { margin: 0; padding-left: 18px; }
.blocker-list li { margin: 4px 0; font-size: 14px; }
.data-table.mini th, .data-table.mini td { padding: 5px 8px; font-size: 13px; }
.report-note { margin-top: 14px; font-size: 13px; color: var(--muted); font-style: italic; background: var(--warn-bg); border-radius: 8px; padding: 8px 12px; }
.report-foot { margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--muted); }

/* Print: show ONLY the Daily Close Report, cleanly. */
@media print {
  body { background: #fff; font-size: 12px; }
  body * { visibility: hidden; }
  #dailyReport, #dailyReport * { visibility: visible; }
  #dailyReport { position: absolute; left: 0; top: 0; width: 100%; border: none; padding: 0; }
  .daily-report { box-shadow: none; }
  .tw-badge { border-width: 1px; }
  .report-section, .tw-leg, .report-grid > div { break-inside: avoid; }
  .report-foot { color: #444; }
}

/* Fix: make the hidden attribute win over display rules (modals were stuck open). */
[hidden] { display: none !important; }
