/* Brige Books — theme
 *
 * The palette is Brige's, taken from the Brige Ship panel and brige.world so a
 * customer moving between the products does not meet a different company.
 *
 * ⚠ ONLY COLOURS WERE CHANGED. Books is a deliberate Tally look-alike and what makes
 * it worth using to an accountant is the muscle memory in its layout, density and
 * keyboard shortcuts — not its looks. Every padding, size and position here is still
 * the one that was tested against Tally. Re-skin freely; re-arrange nothing.
 */
:root {
  /* Straight from the Brige Ship panel. Keep in step if that palette ever moves. */
  --ground:#FFFCF9;  --surface:#FFFFFF;  --surface-2:#FDF1E4;
  --ink:#3A281E;     --ink-2:#6B5344;    --muted:#9A8577;
  --line:#F0E1D3;    --line-2:#E1CAB3;
  --signal:#D4761E;  --signal-soft:#FDEEDD;
  /* Money keeps its own green and red: brown on brown cannot say paid vs failed. */
  --ledger:#2E7D52;  --ledger-soft:#E7F2EA;
  --risk:#A8452F;    --risk-soft:#FBE9E3;
  --rail:#3A281E;    --rail-ink:#F7E8DA;

  /* Derived here, because Books has chrome the Brige panel does not. */
  --rail-2:#2C1E16;        /* nested nav + the gradient's dark end */
  --rail-hover:#4A362A;
  --rail-active:#55402F;
  --rail-ink-2:#D9C3AE;    /* sub-items, a step quieter than --rail-ink */
  /* ⚠ --signal is too dark to read on the rail; this is the same hue, lifted. */
  --accent-rail:#E79A4D;
  --accent-rail-hi:#F2B477;
  --risk-deep:#7A2E1F;

  /* The keyboard selection an accountant's eye follows all day. It replaces Tally's
     yellow and has to stay legible under black text — hence a tint, not the accent. */
  --select:#F7DCBE;
  --select-strong:#F0C79A;
  --field-focus-bg:#FFFBF6;

  color-scheme: light;
}

/* Focus is the same ring as the Brige panel. */
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Segoe UI", Tahoma, Verdana, Arial, sans-serif;
  font-size: 14px; color: var(--ink); background: var(--ground);
  overflow: hidden; user-select: none;
}
#app { height: 100vh; display: flex; flex-direction: column; }
/* full-height app shell so the bottom bar always sits at the bottom of the viewport */
#app > .shell { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

/* ---- top bar ---- */
.topbar { background: linear-gradient(var(--rail), var(--rail-2)); color: #fff; display: flex;
  align-items: center; height: 40px; padding: 0 10px; flex: 0 0 auto; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: .3px; margin-right: 6px; }
.brand small { font-size: 10px; opacity: .8; font-weight: 400; vertical-align: super; }
.topmenu { display: flex; gap: 2px; margin-left: auto; }
.topmenu .mi { padding: 4px 9px; border-radius: 3px; font-size: 12.5px; white-space: nowrap; }
.topmenu .mi b { color: var(--accent-rail); font-weight: 700; }
.searchbar { flex: 1; margin: 0 12px; background: var(--surface-2); color: var(--ink-2); height: 26px; border-radius: 4px;
  display: flex; align-items: center; padding: 0 10px; font-size: 12.5px; max-width: 520px; }

/* ---- body layout ---- */
.main { flex: 1; display: flex; min-height: 0; }

/* ---- left navigation drawer (collapsible icon rail with hover-peek overlay) ----
   .drawer is the flex rail (fixed 52px collapsed / 210px pinned). .drawer-inner is
   absolutely positioned so that, when peeking on hover, it overlays the page content
   to the right instead of pushing it. */
.drawer { flex: 0 0 52px; width: 52px; position: relative; z-index: 20;
  transition: flex-basis .16s ease, width .16s ease; }
