/* Legacy Books – theme matched to legacyskills.co.za */
:root {
  --primary: #1b3a6b;
  --primary-hover: #142d54;
  --dark: #0f1f3d;
  --accent: #d97706;
  --accent-text: #92400e;
  --bg: #ffffff;
  --soft: #f4f5f7;
  --line: #e3e5e8;
  --muted: #5f636a;
  --text: #161616;
  --ok-bg: #dcfce7; --ok: #14532d;
  --warn-bg: #fef3c7; --warn: #78350f;
  --bad-bg: #fee2e2; --bad: #991b1b;
  --info-bg: #e0ecfb; --info: #1b3a6b;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-head: 'Jost', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --nav-w: 240px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-body); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--soft); font-variant-numeric: tabular-nums; }
a { color: var(--primary); }
a:hover { color: var(--accent-text); }
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; color: var(--primary); line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 28px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 .75em; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--soft); padding: 1px 5px; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { float: right; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff; padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* --- top bars --- */
.topbar { background: var(--primary); color: #fff; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; padding: 6px 20px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.topbar-mode { color: #fcd9a8; font-weight: 600; }
.appbar { background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 20px; padding: 10px 20px; flex-wrap: wrap; position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--primary); }
.brand img { height: 44px; width: auto; display: block; }
.brand-name { font-family: var(--font-head); font-weight: 600; font-size: 18px; border-left: 1px solid var(--line); padding-left: 12px; }
.appbar-company { display: flex; flex-direction: column; flex: 1 1 200px; min-width: 0; }
.appbar-company .label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.company-name { font-weight: 600; text-decoration: none; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-user { display: flex; align-items: center; gap: 12px; font-size: 14px; flex-wrap: wrap; }
.appbar-user a { text-decoration: none; font-weight: 600; }
.appbar-user form { margin: 0; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; text-decoration: underline; }
.menu-toggle { display: none; background: none; border: 1px solid var(--line); width: 44px; height: 44px; align-items: center; justify-content: center; color: var(--primary); cursor: pointer; }

/* --- shell --- */
.shell { display: flex; min-height: calc(100vh - 100px); }
.sidenav { width: var(--nav-w); flex: 0 0 var(--nav-w); background: var(--dark); padding: 16px 0 24px; display: flex; flex-direction: column; }
.sidenav a { color: #dde3ee; text-decoration: none; padding: 10px 20px 10px 17px; border-left: 3px solid transparent; font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.sidenav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidenav a.active { background: var(--primary); color: #fff; border-left-color: var(--accent); font-weight: 600; }
.nav-section { color: #93a3bf; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; padding: 18px 20px 6px; }
.main { flex: 1 1 auto; min-width: 0; padding: 28px; max-width: 1280px; }
.main-solo { max-width: none; padding: 0; }

/* --- page parts --- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin-bottom: 4px; }
.page-head p { margin: 0; max-width: 760px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.page-head .actions { margin-top: 0; }
.card { background: #fff; border: 1px solid var(--line); padding: 22px; margin-bottom: 20px; }
.card.narrow { max-width: 560px; }
.card > h2:first-child { margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; margin-bottom: 0; }
.grid-2 > .card { margin-bottom: 20px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--primary); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.kpi span { font-size: 13px; color: var(--muted); }
.kpi strong { font-family: var(--font-head); font-size: 24px; color: var(--primary); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { border: 1px solid var(--line); padding: 16px; text-decoration: none; color: var(--primary); font-weight: 600; min-height: 56px; display: flex; align-items: center; }
.tile:hover { border-color: var(--primary); background: var(--soft); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0 0 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 4px 0; }

/* --- buttons --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 18px; font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; border: 2px solid var(--primary); background: #fff; color: var(--primary); border-radius: 0; text-transform: uppercase; letter-spacing: .04em; }
.btn:hover { background: var(--soft); color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-danger { border-color: #b91c1c; color: #b91c1c; }
.btn-danger:hover { background: #fef2f2; color: #991b1b; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.icon-btn { width: 36px; height: 36px; border: 1px solid var(--line); background: #fff; color: var(--bad); font-size: 20px; line-height: 1; cursor: pointer; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row-actions form { margin: 0; }

/* --- forms --- */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #2b2f36; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; font-size: 14px; }
input[type=text], input[type=password], input[type=email], input[type=number], select, textarea { font: inherit; font-size: 15px; font-weight: 400; color: var(--text); padding: 10px 12px; border: 1px solid #b9bec7; border-radius: 0; background: #fff; width: 100%; min-height: 44px; }
input:disabled, select:disabled, textarea:disabled { background: var(--soft); color: #3a3f46; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); }
input.num { text-align: right; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 8px; }
.form-grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.inline-form label { min-width: 200px; flex: 0 1 auto; }
form { margin: 0; }
.danger-zone { margin: -8px 0 20px; }

/* --- tables --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--soft); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid #eef0f2; vertical-align: middle; }
.num { text-align: right; white-space: nowrap; }
tfoot td { font-weight: 700; background: var(--soft); border-top: 2px solid var(--text); }
tr.inactive td { color: var(--muted); }
tr.current td { background: #fff7ed; }
tr.sub td { color: var(--muted); font-style: italic; }
table.report td.double { border-bottom: 3px double var(--text); }
table.grid td { padding: 4px; }
table.grid input, table.grid select { min-height: 40px; padding: 8px; font-size: 14px; }
table.grid th { padding: 8px; }
.balance-msg { font-weight: 600; background: #fff !important; border-top: 0 !important; }
.balance-msg.ok { color: var(--ok); }
.balance-msg.bad { color: var(--bad); }

/* --- tabs, pills, flashes, hint --- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--text); border-bottom: 3px solid transparent; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--accent); }
.pill { display: inline-block; padding: 3px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-info { background: var(--info-bg); color: var(--info); }
.pill-neutral { background: #eceef1; color: #374151; }
.flash { padding: 12px 16px; margin-bottom: 16px; border: 1px solid; }
.flash ul { margin: 6px 0 0; padding-left: 20px; }
.flash-success { background: var(--ok-bg); color: var(--ok); border-color: #86efac; }
.flash-error { background: var(--bad-bg); color: var(--bad); border-color: #fca5a5; }
.flash-info { background: var(--info-bg); color: var(--info); border-color: #b9cdea; }
.hint { background: #f0fdf4; border: 1px solid #a7f3d0; padding: 18px 22px; margin-bottom: 20px; color: #064e3b; }
.hint h2 { color: #065f46; font-size: 16px; }
.hint table { width: auto; min-width: 360px; }
.hint td { border: 0; padding: 3px 24px 3px 0; }
.hint td.indent { padding-left: 28px; }
.report-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.pager { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.creds { border-color: var(--accent); border-width: 2px; }

/* --- login --- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--soft); }
.login-card { background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--primary); padding: 36px; width: 100%; max-width: 420px; }
.login-logo { height: 64px; width: auto; display: block; margin-bottom: 18px; }

/* --- small screens --- */
@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; }
  .brand-name { display: none; }
  .appbar { gap: 12px; padding: 8px 12px; }
  .appbar-user .muted { display: none; }
  .sidenav { position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; overflow-y: auto; box-shadow: 4px 0 24px rgba(0,0,0,.2); }
  body.menu-open .sidenav { transform: none; }
  body.menu-open::after { content: ''; position: fixed; inset: 0; background: rgba(15,31,61,.4); z-index: 40; }
  .main { padding: 16px; }
  .form-grid .span-2 { grid-column: auto; }
  h1 { font-size: 24px; }
}

/* --- print --- */
.print-only { display: none; }
@media print {
  .topbar, .appbar, .sidenav, .no-print, .actions, .flash, form.card.inline-form, .skip { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .main { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; }
  .print-only { display: block; }
  a { color: inherit; text-decoration: none; }
}
