/* ==========================================================================
   Accounts Dashboard - single stylesheet
   Sections: tokens / base / login / shell / sidebar / submenu / topbar
             cards / tables / forms / responsive
   ========================================================================== */

/* ---------- tokens ---------- */
:root {
  --sidebar-w: 268px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 68px;
  --radius: 12px;
  --radius-sm: 8px;

  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e4e8f0;
  /* The line a list is read by. --border is a hairline meant for panel
     edges; a register read down a column needs a rule that is actually
     visible on a bright screen, so lists draw with this instead. */
  --border-strong: #a9b2c6;
  --text: #1a2233;
  --text-dim: #6b7688;
  --text-faint: #98a1b3;

  --brand: #2f6df6;
  --brand-dark: #1e51cc;
  --brand-soft: #e8f0ff;

  --side-bg: #131a2b;
  --side-bg-2: #0e1421;
  --side-text: #a9b4c9;
  --side-text-hi: #ffffff;
  --side-hover: rgba(255, 255, 255, .06);
  --side-active: rgba(47, 109, 246, .18);

  --ok: #16a34a;
  --ok-soft: #e7f7ed;
  --warn: #d97706;
  --warn-soft: #fef3e2;
  --danger: #dc2626;
  --danger-soft: #fdeaea;
  --info: #0891b2;
  --info-soft: #e2f6fa;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 4px 16px rgba(16, 24, 40, .08);
  --shadow-lg: 0 18px 44px rgba(16, 24, 40, .18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1220;
    --surface: #151c2e;
    --surface-2: #1b2338;
    --border: #26304a;
    --border-strong: #46536f;
    --text: #e8ecf5;
    --text-dim: #9aa5bb;
    --text-faint: #74809a;
    --brand-soft: #1c2b4d;
    --side-bg: #0b101c;
    --side-bg-2: #080c15;
    --ok-soft: #12291c;
    --warn-soft: #2e2312;
    --danger-soft: #2e1717;
    --info-soft: #102a30;
    --shadow: 0 4px 16px rgba(0, 0, 0, .4);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, .55);
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", Roboto, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ==========================================================================
   LOGIN
   ========================================================================== */
body.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(47, 109, 246, .30), transparent 60%),
    radial-gradient(900px 700px at 105% 110%, rgba(14, 165, 233, .22), transparent 55%),
    var(--side-bg);
}

.login-card {
  width: 100%;
  max-width: 940px;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  background: var(--surface);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.login-aside {
  padding: 44px 40px;
  color: #fff;
  background: linear-gradient(155deg, #2f6df6 0%, #1e3fae 55%, #16256b 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 480px;
}
.login-aside .brand-mark {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, .16);
  font-weight: 700; letter-spacing: .5px;
}
.login-aside h2 { font-size: 27px; line-height: 1.3; margin: 26px 0 10px; }
.login-aside p  { margin: 0; color: rgba(255, 255, 255, .82); font-size: 14.5px; }
.login-points { list-style: none; margin: 30px 0 0; padding: 0; }
.login-points li {
  display: flex; gap: 10px; align-items: center;
  padding: 7px 0; font-size: 14px; color: rgba(255, 255, 255, .9);
}
.login-points svg { width: 18px; height: 18px; flex: 0 0 18px; }

.login-form { padding: 46px 46px 40px; display: flex; flex-direction: column; justify-content: center; }
.login-form h1 { font-size: 24px; }
.login-form .lead { margin: 8px 0 26px; color: var(--text-dim); font-size: 14.5px; }

.field { margin-bottom: 16px; }
.field label {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 600; color: var(--text-dim);
}
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > svg {
  position: absolute; left: 13px; width: 18px; height: 18px;
  color: var(--text-faint); pointer-events: none;
}
.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.input-wrap .input { padding-left: 40px; }
.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.pw-toggle {
  position: absolute; right: 6px;
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border: 0; border-radius: 6px; background: none;
  color: var(--text-faint); cursor: pointer;
}
.pw-toggle:hover { background: var(--surface-2); color: var(--text); }
.pw-toggle svg { width: 18px; height: 18px; }

.row-between { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 22px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-dim); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--brand); color: #fff;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background .15s, transform .06s, box-shadow .15s;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-block { width: 100%; padding: 13px 18px; }
/* .btn-ghost {
  background: var(--surface); color: var(--text); border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 7px 12px; font-size: 13.5px; } */