.drawer.open { flex-basis: 210px; width: 210px; }
.drawer-inner { position: absolute; top: 0; bottom: 0; left: 0; width: 52px;
  background: var(--rail); color: var(--rail-ink); display: flex; flex-direction: column; gap: 1px;
  padding: 6px 0; overflow-x: hidden; overflow-y: auto; transition: width .16s ease; }
.drawer.open .drawer-inner { width: 210px; }
.drawer:not(.open):hover .drawer-inner { width: 210px; box-shadow: 4px 0 16px rgba(0,0,0,.3); }
.drawer-toggle, .drawer-item { background: transparent; border: none; color: var(--rail-ink); cursor: pointer;
  height: 40px; min-height: 40px; display: flex; align-items: center; gap: 14px; padding: 0 15px; width: 100%;
  white-space: nowrap; font-size: 13px; font-family: inherit; text-align: left; }
.drawer-toggle { margin-bottom: 6px; color: var(--accent-rail); }
.drawer-item:hover, .drawer-toggle:hover { background: var(--rail-hover); }
.drawer-item.active { background: var(--rail-active); box-shadow: inset 3px 0 0 var(--accent-rail); }
.drawer .di-ic { flex: 0 0 22px; display: flex; align-items: center; justify-content: center; }
.drawer .di-ic svg { width: 19px; height: 19px; fill: currentColor; display: block; }
.drawer .di-lbl { opacity: 0; transition: opacity .12s ease; }
.drawer.open .di-lbl, .drawer:not(.open):hover .di-lbl { opacity: 1; }
/* accordion groups + sub-items */
.nav-group { display: flex; flex-direction: column; }
.nav-chev { margin-left: auto; font-size: 10px; opacity: .8; }
.drawer:not(.open) .nav-chev { display: none; }
.drawer:not(.open):hover .nav-chev { display: inline; }
.nav-sub { display: none; flex-direction: column; background: var(--rail-2); }
.drawer.open .nav-group.open .nav-sub,
.drawer:not(.open):hover .nav-group.open .nav-sub { display: flex; }
.nav-subitem { background: transparent; border: none; color: var(--rail-ink-2); cursor: pointer; font-family: inherit;
  text-align: left; font-size: 12.5px; padding: 8px 14px 8px 51px; white-space: nowrap; width: 100%; }
.nav-subitem:hover { background: var(--rail-hover); color: #fff; }
.nav-head.expanded { background: var(--rail-hover); }
/* keyboard selection highlight (Tally-style) */
.drawer-item.kbdsel, .nav-subitem.kbdsel { background: var(--rail-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent-rail); }
/* quit? yes/no prompt */
.quit-box { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%);
  background: #fff; border: 1px solid var(--line-2); border-radius: 8px; min-width: 250px;
  overflow: hidden; box-shadow: 0 16px 48px rgba(0,0,0,.3); }
