/* Accounts Portal — one stylesheet.
   Everything is sized in rem, so the Size setting (html[data-size]) scales the whole interface:
   text, spacing, controls, icons, sidebar and logos. */

/* ---------- tokens ---------- */
:root {
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #eef1f5; --border: #d9dee6; --border-strong: #c3cad6;
  --text: #1b2230; --muted: #5b6577;
  --accent: #1f5f8b; --accent-hover: #174a6c; --accent-text: #ffffff; --accent-soft: #e4eef6;
  --danger: #b3261e; --danger-soft: #fbeaea; --danger-text: #ffffff;
  --ok: #1e7a46; --ok-soft: #e5f4ec; --warn: #8a5a00; --warn-bg: #fff4d6;
  --radius: .6rem; --radius-sm: .45rem; --shadow: 0 1px 3px rgba(20, 30, 50, .08); --shadow-lg: 0 .6rem 1.8rem rgba(16, 30, 54, .14);
  --sidebar-w: 13.5rem; --sidebar-w-collapsed: 3.9rem; --topbar-h: 3.4rem; --ctl-h: 2.4rem;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #12161d; --surface: #1b212b; --surface-2: #232b37; --border: #323c4b; --border-strong: #46526380;
  --text: #e8ecf2; --muted: #9aa5b8;
  --accent: #5aa7d6; --accent-hover: #7bbbe2; --accent-text: #0c1117; --accent-soft: #1d3346;
  --danger: #f0847d; --danger-soft: #3a2224; --danger-text: #1b0f0e;
  --ok: #62c08a; --ok-soft: #1c3327; --warn: #f2c66d; --warn-bg: #3a3320;
  --shadow: none; --shadow-lg: 0 .6rem 1.8rem rgba(0, 0, 0, .45);
  color-scheme: dark;
}
html { font-size: 17px; }                       /* Medium */
html[data-size="s"] { font-size: 15px; }       /* Small */
html[data-size="l"] { font-size: 19.5px; }     /* Large */

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5;
  font-family: system-ui, "Segoe UI", "Nirmala UI", "Noto Sans Telugu", sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.55rem; line-height: 1.25; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .75rem; }