.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-ghost:hover {
    background: var(--surface-2);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 7px 12px;
    font-size: 13.5px;
    font-weight: 600;
}

/* ---------- row actions ----------
   The buttons at the end of a register row. Edit changes the voucher, Open
   only shows it - two different things one click apart, so they are told
   apart by colour rather than by reading the word each time: amber for the
   one that writes, blue for the one that looks. Both are tinted rather than
   solid, so a page of them does not shout over the figures. */
.row-actions { white-space: nowrap; }
.row-actions .btn { margin-right: 4px; }
.row-actions .btn:last-child { margin-right: 0; }

.btn-edit {
    background: var(--warn-soft);
    color: var(--warn);
    border-color: rgba(217, 119, 6, .40);
}
.btn-edit:hover { background: var(--warn); color: #fff; border-color: var(--warn); }

.btn-open {
    background: var(--brand-soft);
    color: var(--brand);
    border-color: rgba(47, 109, 246, .35);
}
.btn-open:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px; margin-bottom: 18px;
  border-radius: var(--radius-sm);
  font-size: 14px; line-height: 1.45;
}
.alert svg { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 1px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-ok    { background: var(--ok-soft);     color: var(--ok); }
.alert-info  { background: var(--info-soft);   color: var(--info); }
.alert-warn  { background: var(--warn-soft);   color: var(--warn); }

.login-foot { margin-top: 22px; font-size: 12.5px; color: var(--text-faint); text-align: center; }

/* ==========================================================================
   APP SHELL
   ========================================================================== */
.app { display: flex; min-height: 100vh; }

.main {
  flex: 1;
  min-width: 0;                      /* lets wide tables scroll instead of pushing */
  margin-left: var(--sidebar-w);
  display: flex; flex-direction: column;
  transition: margin-left .22s ease;
}
body.sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }

.content { flex: 1; padding: 24px 26px 34px; }

.page-foot {
  display: flex; justify-content: space-between;
  padding: 14px 26px;
  border-top: 1px solid var(--border);
  color: var(--text-faint); font-size: 12.5px;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-2) 100%);
  color: var(--side-text);
  z-index: 60;
  transition: width .22s ease, transform .22s ease;
}
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }

.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h);
  padding: 0 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  flex: 0 0 auto;
}
.brand-mark {
  flex: 0 0 38px; width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #17a2f5);
  color: #fff; font-weight: 700; font-size: 14px; letter-spacing: .5px;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { color: var(--side-text-hi); font-size: 15px; white-space: nowrap; }
.brand-text small  { color: var(--text-faint); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 14px 10px; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .13); border-radius: 3px; }

.menu, .submenu { list-style: none; margin: 0; padding: 0; }
.menu-item { position: relative; margin-bottom: 2px; }

.menu-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--side-text);
  font-size: 14.5px; font-weight: 500;
  cursor: pointer; user-select: none;
  transition: background .14s, color .14s;
}
.menu-link:hover { background: var(--side-hover); color: var(--side-text-hi); text-decoration: none; }

.menu-icon { flex: 0 0 22px; display: grid; place-items: center; }
.menu-icon svg { width: 20px; height: 20px; }
.menu-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.menu-caret { flex: 0 0 16px; display: grid; place-items: center; transition: transform .2s ease; }
.menu-caret svg { width: 14px; height: 14px; }

/* active top-level item */
.menu-item.is-active > .menu-link,
.menu-item.is-open   > .menu-link {
  background: var(--side-active);
  color: var(--side-text-hi);
}
.menu-item.is-active > .menu-link::before,
.menu-item.is-open   > .menu-link::before {
  content: "";
  position: absolute; left: -10px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--brand);
}

.sidebar-foot { flex: 0 0 auto; padding: 12px 10px; border-top: 1px solid rgba(255, 255, 255, .07); }
.menu-link.logout:hover { background: rgba(220, 38, 38, .16); color: #ffb4b4; }

/* ==========================================================================
   SUBMENU
   Two presentations of the same markup:
     a) sidebar expanded  -> inline accordion
     b) sidebar collapsed -> flyout panel to the right
   Both open on hover (pointer devices) and on click (.is-open, set by JS).
   ========================================================================== */

/* (a) inline accordion */
.submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height .26s cubic-bezier(.4, 0, .2, 1);
}
.submenu-title { display: none; }