.quit-box .q-msg { padding: 20px 24px; font-size: 16px; font-weight: 600; color: var(--ink); text-align: center; }
.quit-box .q-btns { display: flex; border-top: 1px solid var(--line); }
.quit-box .q-btns .btn { flex: 1; border: none; padding: 12px; cursor: pointer; font-size: 14px;
  font-family: inherit; background: var(--signal); color: #fff; }
.quit-box .q-btns .btn.sec { background: var(--surface-2); color: var(--ink-2); }
.quit-box .q-btns .btn:hover { filter: brightness(1.06); }
.quit-box .q-btns .btn.qsel { box-shadow: inset 0 0 0 3px var(--accent-rail); }
/* form section subtitle + create-item modal */
.form-subtitle { font-weight: 700; color: var(--ink); margin: 14px 0 6px; font-size: 13px;
  border-top: 1px solid var(--line); padding-top: 10px; }
.form-modal { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: #fff; border: 1px solid var(--line-2); border-radius: 8px; width: 560px; max-width: 94vw;
  max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 18px 50px rgba(0,0,0,.3); }
.form-modal .fm-head { background: var(--surface-2); color: var(--ink); font-weight: 700; padding: 10px 16px; }
.form-modal .fm-body { overflow: auto; padding: 4px 16px; }
.form-modal .fm-body .form-wrap { padding: 8px 0; max-width: none; }
.form-modal .fm-foot { border-top: 1px solid var(--line); padding: 10px 16px; display: flex; gap: 10px; justify-content: flex-end; }
.content { flex: 1; overflow: auto; position: relative; background: var(--ground); }
.rightpanel { width: 150px; flex: 0 0 150px; background: var(--surface-2); border-left: 1px solid var(--line-2);
  overflow: auto; padding: 4px; display: flex; flex-direction: column; gap: 3px; }
.rbtn { background: var(--surface); border: 1px solid var(--line-2); border-radius: 3px; padding: 4px 6px;
  font-size: 11.5px; line-height: 1.25; cursor: pointer; }
.rbtn b { color: var(--signal); }
.rbtn:hover { background: var(--signal-soft); }
.rbtn .k { color: var(--risk); font-weight: 700; }

/* ---- header strip (report title + period) ---- */
/* ⚠ The company/period band sits above EVERY report, so it takes the chrome brown,
   not the signal orange. Orange is Brige's accent — a full-width saturated band of it
   shouts over the figures the page exists to show. */
.strip { background: var(--rail); color: var(--rail-ink); padding: 5px 12px; display: flex; justify-content: space-between;
  align-items: center; font-size: 13px; }
.strip .co { font-weight: 700; }
.strip .period { font-size: 12px; opacity: .95; }

/* ---- home dashboard ---- */
.dash { padding: 26px 30px; max-width: 1000px; }
.dash-head h1 { font-size: 24px; color: var(--ink); font-weight: 700; margin-bottom: 4px; }
.dash-head .dash-sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.dash-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; cursor: pointer;
  box-shadow: 0 1px 2px rgba(58,40,30,.06); transition: box-shadow .12s, border-color .12s, transform .08s; }
.dash-card:hover { border-color: var(--signal); box-shadow: 0 6px 18px rgba(58,40,30,.14); transform: translateY(-1px); }
.dash-card .dc-t { font-weight: 700; color: var(--ink); font-size: 15px; margin-bottom: 3px; }
.dash-card .dc-s { color: var(--muted); font-size: 12.5px; }
.dash-hint { margin-top: 20px; color: var(--muted); font-size: 12.5px; }

