/* Munshian Ledger: a Xero-style layout in the Munshian colours */
:root {
  --primary: #114688;
  --primary-hover: #0d3a72;
  --accent: #13B5EA;
  --nav: #192B4F;
  --nav-2: #22375f;
  --bg: #F2F4F7;
  --card: #FFFFFF;
  --subtle: #F7F9FC;
  --blue-surface: #EEF4FB;
  --text: #192B4F;
  --text-2: #5B6B85;
  --text-3: #98A2B3;
  --line: #E3E8EF;
  --line-strong: #CDD5E1;
  --ok: #067647;
  --ok-bg: #ECFDF3;
  --err: #B42318;
  --err-bg: #FEF3F2;
  --warn: #93370D;
  --warn-bg: #FFFAEB;
  --r: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; font: 400 14px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; font-weight: 650; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* Top navigation */
.topnav { background: var(--nav); color: #fff; }
.topnav-inner { max-width: 1280px; margin: 0 auto; padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 24px; }
.org-name { font-weight: 650; font-size: 15px; color: #fff; white-space: nowrap; display: flex; align-items: center; gap: 10px; }
.org-name:hover { text-decoration: none; }
.org-badge { width: 30px; height: 30px; border-radius: 6px; background: var(--accent); color: var(--nav); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.menu { display: flex; height: 100%; gap: 4px; }
.menu > li { list-style: none; position: relative; display: flex; }
.menu { margin: 0; padding: 0; }
.menu > li > a, .menu > li > button { white-space: nowrap; display: flex; align-items: center; padding: 0 12px; color: #D6DEEB; font: inherit; font-weight: 500; background: none; border: 0; cursor: pointer; border-bottom: 3px solid transparent; border-top: 3px solid transparent; }
.menu > li > a:hover, .menu > li > button:hover, .menu > li:focus-within > button { color: #fff; text-decoration: none; background: var(--nav-2); }
.menu > li.active > a, .menu > li.active > button { color: #fff; border-bottom-color: var(--accent); }
.dropdown { display: none; position: absolute; top: 100%; left: 0; min-width: 210px; background: #fff; border-radius: 0 0 var(--r) var(--r); box-shadow: 0 8px 24px rgba(16, 24, 40, 0.18); padding: 6px 0; z-index: 20; }
.menu > li:hover .dropdown, .menu > li:focus-within .dropdown { display: block; }
.dropdown a { display: block; padding: 8px 16px; color: var(--text); }
.dropdown a:hover { background: var(--blue-surface); text-decoration: none; }
.dropdown hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.topnav-right { margin-left: auto; display: flex; align-items: center; gap: 14px; color: #D6DEEB; font-size: 13px; }
.topnav-right button { background: none; border: 1px solid rgba(255,255,255,.25); color: #fff; border-radius: var(--r); padding: 5px 10px; font: inherit; cursor: pointer; }
.topnav-right button:hover { background: var(--nav-2); }

/* Page header band */
.page-head { background: #fff; border-bottom: 1px solid var(--line); }
.page-head-inner { max-width: 1280px; margin: 0 auto; padding: 18px 24px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.crumbs { font-size: 13px; color: var(--text-2); margin-bottom: 2px; }
.page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
main { max-width: 1280px; margin: 0 auto; padding: 24px 24px 64px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line-strong); background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--subtle); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.green { background: #0A8A4F; border-color: #0A8A4F; color: #fff; }
.btn.green:hover { background: #087641; }
.btn.danger { color: var(--err); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn.danger { color: var(--err); }
form.inline { display: inline; }

/* Cards and panels */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card.flush { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 20px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.stat { font-size: 26px; font-weight: 650; letter-spacing: -0.01em; }
.stat-row { display: flex; gap: 32px; flex-wrap: wrap; margin: 6px 0 14px; }
.stat-label { font-size: 12.5px; color: var(--text-2); }
.stat.overdue { color: var(--err); }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); background: #fff; padding: 0 16px; overflow-x: auto; }
.tabs a { padding: 12px 14px; color: var(--text-2); font-weight: 500; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .count { display: inline-block; min-width: 20px; margin-left: 4px; padding: 0 6px; border-radius: 10px; background: var(--subtle); font-size: 12px; text-align: center; }
.toolbar { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fff; flex-wrap: wrap; }
.toolbar input[type=search] { width: 280px; max-width: 100%; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: none; padding: 10px 12px; border-bottom: 1px solid var(--line-strong); background: var(--subtle); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--blue-surface); }
tfoot td { font-weight: 600; background: var(--subtle); }
.empty { padding: 40px 16px; text-align: center; color: var(--text-2); }

/* Status badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--subtle); color: var(--text-2); }
.badge.DRAFT { background: #F2F4F7; color: #475467; }
.badge.AUTHORISED { background: var(--blue-surface); color: var(--primary); }
.badge.PAID { background: var(--ok-bg); color: var(--ok); }
.badge.VOIDED { background: #F2F4F7; color: var(--text-3); text-decoration: line-through; }
.badge.overdue { background: var(--err-bg); color: var(--err); }
.badge.paused { background: var(--warn-bg); color: var(--warn); }

/* Forms */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.hint { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r); font: inherit; color: var(--text); background: #fff;
}
textarea { height: auto; min-height: 70px; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(17, 70, 136, 0.15); }
input[readonly] { background: var(--subtle); }
.form-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; height: auto; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }

/* Line items editor */
.lines td { padding: 6px; }
.lines input, .lines select { height: 34px; }
.lines .c-item { width: 150px; }
.lines .c-desc { min-width: 220px; }
.lines .c-qty { width: 80px; }
.lines .c-price { width: 110px; }
.lines .c-acc { width: 200px; }
.lines .c-tax { width: 190px; }
.lines .c-amt { width: 110px; }
.lines .c-del { width: 34px; }
.lines textarea { min-height: 34px; height: 34px; }
.remove-line { background: none; border: 0; color: var(--text-3); font-size: 18px; cursor: pointer; line-height: 1; }
.remove-line:hover { color: var(--err); }
.totals { margin-left: auto; width: 340px; max-width: 100%; }
.totals div { display: flex; justify-content: space-between; padding: 5px 0; }
.totals .grand { border-top: 2px solid var(--text); margin-top: 6px; padding-top: 8px; font-size: 18px; font-weight: 650; }
.rates-box { background: var(--subtle); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin-top: 14px; }

/* Messages */
.alert { padding: 12px 14px; border-radius: var(--r); margin-bottom: 16px; border: 1px solid; }
.alert.error { background: var(--err-bg); color: var(--err); border-color: #FECDCA; }
.alert.ok { background: var(--ok-bg); color: var(--ok); border-color: #ABEFC6; }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: #FEDF89; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

/* Document view */
.doc-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 18px; }
.doc-meta .k { font-size: 12px; color: var(--text-2); }
.doc-meta .v { font-weight: 600; }
details.panel summary { cursor: pointer; font-weight: 600; }
details.panel[open] summary { margin-bottom: 12px; }

/* Bank accounts */
.bank-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.bank-card-head h2 { margin: 0; }
.bank-links { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13.5px; }

/* Reconcile: statement line on the left, what it matches on the right */
.rec-list { padding: 16px; display: grid; gap: 14px; background: var(--bg); }
.rec { display: grid; grid-template-columns: minmax(220px, 1fr) 32px minmax(320px, 1.4fr); background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.rec-line { display: grid; grid-template-columns: 90px 1fr auto; gap: 12px; padding: 14px; background: var(--subtle); border-radius: var(--r) 0 0 var(--r); }
.rec-date { font-size: 13px; color: var(--text-2); }
.rec-desc { word-break: break-word; }
.rec-amt { font-size: 12px; color: var(--text-2); }
.rec-amt strong { font-size: 15px; }
.rec-amt.in strong { color: var(--ok); }
.rec-amt.out strong { color: var(--text); }
.rec-arrow { display: grid; place-items: center; color: var(--text-3); font-size: 18px; }
.rec-actions { padding: 10px 14px 14px; }
.rec-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.rec-tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 6px 10px; font: inherit; font-weight: 500; color: var(--text-2); cursor: pointer; }
.rec-tabs button.on { color: var(--primary); border-bottom-color: var(--primary); }
.rec-ok { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; background: var(--ok-bg); border-radius: var(--r); margin-bottom: 10px; }
.rec-row { display: flex; gap: 8px; margin-bottom: 8px; }
.rec-row select { flex: 1; min-width: 0; }
.rec-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 4px; }
.rec .field { margin-bottom: 10px; }
@media (max-width: 860px) {
  .rec { grid-template-columns: 1fr; }
  .rec-line { border-radius: var(--r) var(--r) 0 0; }
  .rec-arrow { display: none; }
}

/* Sign-in pages */
body.auth { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(180deg, var(--nav) 0, var(--nav) 220px, var(--bg) 220px); }
.auth-card { width: 420px; max-width: calc(100vw - 32px); background: #fff; border-radius: 10px; box-shadow: 0 12px 40px rgba(16, 24, 40, 0.18); padding: 32px; }
.auth-card img.logo { height: 40px; margin-bottom: 18px; }
.auth-card h1 { margin-bottom: 6px; }
.qr { display: block; margin: 12px auto; }
code { background: var(--subtle); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; word-break: break-all; }

@media (max-width: 860px) {
  .topnav-inner { height: auto; flex-wrap: wrap; padding: 8px 16px; gap: 6px 12px; }
  .menu { order: 3; width: 100%; overflow-x: auto; height: 44px; }
  .dropdown { position: fixed; top: auto; left: 16px; right: 16px; }
  .page-head-inner, main { padding-left: 16px; padding-right: 16px; }
  .topnav-right .who { display: none; }
}

@media print {
  .topnav, .page-actions, .no-print { display: none !important; }
  body { background: #fff; }
}

/* VAT return */
.vat-boxes td { vertical-align: middle; }
.vat-boxes tr.total td { background: var(--blue-surface); }
.vat-boxes input.adj { width: 120px; }
.overdue-text { color: var(--err); font-weight: 600; }

/* Dashboard */
.dash { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.dash-col { min-width: 0; }
@media (max-width: 860px) { .dash { grid-template-columns: 1fr; } }
.dash-card h2 { margin: 0; font-size: 15px; }
.dash-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.dash-split { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.dash-figures { width: auto; margin-left: auto; }
.dash-figures td { padding: 3px 0 3px 18px; border: 0; font-size: 13px; color: var(--text-2); }
.dash-figures td.num { color: var(--text); font-weight: 600; }
.overdue-text, .dash-figures td.overdue-text { color: var(--err); }
.chart { display: block; overflow: visible; }
.chart-axis { font: 400 10.5px var(--font); fill: var(--text-2); }
@media (max-width: 600px) { .chart-axis { font-size: 14px; } }
.chart a .chart-hit, .chart-hit { cursor: default; outline: none; }
.chart a .chart-hit { cursor: pointer; }
.chart-hit:hover, .chart-hit:focus { fill: rgba(17, 70, 136, 0.06); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.chart-tip { position: fixed; z-index: 50; pointer-events: none; background: var(--nav); color: #fff; font-size: 12px; line-height: 1.4; padding: 6px 9px; border-radius: 5px; white-space: pre-line; box-shadow: 0 4px 12px rgba(16, 24, 40, 0.18); max-width: 260px; }

/* Reports */
.report-links { list-style: none; margin: 0; padding: 0; }
.report-links li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.report-links li:last-child { border-bottom: 0; }
.report-head { padding: 14px 16px; border-bottom: 1px solid var(--line); }
table.report td { padding: 7px 12px; }
table.report td.indent { padding-left: 28px; }
table.report tr.section td { font-weight: 650; border-bottom: 0; padding-top: 14px; }
table.report tr.total td { font-weight: 600; border-top: 1px solid var(--line-strong); }
table.report tr.grand td { font-weight: 700; border-top: 1px solid var(--text); border-bottom: 2px solid var(--line-strong); }
table.report tr.gap td { border: 0; padding: 4px; }
@media print { table.report tr.clickable td a { color: inherit; } }
.badge.SENT, .badge.APPROVED { background: var(--blue-surface); color: var(--primary); }
.badge.ACCEPTED, .badge.INVOICED, .badge.BILLED { background: var(--ok-bg); color: var(--ok); }
.badge.DECLINED { background: #F2F4F7; color: var(--text-3); }
.receipts { display: flex; flex-wrap: wrap; gap: 12px; }
.receipt { width: 140px; }
.receipt img, .receipt-file { display: grid; place-items: center; width: 140px; height: 140px; object-fit: cover; border: 1px solid var(--line); border-radius: 6px; background: var(--subtle); font-weight: 700; color: var(--text-2); }

/* Budgets: a grid of months, the account column kept in view while scrolling sideways. */
.budget-grid input { width: 92px; text-align: right; padding: 5px 6px; }
.budget-grid td, .budget-grid th { padding: 4px 6px; }
.budget-grid td:first-child, .budget-grid th:first-child { position: sticky; left: 0; background: var(--card); z-index: 1; }
.budget-grid tr.section td { padding-top: 12px; }
td.neg { color: var(--err); }
.badge.refused { background: var(--err-bg); color: var(--err); }