.submenu-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 8px 46px;
  border-radius: var(--radius-sm);
  color: var(--side-text);
  font-size: 13.8px;
  white-space: nowrap;
  transition: background .14s, color .14s;
}
.submenu-link:hover { background: var(--side-hover); color: var(--side-text-hi); text-decoration: none; }
.submenu-link .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; opacity: .45; flex: 0 0 5px;
}
.submenu-link.is-active { color: var(--side-text-hi); background: var(--side-hover); font-weight: 600; }
.submenu-link.is-active .dot { opacity: 1; background: var(--brand); box-shadow: 0 0 0 3px rgba(47, 109, 246, .25); }

/* open by click (JS) */
.menu-item.has-sub.is-open > .submenu { max-height: 460px; }
.menu-item.has-sub.is-open > .menu-link .menu-caret { transform: rotate(90deg); }

/* open by hover - pointer devices only, so a tap on mobile does not double-fire */
@media (hover: hover) and (pointer: fine) {
  body:not(.sidebar-collapsed) .menu-item.has-sub:hover > .submenu { max-height: 460px; }
  body:not(.sidebar-collapsed) .menu-item.has-sub:hover > .menu-link .menu-caret { transform: rotate(90deg); }
}

/* (b) flyout, when the rail is collapsed */
body.sidebar-collapsed .sidebar .brand-text,
body.sidebar-collapsed .sidebar .menu-label,
body.sidebar-collapsed .sidebar .menu-caret { display: none; }

body.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; }
body.sidebar-collapsed .menu-link { justify-content: center; padding: 12px 0; }
body.sidebar-collapsed .sidebar-nav { overflow: visible; }   /* or the flyout is clipped */

body.sidebar-collapsed .menu-item.has-sub > .submenu,
body.sidebar-collapsed .menu-item.has-sub.is-open > .submenu {
  position: absolute; left: 100%; top: -6px;
  min-width: 212px;
  max-height: none;
  padding: 8px;
  margin-left: 8px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius);
  background: var(--side-bg);
  box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden;
  transform: translateX(-6px);
  transition: opacity .16s, transform .16s, visibility .16s;
}
/* invisible bridge, so the pointer can cross the 8px gap without closing */
body.sidebar-collapsed .menu-item.has-sub > .submenu::before {
  content: ""; position: absolute; left: -10px; top: 0; bottom: 0; width: 10px;
}
body.sidebar-collapsed .submenu-title {
  display: block;
  padding: 6px 12px 10px;
  color: var(--side-text-hi);
  font-size: 12px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  margin-bottom: 6px;
}
body.sidebar-collapsed .submenu-link { padding-left: 12px; }

body.sidebar-collapsed .menu-item.has-sub.is-open > .submenu {
  opacity: 1; visibility: visible; transform: translateX(0);
}
@media (hover: hover) and (pointer: fine) {
  body.sidebar-collapsed .menu-item.has-sub:hover > .submenu {
    opacity: 1; visibility: visible; transform: translateX(0);
  }
  /* tooltip for items without a submenu */
  body.sidebar-collapsed .menu-item:not(.has-sub) > .menu-link { position: relative; }
  body.sidebar-collapsed .menu-item:not(.has-sub) > .menu-link:hover::after {
    content: attr(data-tip);
    position: absolute; left: calc(100% + 12px); top: 50%;
    transform: translateY(-50%);
    padding: 6px 10px; border-radius: 6px;
    background: var(--side-bg); color: var(--side-text-hi);
    font-size: 12.5px; white-space: nowrap;
    box-shadow: var(--shadow-lg);
  }
}

/* ==========================================================================
   TOPBAR
   ========================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 19px; }
.topbar-title p  { margin: 2px 0 0; font-size: 13px; color: var(--text-dim); }

.icon-btn {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-dim);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }

.topbar-right { display: flex; align-items: center; gap: 16px; }
.today { font-size: 13px; color: var(--text-dim); white-space: nowrap; }

/* Year picker - the financial year every screen reads from. Sits left of
   the date so the two read as one group: which year, then which day. */
.year-picker { display: flex; align-items: center; gap: 7px; }
.year-picker-label {
  font-size: 12px; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .04em;
}
.year-picker select {
  height: 32px;
  padding: 0 26px 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
  /* the caret, drawn rather than left to the platform's own */
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  background-size: 14px;
}
.year-picker select:hover { background-color: var(--surface-2); }
.year-picker select:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.year-picker-go {
  height: 32px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
  cursor: pointer;
}