/* ---- gateway menu ---- */
.gw-wrap { display: flex; justify-content: center; padding-top: 26px; }
.gw { background: #fff; border: 1px solid var(--line-2); width: 430px; box-shadow: 0 6px 24px rgba(0,0,0,.12); }
.gw-title { background: var(--surface-2); text-align: center; font-weight: 700; padding: 6px; border-bottom: 1px solid var(--line-2);
  color: var(--ink); }
.gw-sec { font-size: 11px; color: var(--muted); padding: 8px 16px 2px; text-transform: uppercase; letter-spacing: .5px; }
.menu-item { padding: 4px 16px; cursor: pointer; display: flex; }
.menu-item .hot { color: var(--risk); font-weight: 700; }
.menu-item.sel { background: var(--select); }
.menu-item.sel .hot { color: var(--risk-deep); }

/* ---- forms ---- */
.form-wrap { padding: 16px 22px; max-width: 860px; }
.form-title { font-weight: 700; color: var(--ink); margin-bottom: 10px; font-size: 15px; }
.frow { display: flex; align-items: center; margin-bottom: 4px; }
.frow label { width: 200px; color: var(--ink-2); }
.frow .fin { flex: 1; max-width: 380px; }
.fin { border: 1px solid var(--line-2); background: #fff; padding: 4px 7px; font-size: 14px; font-family: inherit;
  color: var(--ink); border-radius: 2px; }
.fin:focus { outline: none; border-color: var(--signal); background: var(--field-focus-bg); box-shadow: 0 0 0 2px var(--signal-soft); }
select.fin { min-width: 200px; }
.hint { color: var(--muted); font-size: 11.5px; margin-top: 2px; }

/* ---- voucher ---- */
.vhead { display: flex; justify-content: space-between; align-items: flex-start; padding: 8px 14px;
  border-bottom: 1px solid var(--line); background: var(--surface-2); }
.vtype-name { font-size: 20px; font-weight: 700; color: var(--ink); }
.vno { text-align: right; font-size: 12.5px; color: var(--ink-2); }
.vlines { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.vlines th { background: var(--surface-2); text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line-2); font-size: 12px; }
.vlines td { padding: 2px 6px; border-bottom: 1px dotted var(--line); }
.vlines td.amt, .vlines th.amt { text-align: right; }
.vlines input { border: none; background: transparent; width: 100%; font-size: 13.5px; font-family: inherit;
  padding: 3px 4px; color: var(--ink); }
.vlines input:focus { outline: none; background: var(--field-focus-bg); box-shadow: inset 0 0 0 1px var(--signal); }
.vtot { font-weight: 700; background: var(--surface-2); }
.dc { width: 30px; color: var(--risk); font-weight: 700; text-align: center; }

/* ---- report tables ---- */
.rpt { width: 100%; border-collapse: collapse; font-size: 13px; }
.rpt th { background: var(--surface-2); text-align: left; padding: 5px 10px; border-bottom: 1px solid var(--line-2); }
.rpt td { padding: 3px 10px; border-bottom: 1px solid var(--line); }
.rpt td.num, .rpt th.num { text-align: right; font-variant-numeric: tabular-nums; }
.rpt tr.grp td { font-weight: 700; background: var(--surface-2); color: var(--ink); }
.rpt tr.total td { font-weight: 700; border-top: 2px solid var(--line-2); background: var(--surface-2); }
.rpt tr.click:hover { background: var(--select); cursor: pointer; }
.rpt tr.ksel td { background: var(--select); }
.rpt tr.ksel:hover td { background: var(--select-strong); }
.two-col { display: flex; gap: 0; }
.two-col > div { flex: 1; }
.two-col .side-title { text-align: center; font-weight: 700; background: var(--surface-2); padding: 4px; color: var(--ink);
  border: 1px solid var(--line-2); }

/* ---- bottom bar ---- */
.bottombar { background: var(--rail-2); color: var(--rail-ink); flex: 0 0 auto; display: flex; align-items: center;
  height: 30px; font-size: 11.5px; padding: 0 10px; gap: 14px; }
.bottombar .keyhint b { color: var(--accent-rail); }
.bottombar .right { margin-left: auto; }

/* ---- login / center card ---- */
.center-screen { flex: 1; display: flex; align-items: center; justify-content: center; background: var(--surface-2); }
.card { background: #fff; border: 1px solid var(--line-2); width: 380px; box-shadow: 0 10px 30px rgba(0,0,0,.15); }
.card h2 { background: linear-gradient(var(--rail),var(--rail-2)); color: #fff; padding: 12px 16px; font-size: 16px; }
.card .body { padding: 18px; }
.card .frow label { width: 120px; }
.msg { color: var(--risk); font-size: 12.5px; min-height: 16px; margin-top: 4px; }
.btnrow { margin-top: 14px; display: flex; gap: 8px; }
.btn { background: var(--signal); color: #fff; border: none; padding: 7px 16px; border-radius: 3px; cursor: pointer;
  font-size: 13px; font-family: inherit; }
.btn.sec { background: var(--muted); }
.btn:hover { filter: brightness(1.08); }

/* popups (list picker) */
.overlay { position: absolute; inset: 0; background: rgba(58,40,30,.28); display: flex;
  align-items: flex-start; justify-content: center; padding-top: 60px; z-index: 50; }
.picker { background: #fff; border: 1px solid var(--line-2); width: 380px; max-height: 74vh; display: flex;
  flex-direction: column; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.picker .ph { background: var(--surface-2); padding: 6px 10px; font-weight: 700; color: var(--ink); flex: 0 0 auto; }
.picker .picker-search { flex: 0 0 auto; margin: 6px 8px; padding: 6px 9px; border: 1px solid var(--line-2);
  border-radius: 3px; font-size: 13.5px; font-family: inherit; color: var(--ink); }
.picker .picker-search:focus { outline: none; border-color: var(--signal); background: var(--field-focus-bg); box-shadow: 0 0 0 2px var(--signal-soft); }
.picker .plist { overflow: auto; flex: 1 1 auto; }
.picker .pi { padding: 6px 10px; cursor: pointer; }
.picker .pi:hover { background: var(--surface-2); }
.picker .pi.sel { background: var(--select); }
.picker .pi.sel:hover { background: var(--select-strong); }
.picker .pi.create { color: var(--signal); font-weight: 600; }
.picker .pi.empty { color: var(--muted); font-style: italic; cursor: default; }
.picker .pk-hint { flex: 0 0 auto; padding: 5px 10px; font-size: 11px; color: var(--muted); background: var(--ground); border-top: 1px solid var(--line); }

.toast { position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%); background: var(--ink);
  color: #fff; padding: 8px 18px; border-radius: 4px; font-size: 13px; z-index: 100; opacity: .97; }

/* help / shortcuts */
.helpbtn { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-rail); color: var(--rail-2);
  font-weight: 700; display: flex; align-items: center; justify-content: center; cursor: pointer;
  margin-left: 12px; font-size: 13px; flex: 0 0 auto; }
.helpbtn:hover { background: var(--accent-rail-hi); }
.keyhint.clickable { cursor: pointer; }
.keyhint.clickable:hover { color: #fff; }
.strip .period.clickable { cursor: pointer; }
.strip .period.clickable:hover { text-decoration: underline; }
.modal-overlay { position: fixed; inset: 0; background: rgba(58,40,30,.45); z-index: 200;
  display: flex; align-items: center; justify-content: center; }
.help-box { background: #fff; width: 580px; max-width: 94vw; max-height: 88vh; overflow: auto;
  border-radius: 6px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.help-head { background: linear-gradient(var(--rail), var(--rail-2)); color: #fff; padding: 12px 16px;
  font-size: 16px; font-weight: 700; display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; }
.help-x { cursor: pointer; opacity: .85; font-size: 15px; }
.help-x:hover { opacity: 1; }
.help-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.help-tbl th { text-align: left; background: var(--surface-2); padding: 7px 16px; border-bottom: 1px solid var(--line); }
.help-tbl td { padding: 6px 16px; border-bottom: 1px solid var(--line); }
.help-tbl tr.help-grp td { background: var(--surface-2); font-weight: 700; color: var(--ink); }
.help-tbl td.hl { font-weight: 700; color: var(--ink); background: var(--signal-soft); }
.help-note { padding: 12px 16px; font-size: 12px; color: var(--ink-2); background: var(--ground); line-height: 1.5; }

/* print any report cleanly */
@media print {
  .topbar, .rightpanel, .bottombar, .searchbar, .helpbtn, .modal-overlay, .toast, .drawer { display: none !important; }
  html, body, #app, .main, .content { height: auto !important; overflow: visible !important; }
  .content { background: #fff !important; }
  .strip { color: #000 !important; background: #fff !important; border-bottom: 2px solid #000; }
  .rpt th, .two-col .side-title, .vlines th { background: #eee !important; -webkit-print-color-adjust: exact; }
  .rpt tr.click:hover { background: none !important; }
  .rpt tr.ksel td { background: none !important; }
}
.empty { padding: 30px; text-align: center; color: var(--muted); }