img { max-width: 100%; }
:focus-visible { outline: .14rem solid var(--accent); outline-offset: .12rem; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
kbd { background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: .3rem; padding: .05rem .4rem;
  font-size: .85rem; font-family: ui-monospace, Consolas, monospace; }
.ico { width: 1.15rem; height: 1.15rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- app shell: sidebar + (top bar / scrolling main) ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); height: 100vh; overflow: hidden; }
html.sb-collapsed .layout { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
.content { display: flex; flex-direction: column; height: 100vh; min-width: 0; }
.main { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 1.6rem 2rem 3rem;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* sidebar */
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: .1rem;
  height: 100vh; overflow-y: auto; overscroll-behavior: contain; padding: .9rem .75rem; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.brandrow { display: flex; align-items: center; justify-content: space-between; gap: .4rem; padding: .3rem .15rem .9rem .45rem; }
.brand { display: flex; flex-direction: column; gap: .3rem; text-decoration: none; color: var(--text); min-width: 0; }
.brand .logo-wordmark { display: block; width: 8.8rem; height: auto; }
.brand .logo-full, .brand .logo-icon { display: none; }
.brandsub { font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding-left: .1rem; }
.sidebar a.nav { display: flex; align-items: center; gap: .7rem; padding: .5rem .7rem; border-radius: var(--radius-sm); color: var(--text);
  text-decoration: none; font-size: .98rem; white-space: nowrap; }
.sidebar a.nav:hover { background: var(--surface-2); }
.sidebar a.nav.active { background: var(--accent); color: var(--accent-text); }
.sidebar .sect { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .9rem .7rem .25rem; }
.iconbtn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: .35rem; border-radius: var(--radius-sm); display: inline-flex; }
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
/* collapsed: icons only (unchanged look) */
html.sb-collapsed .sidebar { padding: .9rem .4rem; }
html.sb-collapsed .label, html.sb-collapsed .sect, html.sb-collapsed .brandsub, html.sb-collapsed .brand .logo-wordmark { display: none; }
html.sb-collapsed .brandrow { flex-direction: column; padding: .2rem 0 .6rem; }
html.sb-collapsed .brand { align-items: center; }
html.sb-collapsed .brand .logo-icon { display: block; width: 2.1rem; height: auto; }
html.sb-collapsed .sidebar a.nav { justify-content: center; padding: .6rem 0; }
html.sb-collapsed #sidebtn .ico { transform: rotate(180deg); }
[data-theme="dark"] .brand .logo-wordmark { background: #fff; border-radius: .6rem; padding: .35rem .45rem; box-sizing: content-box; }
[data-theme="dark"] .brand .logo-icon { background: #fff; border-radius: .5rem; padding: .25rem; box-sizing: content-box; }

/* top bar */
.topbar { display: flex; align-items: center; gap: .9rem; height: var(--topbar-h); flex: none; padding: 0 1.1rem;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.tb-left { display: flex; align-items: center; gap: .9rem; min-width: 0; flex: 1; height: 100%; }
.tb-right { display: flex; align-items: center; gap: .45rem; flex: none; }
.cb-name { font-weight: 700; font-size: 1.02rem; color: var(--text); text-decoration: none; white-space: nowrap; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; }
.cb-tabs { display: flex; gap: .1rem; height: 100%; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.cb-tabs a { display: inline-flex; align-items: center; gap: .4rem; padding: 0 .6rem; border-bottom: .14rem solid transparent; text-decoration: none;
  color: var(--muted); font-size: .94rem; white-space: nowrap; }
.cb-tabs a:hover { color: var(--text); }
.cb-tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.cb-tabs .ico { width: 1rem; height: 1rem; }
.topbar .searchbox { margin: 0; width: 13rem; flex: none; }
.topbar .searchbox input, .topbar .langform select, .tbbtn, .topbar .tb-new summary {
  height: var(--ctl-h); margin: 0; border-radius: var(--radius-sm); font-size: .9rem; }
.topbar .searchbox input { padding: 0 .7rem; }
.topbar .langform { display: flex; margin: 0; }
.topbar .langform select { width: auto; padding: 0 .55rem; }
.tbbtn { width: var(--ctl-h); display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); font: inherit; font-weight: 600; }
.tbbtn:hover { background: var(--surface-2); color: var(--text); }
.tbbtn .ico { width: 1.1rem; height: 1.1rem; stroke-width: 2; }
.themebtn .ico-sun { display: none; }
[data-theme="dark"] .themebtn .ico-sun { display: inline; }
[data-theme="dark"] .themebtn .ico-moon { display: none; }
.sizebtn { font-size: .85rem; letter-spacing: -.02em; }
.menu .opt { display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: 100%; }
.menu .opt.on::after { content: "\2713"; color: var(--accent); font-weight: 700; }
.topbar summary { list-style: none; cursor: pointer; }
.topbar summary::-webkit-details-marker { display: none; }
.tb-new summary { display: inline-flex; align-items: center; padding: 0 .9rem; }
.acct summary { display: block; border-radius: 50%; }
.avatar { width: var(--ctl-h); height: var(--ctl-h); border-radius: 50%; background: var(--accent); color: var(--accent-text); display: inline-flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: .78rem; flex: none; }
.acct-head { padding: .5rem .75rem; border-bottom: 1px solid var(--border); margin-bottom: .25rem; }
.acct-head strong, .acct-head .role { display: block; }
.acct-head .role { font-size: .8rem; color: var(--muted); }
.menubtn { display: none; }
.acct-lang { display: none; margin: 0; border-bottom: 1px solid var(--border); padding-bottom: .25rem; margin-bottom: .25rem; }
/* When the top bar is tight (laptops, or Large size): language moves into the account menu and "+ New"
   becomes "+", so the client tabs keep their room */
@media (max-width: 1440px) { html:not([data-size="s"]) { --tight: 1; } }
@media (max-width: 1440px) { html:not([data-size="s"]) .topbar .langform { display: none; } html:not([data-size="s"]) .acct-lang { display: block; }
  html:not([data-size="s"]) .topbar .tb-new summary { width: var(--ctl-h); padding: 0; justify-content: center; font-size: 0; }
  html:not([data-size="s"]) .topbar .tb-new summary::before { content: "+"; font-size: 1.3rem; line-height: 1; } }
@media (max-width: 1900px) {
  html[data-size="l"] .topbar .langform { display: none; }
  html[data-size="l"] .acct-lang { display: block; }
  html[data-size="l"] .cb-tabs a { padding: 0 .35rem; font-size: .88rem; }
  html[data-size="l"] .cb-name { max-width: 7.5rem; }
  html[data-size="l"] .topbar .tb-new summary { width: var(--ctl-h); padding: 0; justify-content: center; font-size: 0; }
  html[data-size="l"] .topbar .tb-new summary::before { content: "+"; font-size: 1.3rem; line-height: 1; }
}

/* dropdown menus (books sub-menu, + New, size, account) */
.dd { position: relative; }
.dd .menu { position: absolute; top: calc(100% + .3rem); left: 0; min-width: 12.5rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .3rem; z-index: 40; }
.dd .menu.right { left: auto; right: 0; }
.dd .menu a, .linkbtn { display: block; width: 100%; padding: .5rem .75rem; border-radius: var(--radius-sm); color: var(--text); text-decoration: none;
  font: inherit; font-size: .94rem; background: none; border: 0; text-align: left; cursor: pointer; }
.dd .menu a:hover, .linkbtn:hover { background: var(--surface-2); }

/* ---------- page furniture ---------- */
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin: 1rem 0; }
.actions > [data-new] { margin-left: auto; }
.actions select, .actions input[type=search], .actions input[type=month], .actions input[type=date] { width: auto; }
.actions input[type=search] { min-width: 14rem; }
.colhead { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: 2.2rem; }
.colhead h2 { margin: 0; }
.bookhead { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: .75rem; flex-wrap: wrap; }
.bookhead h1 { margin: 0; }
.fyform { display: flex; align-items: center; gap: .5rem; }
.fyform label { display: inline; margin: 0; font-weight: 600; color: var(--muted); }
.fyform select { width: auto; }
.subnav { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; margin: 0 0 1.25rem; padding-bottom: .7rem; border-bottom: 1px solid var(--border); }
.subnav > a, .subnav summary { display: block; padding: .42rem .85rem; border-radius: var(--radius-sm); font-size: .95rem; color: var(--text);
  text-decoration: none; cursor: pointer; list-style: none; user-select: none; }
.subnav summary::-webkit-details-marker { display: none; }
.subnav summary::after { content: "\25BE"; margin-left: .4rem; font-size: .7rem; color: var(--muted); }
.subnav > a:hover, .subnav summary:hover { background: var(--surface-2); }
.subnav > a.active, .subnav details.active > summary { background: var(--accent); color: var(--accent-text); }
.subnav details.active > summary::after { color: var(--accent-text); }

/* ---------- cards, stats, grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.grid .card + .card, .twocol .card + .card { margin-top: 0; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { font-size: 1.75rem; font-weight: 700; white-space: nowrap; line-height: 1.25; margin: .15rem 0; }
.stat.sm { font-size: 1.45rem; }
.twocol { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.5rem; align-items: start; }
dl.kv { display: grid; grid-template-columns: 10rem 1fr; gap: .45rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
.firmhead { display: flex; align-items: center; gap: 1rem; }
.firmhead img { width: 5rem; height: auto; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 1.4rem; padding: .75rem 1rem; background: var(--surface-2);
  border-radius: var(--radius-sm); word-break: break-all; user-select: all; }

/* list rows inside a card (portal logins, outstanding items) */
.card.logincard { padding: .3rem 1.25rem; }
.lrow { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; padding: .85rem 0; border-bottom: 1px solid var(--border); }
.lrow:last-child { border-bottom: 0; }
.lmain { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; }
.lmain a { text-decoration: none; }
.lmain a:hover { text-decoration: underline; }
.lmain .luser { margin-left: .75rem; font-variant-numeric: tabular-nums; }
.lrow > .muted:not(.lmain) { flex-basis: 100%; order: 3; }
.lbtns { display: flex; flex-wrap: wrap; gap: .4rem; margin-left: auto; justify-content: flex-end; }
.lrow.missing strong { color: var(--danger); }

/* search results */
.results h2 { margin-top: 1.25rem; }
.results ul { list-style: none; padding: 0; margin: 0; }
.results li { padding: .5rem .75rem; border-bottom: 1px solid var(--border); background: var(--surface); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: .65rem .9rem; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th { background: var(--surface-2); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
th.num, td.num { text-align: right; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
tbody th { font-weight: 600; text-align: left; }
tr.total td, tr.total th, tfoot td, tfoot th { font-weight: 700; background: var(--surface-2); border-top: .12rem solid var(--border-strong);
  border-bottom: 0; text-transform: none; letter-spacing: 0; font-size: 1rem; color: var(--text); }
tr.sub td { padding-left: 2rem; }
tr.grp td { font-weight: 600; }
tr.inactive td { opacity: .55; }
tr.overdue td { background: var(--warn-bg); }
table input[type=text], table input[type=date], table select { padding: .35rem .5rem; font-size: .98rem; min-height: 0; }
td.num input, input.num { text-align: right; font-variant-numeric: tabular-nums; }
.dr::after { content: " Dr"; color: var(--muted); font-size: .85em; }
.cr::after { content: " Cr"; color: var(--muted); font-size: .85em; }
.tablewrap { overflow-x: auto; }

/* ---------- buttons, badges, messages ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: var(--ctl-h); padding: 0 1.05rem;
  border-radius: var(--radius-sm); border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text); font: inherit;
  font-size: .98rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.secondary { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn.secondary:hover { background: var(--accent-soft); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { min-height: 2rem; padding: 0 .7rem; font-size: .88rem; }
.badge { display: inline-block; padding: .08rem .55rem; border-radius: 99rem; background: var(--surface-2); font-size: .82rem; margin: 0 .25rem .25rem 0;
  border: 1px solid var(--border); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--danger); color: var(--danger-text); border-color: transparent; }
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .7rem 1rem; border-radius: var(--radius-sm); background: var(--ok-soft); border-left: .25rem solid var(--ok); margin-bottom: .5rem; }
.messages li.error { background: var(--danger-soft); border-left-color: var(--danger); }
.messages li.warning { background: var(--warn-bg); border-left-color: var(--warn); }
.messages li.info { background: var(--accent-soft); border-left-color: var(--accent); }
.warn { background: var(--warn-bg); padding: .75rem 1rem; border-radius: var(--radius-sm); }
.taxsplit { font-weight: 600; color: var(--accent); margin: 0 0 .8rem; }
.danger-zone { display: flex; justify-content: flex-end; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* ---------- forms ---------- */
form p, .field { margin: 0 0 1rem; }
label { display: block; font-weight: 600; margin-bottom: .3rem; }
input[type=text], input[type=password], input[type=email], input[type=url], input[type=search], input[type=date], input[type=month],
input[type=number], input[type=tel], input[type=file], select, textarea {
  width: 100%; min-height: var(--ctl-h); padding: .45rem .7rem; font: inherit; font-size: 1rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
textarea { min-height: 4.5rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: .14rem solid var(--accent); outline-offset: .06rem; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--accent); }
input[type=date]::-webkit-calendar-picker-indicator, input[type=month]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .65; }
[data-theme="dark"] input[type=date]::-webkit-calendar-picker-indicator, [data-theme="dark"] input[type=month]::-webkit-calendar-picker-indicator { filter: invert(1); }
input[type=file] { padding: .3rem; cursor: pointer; }
input[type=file]::file-selector-button { margin-right: .85rem; padding: .35rem .9rem; border: 1px solid var(--accent); background: transparent; color: var(--accent);
  border-radius: var(--radius-sm); font: inherit; cursor: pointer; }
input[type=file]::file-selector-button:hover { background: var(--accent-soft); }
input.invalid { border-color: var(--danger); }
.helptext { display: block; color: var(--muted); font-size: .85rem; margin-top: .25rem; }
.helptext ul { padding-left: 1.1rem; list-style: disc; margin: .3rem 0 0; }
.fielderr { display: block; font-size: .85rem; margin-top: .25rem; }
.fielderr.bad { color: var(--danger); }
.fielderr.ok { color: var(--ok); }
ul.errorlist { list-style: none; padding: .55rem .8rem; margin: 0 0 1rem; color: var(--danger); background: var(--danger-soft); border-radius: var(--radius-sm); font-size: .95rem; }
p > ul.errorlist, .fgrid ul.errorlist { padding: .2rem 0; background: none; margin: .25rem 0; }
form ul:not(.errorlist) { list-style: none; padding: 0; margin: .3rem 0 0; }
form ul:not(.errorlist) label { font-weight: 400; display: inline-flex; align-items: center; gap: .45rem; margin-right: 1rem; }
form ul:not(.errorlist) li { display: inline-block; }
label.check { display: inline-flex; align-items: center; gap: .5rem; font-weight: 400; }
fieldset.role, fieldset.box { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .9rem 1rem .2rem; margin: 0 0 1rem; }
fieldset legend { padding: 0 .4rem; font-weight: 600; font-size: .95rem; }

/* auto layout for Django {{ form.as_p }} forms inside a card: short fields share a row, long ones get a full row */
.card > form:has(> p) { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); column-gap: 1.25rem; }
.card > form:has(> p) > * { grid-column: 1 / -1; }
.card > form:has(> p) > p { grid-column: auto; }
.card > form:has(> p) > p:is(:has(textarea), :has(ul), :has(input[type=checkbox]), :has(input[maxlength="150"]), :has(input[maxlength="200"]),
  :has(input[maxlength="254"]), :has(input[maxlength="300"]), :has(input[type=password])) { grid-column: 1 / -1; }
/* hand-built forms */
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); column-gap: 1.25rem; }
.fgrid > p, .fgrid > .field { margin: 0 0 1rem; }
.fgrid > .span2 { grid-column: span 2; }
.fgrid > .spanall { grid-column: 1 / -1; }
/* firm details: four columns so the whole form fits one screen */
.card.firmform > form:has(> p) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card.firmform > form > p { grid-column: auto; margin-bottom: .8rem; }
.card.firmform > form > p:is(:nth-of-type(1), :nth-of-type(2), :nth-of-type(7), :nth-of-type(8)) { grid-column: span 2; }
.card.firmform textarea { min-height: 0; }

/* ---------- standalone pages (sign in, reset, 2FA) ---------- */
.center-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem 1rem;
  background: radial-gradient(70rem 36rem at 50% -10%, color-mix(in srgb, var(--accent) 14%, var(--bg)) 0%, var(--bg) 60%); }
.card.center-card { width: 100%; max-width: 24rem; padding: 2rem 2rem 1.5rem; border-radius: .85rem; box-shadow: var(--shadow-lg); }
.center-card > form { display: block; }
.center-card .login-logo { display: block; width: 5.6rem; height: auto; margin: 0 auto .25rem; }
.center-card .login-sub { text-align: center; margin: 0 0 1.25rem; font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.center-card h1 { text-align: center; font-size: 1.3rem; margin: 0 0 1.25rem; }
.center-card label { font-size: .9rem; }
.center-card .cf-turnstile { margin: .25rem 0 1rem; }
.center-card .btn { width: 100%; }
.center-card .login-btn { font-weight: 600; }
.center-card .login-links, .center-card > p:last-child { text-align: center; margin: 1rem 0 0; font-size: .92rem; }
.center-card .login-links a { color: var(--muted); }
.center-card .qr { display: block; margin: 0 auto 1rem; width: 13rem; height: 13rem; background: #fff; padding: .5rem; border-radius: var(--radius-sm); }
.login-foot { margin: 1.25rem 0 0; font-size: .8rem; color: var(--muted); }
[data-theme="dark"] .login-logo, [data-theme="dark"] .firmhead img { background: #fff; border-radius: .7rem; padding: .4rem; box-sizing: content-box; }

/* keyboard help */
#kbhelp { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: grid; place-items: center; z-index: 60; }
#kbhelp[hidden] { display: none; }
#kbhelp .card { max-width: 27rem; width: 92%; }
#kbhelp td { padding: .35rem .5rem; border: 0; }

/* ---------- responsive ---------- */
/* search shrinks to an icon when space is short and opens when focused */
.topbar .searchbox input { background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6577' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat .6rem 50% / 1rem;
  padding-left: 2rem; }
@media (max-width: 1700px) {
  .topbar { gap: .6rem; padding: 0 .85rem; }
  .tb-left { gap: .6rem; }
  .cb-name { max-width: 9rem; }
  .cb-tabs a { padding: 0 .45rem; }
  .cb-tabs .ico { display: none; }
  .topbar .searchbox { width: var(--ctl-h); transition: width .15s ease; }
  .topbar .searchbox input { padding-right: 0; cursor: pointer; }
  .topbar .searchbox input::placeholder { color: transparent; }
  .topbar .searchbox:focus-within { width: 14rem; }
  .topbar .searchbox:focus-within input { cursor: text; padding-right: .7rem; }
  .topbar .searchbox:focus-within input::placeholder { color: var(--muted); }
}
@media (max-width: 1100px) {
  .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid3 { grid-template-columns: 1fr; }
  .twocol { grid-template-columns: 1fr; }
  /* client page on one column: each heading stays with its own card */
  .twocol > :nth-child(1) { order: 1; } .twocol > :nth-child(3) { order: 2; } .twocol > :nth-child(2) { order: 3; } .twocol > :nth-child(4) { order: 4; }
  .twocol > :nth-child(5) { order: 5; } .twocol > :nth-child(7) { order: 6; } .twocol > :nth-child(6) { order: 7; } .twocol > :nth-child(8) { order: 8; }
  .card.firmform > form:has(> p) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  /* phone: sidebar becomes a drawer opened from the top bar */
  .layout, html.sb-collapsed .layout { display: block; height: auto; overflow: visible; }
  .content { height: auto; }
  .main { overflow: visible; padding: 1rem; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 16rem; z-index: 70; transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  html.nav-open .sidebar { transform: none; }
  html.nav-open body::after { content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 65; }
  html.sb-collapsed .label, html.sb-collapsed .sect, html.sb-collapsed .brandsub, html.sb-collapsed .brand .logo-wordmark { display: revert; }
  html.sb-collapsed .brand .logo-icon { display: none; }
  html.sb-collapsed .sidebar a.nav { justify-content: flex-start; padding: .5rem .7rem; }
  #sidebtn { display: none; }
  .menubtn { display: inline-flex; }
  .topbar { position: sticky; top: 0; z-index: 30; height: auto; min-height: var(--topbar-h); flex-wrap: wrap; padding: .45rem .7rem; gap: .4rem; }
  .tb-left { order: 3; flex-basis: 100%; height: 2.6rem; }
  .tb-right { margin-left: auto; gap: .35rem; }
  .topbar .searchbox, .topbar .searchbox:focus-within { flex: 1; width: auto; }
  .topbar .searchbox input::placeholder { color: var(--muted); }
  .topbar .langform { display: none; }
  .acct-lang { display: block; }
  .topbar .tb-new summary { width: var(--ctl-h); padding: 0; justify-content: center; font-size: 0; }
  .topbar .tb-new summary::before { content: "+"; font-size: 1.3rem; line-height: 1; }
  .grid2, .grid4 { grid-template-columns: 1fr; }
  .fgrid > .span2 { grid-column: auto; }
  .card.firmform > form:has(> p), .card > form:has(> p) { grid-template-columns: 1fr; }
  .card.firmform > form > p { grid-column: auto; }
  dl.kv { grid-template-columns: 1fr; gap: .1rem; }
  dl.kv dd { margin-bottom: .5rem; }
  .main .grid, .main .grid2, .main .grid3, .main .grid4 { grid-template-columns: minmax(0, 1fr) !important; }   /* also beats inline column styles */
  .main table { display: block; overflow-x: auto; max-width: 100%; }
  .main .card { min-width: 0; overflow-x: auto; }
}

/* ---------- print ---------- */
@media print {
  .sidebar, .topbar, .subnav, .noprint, .fyform, .messages, .actions { display: none !important; }
  .layout, .content, .main { display: block; height: auto; overflow: visible; padding: 0; }
  body { background: #fff; color: #000; }
  :root { --surface: #fff; --surface-2: #f3f3f3; --border: #999; --text: #000; --muted: #333; }
  a { color: #000; text-decoration: none; }
}

/* pressed toggle buttons (year on year: amounts / % of turnover) */
.btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