/* Off the dashboard the year is read-only: the same shape as the dropdown,
   without the caret or the border that invites a click on it. It still links
   to the dashboard, which is where it can be changed. */
.year-picker-static { text-decoration: none; color: inherit; }
.year-picker-value {
  height: 32px; display: inline-flex; align-items: center;
  padding: 0 10px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.year-picker-static:hover .year-picker-value { border-color: var(--border); }
.year-picker-static:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; flex: 0 0 36px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #17a2f5);
  color: #fff; font-size: 13px; font-weight: 700;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-meta strong { font-size: 13.5px; }
.user-meta small  { font-size: 11.5px; color: var(--text-faint); text-transform: capitalize; }

/* ==========================================================================
   CARDS / STATS
   ========================================================================== */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 15px; }
.card-head p  { margin: 2px 0 0; font-size: 12.5px; color: var(--text-dim); }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

.stat { display: flex; gap: 14px; align-items: flex-start; padding: 18px; }
.stat-icon {
  width: 44px; height: 44px; flex: 0 0 44px;
  display: grid; place-items: center;
  border-radius: 11px;
}
.stat-icon svg { width: 21px; height: 21px; }
.stat-icon.blue   { background: var(--brand-soft);  color: var(--brand); }
.stat-icon.green  { background: var(--ok-soft);     color: var(--ok); }
.stat-icon.orange { background: var(--warn-soft);   color: var(--warn); }
.stat-icon.red    { background: var(--danger-soft); color: var(--danger); }
.stat-icon.cyan   { background: var(--info-soft);   color: var(--info); }

.stat-body { min-width: 0; }
.stat-label { font-size: 12.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 23px; font-weight: 700; margin-top: 3px; letter-spacing: -.02em; }
.stat-sub   { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.badge-green  { background: var(--ok-soft);     color: var(--ok); }
.badge-red    { background: var(--danger-soft); color: var(--danger); }
.badge-orange { background: var(--warn-soft);   color: var(--warn); }
.badge-blue   { background: var(--brand-soft);  color: var(--brand); }
.badge-grey   { background: var(--surface-2);   color: var(--text-dim); }

/* simple CSS bar chart, no library */
.bars { display: flex; align-items: flex-end; gap: 12px; height: 190px; padding: 8px 4px 0; }
.bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 8px; height: 100%; }
.bars .bar span.fill {
  width: 100%; max-width: 46px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--brand), #6ea2ff);
  min-height: 3px;
}
.bars .bar span.lab { font-size: 11.5px; color: var(--text-dim); white-space: nowrap; }

/* ==========================================================================
   TABLES
   ========================================================================== */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }

/* Every cell is boxed, in --border-strong: a register is read across a row
   and down a column, and a column with nothing at its edge is a column the
   eye has to keep its own place in. The outer edges are dropped below - the
   card the table sits in already draws that line, and two lines a pixel
   apart read as a mistake. */
