* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f5f5f7;
  --panel: #ffffff;
  --border: #e3e3e6;
  --hairline: #ededf0;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --primary: #0071e3;
  --primary-dark: #0059b8;
  --navy: rgba(29,29,31,.82);
  --navy-solid: #1d1d1f;
  --accent: #0a84ff;
  --danger: #d70015;
  --amber: #b25000;
  --green: #248a3d;
  --field: #ffffff;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.03);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.20), 0 2px 8px rgba(0,0,0,.08);
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.47;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

/* ---------- Top navigation (frosted, macOS-style) ---------- */
.topbar {
  background: var(--navy);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  color: #f5f5f7;
  display: flex; align-items: center; flex-wrap: wrap;
  padding: 0 20px; min-height: 48px; gap: 2px;
  position: sticky; top: 0; z-index: 40;
}
.topbar .brand {
  font-size: 15px; font-weight: 600; margin-right: 22px; white-space: nowrap;
  letter-spacing: -0.02em; color: #fff;
}
.topbar .brand small {
  display: block; font-size: 10px; font-weight: 400; color: #a1a1a6;
  margin-top: -3px; letter-spacing: 0;
}
.nav-btn {
  background: none; border: none; color: #d2d2d7; padding: 0 13px; height: 48px;
  font-size: 13.5px; cursor: pointer; white-space: nowrap;
  font-family: inherit; letter-spacing: -0.01em;
  border-bottom: 2px solid transparent; transition: color .18s ease;
}
.nav-btn:hover { color: #fff; }
.nav-btn.active { color: #fff; font-weight: 600; border-bottom-color: var(--accent); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-right select {
  background: rgba(255,255,255,.14); color: #fff; border: none;
  border-radius: 7px; padding: 5px 9px; font-size: 12.5px; max-width: 180px;
  font-family: inherit; -webkit-appearance: none; appearance: none;
}
.topbar-right select option { color: #1d1d1f; }
.muted-light { color: #a1a1a6; font-size: 12.5px; white-space: nowrap; }

.main { padding: 26px 30px 60px; max-width: 1260px; margin: 0 auto; }
.page-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-title h2 { font-size: 27px; font-weight: 600; letter-spacing: -0.025em; }

/* ---------- Segmented sub-tabs ---------- */
.subtabs {
  display: inline-flex; gap: 2px; margin-bottom: 18px; flex-wrap: wrap;
  background: rgba(120,120,128,.10); padding: 3px; border-radius: 10px;
}
.subtab {
  background: none; border: none; padding: 6px 15px; font-size: 13px; cursor: pointer;
  color: var(--text); border-radius: 7px; font-family: inherit; letter-spacing: -0.01em;
  transition: background .18s ease, box-shadow .18s ease;
}
.subtab:hover { color: #000; }
.subtab.active { background: var(--field); font-weight: 600; box-shadow: var(--shadow-sm); }

/* ---------- Cards ---------- */
.card {
  background: var(--panel); border: none; border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow-sm);
}
.cards-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: none; border-radius: var(--radius);
  padding: 16px 18px; min-width: 168px; flex: 1; box-shadow: var(--shadow-sm);
}
.stat .label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 500; }
.stat .value { font-size: 25px; font-weight: 600; margin-top: 5px; letter-spacing: -0.025em; }
.stat .value.neg { color: var(--danger); }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
@media (max-width: 900px) { .panel-grid { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: none; border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow-sm); }
.panel h4 { font-size: 15px; margin-bottom: 12px; font-weight: 600; letter-spacing: -0.015em; }
.panel .big { font-size: 30px; font-weight: 600; letter-spacing: -0.03em; }
.panel .row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--hairline); font-size: 13px; }
.panel .row:last-child { border-bottom: none; }
.panel .row .bad { color: var(--danger); font-weight: 600; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; background: transparent; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .045em;
  color: var(--muted); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--border);
}
td { padding: 11px 12px; border-bottom: 1px solid var(--hairline); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: color-mix(in srgb, var(--primary) 3.5%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 600; border-top: 1px solid var(--border); background: rgba(120,120,128,.06); }
tr.total:hover td { background: rgba(120,120,128,.09); }
.clickable { cursor: pointer; }
.clickable:hover { color: var(--primary); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- Buttons ---------- */
.btn {
  background: var(--primary); color: #fff; border: none; border-radius: 980px;
  padding: 8px 17px; font-size: 13px; font-weight: 500; cursor: pointer;
  font-family: inherit; letter-spacing: -0.01em;
  transition: background .18s ease, transform .1s ease;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(.97); }
.btn.secondary { background: rgba(120,120,128,.10); color: var(--text); }
.btn.secondary:hover { background: rgba(120,120,128,.17); }
.btn.danger { background: rgba(215,0,21,.09); color: var(--danger); }
.btn.danger:hover { background: rgba(215,0,21,.16); }
.btn.green { background: var(--green); }
.btn.green:hover { background: #1c6f31; }
.btn.small { padding: 4px 11px; font-size: 12px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 2.5px 9px; border-radius: 980px;
  font-size: 11px; font-weight: 500; letter-spacing: 0; text-transform: none;
}
.badge.paid, .badge.applied, .badge.accepted, .badge.reconciled { background: rgba(36,138,61,.12); color: var(--green); }
.badge.awaiting, .badge.open { background: color-mix(in srgb, var(--primary) 11%, transparent); color: var(--primary); }
.badge.overdue, .badge.declined { background: rgba(215,0,21,.10); color: var(--danger); }
.badge.partial, .badge.unapplied, .badge.low { background: rgba(178,80,0,.12); color: var(--amber); }
.badge.draft { background: rgba(120,120,128,.14); color: var(--muted); }
.badge.invoiced { background: rgba(94,92,230,.12); color: #5e5ce6; }

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.42);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 44px 18px; overflow-y: auto; z-index: 50;
}
.modal {
  background: var(--panel); border-radius: 18px; padding: 26px 28px; width: 100%;
  max-width: 560px; box-shadow: var(--shadow-lg);
}
.modal.wide { max-width: 900px; }
.modal h3 { margin-bottom: 18px; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
label.fld { display: block; font-size: 12px; color: var(--muted); font-weight: 500; letter-spacing: -0.005em; }
label.fld input, label.fld select, label.fld textarea {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; background: var(--field); color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
label.fld input:focus, label.fld select:focus, label.fld textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--primary) 16%, transparent);
}
label.fld input[readonly] { background: rgba(120,120,128,.07); color: var(--muted); }
/* fast date entry: text the parser could not turn into a real date */
input.date-bad, input.date-bad:focus {
  border-color: var(--danger) !important; box-shadow: 0 0 0 3px rgba(215,0,21,.14) !important;
}
input[data-fastdate] { font-variant-numeric: tabular-nums; }

/* ---------- Code lookup boxes ---------- */
input[data-combo-for] {
  width: 100%;
  padding-right: 26px !important;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M1 1l4 4 4-4' fill='none' stroke='%236e6e73' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 9px center;
  text-overflow: ellipsis;
}
input[data-combo-for]:disabled { background-color: rgba(120,120,128,.07); color: var(--muted); }
.combo-list {
  position: fixed; z-index: 1000; background: var(--field); border-radius: 11px;
  box-shadow: 0 14px 36px rgba(0,0,0,.18), 0 0 0 1px rgba(0,0,0,.06);
  max-height: 290px; overflow-y: auto; padding: 4px; font-size: 13px; max-width: min(520px, 94vw);
}
.combo-item { display: flex; gap: 12px; align-items: baseline; padding: 6px 10px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.combo-item:hover { background: rgba(120,120,128,.08); }
.combo-item.hi { background: color-mix(in srgb, var(--primary) 13%, transparent); }
.combo-code { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 56px; color: var(--text); }
.combo-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.combo-empty { padding: 8px 10px; color: var(--muted); }

/* ---------- Right-click options menu ---------- */
.ctx-menu {
  position: fixed; z-index: 1100; min-width: 220px; max-width: 320px; background: var(--field);
  border-radius: 11px; padding: 5px; font-size: 13.5px;
  box-shadow: 0 14px 36px rgba(0,0,0,.18), 0 0 0 1px rgba(0,0,0,.06);
}
.ctx-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%;
  border: none; background: none; text-align: left; padding: 6px 11px; border-radius: 7px;
  cursor: pointer; font-family: inherit; font-size: inherit; color: var(--text);
}
.ctx-item:not(:disabled):hover, .ctx-item:not(:disabled):focus { background: var(--primary); color: #fff; outline: none; }
.ctx-item:disabled { color: #aeaeb2; cursor: default; }
.ctx-item small { font-size: 11.5px; color: var(--muted); }
.ctx-sep { height: 1px; background: var(--hairline); margin: 4px 8px; }
tr.ctx-row td { background: color-mix(in srgb, var(--primary) 10%, transparent) !important; }

/* Debtors / Creditors "every line" ledger */
tr.lg-ent td { background: rgba(120,120,128,.07); padding-top: 9px; padding-bottom: 9px; }
tr.lg-open td { color: var(--muted); }
tr.lg-sub td { border-top: 1px solid var(--border); font-weight: 500; }
tr.lg-sub:hover td { background: transparent; }
label.fld textarea { min-height: 70px; resize: vertical; }
label.chk { font-size: 13.5px; display: flex; align-items: center; gap: 7px; margin-top: 8px; cursor: pointer; }
label.chk input { accent-color: var(--primary); width: 15px; height: 15px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; flex-wrap: wrap; }
.err { color: var(--danger); font-size: 13px; margin-top: 12px; display: none; }

.lines-table input, .lines-table select {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: 7px; font-size: 13px; font-family: inherit; background: var(--field);
}
.lines-table input:focus, .lines-table select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}
.lines-table td { padding: 5px 6px; }
.lines-table th { padding: 6px; }

.filter-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px; }
.filter-row label.fld { min-width: 145px; }
.muted { color: var(--muted); }
.right { text-align: right; }
h4.section { margin: 18px 0 10px; font-size: 15px; font-weight: 600; letter-spacing: -0.015em; }
hr { border: none; border-top: 1px solid var(--hairline); }

/* ---------- Chart ---------- */
.chart-bars { display: flex; align-items: flex-end; gap: 14px; height: 152px; padding: 8px 4px 0; }
.chart-month { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.chart-pair { display: flex; gap: 4px; align-items: flex-end; height: 120px; }
.chart-bar { width: 20px; border-radius: 5px 5px 2px 2px; min-height: 2px; }
.chart-bar.in { background: var(--accent); }
.chart-bar.out { background: #c7c7cc; }
.chart-label { font-size: 11px; color: var(--muted); }
.chart-legend { display: flex; gap: 18px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.chart-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.drop-note { border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 16px; text-align: center; color: var(--muted); }

/* ---------- Auth ---------- */
.auth-wrap { max-width: 400px; margin: 90px auto; }
.auth-wrap .card { padding: 32px; border-radius: 18px; box-shadow: var(--shadow-sm); }
.auth-wrap h2 { margin-bottom: 4px; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.auth-wrap p.muted { margin-bottom: 20px; }
.auth-wrap label.fld { margin-bottom: 14px; }

/* ---------- Wide matrices ---------- */
table.matrix th, table.matrix td { font-size: 12px; padding: 6px 8px; white-space: nowrap; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: rgba(120,120,128,.32); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(120,120,128,.5); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

@media print {
  .topbar, .page-title .btn, .subtabs, .filter-row, .no-print { display: none !important; }
  .main { padding: 0; max-width: none; }
  body { background: #fff; }
  .card { border: none; padding: 0; box-shadow: none; }
  table.matrix th, table.matrix td { font-size: 9px; padding: 3px 4px; }
}

/* Find & Recode: each entry shows all of its debit and credit lines */
tr.rc-first td { border-top: 1px solid var(--border); }
tr.rc-more td { border-top: none; }
tr.rc-match td:nth-child(5) { font-weight: 600; }

/* Tax invoice details on the invoice screen */
.tax-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-top: 16px;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; font-size: 13px; line-height: 1.5; }
.tax-col { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.tax-h { font-size: 11px; text-transform: uppercase; letter-spacing: .045em; color: var(--muted); font-weight: 600; }
.tax-col textarea { width: 100%; resize: vertical; }
.tax-miss { color: var(--danger); }
.tax-status { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }

a.btn { text-decoration: none; display: inline-block; }

/* ---------- Invoice-style capture screen ---------- */
.modal.inv-modal { max-width: 1120px; padding: 18px 20px 16px; }
.inv-doc { border: 1px solid var(--border); border-top: 6px solid var(--brand); border-radius: 10px; padding: 16px 18px 14px;
  display: flex; flex-direction: column; gap: 12px; font-size: 13px; }
.inv-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.inv-co { display: flex; gap: 14px; align-items: flex-start; min-width: 0; flex: 1 1 320px; }
.inv-logo { max-height: 72px; max-width: 190px; object-fit: contain; }
.inv-logo-ph { width: 120px; height: 60px; border: 1px dashed var(--border); border-radius: 8px; color: var(--muted);
  font-size: 11px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 6px; flex: none; }
.inv-co-text { display: flex; flex-direction: column; line-height: 1.45; color: var(--muted); font-size: 12px; min-width: 0; }
.inv-co-text strong { font-size: 16px; color: var(--text, inherit); letter-spacing: -0.01em; }
.inv-title { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.inv-word { font-size: 24px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--brand); line-height: 1.1; }
.inv-meta { display: grid; grid-template-columns: auto 150px; gap: 4px 10px; align-items: center; font-size: 12px; color: var(--muted); }
.inv-meta strong { color: var(--text, inherit); }
.inv-doc input:not([type=checkbox]), .inv-doc select, .inv-doc textarea {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 7px; font: inherit; font-size: 13px; background: var(--field); }
.inv-doc input:focus, .inv-doc select:focus, .inv-doc textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }
.inv-doc textarea { resize: vertical; min-height: 0; }
.inv-doc input.num { text-align: right; }
.inv-doc input[type=number]::-webkit-outer-spin-button, .inv-doc input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.inv-doc input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding-top: 10px; border-top: 1px solid var(--border); }
.inv-party { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.inv-lines thead th { background: var(--head, var(--brand)); color: var(--brand-text); border: none; padding: 7px 6px; }
.inv-lines thead th:first-child { border-radius: 6px 0 0 6px; }
.inv-lines thead th:last-child { border-radius: 0 6px 6px 0; }
.inv-lines td { padding: 3px 4px; border-bottom: 1px solid var(--border); }
.inv-lines td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.inv-doc.one-store .lStoreCell { display: none; }
.inv-foot { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.inv-foot-left { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; flex: 1 1 320px; min-width: 0; }
.inv-bank { font-size: 12px; color: var(--muted); line-height: 1.45; }
.inv-totals td:first-child { white-space: nowrap; }
.inv-totals tr.alloc-row td { color: var(--muted); font-size: 11.5px; padding-top: 2px; padding-bottom: 2px; white-space: nowrap; }
.inv-totals tr.alloc-row.alloc-last td { border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.inv-foot-left > .inv-bank { font-size: 14px; color: var(--text); }
.inv-totals { width: 280px; border-collapse: collapse; }
.inv-totals td { padding: 4px 8px; border: none; }
.inv-totals td.num { text-align: right; font-variant-numeric: tabular-nums; }
.inv-totals tr.grand td { font-weight: 800; font-size: 16px; color: var(--brand); border-top: 2px solid var(--brand); }
.inv-modal .modal-actions { margin-top: 12px; }
@media (max-width: 700px) { .inv-parties { grid-template-columns: 1fr; } .inv-title { align-items: flex-start; } .inv-word { text-align: left; } }

/* Settings: logo + brand colour */
.brand-row { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.brand-row > div { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.brand-logo img { max-height: 80px; max-width: 260px; border: 1px solid var(--border); border-radius: 8px; padding: 6px; background: #fff; }

.print-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; }
@media (max-width: 560px) { .print-opts { grid-template-columns: 1fr; } }

/* ---------- Document layout: two rows of three positions, editable by drag and drop ---------- */
.inv-layout { display: flex; flex-direction: column; gap: 10px; }
.inv-row { display: flex; gap: 18px; align-items: flex-start; }
.inv-row + .inv-row { padding-top: 10px; border-top: 1px solid var(--border); }
.inv-slot { flex: 1 1 0; min-width: 0; }
.inv-slot.slot-logo { flex: 0 0 auto; }
.inv-slot.slot-empty { display: none; }
.inv-slot.slot-empty.slot-gap { display: block; }
.inv-slot[data-col="3"] .inv-title { align-items: flex-end; }
.inv-slot[data-col="3"] .inv-word { text-align: right; }
.lay-bar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 10px 12px; margin-bottom: 10px;
  border-radius: 10px; background: color-mix(in srgb, var(--primary) 8%, transparent); font-size: 13px; }
.lay-bar label { display: flex; align-items: center; gap: 6px; }
.lay-bar input[type=color] { width: 34px; height: 26px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; }
.lay-btns { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.lay-editing .inv-slot, .lay-editing .inv-slot.slot-logo { display: block; flex: 1 1 0; min-height: 64px; padding: 6px;
  border: 1.5px dashed var(--border); border-radius: 10px; }
.lay-editing .inv-slot.slot-empty::before { content: 'Empty position'; color: var(--muted); font-size: 12px; }
.lay-editing .inv-slot.drop-over { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 7%, transparent); }
.lay-editing .inv-block { cursor: grab; border-radius: 8px; }
.lay-editing .inv-block:hover { outline: 2px solid var(--primary); outline-offset: 3px; }
.lay-editing .inv-block.dragging { opacity: .45; }
.lay-editing .inv-block * { pointer-events: none; }

@media (max-width: 700px) { .inv-row { flex-wrap: wrap; } .inv-slot { flex-basis: 100%; } }

/* ---------- Free placement of the top blocks ---------- */
.inv-layout.inv-canvas { display: block; position: relative; }
.inv-canvas .inv-block[data-block="logo"] .inv-logo { width: 100%; max-width: none; max-height: none; height: auto; display: block; }
.inv-canvas .inv-block[data-block="logo"] .inv-logo-ph { width: 100%; }
.blk-right .inv-title { align-items: flex-end; }
.blk-right .inv-word { text-align: right; }
.lay-editing .inv-canvas { outline: 1.5px dashed var(--border); outline-offset: 6px; border-radius: 6px;
  background-image: linear-gradient(to right, rgba(0,0,0,.04) 1px, transparent 1px); background-size: 5% 100%; }
.lay-editing .inv-canvas .inv-block { outline: 1.5px dashed var(--primary); outline-offset: 3px; min-height: 26px;
  touch-action: none; user-select: none; background: rgba(255,255,255,.75); }
.lay-editing .inv-block.dragging { cursor: grabbing; }
.lay-editing .inv-block .blk-handle { pointer-events: auto; position: absolute; right: -8px; bottom: -8px; width: 14px; height: 14px;
  background: var(--primary); border: 2px solid #fff; border-radius: 4px; cursor: nwse-resize; }

/* ---------- Print / PDF / Excel / Email buttons ---------- */
.share-bar { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.page-title .share-bar { margin-left: auto; }
.page-title .share-bar + * { margin-left: 0; }
.modal > .share-bar { float: right; margin: 0 0 8px 12px; }

/* ---------- Every block of the document is a movable, resizable block ---------- */
.inv-foot > .inv-block[data-block="notes"] { flex: 1 1 320px; min-width: 0; }
.inv-canvas .inv-totals { width: 100%; }
.inv-canvas .inv-meta { grid-template-columns: auto 1fr; }
.inv-canvas .inv-foot-left { align-items: stretch; }
.inv-canvas .inv-foot-left > .btn { align-self: flex-start; }
.inv-canvas .inv-block[data-block="lines"] .table-wrap { overflow-x: auto; }

.lay-bar[hidden] { display: none; }

/* ---------- Statement window ---------- */
.stmt-lines { width: 100%; }
.stmt-lines td { padding: 6px 6px; }
.inv-party > span { color: var(--muted); font-size: 12px; }
.stmt-due { font-size: 20px; color: var(--brand); }
.inv-modal > .share-bar { margin-bottom: 10px; }

/* ---------- Read-only document view (quote) ---------- */
.doc-status { margin: 0 0 10px; font-weight: 600; }
.inv-title .inv-meta > span:nth-child(even) { color: var(--text); }
.inv-foot-left > div { font-size: 12.5px; }

.inv-modal > .inv-doc { clear: both; }

/* per-line print tick */
.lPrintCell { width: 44px; text-align: center; }
.inv-doc .lPrintCell input { width: 16px; height: 16px; accent-color: var(--brand); }
tr.line-noprint td { opacity: .55; }

/* ---------- Resizable columns of the lines table (edit layout) ---------- */
.lay-editing .inv-block[data-block="lines"] thead th { position: relative; }
.lay-editing .inv-block .col-handle { pointer-events: auto; position: absolute; top: -2px; bottom: -2px; right: -5px; width: 10px;
  cursor: col-resize; z-index: 2; }
.lay-editing .inv-block .col-handle::after { content: ''; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px;
  background: var(--primary); border-radius: 1px; }
.inv-lines { width: 100%; }
.inv-lines td, .inv-lines th { overflow: hidden; text-overflow: ellipsis; }

/* ---------- Document windows can be resized by dragging the bottom-right corner ---------- */
.modal.inv-modal { width: min(1120px, 100%); min-width: 560px; min-height: 260px; }
.win-reset { display: none; text-align: right; margin-top: 6px; font-size: 11.5px; color: var(--muted); cursor: pointer; padding-right: 14px; }
.win-reset:hover { color: var(--primary); text-decoration: underline; }


/* ---------- Form layout editor (every capture form) ---------- */
.form-grid.fl-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.form-grid.fl-grid > * { min-width: 0; }
.form-grid.fl-grid textarea { width: 100%; }
.fl-bar { margin-bottom: 12px; }
.fl-editing .fl-grid { outline: 1.5px dashed var(--border); outline-offset: 6px; border-radius: 6px;
  background-image: linear-gradient(to right, rgba(0,0,0,.035) 1px, transparent 1px); background-size: calc(100% / 12) 100%; }
.fl-editing .fl-grid > [data-fl-key] { position: relative; outline: 1.5px dashed var(--primary); outline-offset: 3px; border-radius: 6px;
  cursor: grab; touch-action: none; user-select: none; }
.fl-editing .fl-grid > [data-fl-key] * { pointer-events: none; }
.fl-editing .fl-grid > [data-fl-key].fl-dragging { opacity: .5; cursor: grabbing; }
.fl-editing .fl-grid > [data-fl-key] > .fl-handle { pointer-events: auto; position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px;
  background: var(--primary); border: 2px solid #fff; border-radius: 4px; cursor: nwse-resize; z-index: 2; }
.fl-editing .modal-actions { opacity: .4; pointer-events: none; }
@media (max-width: 700px) { .form-grid.fl-grid > * { grid-column: 1 / -1 !important; } }

/* ---------- Entry grids: movable, resizable columns (edit layout) ---------- */
table[data-gl-armed] thead th { position: relative; cursor: grab; outline: 1.5px dashed var(--primary); outline-offset: -2px; user-select: none; touch-action: none; }
table[data-gl-armed] thead th.fl-dragging { opacity: .5; cursor: grabbing; }
table[data-gl-armed] tbody, table[data-gl-armed] tfoot { opacity: .55; pointer-events: none; }
table[data-gl-armed] .col-handle { position: absolute; top: -2px; bottom: -2px; right: -5px; width: 10px; cursor: col-resize; z-index: 2; }
table[data-gl-armed] .col-handle::after { content: ''; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px; background: var(--primary); border-radius: 1px; }
table.lines-table[style*="fixed"] td, table.lines-table[style*="fixed"] th { overflow: hidden; text-overflow: ellipsis; }

/* hidden columns of an entry grid */
table[data-gl] .gl-hidden { display: none; }
table[data-gl-armed] .gl-hidden { display: table-cell; }
table[data-gl-armed] thead th.gl-hidden { opacity: .45; text-decoration: line-through; }
table[data-gl-armed] .col-hide { display: block; margin-top: 3px; font-size: 10px; font-weight: 600; letter-spacing: 0; text-transform: none;
  color: var(--primary); cursor: pointer; text-decoration: none; }
table[data-gl-armed] thead th.gl-hidden .col-hide { text-decoration: none; }

/* hidden columns of a document's lines table */
.inv-doc .col-off { display: none; }
.lay-editing .inv-doc .col-off { display: table-cell; opacity: .4; }
.lay-editing .inv-doc thead th.col-off { text-decoration: line-through; }
.lay-editing .inv-block .col-hide { pointer-events: auto; display: block; margin-top: 3px; font-size: 10px; font-weight: 600; letter-spacing: 0;
  text-transform: none; cursor: pointer; text-decoration: underline; color: inherit; }

/* moving columns of a document's lines table (edit layout) */
.lay-editing .inv-block[data-block="lines"] thead th { pointer-events: auto; cursor: grab; user-select: none; touch-action: none; }
.lay-editing .inv-block[data-block="lines"] thead th.dragging { opacity: .5; cursor: grabbing; }

/* fixed-width report / list tables keep their text inside the column */
table[data-gl][style*="fixed"] td, table[data-gl][style*="fixed"] th { overflow: hidden; text-overflow: ellipsis; }

/* ---------- Dashboard blocks: movable, resizable, hideable ---------- */
.fl-tiles.fl-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.fl-tiles.fl-grid > * { min-width: 0; }
.fl-tiles .fl-off { display: none; }
.fl-editing .fl-tiles .fl-off { display: block; opacity: .4; }
.fl-editing .fl-grid > [data-fl-key] > .fl-hide { pointer-events: auto; position: absolute; top: 6px; right: 10px; font-size: 11px; font-weight: 600;
  color: var(--primary); cursor: pointer; background: var(--panel); padding: 1px 6px; border-radius: 6px; z-index: 2; }
@media (max-width: 900px) { .fl-tiles.fl-grid > * { grid-column: 1 / -1 !important; } }

/* ---------- Dashboard: cards and panels share one 12-column grid ---------- */
.dash-tiles { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.dash-tiles > * { min-width: 0; margin: 0; }
.dash-tiles > .stat { grid-column: span 3; }
.dash-tiles > .panel { grid-column: span 6; }
@media (max-width: 900px) { .dash-tiles > * { grid-column: 1 / -1 !important; } }

/* a label that used to span several columns: let its text run over the empty cells beside it */
td.gl-label { white-space: nowrap; max-width: 0; overflow: visible !important; }

/* ---------- Every window is resizable by its bottom-right corner ---------- */
.modal { resize: both; overflow: auto; width: min(560px, 100%); max-width: none; min-width: 320px; min-height: 140px; position: relative; }
.modal.wide { width: min(900px, 100%); max-width: none; }
.modal.inv-modal { width: min(1120px, 100%); max-width: none; }
.modal.win-custom .win-reset { display: block; }
@media (max-width: 700px) { .modal, .modal.inv-modal { resize: none; min-width: 0; width: 100%; } }
/* ---------- The page width can be dragged from its right edge ---------- */
.main { position: relative; }
.page-sizer { position: absolute; top: 20px; bottom: 20px; right: 8px; width: 10px; cursor: ew-resize; border-radius: 5px; }
.page-sizer::after { content: ''; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px; border-radius: 1px; background: var(--border); opacity: 0; transition: opacity .15s; }
.page-sizer:hover::after { opacity: 1; background: var(--primary); }
@media (max-width: 900px) { .page-sizer { display: none; } }

/* ---------- Print preview ---------- */
.preview-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(40,44,52,.82); display: flex; flex-direction: column; }
.preview-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 10px 18px; background: var(--panel);
  box-shadow: 0 2px 10px rgba(0,0,0,.2); font-size: 13px; }
.preview-btns { margin-left: auto; display: flex; gap: 8px; }
.preview-paper-wrap { flex: 1; overflow: auto; padding: 28px 16px; display: flex; justify-content: center; align-items: flex-start; }
.preview-paper { width: 794px; max-width: 100%; height: 1123px; border: 0; background: #fff; box-shadow: 0 6px 30px rgba(0,0,0,.35); flex: none; }
.preview-paper.landscape { width: 1123px; }

/* Settings → Users: the privilege picker; "no access" stands out until it is set */
.priv-sel { padding: 5px 8px; min-width: 140px; }
.priv-sel.priv-none { border-color: var(--amber); color: var(--amber); }
.rights-sum { font-size: 11.5px; margin-top: 3px; max-width: 260px; }
.rights-table td.center, .rights-table th.center { text-align: center; width: 70px; }
.rights-table input[type=radio] { width: 16px; height: 16px; }
.ro-hidden { display: none !important; }

/* ---------- Portal ---------- */
.portal-hero { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.portal-logo { max-height: 64px; max-width: 180px; object-fit: contain; }
.portal-co { flex: 1 1 260px; min-width: 0; }
.portal-co h3 { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 4px; }
.portal-co .muted { font-size: 12.5px; }
.portal-me { flex: 1 1 260px; text-align: right; font-size: 13.5px; }
.portal-access { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; margin-top: 8px; }
.portal-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.portal-head h4 { margin: 0; }
.portal-sub { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 500; margin: 14px 0 6px; }
.portal-docs { width: 100%; font-size: 12.5px; border-collapse: collapse; }
.portal-docs td { padding: 6px 4px; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
.portal-docs td.pd-name { white-space: normal; width: 99%; }
.portal-docs tr[data-pinv] { cursor: pointer; }
.portal-docs tr[data-pinv]:hover td { background: var(--hover, rgba(0,0,0,.03)); }
.portal-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.portal-reports { display: flex; flex-wrap: wrap; gap: 6px; }
.portal-chart { margin-top: 10px; }
.portal-chart .chart-pair { height: 72px; }
.portal-preview { background: color-mix(in srgb, var(--primary) 9%, transparent); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px;
  font-size: 13.5px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
@media (max-width: 700px) { .portal-me { text-align: left; } .portal-access { justify-content: flex-start; } }

/* ---------- Specials: bringing books over ---------- */
.conv-guides { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.conv-guides h5 { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.conv-guides ol { padding-left: 18px; font-size: 13px; line-height: 1.6; }
@media (max-width: 760px) { .conv-guides { grid-template-columns: 1fr; } }
.conv-drop { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 26px 16px; margin-top: 14px;
  border: 2px dashed var(--hairline, #d2d2d7); border-radius: 12px; cursor: pointer; text-align: center; }
.conv-drop.over, .conv-drop:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 5%, transparent); }
.conv-file { border: 1px solid var(--hairline, #e5e5ea); border-radius: 10px; padding: 12px 14px; margin-top: 10px; }
.conv-file.warn { border-color: var(--amber); }
.conv-file.bad { border-color: var(--danger); }
.conv-file-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.conv-file-head strong { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.conv-cols { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.conv-msg { padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-top: 8px; }
.conv-msg.bad { background: rgba(215,0,21,.08); color: var(--danger); }
.conv-msg.warn { background: rgba(178,80,0,.10); color: var(--amber); }
.conv-sum > .stat { grid-column: span 3; }
.conv-ctrl { margin-top: 12px; max-width: 640px; }
.conv-accts tr.unsure td { background: rgba(178,80,0,.08); }
.conv-accts select { max-width: 320px; }
.conv-accts select { padding: 5px 8px; border: 1px solid var(--hairline, #d2d2d7); border-radius: 8px;
  background: var(--panel); color: inherit; font: inherit; font-size: 12.5px; width: 100%; }
.conv-xero { border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent); background: color-mix(in srgb, var(--primary) 4%, transparent); border-radius: 12px; padding: 14px 16px; margin-top: 14px; }
.conv-xero-head { display: flex; gap: 12px; align-items: flex-start; }
.conv-xero-head .muted { font-size: 13px; margin-top: 2px; }
.xero-dot { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 600;
  display: flex; align-items: center; justify-content: center; font-size: 15px; }
.conv-msg.good { background: rgba(36,138,61,.10); color: var(--green); }
.conv-tabs { margin: 12px 0 10px; }
.conv-src > p.muted { font-size: 13px; }
.conv-steps { padding-left: 20px; font-size: 13.5px; line-height: 1.9; margin: 8px 0; }
.conv-wait { font-style: italic; }
.tx-more summary { cursor: pointer; font-size: 13px; color: var(--muted); margin-top: 10px; }

/* ---------- Fast Cashbook: drop a bank statement ---------- */
.stm-drop { display: flex; gap: 14px; align-items: center; padding: 14px 18px; margin-bottom: 18px; cursor: pointer;
  border: 2px dashed var(--hairline, #d2d2d7); border-radius: 14px; background: var(--panel); font-size: 13.5px; }
.stm-drop:hover, .stm-drop.over { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 5%, transparent); }
.stm-icon { flex: none; width: 36px; height: 36px; border-radius: 50%; background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 600; }
.stm-table { font-size: 12.5px; }
.stm-table td { vertical-align: top; }
.stm-table tr.stm-duplicate td { opacity: .55; }
.stm-table tr.stm-possible td { background: rgba(178,80,0,.06); }
.stm-table td.num, .stm-table th.num { white-space: nowrap; }
.modal.wide:has(.stm-table) { width: min(1100px, 96vw); }
.stm-drop .stm-rules { margin-left: auto; flex: none; }
.fRem { color: var(--amber); }
.saved-flash { outline: 2px solid var(--green); }
/* Fast Cashbook: the G / C / S picker stays readable however narrow the column is dragged */
#fGrid select.fGcs { min-width: 62px; padding-left: 10px; padding-right: 22px; font-weight: 600; }
/* Fast Cashbook: the description gets the room (bank narrations are long); the grid scrolls sideways on small screens */
#fGrid { width: 100%; min-width: 1240px; table-layout: fixed; }
#fGrid .fc-seq { width: 30px; } #fGrid .fc-date { width: 112px; } #fGrid .fc-gcs { width: 70px; }
#fGrid .fc-who { width: 240px; } #fGrid .fc-ref { width: 140px; } #fGrid .fc-desc { width: auto; }
#fGrid .fc-tax { width: 78px; } #fGrid .fc-amt { width: 96px; } #fGrid .fc-disc { width: 70px; } #fGrid .fc-btn { width: 36px; }
/* the page takes more of the screen while a cashbook batch is open (a width dragged by hand still wins) */
.main:has(#fGrid) { max-width: 1600px; }

/* ---------- Drop-down calendar on date boxes ---------- */
input.has-cal { padding-right: 28px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2369778a' stroke-width='2' stroke-linecap='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important; background-position: right 7px center !important; background-size: 16px !important; }
.cal-pop { position: fixed; z-index: 10000; background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 8px; width: 252px; font-size: 13px; }
.cal-pop button { padding: 0; min-width: 0; margin: 0; border: none; background: none; color: inherit; cursor: pointer; font: inherit; box-shadow: none; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-head button { font-size: 18px; width: 30px; height: 28px; border-radius: 6px; }
.cal-pop button:hover { background: rgba(120,120,128,.12); }
.cal-dow, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; text-align: center; }
.cal-dow span { font-size: 11px; color: var(--muted); padding: 2px 0; }
.cal-grid button { height: 30px; border-radius: 6px; font-size: 13px; }
.cal-grid button.tdy { font-weight: 800; color: var(--primary); }
.cal-pop .cal-grid button.sel { background: var(--primary); color: #fff; }
.cal-foot { display: flex; justify-content: space-between; margin-top: 6px; border-top: 1px solid var(--hairline); padding-top: 6px; }
.cal-foot button { color: var(--primary); font-size: 12.5px; padding: 4px 8px; border-radius: 6px; }

/* ---------- Address in separate lines ---------- */
.addr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.addr-grid input:first-child { grid-column: 1 / -1; }

/* ---------- Repeating invoice settings above the document ---------- */
.rpt-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 10px 14px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: 10px; background: color-mix(in srgb, var(--primary) 5%, transparent); font-size: 13px; }
.rpt-bar label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.rpt-bar input, .rpt-bar select { padding: 5px 8px; border: 1px solid var(--border); border-radius: 7px; font: inherit; background: var(--panel); }
.rpt-bar .muted { flex-basis: 100%; font-size: 12px; }
.rpt-bar .rpt-notify input { width: 260px; }

/* ---------- Xero: the four steps ---------- */
.xero-steps { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.xero-steps > li { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; background: var(--panel); }
.xero-steps > li.now { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent); }
.xero-steps > li.later { opacity: .6; }
.xero-steps .xs-head { display: flex; align-items: center; gap: 10px; }
.xero-steps .xs-num { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; background: rgba(120,120,128,.14); color: var(--muted); flex: 0 0 auto; }
.xero-steps li.now .xs-num { background: var(--primary); color: #fff; }
.xero-steps li.done .xs-num { background: var(--green); color: #fff; }
.xero-steps .filter-row { margin: 0; }

/* ---------- Xero: what to bring over ---------- */
.xero-mode { display: flex; flex-direction: column; gap: 6px; }
.xero-mode label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 13px; }
.xero-mode label.on { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 5%, transparent); }
.xero-mode input { margin-top: 3px; }
.xero-mode .muted { display: block; font-size: 12px; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid color-mix(in srgb, var(--primary) 25%, transparent); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; margin-right: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- General ledger, every line ---------- */
.gl-lines .gl-type { background: #eef1f5; }
.gl-lines tr.gl-acct td { padding-top: 14px; border-bottom: 1px solid var(--border); }
.gl-lines tr.gl-acct a { color: var(--text); text-decoration: none; }
.gl-lines tr.gl-acct a:hover { color: var(--primary); text-decoration: underline; }
.gl-lines tr.gl-sub td { border-top: 1px solid var(--border); background: rgba(120,120,128,.05); font-size: 12.5px; }
.gl-lines td:nth-child(1), .gl-lines td:nth-child(2), .gl-lines td:nth-child(3), .gl-lines td.num { white-space: nowrap; }
.src-tag { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: rgba(120,120,128,.12); color: var(--muted); }
.gl-lines tr.gl-acct td, .gl-lines tr.gl-sub td:first-child { white-space: normal; }

/* ---------- Pastel: upload a zip of the company folder ---------- */
.pz-box { border: 1px solid var(--primary); border-radius: 10px; padding: 12px 14px; background: color-mix(in srgb, var(--primary) 4%, transparent); margin-bottom: 6px; }
.pz-drop { display: flex; align-items: center; justify-content: center; min-height: 86px; border: 2px dashed var(--border); border-radius: 10px;
  background: var(--panel); cursor: pointer; text-align: center; padding: 12px; font-size: 13.5px; }
.pz-drop.over, .pz-drop:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 6%, transparent); }
.pz-progress { height: 8px; border-radius: 4px; background: rgba(120,120,128,.15); overflow: hidden; margin: 6px 0; }
.pz-progress > div { height: 100%; background: var(--primary); transition: width .2s; }
.gl-half { background: var(--navy-solid, #1d1d1f); color: #fff; font-weight: 700; font-size: 12.5px; letter-spacing: .04em; text-transform: uppercase; padding: 7px 10px !important; }

/* ---------- Supplier invoice: drop the PDF to fill the window in ---------- */
.si-drop { display: flex; align-items: center; gap: 10px; border: 2px dashed var(--border); border-radius: 10px; padding: 10px 14px;
  margin-bottom: 10px; cursor: pointer; font-size: 13px; background: var(--panel); }
.si-drop.over, .si-drop:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 5%, transparent); }
#siResult .conv-msg { margin-bottom: 8px; }

/* ---------- Ledger totals: + opens an account's lines under it ---------- */
.gl-totals .gl-plus-cell { width: 34px; padding-right: 0; }
.gl-plus { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel); cursor: pointer;
  font-weight: 700; line-height: 1; color: var(--primary); padding: 0; }
.gl-plus:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 6%, transparent); }
.gl-detail > td { padding: 0 0 10px; background: color-mix(in srgb, var(--primary) 3%, transparent); }
.gl-sub-lines { font-size: 12.5px; margin: 4px 0 0; }
.gl-sub-lines th { font-size: 10.5px; }

/* ---------- VAT201 ---------- */
.v2-headline { font-size: 18px; margin: 12px 0 14px; }
.stat.v2-pay .value { color: var(--danger); }
.stat.v2-refund .value { color: var(--green); }
.v2-bars { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; max-width: 640px; }
.v2-bars > div { display: grid; grid-template-columns: 70px 1fr 120px; align-items: center; gap: 10px; font-size: 13px; }
.v2-bars strong { text-align: right; }
.v2-bar { height: 12px; background: rgba(120,120,128,.12); border-radius: 6px; overflow: hidden; }
.v2-bar > div { height: 100%; background: var(--danger); border-radius: 6px; }
.v2-bar.claim > div { background: var(--green); }
.v2-two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 10px; }
@media (max-width: 760px) { .v2-two { grid-template-columns: 1fr; } }
.v2-top { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--hairline); font-size: 13px; }
.v2-form-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.v2-table td:first-child { width: 50px; font-weight: 600; }
.v2-table td:nth-child(4) { width: 50px; color: var(--muted); }
.v2-20 td { font-size: 15px; border-top: 2px solid var(--text) !important; }
.vat-badge { display: inline-block; font-size: 9.5px; font-weight: 700; letter-spacing: .03em; padding: 0 5px; margin-left: 4px; border-radius: 4px;
  background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary); vertical-align: 1px; }
.doc-clip { font-size: 12px; margin-left: 4px; cursor: default; }

/* ---- Matching payments to invoices: drag & drop ---- */
.mt-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 6px 0 10px; }
.mt-pool { display: inline-flex; gap: 6px; align-items: center; padding: 4px 8px; border: 1px dashed var(--border, #d0d7de); border-radius: 8px; font-size: 13px; }
.mt-chip { display: inline-block; padding: 3px 9px; margin: 2px 4px 2px 0; border-radius: 999px; font-size: 12.5px; font-variant-numeric: tabular-nums;
  background: #e8f1fb; color: #0b5cad; border: 1px solid #b7d3f2; cursor: grab; user-select: none; white-space: nowrap; }
.mt-chip:active { cursor: grabbing; }
.mt-chip.src { background: #e6f6ec; color: #13703a; border-color: #a9dcbb; font-weight: 600; }
.mt-chip.inv { background: #fff4e5; color: #9a5b00; border-color: #f3cf99; }
.mt-chip.neg { background: #fdecec; color: #b42318; border-color: #f4b4ae; }
.mt-chip.empty { opacity: .55; }
.mt-chip.mt-dragging { opacity: .4; }
.mt-grip { cursor: grab; color: #8a94a3; font-size: 15px; user-select: none; }
.mt-grip.off { visibility: hidden; }
.mt-over { outline: 2px dashed var(--primary); outline-offset: -2px; background: color-mix(in srgb, var(--primary) 7%, transparent) !important; }
.mt-wrap { display: grid; grid-template-columns: minmax(240px, 34%) 1fr; gap: 14px; align-items: start; }
.mt-col { border: 1px solid var(--border, #e3e8ee); border-radius: 10px; padding: 8px; min-height: 120px; max-height: 58vh; overflow: auto; }
.mt-h { font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: #5b6676; margin: 2px 4px 8px; }
.mt-src { border: 1px solid var(--border, #e3e8ee); border-radius: 8px; padding: 7px 9px; margin-bottom: 7px; background: var(--card, #fff); }
.mt-src-h { display: flex; gap: 6px; align-items: baseline; }
.mt-src-h .mt-amt { margin-left: auto; }
.mt-src-b { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.mt-to { flex-basis: 100%; }
.mt-tbl td { vertical-align: middle; white-space: nowrap; }
.mt-tbl td.mt-cell { white-space: normal; }
.mt-cell { min-width: 140px; }
.mt-edit { width: 110px; padding: 2px 6px; font-size: 12.5px; }
.mt-foot { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 10px; font-size: 13.5px; }
.mt-dirty { color: #b25e00; font-weight: 600; margin-left: auto; }
.mt-empty { padding: 10px; }
@media (max-width: 760px) { .mt-wrap { grid-template-columns: 1fr; } }
.modal.mt-modal { width: min(1180px, 100%); }

/* ---- VAT periods: submitted (locked) / open, and VAT dates moved to another return ---- */
.v2-lock, .v2-open { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 10px; margin: 0 0 10px; font-size: 13.5px; }
.v2-lock { background: #eef6ee; border: 1px solid #b9dcc0; }
.v2-open { background: #f6f7f9; border: 1px solid #e3e8ee; }
.v2-lock-ico { font-size: 18px; }
.v2-moved { font-size: 11px; color: #9a5b00; white-space: nowrap; }

/* ---- Change a transaction (account, VAT, amounts) ---- */
.te-tbl td { vertical-align: middle; }
.te-tbl input.teDr, .te-tbl input.teCr { width: 110px; text-align: right; }
.te-tbl input.teMemo { width: 100%; min-width: 140px; }
.te-tbl tr.te-vatline td { background: #fbf7ee; }
.te-sum { margin-top: 10px; font-size: 13.5px; display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.te-off { color: #b42318; font-weight: 600; }
.te-ok { color: #13703a; font-weight: 600; }

.v2-out { color: var(--danger, #b42318); }

/* Bank: the contra account changes with a dropdown */
td.contra-edit { cursor: pointer; }
td.contra-edit:hover { background: color-mix(in srgb, var(--primary) 7%, transparent); }
.contra-caret { color: #8a94a3; font-size: 11px; }
.contra-sel { max-width: 260px; font-size: 13px; }

/* ================= My look (Settings → My look): per user ================= */

/* ---------- Company picker (top right) ---------- */
.co-pick {
  display: flex; align-items: center; gap: 8px; max-width: 320px; min-width: 0;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.16); color: #fff;
  border-radius: 10px; padding: 4px 10px 4px 4px; font: inherit; font-size: 13px; cursor: pointer;
  transition: background .15s ease;
}
.co-pick:hover, .co-pick:focus-visible { background: rgba(255,255,255,.22); outline: none; }
.co-pick .co-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.co-caret { opacity: .75; font-size: 10px; }
.co-av {
  flex: none; width: 26px; height: 26px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; letter-spacing: 0; background: hsl(var(--h, 210) 52% 46%);
}
.co-pop {
  position: fixed; z-index: 1200; width: 360px; max-width: calc(100vw - 16px); max-height: min(540px, calc(100vh - 70px));
  display: flex; flex-direction: column; padding: 10px; border-radius: 14px;
  background: var(--panel); color: var(--text); box-shadow: var(--shadow-lg); border: 1px solid var(--hairline);
}
.co-search {
  width: 100%; padding: 9px 11px; margin-bottom: 6px; border: 1px solid var(--border); border-radius: 9px;
  font: inherit; font-size: 14px; background: var(--field); color: var(--text);
}
.co-search:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.co-list { overflow-y: auto; min-height: 0; }
.co-h { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 9px 8px 4px; }
.co-row {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: none; border-radius: 9px;
  background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.co-row.hi { background: color-mix(in srgb, var(--primary) 12%, transparent); }
.co-row.cur .co-rn { font-weight: 600; }
.co-row.off { opacity: .55; cursor: default; }
.co-rn { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.co-rn small { color: var(--muted); font-size: 11.5px; font-weight: 400; }
.co-tick { color: var(--primary); font-weight: 700; }
.co-none { padding: 16px 8px; color: var(--muted); }
.co-add {
  border: none; border-top: 1px solid var(--hairline); background: none; text-align: left; margin-top: 6px; padding: 10px 8px 4px;
  color: var(--primary); font: inherit; font-weight: 600; cursor: pointer;
}

/* ---------- The My look page ---------- */
.look-card .section { margin-top: 22px; }
.look-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.look-sw {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--field); color: var(--text); font: inherit; font-size: 13px;
}
.look-sw i { width: 22px; height: 22px; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.look-sw input[type=color] { width: 24px; height: 24px; padding: 0; border: none; border-radius: 50%; background: none; cursor: pointer; }
.look-sw input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.look-sw input[type=color]::-webkit-color-swatch { border: none; border-radius: 50%; }
.look-sw.on { border-color: var(--sw); box-shadow: 0 0 0 2px color-mix(in srgb, var(--sw) 30%, transparent); font-weight: 600; }
.look-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; max-width: 620px; }
.look-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px; text-align: left; cursor: pointer;
  border: 1.5px solid var(--border); border-radius: 12px; background: var(--field); color: var(--text); font: inherit;
}
.look-opt.on { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.look-mini { position: relative; display: block; width: 100%; height: 86px; border-radius: 8px; overflow: hidden; margin-bottom: 6px; background: #f0f0f3; }
.look-mini.glass {
  background:
    radial-gradient(120px 90px at 10% 10%, color-mix(in srgb, var(--primary) 60%, transparent), transparent 70%),
    radial-gradient(120px 90px at 95% 30%, rgba(255,160,120,.55), transparent 70%),
    radial-gradient(140px 90px at 60% 110%, rgba(120,200,255,.6), transparent 70%), #e9ecf4;
}
.look-mini .lm-bar { position: absolute; left: 0; right: 0; top: 0; height: 16px; background: #2a2a2e; }
.look-tint .look-mini .lm-bar { background: color-mix(in srgb, var(--primary) 35%, #18181b); }
.look-mini.glass .lm-bar { background: color-mix(in srgb, var(--primary) 45%, rgba(20,20,30,.45)); }
.look-mini .lm-card { position: absolute; top: 26px; height: 48px; width: 42%; border-radius: 6px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.look-mini .lm-card + .lm-card { left: 52%; }
.look-mini .lm-card:first-of-type, .look-mini .lm-bar + .lm-card { left: 6%; }
.look-mini.glass .lm-card { background: rgba(255,255,255,.5); border: 1px solid rgba(255,255,255,.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.look-seg { display: inline-flex; }

/* ---------- A colour of your own: the menu bar takes a shade of it ---------- */
body.look-tint .topbar { background: color-mix(in srgb, var(--primary) 34%, rgba(20,20,24,.92)); }
body.look-tint .nav-btn.active { border-bottom-color: #fff; }

/* ---------- Larger text ---------- */
body.look-large { font-size: 15.5px; }
body.look-large .nav-btn { font-size: 14.5px; }
body.look-large th { font-size: 12px; }
body.look-large .btn { font-size: 14px; }
body.look-large .subtab { font-size: 14px; }
body.look-large label.fld { font-size: 13px; }
body.look-large label.fld input, body.look-large label.fld select, body.look-large label.fld textarea { font-size: 15px; }
body.look-large .panel .row { font-size: 14px; }
body.look-large .stat .label { font-size: 12.5px; }
body.look-large .stat .value { font-size: 27px; }
body.look-large .muted.small, body.look-large .small { font-size: 13px; }

/* ---------- Dark ---------- */
body.look-dark {
  --bg: #121214; --panel: #222226; --field: #1a1a1d; --border: #3a3a40; --hairline: #2d2d32;
  --text: #f2f2f7; --muted: #a1a1aa; --danger: #ff6b61; --green: #3fcf6a; --amber: #ffad42;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.45); --shadow-lg: 0 24px 60px rgba(0,0,0,.6), 0 2px 8px rgba(0,0,0,.4);
  color-scheme: dark;
}
body.look-dark .subtabs { background: rgba(255,255,255,.07); }
body.look-dark .subtab { color: var(--text); }
body.look-dark .subtab.active { background: #3a3a40; }
body.look-dark .btn.secondary { background: rgba(255,255,255,.10); }
body.look-dark .btn.secondary:hover { background: rgba(255,255,255,.17); }
body.look-dark .gl-lines .gl-type, body.look-dark [style*="background:#eef1f5"] { background: #2b2e35 !important; }
body.look-dark [style*="color: #222"], body.look-dark [style*="color: #1c2430"], body.look-dark [style*="color: #444"] { color: var(--text) !important; }
body.look-dark .mt-chip { background: rgba(10,132,255,.16); color: #9ecbff; border-color: rgba(10,132,255,.4); }
body.look-dark .mt-chip.src { background: rgba(48,209,88,.14); color: #8fe3a5; border-color: rgba(48,209,88,.4); }
body.look-dark .mt-chip.inv { background: rgba(255,159,10,.14); color: #ffc46b; border-color: rgba(255,159,10,.4); }
body.look-dark .mt-chip.neg { background: rgba(255,69,58,.14); color: #ff9a92; border-color: rgba(255,69,58,.4); }
body.look-dark .v2-lock { background: rgba(48,209,88,.10); border-color: rgba(48,209,88,.35); }
body.look-dark .v2-open { background: rgba(255,255,255,.04); border-color: var(--border); }
body.look-dark .te-tbl tr.te-vatline td { background: rgba(255,159,10,.10); }
body.look-dark .chart-bar.out { background: #5a5a62; }
body.look-dark .modal-overlay { background: rgba(0,0,0,.6); }
/* documents are paper: they stay white with dark text */
body.look-dark .inv-doc, body.look-dark .p-doc {
  --bg: #f5f5f7; --panel: #fff; --field: #fff; --border: #e3e3e6; --hairline: #ededf0; --text: #1d1d1f; --muted: #6e6e73;
  --danger: #d70015; --green: #248a3d; --amber: #b25000;
  background: #fff; color: var(--text); color-scheme: light;
}

/* ---------- Glass ---------- */
body.look-glass {
  --panel: rgba(255,255,255,.56); --field: rgba(255,255,255,.72); --border: rgba(255,255,255,.7); --hairline: rgba(20,20,40,.08);
  background:
    radial-gradient(1100px 760px at -5% -10%, color-mix(in srgb, var(--primary) 62%, transparent), transparent 64%),
    radial-gradient(900px 640px at 105% 0%, rgba(255,150,110,.55), transparent 62%),
    radial-gradient(1000px 720px at 50% 115%, rgba(100,190,255,.58), transparent 64%),
    radial-gradient(700px 500px at 80% 60%, color-mix(in srgb, var(--primary) 28%, transparent), transparent 70%),
    #e7ebf4;
  background-attachment: fixed;
}
body.look-glass .card, body.look-glass .stat, body.look-glass .panel, body.look-glass .modal, body.look-glass .co-pop,
body.look-glass .ctx-menu, body.look-glass .combo-list, body.look-glass .cal-pop {
  -webkit-backdrop-filter: blur(22px) saturate(170%); backdrop-filter: blur(22px) saturate(170%);
  border: 1px solid rgba(255,255,255,.62);
  box-shadow: 0 10px 34px rgba(30,40,90,.10), inset 0 1px 0 rgba(255,255,255,.55);
}
body.look-glass .modal, body.look-glass .co-pop, body.look-glass .ctx-menu, body.look-glass .combo-list, body.look-glass .cal-pop { --panel: rgba(255,255,255,.82); background: var(--panel); }
body.look-glass .topbar {
  background: color-mix(in srgb, var(--primary) 52%, rgba(14,16,26,.80));
  -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid rgba(255,255,255,.18);
}
body.look-glass .subtabs { background: rgba(255,255,255,.35); }
body.look-glass .btn.secondary { background: rgba(255,255,255,.55); }
body.look-glass .btn.secondary:hover { background: rgba(255,255,255,.8); }
body.look-glass tr.total td { background: rgba(255,255,255,.35); }
body.look-glass .page-title h2 { text-shadow: 0 1px 0 rgba(255,255,255,.5); }

/* Glass in the dark */
body.look-glass.look-dark {
  --panel: rgba(36,36,44,.55); --field: rgba(20,20,26,.6); --border: rgba(255,255,255,.12); --hairline: rgba(255,255,255,.08);
  background:
    radial-gradient(1100px 760px at -5% -10%, color-mix(in srgb, var(--primary) 45%, transparent), transparent 62%),
    radial-gradient(900px 640px at 105% 5%, rgba(190,80,140,.30), transparent 60%),
    radial-gradient(1000px 700px at 55% 110%, rgba(40,120,200,.35), transparent 62%),
    #0e0f15;
  background-attachment: fixed;
}
body.look-glass.look-dark .card, body.look-glass.look-dark .stat, body.look-glass.look-dark .panel, body.look-glass.look-dark .modal,
body.look-glass.look-dark .co-pop, body.look-glass.look-dark .ctx-menu, body.look-glass.look-dark .combo-list, body.look-glass.look-dark .cal-pop {
  border-color: rgba(255,255,255,.10); box-shadow: 0 10px 34px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.06);
}
body.look-glass.look-dark .modal, body.look-glass.look-dark .co-pop, body.look-glass.look-dark .ctx-menu,
body.look-glass.look-dark .combo-list, body.look-glass.look-dark .cal-pop { --panel: rgba(34,34,40,.9); }
body.look-glass.look-dark .subtabs { background: rgba(255,255,255,.07); }
body.look-glass.look-dark .btn.secondary { background: rgba(255,255,255,.10); }
body.look-glass.look-dark tr.total td { background: rgba(255,255,255,.05); }
body.look-glass.look-dark .page-title h2 { text-shadow: none; }

/* printing is always plain */
@media print {
  body.look-glass, body.look-dark { background: #fff !important; color: #000; }
  body.look-glass .card, body.look-glass .panel, body.look-glass .stat { backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; }
}

/* document windows (invoice, quote, credit note, supplier invoice) open at full size */
.modal-overlay:has(.modal.win-max) { padding: 12px; }
.modal.inv-modal.win-max { width: calc(100vw - 24px); height: calc(100vh - 24px); max-width: none; }

/* ---------- Help: training manual, how-to steps, client guide ---------- */
.help-btn {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.16); color: #fff; border-radius: 999px;
  padding: 4px 11px; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.help-btn:hover { background: rgba(255,255,255,.22); }
.help-wrap { display: grid; grid-template-columns: 230px 1fr; gap: 18px; align-items: start; }
.help-toc { position: sticky; top: 64px; display: flex; flex-direction: column; gap: 2px; padding: 10px; border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow-sm); max-height: calc(100vh - 90px); overflow-y: auto; }
.help-toc a { color: var(--text); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: 13px; }
.help-toc a:hover { background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary); }
.help-ch { scroll-margin-top: 64px; max-width: 860px; }
.help-ch h3 { font-size: 19px; margin-bottom: 10px; letter-spacing: -0.02em; }
.help-ch h4 { font-size: 14.5px; margin: 16px 0 6px; }
.help-ch p, .help-ch li { line-height: 1.6; }
.help-ch p { margin-bottom: 8px; }
.help-ch ul, .help-ch ol, .help-how ol { padding-left: 22px; margin: 4px 0 10px; }
.help-ch li, .help-how li { margin-bottom: 4px; }
.help-ch kbd, .help-how kbd { font: inherit; font-size: 12px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border); background: var(--field); }
.help-ch .ui, .help-how .ui { font-weight: 600; color: var(--primary); }
.help-tip { margin-top: 6px; padding: 8px 12px; border-radius: 9px; background: color-mix(in srgb, var(--primary) 8%, transparent); font-size: 13px; }
.help-area { max-width: 900px; }
.tv-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; align-items: start; }
.tv-main { padding: 12px; }
.tv-main video { width: 100%; aspect-ratio: 16 / 9; display: block; border-radius: 10px; background: #000; }
.tv-note { margin: 10px 4px 2px; font-size: 13px; }
.tv-chapters { position: sticky; top: 64px; display: flex; flex-direction: column; gap: 2px; padding: 12px; max-height: calc(100vh - 90px); overflow-y: auto; }
.tv-chapters a { display: flex; justify-content: space-between; gap: 10px; color: var(--text); text-decoration: none; padding: 7px 10px; border-radius: 8px; font-size: 13px; }
.tv-chapters a small { color: var(--muted); font-variant-numeric: tabular-nums; }
.tv-chapters a:hover, .tv-chapters a.active { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
@media (max-width: 900px) { .tv-wrap { grid-template-columns: 1fr; } .tv-chapters { position: static; max-height: none; } }
.help-how { border-top: 1px solid var(--hairline); padding: 9px 2px; }
.help-how:first-of-type { border-top: none; }
.help-how h5 { font-size: 14.5px; font-weight: 600; margin-bottom: 4px; }
@media (max-width: 900px) { .help-wrap { grid-template-columns: 1fr; } .help-toc { position: static; max-height: none; } }
@media print {
  .help-wrap { display: block; }
  .help-ch { break-inside: auto; box-shadow: none; }
  .help-how { break-inside: avoid; }
}

/* the company picker leads the menu bar, where the company name used to be */
.topbar > .co-pick { margin-right: 18px; }
.topbar .brand[hidden] { display: none; }

/* ---------- Easier-to-read tables and reports ---------- */
table.rt th {
  color: color-mix(in srgb, var(--text) 62%, transparent); font-size: 11.5px; letter-spacing: .04em;
  border-bottom: 1.5px solid var(--border); background: var(--panel);
}
table.rt.rt-sticky > thead th { position: sticky; top: var(--topbar-h, 48px); z-index: 2; }
body.look-glass table.rt.rt-sticky > thead th { background: rgba(255,255,255,.88); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
body.look-glass.look-dark table.rt.rt-sticky > thead th { background: rgba(34,34,40,.92); }
/* every other row lightly shaded, so a line can be followed across a wide table */
table.rt > tbody > tr:nth-child(even):not(.total) > td { background: color-mix(in srgb, var(--text) 2.6%, transparent); }
table.rt > tbody > tr:hover > td { background: color-mix(in srgb, var(--primary) 7%, transparent); }
table.rt > tbody > tr.clickable:hover > td, table.rt > tbody > tr[data-ln]:hover > td { background: color-mix(in srgb, var(--primary) 10%, transparent); }
table.rt td.num, table.rt th.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.rt td.num.z { color: color-mix(in srgb, var(--muted) 70%, transparent); }
table.rt td.num.neg { color: var(--danger); }
/* totals: a line above and bold; the grand total also gets the accountant's double line underneath */
table.rt tr.total > td { border-top: 1px solid color-mix(in srgb, var(--text) 30%, transparent); font-weight: 600; background: color-mix(in srgb, var(--text) 4%, transparent); }
table.rt tr.tot-final > td { border-top: 1.5px solid var(--text); border-bottom: 3px double var(--text); font-weight: 700; }
table.rt tr.tot-final > td.num.z { color: inherit; }
/* a short report keeps its amounts near their names */
table.rt.rt-narrow { max-width: 920px; }
/* report section headings (Non-current assets, Equity, ...) */
table.rt td[colspan][style*="background:#eef1f5"] { background: color-mix(in srgb, var(--primary) 9%, var(--panel)) !important; color: var(--text); letter-spacing: .01em; }
body.look-dark table.rt td[colspan][style*="background:#eef1f5"] { background: color-mix(in srgb, var(--primary) 18%, #222226) !important; }
/* compact rows (My look) */
body.look-compact td { padding-top: 6px; padding-bottom: 6px; }
body.look-compact th { padding-top: 6px; padding-bottom: 6px; }
body.look-compact .panel .row { padding: 4px 0; }
@media print {
  table.rt.rt-sticky > thead th { position: static; }
  table.rt > tbody > tr:nth-child(even) > td { background: transparent; }
  table.rt.rt-narrow { max-width: none; }
}

/* Age analysis: the Auto-match all bar */
.am-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

/* Bank: rename a bank account from its tile */
.bank-label { display: flex; align-items: center; gap: 6px; }
.bank-ren { border: none; background: none; padding: 0 2px; cursor: pointer; color: var(--muted); font-size: 12px; opacity: 0; transition: opacity .15s; }
.stat:hover .bank-ren, .bank-ren:focus { opacity: 1; }
.bank-ren:hover { color: var(--primary); }

/* Bank statement preview: swap money in / out */
.stm-flipcol { width: 34px; text-align: center; padding-left: 2px !important; padding-right: 2px !important; }
.stm-flip { padding: 1px 6px; font-size: 13px; line-height: 1.2; }

/* Reports: the prior-year comparative columns */
th.cmp-first, td.cmp-first { border-left: 1px solid var(--border, rgba(127,127,127,.25)); }
/* VAT report: output / input sections grouped by box */
.v2-part { margin: 22px 0 4px; font-size: 17px; }
.v2-tx tr.v2-grp td { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding-top: 12px; border-bottom: 1px solid var(--border); background: none; }
.v2-tx tr.v2-sub td { font-style: italic; color: var(--muted); border-top: 1px solid var(--hairline); }
table.v2-net { margin-top: 14px; width: 100%; }
table.v2-net td.num { width: 160px; }
/* split a bank amount over several accounts */
.f-who { display: flex; gap: 4px; align-items: center; }
.f-who select { flex: 1; min-width: 0; }
.f-who .fSplit { flex: none; padding: 3px 7px; font-size: 11.5px; }
.f-who .fSplit.on { border-color: var(--primary); color: var(--primary); font-weight: 600; }
.sp-tbl td { vertical-align: middle; }
.sp-tbl input.spMemo { width: 100%; }