table.data th
{
  padding: 5px 5px;
  text-align: center;
  border-right:  1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
table.data td {
  padding: 5px 5px;
  text-align: left;
  border-right:  1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
/* The last column's right edge is the card's edge. */
table.data tr > *:last-child { border-right: 0; }

table.data thead th {
  position: sticky; top: 0;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
}
/* The head is the heaviest line on the page - it is what the columns hang
   from, and sticky, so rows scroll under it and need somewhere to stop. */
table.data thead th { border-bottom: 2px solid var(--border-strong); }

table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.right, table.data th.right { text-align: right; }
table.data tfoot td {
  font-weight: 700;
  background: var(--surface-2);
  border-top: 2px solid var(--border-strong);
  border-bottom: 0;
}

.empty { padding: 44px 20px; text-align: center; color: var(--text-dim); }
.empty svg { width: 40px; height: 40px; color: var(--text-faint); margin-bottom: 10px; }
.empty p { margin: 0 0 4px; font-weight: 600; color: var(--text); }
.empty small { font-size: 13px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 18px; border-top: 1px solid var(--border); }
.pager .info { font-size: 13px; color: var(--text-dim); }
.pager .links { display: flex; gap: 8px; }

/* ==========================================================================
   FILTER BAR
   ========================================================================== */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters .field { margin: 0; }
.filters .input, .filters select { min-width: 170px; padding: 9px 12px; font-size: 14px; }
select.input { appearance: none; background-image: none; }

/* tab strip for the ?view= switch */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.tabs a {
  padding: 8px 14px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-dim);
  font-size: 13.5px; font-weight: 600;
}
.tabs a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.tabs a.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
.scrim {
  position: fixed; inset: 0;
  background: rgba(8, 12, 22, .5);
  z-index: 55;
  opacity: 0;
  transition: opacity .2s;
}
.scrim.show { opacity: 1; }

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 991px) {
  /* off-canvas drawer; the collapsed rail is a desktop-only idea.
     body.sidebar-collapsed has to be named here: the rail width up at
     `body.sidebar-collapsed .sidebar` carries one class more than a bare
     .sidebar, so without it the drawer slid out 76px wide - a rail with no
     labels rather than a menu. */
  .sidebar,
  body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .main, body.sidebar-collapsed .main { margin-left: 0; }

  body.sidebar-collapsed .sidebar .brand-text,
  body.sidebar-collapsed .sidebar .menu-label,
  body.sidebar-collapsed .sidebar .menu-caret { display: revert; }
  body.sidebar-collapsed .menu-link { justify-content: flex-start; padding: 11px 12px; }
  /* Back to an inline accordion. The .is-open selector has to be listed as
     well, not just the plain one: the flyout rule above is written against
     both, and its .is-open half carries an extra class - so a one-selector
     reset here never outweighed it. The open branch kept position:absolute
     and left:100%, which on a drawer sitting off canvas put the panel at
     x=0 - a menu hanging over the page on every load, since the branch
     holding the current page is opened for us. */
  body.sidebar-collapsed .menu-item.has-sub > .submenu,
  body.sidebar-collapsed .menu-item.has-sub.is-open > .submenu {
    position: static; opacity: 1; visibility: visible; transform: none;
    min-width: 0; margin: 0; padding: 0; border: 0; background: none; box-shadow: none;
    max-height: 0;
  }
  body.sidebar-collapsed .menu-item.has-sub.is-open > .submenu { max-height: 460px; }
  body.sidebar-collapsed .submenu-title { display: none; }
  body.sidebar-collapsed .submenu-link { padding-left: 46px; }

  .content { padding: 18px 16px 28px; }
  .topbar { padding: 0 14px; }
  .today, .user-meta, .year-picker-label { display: none; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }

  .login-card { grid-template-columns: 1fr; max-width: 460px; }
  .login-aside { display: none; }
  .login-form { padding: 34px 26px 30px; }
}

@media (max-width: 560px) {
  .grid-4 { grid-template-columns: 1fr; }
  .topbar-title h1 { font-size: 17px; }
  .topbar-title p { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* print: drop the chrome, keep the table */
@media print {
  .sidebar, .topbar, .page-foot, .tabs, .filters, .pager { display: none !important; }
  .main { margin-left: 0 !important; }
  .card { border: 0; box-shadow: none; }
}
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
}

.modal-content {
    background: var(--surface);
    width: 90%;
    height: 85%;
    margin: 40px auto;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.modal-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.close {
    position: absolute;
    right: 15px;
    top: 5px;
    font-size: 30px;
    cursor: pointer;
    z-index: 10;
}

/* ==========================================================================
   LIST TOOLS - the strip above a register, and the boxes under its headings
   ========================================================================== */
/* The tab strip and the list's own buttons on one line: what the list IS on
   the left, what to do with it on the right. */
.page-bar {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.page-bar .tabs { margin-bottom: 0; }

.list-tools {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.list-tools .btn { gap: 6px; }
.list-tools svg { width: 15px; height: 15px; }

/* Columns: a plain <details>, so it opens without a line of JavaScript and
   closes when the page moves on. */
.colmenu { position: relative; }
.colmenu > summary {
  list-style: none; user-select: none;
  padding: 7px 12px; font-size: 13.5px; font-weight: 600;
}
.colmenu > summary::-webkit-details-marker { display: none; }
.colmenu[open] > summary { background: var(--surface-2); border-color: var(--border-strong); }

.colmenu-panel {
  position: absolute; z-index: 40; top: calc(100% + 6px); right: 0;
  width: 258px; padding: 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); box-shadow: var(--shadow-lg);
}
.colmenu-note { margin: 0 0 9px; font-size: 11.5px; color: var(--text-faint); line-height: 1.4; }
.colmenu-list { max-height: 46vh; overflow-y: auto; display: grid; gap: 2px; }
.colmenu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px; border-radius: 6px;
  font-size: 13.5px; cursor: pointer;
}
.colmenu-item:hover { background: var(--surface-2); }
.colmenu-item input { width: 15px; height: 15px; accent-color: var(--brand); }
.colmenu-item em { margin-left: auto; font-size: 11px; color: var(--text-faint); font-style: normal; }
.colmenu-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border);
}

/* A heading that sorts. The arrow is always there, faint until it is the
   column being sorted by - a heading that grows an arrow on click makes the
   whole row jump sideways. */
.sort-link {
  display: inline-flex; align-items: center; gap: 5px;
  color: inherit; text-decoration: none; white-space: nowrap;
}
.sort-link:hover { color: var(--brand); text-decoration: none; }
.sort-arrow { font-size: 9px; opacity: .35; }
.sort-link.is-sorted { color: var(--brand); }
.sort-link.is-sorted .sort-arrow { opacity: 1; }
table.data th.num .sort-link, table.data th.right .sort-link { justify-content: flex-end; }

/* The filter row sits under the headings and scrolls with them. */
table.data tr.filter-row td {
  padding: 4px 4px;
  background: var(--surface-2);
  border-bottom: 2px solid var(--border-strong);
}
table.data tr.filter-row:hover td { background: var(--surface-2); }
.filter-input {
  width: 100%; min-width: 70px;
  padding: 4px 6px;
  border: 1px solid var(--border-strong); border-radius: 5px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 12.5px;
}
.filter-input::placeholder { color: var(--text-faint); }
.filter-input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-soft);
}

/* --------------------------------------------------------------------
   The actions column is pinned to the right

   A register is wider than the screen once a few columns are turned on, and
   Edit is what the scrolling was for - a button that has to be scrolled back
   to is a button in the wrong place. The cells opt in by class, so the
   column stays put while everything left of it slides under it.

   The left edge is drawn with a box-shadow rather than a border: a collapsed
   table's borders belong to the table, not to the cell, and a sticky cell
   leaves them behind when it moves.
   -------------------------------------------------------------------- */
table.data th.col-actions,
table.data td.row-actions {
  position: sticky; right: 0; z-index: 2;
  background: var(--surface);
  box-shadow: -1px 0 0 var(--border-strong);
}
table.data thead th.col-actions {
  z-index: 3;                       /* over the body cells sliding beneath */
  background: var(--surface-2);
}
table.data tr.filter-row td.row-actions,
table.data tfoot td.row-actions     { background: var(--surface-2); }

/* The pinned cell paints its own background, so it has to be told about the
   hover as well or the row lights up everywhere except its last cell. */
table.data tbody tr:hover td.row-actions { background: var(--surface-2); }

/* Printed only. */
.print-head { display: none; }

/* The line under the toolbar when a column filter is on - the boxes are
   small and easy to lose track of once you have paged away from them. */
.filter-note { margin: 8px 18px 0; font-size: 12.5px; color: var(--text-dim); }

/* ==========================================================================
   PRINT - a register on paper is the table and nothing else
   ========================================================================== */
@media print {
  /* The actions column goes head and body together, or the headings end up
     one cell out of step with the figures under them. */
  .list-tools, .row-actions, .col-actions, .ms-actions,
  table.data tr.filter-row, .filter-note,
  .alert, .ms-note, .ms-head a { display: none !important; }

  .print-head {
    display: block !important;
    margin: 0 0 10px; padding-bottom: 8px;
    border-bottom: 2px solid #000;
  }
  .print-head strong { display: block; font-size: 15px; }
  .print-head span   { display: block; font-size: 11px; color: #333; }

  /* Black on white: the tinted heads and the soft grey rules come out of an
     office printer as a grey wash. */
  table.data { font-size: 10.5px; }
  table.data th, table.data td {
    position: static !important; box-shadow: none !important;
    border-color: #000 !important;
    background: #fff !important;
    color: #000 !important;
    white-space: normal;
  }
  table.data thead th { border-bottom-width: 2px !important; }
  table.data thead    { display: table-header-group; }   /* repeats each page */
  table.data tr       { page-break-inside: avoid; }
  .sort-arrow { display: none; }

  @page { margin: 12mm; }
}
