:root {
    --green: #2CA01C;
    --green-dark: #1F7A13;
    --green-light: #E9F7E6;
    --sidebar-bg: #0F1F2C;
    --sidebar-bg-hover: #1A3242;
    --sidebar-text: #B7C5CE;
    --sidebar-text-active: #FFFFFF;
    --bg: #F4F6F8;
    --card-bg: #FFFFFF;
    --border: #E1E5E9;
    --text: #1A2733;
    --text-muted: #6B7B87;
    --danger: #D64545;
    --danger-light: #FBEAEA;
    --warning: #B8860B;
    --warning-light: #FDF4E0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(16, 24, 32, 0.08), 0 1px 2px rgba(16, 24, 32, 0.06);
    --sidebar-width: 92px;
    --header-height: 64px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    padding-left: var(--sidebar-width);
    padding-top: var(--header-height);
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: var(--green-dark);
}

/* ---------- Sidebar: vertical icon-over-label nav rail, hover flyouts to the side ---------- */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 20;
    /* No overflow-y here on purpose: setting it to 'auto' forces overflow-x to also become
       'auto' (a CSS overflow-axis-pairing rule), which would clip the flyouts to the right —
       they extend past this column's own width. A very short window just runs items off the
       bottom instead, an acceptable tradeoff for a desktop app. */
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .brand-mark {
    width: 28px;
    height: 28px;
    background: var(--green);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    flex-shrink: 0;
}

.nav-rail {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 8px 6px;
    flex: 1;
    min-height: 0; /* lets a flex child actually shrink and scroll internally, instead of
                      growing past .sidebar's own fixed height */
    overflow-y: auto;
    overflow-x: hidden;
    /* Flyouts (.nav-flyout) are moved to <body> and positioned `fixed` via JS
       (initSidebarFlyouts in nav.js) specifically so they can escape this scroll
       container's clipping — the old pure-CSS :hover popup couldn't have overflow-y:auto
       here at all, since a non-visible overflow-y forces overflow-x to clip too, cutting
       the flyout off at this rail's own right edge. */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.25) transparent;
}

.nav-rail::-webkit-scrollbar {
    width: 6px;
}

.nav-rail::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.25);
    border-radius: 3px;
}

.nav-cat {
    position: relative;
    display: flex;
    align-items: stretch;
}

/* Top-level trigger: icon above, label below — applies both to a plain single-page link
   (a direct child of .nav-rail) and to a category's own trigger link (nested one level
   inside .nav-cat, which is itself the direct child). */
.nav-rail > a.nav-link,
.nav-rail > .nav-cat > a.nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 4px;
    width: 100%;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 10.5px;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
    transition: background 0.12s, color 0.12s;
}

.nav-rail > a.nav-link svg,
.nav-rail > .nav-cat > a.nav-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke: currentColor;
}

.nav-rail > a.nav-link:hover,
.nav-rail > .nav-cat > a.nav-link:hover {
    background: var(--sidebar-bg-hover);
    color: var(--sidebar-text-active);
}

.nav-rail > a.nav-link.active,
.nav-rail > .nav-cat > a.nav-link.active {
    background: var(--green);
    color: #fff;
}

/* Flyout: a category's own pages, revealed on hover, appearing to the RIGHT of the sidebar
   (not below — this is a vertical rail, so "below" would just run into the next category).
   Touches the trigger with no gap, same reasoning as .profile-menu below: a gap would create
   a dead zone where a diagonal mouse move loses :hover before it reaches the menu. */
/* Positioned `fixed` (not `absolute`) and top/left set by JS (initSidebarFlyouts in
   nav.js) rather than a plain `left:100%` — it's moved out to a direct child of <body> at
   render time so it can escape .nav-rail's overflow-y:auto clipping (see that rule's own
   comment), which an absolutely-positioned descendant of a scrolling ancestor cannot. */
.nav-flyout {
    display: none;
    position: fixed;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 220px;
    padding: 6px;
    z-index: 40;
}

.nav-flyout a.nav-link {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    white-space: nowrap;
}

.nav-flyout a.nav-link svg {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    stroke: currentColor;
}

.nav-flyout a.nav-link:hover {
    background: var(--bg);
}

.nav-flyout a.nav-link.active {
    background: var(--green-light);
    color: var(--green-dark);
}

/* ---------- Top header: company switcher + Approvals/Settings/Help + profile ---------- */

.topheader {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--header-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 10;
}

.company-switcher {
    position: relative;
}

.company-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 7px 14px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    color: var(--text);
}

.company-pill-name {
    white-space: nowrap;
}

.company-pill:hover {
    border-color: var(--green);
}

.company-pill svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    stroke: currentColor;
}

.company-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 220px;
    display: none;
    overflow: hidden;
    z-index: 30;
}

.company-menu.open {
    display: block;
}

.company-menu a {
    display: block;
    padding: 10px 14px;
    color: var(--text);
    text-decoration: none;
    font-size: 13.5px;
}

.company-menu a:hover {
    background: var(--bg);
}

.topheader-utility {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* ---------- Global search (top header — pages/reports + transactions/master data) ---------- */

.global-search {
    position: relative;
    flex: 1;
    max-width: 420px;
    margin: 0 20px;
}

.global-search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 7px 14px;
}

.global-search-box:focus-within {
    border-color: var(--green);
    background: #fff;
    box-shadow: 0 0 0 3px var(--green-light);
}

.global-search-box svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    stroke: var(--text-muted);
}

.global-search-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    outline: none;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--text);
    padding: 0;
}

.global-search-kbd {
    flex-shrink: 0;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    white-space: nowrap;
}

.global-search-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-height: 420px;
    overflow-y: auto;
    z-index: 200;
}

.global-search-dropdown.open {
    display: block;
}

.global-search-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    font-size: 13.5px;
    border-top: 1px solid var(--border);
}

.global-search-row:first-child {
    border-top: none;
}

.global-search-row:hover,
.global-search-row.highlighted {
    background: var(--green-light);
}

.global-search-badge {
    flex-shrink: 0;
    background: var(--bg);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 3px 8px;
    border-radius: 999px;
}

.global-search-label {
    color: var(--text);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.global-search-sub {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-left: auto;
    padding-left: 10px;
}

.global-search-empty {
    padding: 14px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--green);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

/* Profile menu — hover-triggered (not click), per its own convention: appear the instant
   the cursor reaches the avatar, disappear the instant it leaves both the avatar and the
   menu. touching the trigger with no gap (top: 100%, no margin) is what makes that reliable
   — a gap between the two would create a dead zone where a diagonal mouse move loses :hover
   before it reaches the menu. */
.profile-widget {
    position: relative;
    display: flex;
    align-items: center;
}

.profile-widget .avatar {
    cursor: pointer;
}

.profile-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 210px;
    padding: 8px;
    z-index: 40;
}

.profile-widget:hover .profile-menu {
    display: block;
}

.profile-menu-header {
    padding: 6px 10px 10px 10px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.profile-menu-header .user-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
}

.profile-menu-header .user-role {
    font-size: 11.5px;
    color: var(--text-muted);
}

.profile-menu-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: transparent !important;
    border: none !important;
    padding: 9px 10px;
    border-radius: 6px;
    color: var(--text) !important;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
}

.profile-menu-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    flex-shrink: 0;
}

.profile-menu-btn:hover {
    background: var(--bg) !important;
}

/* ---------- Support widget ---------- */

.support-widget {
    position: relative;
}

.support-widget-standalone {
    position: fixed;
    top: 16px;
    right: 20px;
    z-index: 1000;
}

.support-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 5px 11px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

.support-btn svg {
    width: 13px;
    height: 13px;
    stroke: currentColor;
    flex-shrink: 0;
}

.support-btn:hover {
    background: var(--bg);
    color: var(--text);
    border-color: var(--green);
}

.support-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 260px;
    display: none;
    padding: 14px 16px;
    z-index: 1001;
}

.support-menu.open {
    display: block;
}

.support-menu-title {
    font-weight: 700;
    font-size: 13.5px;
    margin-bottom: 10px;
    color: var(--text);
}

.support-menu-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 13px;
    border-top: 1px solid var(--border);
}

.support-menu-row:first-of-type {
    border-top: none;
}

.support-menu-label {
    color: var(--text-muted);
    font-weight: 600;
}

.support-menu-row a {
    color: var(--green);
    text-decoration: none;
}

.support-menu-row a:hover {
    text-decoration: underline;
}

.support-menu-value.muted {
    color: var(--text-muted);
}

/* A wide data-entry table (e.g. bill/invoice line items with several optional columns)
   scrolls horizontally within itself instead of overflowing past its card's background —
   keeps the card's edges/border-radius intact on narrower windows regardless of how many
   optional columns happen to be visible. */
.table-scroll-x {
    overflow-x: auto;
}

/* ---------- Page layout ---------- */

/* No max-width here (unlike .container) — .page is dashboard.html's only consumer, and its
   own flex layout (stat-row + Recent Invoices on the left, the Ask AI sidebar on the right,
   see dashboard.html) needs the full available width so the sidebar actually reaches the
   real right edge of the screen instead of being stranded next to a leftover blank margin. */
.page {
    padding: 28px 32px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 22px;
    margin: 0;
    font-weight: 700;
}

.page-header p.subtitle {
    color: var(--text-muted);
    margin: 4px 0 0 0;
    font-size: 13.5px;
}

/* legacy container kept for existing pages */
.header {
    display: none;
}

.container {
    max-width: 1000px;
    margin: 28px 32px;
    background: var(--card-bg);
    padding: 28px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.container.narrow {
    max-width: 420px;
    margin: 60px auto;
}

/* A wider variant for data-dense list/table pages (many columns, a filter bar) where
   the standard 1000px cap leaves an awkward amount of unused space on a normal desktop
   monitor — opt-in per page rather than changing the default, so every existing
   narrower form/card page is unaffected. */
.container.wide {
    max-width: 1400px;
}

h2 {
    margin-top: 0;
    font-size: 17px;
    font-weight: 700;
}

h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin: 20px 0 8px 0;
}

/* ---------- Forms ---------- */

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 12.5px;
    color: var(--text-muted);
}

input,
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
}

/* A <select> (and the bounded-content input types below) never needs more room than a
   short option label — the base `width:100%` rule above is meant for free-text fields
   whose content length actually varies (name, address, notes...), not for these. Without
   a ceiling, a select/date/number sitting alone in a wide container (no sibling in a
   `.row`, no page-specific inline width) stretches to the full container width, which on
   a normal ~1000px page leaves a short label floating in a mostly-empty ~900px box — the
   exact "unnecessary width" pattern reported and audited across the app. A page that
   explicitly sets a narrower inline width/max-width (already common, e.g.
   `style="max-width:360px"` on several pickers) is unaffected, since max-width only ever
   lowers the ceiling, never raises it above what's already set narrower. Free-text
   `input`/`textarea` are deliberately left uncapped here — those legitimately vary. */
select,
input[type="date"],
input[type="number"] {
    max-width: 420px;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px var(--green-light);
}

/* A plain <label><input type="checkbox"> Text</label> pair would otherwise inherit
   `label { display:block }` and `input { width:100% }` above, stretching the checkbox to
   fill the row and pushing its own label text onto the next line. Scoped to a label whose
   DIRECT child is a checkbox/radio, so it never touches the unrelated .toggle-switch
   component (its checkbox is hidden and its visible child is a styled <span>, not text). */
input[type="checkbox"],
input[type="radio"] {
    width: auto;
}

label:has(> input[type="checkbox"]),
label:has(> input[type="radio"]) {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: normal;
}

textarea {
    min-height: 80px;
    resize: vertical;
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

/* ---------- Line Items / GL preview tabs (bill-new.html, invoice-new.html) ---------- */

.li-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
}

/* !important because the app's global button[type="button"] rule (higher specificity —
   see style.css's own note near that rule) would otherwise repaint these as individually
   outlined boxes instead of plain underline-style tabs. */
button.li-tab[type="button"] {
    background: none !important;
    border: none !important;
    border-bottom: 2px solid transparent !important;
    padding: 8px 4px !important;
    margin-right: 18px;
    font-size: 15px;
    font-weight: 600;
    color: #6b7b87;
    cursor: pointer;
}

button.li-tab[type="button"]:hover {
    background: none !important;
    border-color: transparent !important;
    color: var(--green);
}

button.li-tab.active[type="button"] {
    color: var(--green) !important;
    border-bottom-color: var(--green) !important;
}

.li-panel-wrap {
    position: relative;
}

.li-panel {
    animation-duration: 0.22s;
    animation-timing-function: ease-out;
    animation-fill-mode: both;
}

.li-panel.slide-in-right {
    animation-name: liSlideInRight;
}

.li-panel.slide-in-left {
    animation-name: liSlideInLeft;
}

@keyframes liSlideInRight {
    from { transform: translateX(40px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes liSlideInLeft {
    from { transform: translateX(-40px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ---------- Searchable dropdown ---------- */

.searchable-select {
    position: relative;
    width: 100%;
    max-width: 420px;
}

/* !important because some pages (e.g. bill-new.html's Item/Account toggle) set inline
   style.display directly on the original <select> to show/hide it — an inline style
   would otherwise beat this class rule and make the native select reappear next to the
   fake search input. The wrapper's own display (mirrored from this same inline style via
   a MutationObserver) still toggles normally; only the native select itself stays hidden. */
.searchable-select select.searchable-select-native {
    display: none !important;
}

.searchable-select-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
}

.searchable-select-input:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px var(--green-light);
}

.searchable-select-list {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    /* Grows to fit the longest option (e.g. a long Chart of Accounts name) instead of
       clipping to the trigger input's own width, which can be narrow inside a table
       cell — capped so it never runs off-screen. */
    min-width: 100%;
    width: max-content;
    max-width: min(480px, calc(100vw - 48px));
    max-height: 220px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    z-index: 200;
}

/* Rendered into document.body instead of the wrapper (see nav.js's attachFloatingList) so
   it never gets clipped by a scrollable ancestor like .table-scroll-x — top/left/width are
   set inline from the input's own bounding box each time it opens, overriding the
   absolute-positioning defaults above. */
.searchable-select-list-floating {
    position: fixed;
}

.searchable-select-option {
    padding: 8px 12px;
    font-size: 13.5px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.searchable-select-option:hover,
.searchable-select-option.highlighted {
    background: var(--green-light);
}

.searchable-select-option.selected {
    font-weight: 600;
}

.searchable-select-option.searchable-select-create {
    color: var(--green);
    font-weight: 600;
    border-top: 1px solid var(--border);
}

.searchable-select-empty {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.searchable-select-option.searchable-select-loadmore {
    text-align: center;
    font-size: 12.5px;
    font-style: italic;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

button, button[type="submit"] {
    background: var(--green);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
}

button:hover {
    background: var(--green-dark);
}

button[type="button"]:not(.logout):not(.removeRow) {
    background: #fff;
    color: var(--green-dark);
    border: 1px solid var(--green);
}

button[type="button"]:not(.logout):not(.removeRow):hover {
    background: var(--green-light);
}

button.removeRow {
    background: transparent;
    color: var(--danger);
    border: none;
    padding: 4px 8px;
    font-size: 14px;
}

button.removeRow:hover {
    background: var(--danger-light);
}

button.tabBtn.active-tab[type="button"] {
    background: var(--green);
    color: white;
    border-color: var(--green);
}

button.btn-danger,
button[type="button"].btn-danger:not(.logout):not(.removeRow) {
    background: var(--danger);
    color: white;
    border: 1px solid var(--danger);
}

button.btn-danger:hover,
button[type="button"].btn-danger:not(.logout):not(.removeRow):hover {
    background: #b83a3a;
}

button.btn-danger:disabled,
button[type="button"].btn-danger:not(.logout):not(.removeRow):disabled {
    background: #ccc;
    border-color: #ccc;
    color: #888;
    cursor: not-allowed;
}

#message {
    margin-top: 18px;
    padding: 12px 14px;
    border-radius: 6px;
    display: none;
    font-size: 13.5px;
}

.success {
    background: var(--green-light);
    color: var(--green-dark);
}

.error {
    background: var(--danger-light);
    color: var(--danger);
}

/* ---------- Tables ---------- */

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 14px;
}

th, td {
    text-align: left;
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
}

th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--bg);
    position: sticky;
    top: var(--header-height);
    z-index: 5;
}

tbody tr:hover {
    background: #FAFBFC;
}

/* Two stacked GST Type+Rate slots in one table cell (Bill/Expense line items) */
.gst-cell {
    padding-top: 6px;
    padding-bottom: 6px;
}

.gst-slot {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
}

.gst-slot:last-child {
    margin-bottom: 0;
}

.gst-slot select {
    padding: 4px 6px;
    font-size: 12.5px;
}

/* ---------- Cards / dashboard widgets ---------- */

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.card:hover {
    box-shadow: var(--shadow);
    border-color: var(--green);
}

.card h3 {
    margin: 0 0 6px 0;
    font-size: 15px;
}

.card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
}

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: border-color 0.15s;
}

.stat-card:hover {
    border-color: var(--green);
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-card .stat-value {
    font-size: 24px;
    font-weight: 700;
    margin-top: 6px;
}

.stat-card .stat-value.positive { color: var(--green-dark); }
.stat-card .stat-value.negative { color: var(--danger); }

/* Marks whichever clickable stat card reflects the register's current view (e.g. Active
   vs. Disposed on the Fixed Asset dashboard) so the selection stays visible after the
   pointer moves away, not just on :hover. */
.stat-card.view-active {
    border-color: var(--green);
    border-width: 2px;
    box-shadow: 0 0 0 1px var(--green);
}

/* Icon-badge variant, opt-in via an extra class so the plain stat-card used elsewhere
   (dashboard.html's company cards) is completely unaffected. */
.stat-card.with-icon {
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    color: var(--text-muted);
}

.stat-card.accent-green .stat-icon {
    background: var(--green-light);
    color: var(--green-dark);
}

.stat-card .stat-icon svg {
    width: 19px;
    height: 19px;
    stroke: currentColor;
}

.stat-card.with-icon .stat-label {
    margin: 0;
}

.stat-card.with-icon .stat-value {
    margin-top: 2px;
}

/* ---------- Module sub-navigation (a horizontal tab strip of real links across a
   multi-page module, e.g. Fixed Assets' Overview/Depreciation/Transfers/...) ---------- */

.module-subnav {
    display: flex;
    gap: 4px;
    margin: 0 0 22px;
    border-bottom: 2px solid var(--border);
    flex-wrap: wrap;
}

.module-subnav a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 16px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
}

.module-subnav a svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    flex-shrink: 0;
}

.module-subnav a:hover {
    color: var(--text);
}

.module-subnav a.active {
    color: var(--green-dark);
    border-bottom-color: var(--green);
}

/* ---------- Two-panel category/item picker (pick a category on the left, its items
   appear on the right with a checkbox multi-select) — used by the Transfer/Dispose/
   Revalue "New ..." flows instead of a plain dropdown + full-width table. Each panel
   scrolls independently so the picker never pushes the page itself to an awkward height. */

.fam-picker {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 6px;
    background: var(--card-bg);
}

.fam-picker-categories {
    width: 240px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    max-height: 460px;
    overflow-y: auto;
    background: var(--bg);
}

/* Overrides the app's global `button[type="button"]` outline (higher specificity than a
   plain class) since this widget needs a plain list-row look, not a standalone button. */
button.fam-picker-cat[type="button"] {
    display: block;
    width: 100%;
    text-align: left;
    padding: 11px 16px !important;
    border: none !important;
    border-left: 3px solid transparent !important;
    border-bottom: 1px solid var(--border) !important;
    border-radius: 0 !important;
    background: transparent !important;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: normal;
    color: var(--text) !important;
}

button.fam-picker-cat[type="button"]:hover {
    background: var(--card-bg) !important;
}

.fam-picker-cat .fam-picker-cat-code {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 2px;
}

button.fam-picker-cat[type="button"].active {
    background: var(--green-light) !important;
    border-left-color: var(--green) !important;
}

.fam-picker-cat.active .fam-picker-cat-code {
    color: var(--green-dark);
}

.fam-picker-assets {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.fam-picker-assets-toolbar {
    padding: 12px 16px 0;
    flex-shrink: 0;
}

.fam-picker-assets-scroll {
    overflow: auto;
    max-height: 420px;
}

.fam-picker-assets-scroll table th {
    position: static;
}

.fam-picker-placeholder {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13.5px;
}

/* ---------- Reports page: filter bar (Book/GSTIN/Period/... + Run Report), all in one
   compact horizontal card instead of each control stacked full-width on its own line ---------- */

.reports-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 0 0 10px;
}

.reports-filter-bar .form-group {
    margin-bottom: 0;
}

/* Shorter label + input than the app-wide default — this bar holds short, bounded-content
   fields (dropdowns, dates), never free text, so the extra breathing room elsewhere isn't
   needed here and only adds height to a bar shown above every single report. */
.reports-filter-bar label {
    margin-bottom: 3px;
    font-size: 11.5px;
}

.reports-filter-bar select,
.reports-filter-bar input {
    padding: 6px 10px;
    font-size: 13px;
}

/* A couple of the existing controls (Ledger Party Type/Party, GL Account, Management
   Show-Me/Show-Top) are themselves a `.row` (2-column grid) — `display:contents` unwraps
   that grid so its two form-groups become direct flex items of the bar above instead of a
   separately-boxed 2-column strip, so everything lines up in the same horizontal row. */
.reports-filter-bar .row {
    display: contents;
}

/* Customize Columns / Run / Export / Expand-Collapse: one right-aligned icon-button
   cluster sharing the filter bar's own row (margin-left:auto pushes it to the row's end;
   the bar's own flex-wrap lets it drop to its own line on a narrow screen instead of
   squeezing the filter fields). */
.reports-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.icon-btn-badge-wrap {
    position: relative;
}

.icon-btn-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 16px;
    height: 16px;
    padding: 0 3px;
    border-radius: 999px;
    background: var(--green);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

/* Customize Columns: a small checklist dropdown anchored under its own trigger button —
   same floating-panel idea as the searchable-select dropdown, just simpler (no search box,
   fixed small list) since the option set per report type is at most 5 checkboxes. */
.col-customize-panel {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 50;
    margin-top: 4px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
    padding: 8px 4px;
    min-width: 200px;
}
.col-customize-panel label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    padding: 6px 10px;
    margin: 0;
    cursor: pointer;
    white-space: nowrap;
}
.col-customize-panel label:hover {
    background: var(--bg);
}

/* The printed header block above a financial statement's table (company name, report
   title, basis, period) — shown on screen and mirrored in every export format. */
.statement-report-header h2 {
    margin: 0 0 2px;
    font-size: 20px;
}
.statement-report-header h3 {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 600;
}
.statement-report-header .meta {
    color: var(--text-muted);
    font-size: 13px;
}

/* A richer "nothing here yet" block for a list page's own container — icon + short
   copy, optionally a CTA button — instead of a single muted line of text floating in
   an otherwise-empty card. */
.empty-state {
    text-align: center;
    padding: 44px 20px 36px;
    color: var(--text-muted);
}

.empty-state .empty-state-icon {
    width: 46px;
    height: 46px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-muted);
}

.empty-state .empty-state-icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
}

.empty-state h3 {
    margin: 0 0 4px;
    font-size: 14.5px;
    color: var(--text);
}

.empty-state p {
    margin: 0 0 16px;
    font-size: 13px;
}

.empty-state p:last-child {
    margin-bottom: 0;
}

.quick-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.quick-actions a button {
    white-space: nowrap;
}

.empty {
    color: var(--text-muted);
    font-size: 13.5px;
    margin-top: 10px;
}

/* ---------- Status pills ---------- */

.pill {
    display: inline-block;
    background: var(--bg);
    color: var(--text-muted);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    margin: 2px 4px 2px 0;
}

.pill.PAID { background: var(--green-light); color: var(--green-dark); }
.pill.UNPAID { background: var(--danger-light); color: var(--danger); }
.pill.PARTIAL { background: var(--warning-light); color: var(--warning); }
.pill.ACTIVE { background: var(--green-light); color: var(--green-dark); }
.pill.INACTIVE { background: var(--bg); color: var(--text-muted); }

/* ---------- Toolbar / list-page header ---------- */

.list-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 6px;
}

.list-toolbar h2 {
    margin: 0;
}

.list-toolbar .toolbar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.pagination-mount {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 16px 0 4px;
}

.pagination-mount:empty {
    margin: 0;
}

.pagination-mount button {
    padding: 5px 14px;
    font-size: 13px;
}

.pagination-mount .pagination-info {
    font-size: 13px;
    color: var(--text-muted, #667085);
}

.link-btn {
    background: transparent;
    border: none;
    color: var(--green-dark);
    cursor: pointer;
    font-size: 12.5px;
    padding: 0;
    text-decoration: underline;
}

/* ---------- Clickable references / party links ---------- */

a.ref-link, a.party-link {
    color: var(--green-dark);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

a.ref-link:hover, a.party-link:hover {
    text-decoration: underline;
}

/* ---------- Settings page ---------- */

.page-header {
    margin: 28px 32px 4px;
}

.page-header h1 {
    font-size: 22px;
    margin: 0 0 4px;
}

.page-header p {
    color: var(--text-muted);
    font-size: 13.5px;
    margin: 0;
}

.settings-section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.settings-section-header h2 {
    margin-bottom: 4px;
}

.settings-section-desc {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0;
    max-width: 560px;
}

/* Collapsed-by-default only applies inside the Modules & Features grid — every other tab
   (Company Profile, Format Settings, Backup & Restore, Danger Zone) reuses this same
   .settings-section-desc class for its own section descriptions, which should keep
   showing normally; only #modulesGrid's many module toggles needed the "wall of
   paragraphs" fixed. See initCollapsibleSectionDescriptions(), scoped the same way. */
#modulesGrid .settings-section-desc {
    display: none;
}

#modulesGrid .settings-section-desc.expanded {
    display: block;
    margin-top: 6px;
}

/* Small "i" affordance appended next to a section's own heading (h2 or h3) — toggles the
   sibling .settings-section-desc paragraph. Collapsed by default so a page with many
   module toggles reads as a scannable list of titles+switches, not a wall of paragraphs;
   the description is one click away for whoever wants it. See
   initCollapsibleSectionDescriptions() in each page that uses this pattern. */
.settings-info-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    margin-left: 7px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    font-style: italic;
    font-family: Georgia, 'Times New Roman', serif;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    vertical-align: middle;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.settings-info-toggle:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

.settings-info-toggle.expanded {
    background: var(--green);
    border-color: var(--green);
    color: white;
}

/* Wraps everything after a TOP-LEVEL module header (inline messages, and for a couple of
   modules whole sub-setting rows like Costing Method/Barcode/Manufacturing/FIFO-LIFO) so
   the same "i" click that reveals the description also collapses those — otherwise a
   module with extra sub-settings stayed far taller than every plain on/off card next to
   it in the grid. Built at runtime by initCollapsibleSectionDescriptions(); see its own
   comment for why hiding this wrapper is always safe even though its children may have
   their own inline style.display already set by existing render functions. */
.settings-section-body {
    display: none;
}

.settings-section-body.expanded {
    display: block;
    margin-top: 10px;
}

.settings-section-action {
    flex-shrink: 0;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.format-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.format-toggle-row:last-of-type {
    border-bottom: none;
}

.format-toggle-row strong {
    font-size: 13.5px;
}

.format-toggle-row .settings-section-desc {
    margin-top: 2px;
    max-width: 480px;
}

.toggle-row .toggle-label {
    font-weight: 600;
    font-size: 13.5px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    cursor: pointer;
    background: #ccc;
    transition: background 0.2s;
    border-radius: 24px;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background: white;
    transition: transform 0.2s;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--green);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

.danger-zone-title {
    margin: 36px 32px 8px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--danger);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---------- Settings page: tabs + module grid ---------- */

.settings-tabs {
    display: flex;
    gap: 4px;
    margin: 0 32px 22px;
    border-bottom: 2px solid var(--border);
    flex-wrap: wrap;
}

#settingsTabs button.settings-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 18px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    margin-bottom: -2px;
    border-radius: 0;
}

#settingsTabs button.settings-tab:hover {
    background: transparent;
    color: var(--text);
}

#settingsTabs button.settings-tab.active {
    color: var(--green-dark);
    border-bottom-color: var(--green);
}

#settingsTabs button.settings-tab-danger.active {
    color: var(--danger);
    border-bottom-color: var(--danger);
}

.settings-panel {
    display: none;
}

.settings-panel.active {
    display: block;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    align-items: start;
    gap: 20px;
    margin: 0 32px 28px;
}

.settings-grid .container {
    margin: 0;
    max-width: none;
    padding: 22px;
    /* Collapsed, every module card is just a header row — min-height + centering makes
       them all render at the exact same height regardless of small differences in title
       length or action control (toggle vs. button), rather than each shrinking to its own
       natural content size. Once a card's own body is expanded (see .settings-section-body
       above), its real content already exceeds this minimum, so centering becomes a no-op
       and the card simply grows to fit — no separate rule needed for that state. */
    min-height: 88px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.settings-grid-span2 {
    grid-column: span 2;
}

@media (max-width: 820px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
    .settings-grid-span2 {
        grid-column: span 1;
    }
}

.settings-profile-view .detail-grid {
    margin-bottom: 0;
}

/* ---------- Modal ---------- */

.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 31, 44, 0.5);
    z-index: 100;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 40px 20px;
}

.modal-backdrop.open {
    display: flex;
}

.modal-box {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(15, 31, 44, 0.3);
    max-width: 720px;
    width: 100%;
    padding: 28px;
    position: relative;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

.modal-box.narrow {
    max-width: 480px;
}

.modal-box.wide {
    max-width: 960px;
}

.modal-box.stmt-modal {
    max-width: 1240px;
}

/* A sticky <th> (see "Tables" below) makes sense for a long page-scrolled table, but
   inside a modal's own separate scroll container it creates a compositor overlap with
   whichever row sits directly beneath it — visible as that row's top half being clipped.
   Modals are short enough that a sticky header buys nothing anyway, so just turn it off. */
.modal-box th {
    position: static;
    top: auto;
}

/* Same compositor-overlap issue as .modal-box th above, same fix — .table-scroll-x
   (bill-new.html's item table, wrapped for horizontal scrolling) is its own separate
   scroll container too, so the sticky header clips the row directly beneath it. */
.table-scroll-x th {
    position: static;
    top: auto;
}

.modal-close {
    position: absolute;
    top: 18px;
    right: 18px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

.modal-close:hover {
    color: var(--text);
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 24px;
    margin-bottom: 16px;
}

.detail-grid .label {
    font-size: 11.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
}

.detail-grid .value {
    font-size: 14px;
    margin-top: 2px;
}

/* ---------- Access-level hiding ---------- */

body:not([data-access="FULL"]):not([data-access="OWNER"]) [data-requires="full"] {
    display: none !important;
}

body[data-access="VIEW"] [data-requires="write"] {
    display: none !important;
}

/* ---------- Period selector ---------- */

.period-selector {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.period-selector select,
.period-selector input {
    width: auto;
    padding: 7px 10px;
    font-size: 12.5px;
}

.period-selector .periodSep {
    font-size: 12.5px;
    color: var(--text-muted);
}

/* ---------- Advanced filters ---------- */

.adv-filter-panel {
    margin-top: 10px;
    padding: 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.adv-filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.adv-filter-row select,
.adv-filter-row input {
    width: auto;
    padding: 6px 10px;
    font-size: 12.5px;
}

.adv-filter-row .af-col { min-width: 140px; }
.adv-filter-row .af-op { min-width: 120px; }
.adv-filter-row .af-val { min-width: 140px; }

.adv-filter-row .af-remove {
    background: transparent;
    border: none;
    color: var(--danger);
    padding: 4px 8px;
    font-size: 13px;
}

/* ---------- Download button ---------- */

.icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.icon-btn:hover {
    border-color: var(--green);
    color: var(--green-dark);
    background: var(--green-light);
}

.icon-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

.download-btn-wrap {
    position: relative;
    display: inline-block;
}

.download-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 170px;
    display: none;
    overflow: hidden;
    z-index: 30;
}

.download-btn-wrap.open .download-menu {
    display: block;
}

.download-menu a {
    display: block;
    padding: 10px 14px;
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
}

.download-menu a:hover {
    background: var(--bg);
    color: var(--green-dark);
}

/* ---------- Keyboard shortcut cheat-sheet (Shift+/), nav.js's kbdToggleHelp ---------- */

.kbd-help-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 31, 44, 0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.kbd-help-box {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(15, 31, 44, 0.3);
    max-width: 380px;
    width: 100%;
    padding: 20px 22px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

.kbd-help-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 12px;
}

.kbd-help-title button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.kbd-help-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 7px 0;
    border-top: 1px solid var(--border);
    font-size: 13px;
}

.kbd-help-row:first-of-type {
    border-top: none;
}

.kbd-help-row span {
    color: var(--text-muted);
    text-align: right;
}

.kbd-help-row kbd {
    background: var(--bg);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 5px;
    padding: 3px 7px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

/* ---------- Row action menu (kebab button: Edit/Return/Delete etc. on a list row) ---------- */

.action-menu-wrap {
    position: relative;
    display: inline-block;
}

.action-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 190px;
    padding: 6px;
    z-index: 30;
}

.action-menu-wrap.open .action-menu {
    display: block;
}

.action-menu-wrap .action-menu a,
.action-menu-wrap .action-menu button[type="button"] {
    display: block;
    width: 100%;
    background: transparent !important;
    border: none !important;
    padding: 9px 12px;
    border-radius: 6px;
    color: var(--text) !important;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    box-sizing: border-box;
}

.action-menu-wrap .action-menu a:hover,
.action-menu-wrap .action-menu button[type="button"]:hover {
    background: var(--bg) !important;
}

.action-menu-wrap .action-menu button.removeRow {
    color: var(--danger) !important;
}

@media (max-width: 900px) {
    .nav-rail > a.nav-link,
    .nav-rail > .nav-cat > a.nav-link {
        min-width: 60px;
        padding: 8px 10px;
        font-size: 10px;
    }
}

@media (max-width: 600px) {
    .row {
        grid-template-columns: 1fr;
    }

    .container {
        margin: 16px;
        padding: 20px;
    }
}

/* Toasts — floating feedback for slow/loading actions (deletes, backups, PDF/report
   generation, imports, AI calls). See public/js/nav.js's showToast()/updateToast(). */
.toast-container {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: 380px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-left: 4px solid var(--text-muted);
    border-radius: var(--radius);
    box-shadow: 0 10px 28px rgba(16, 24, 32, 0.18), 0 2px 6px rgba(16, 24, 32, 0.08);
    padding: 12px 14px;
    opacity: 0;
    transform: translateY(-12px) scale(0.98);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.toast-in { opacity: 1; transform: translateY(0) scale(1); }
.toast.toast-out { opacity: 0; transform: translateY(-12px) scale(0.98); }

.toast-loading, .toast-success { border-left-color: var(--green); }
.toast-error { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--warning); }

.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 1px;
}
.toast-icon svg { width: 20px; height: 20px; display: block; }
.toast-success .toast-icon { color: var(--green); }
.toast-error .toast-icon { color: var(--danger); }
.toast-info .toast-icon { color: var(--warning); }

.toast-msg {
    flex: 1;
    font-size: 13.5px;
    color: var(--text);
    line-height: 1.4;
    padding-top: 1px;
    word-break: break-word;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    margin-left: 4px;
}
.toast-close:hover { color: var(--text); }

.toast-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2.5px solid var(--green-light);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: toast-spin 0.7s linear infinite;
}

@keyframes toast-spin {
    to { transform: rotate(360deg); }
}

/* ---------- Login screen ---------- */
/* Pre-login pages render before the sidebar/header exist, so body's default
   padding-left/padding-top (sized for the post-login layout) needs resetting here. */
.login-body {
    padding-left: 0;
    padding-top: 0;
    background: var(--card-bg);
}

.login-screen {
    display: flex;
    min-height: 100vh;
}

.login-brand {
    position: relative;
    flex: 0 0 42%;
    min-width: 380px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text-active);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    overflow: hidden;
}

.login-brand-glow {
    position: absolute;
    top: -120px;
    left: -100px;
    width: 480px;
    height: 480px;
    background: radial-gradient(circle, rgba(44, 160, 28, 0.35) 0%, rgba(44, 160, 28, 0) 70%);
    pointer-events: none;
}

.login-brand::after {
    content: "";
    position: absolute;
    bottom: -160px;
    right: -140px;
    width: 420px;
    height: 420px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0) 70%);
    pointer-events: none;
}

/* ---------- Multi-Book selector (entry screens) ---------- */
.book-selector-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    margin-top: 4px;
}

.book-check-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    font-size: 13.5px;
    color: var(--text);
    text-transform: none;
    letter-spacing: normal;
    margin-bottom: 0;
    cursor: pointer;
}

.book-check-label input[type="checkbox"] {
    width: auto;
}

/* ---------- Freeze pane (sticky bottom action bar) ---------- */

/* The bar itself — not just the buttons inside it — matches .container's own box model
   (same left offset, same max-width, same horizontal padding), so it reads as a matching-
   width sibling of the card above it rather than a full-width strip with the card's
   narrower silhouette floating inside it. */
.freeze-pane {
    position: fixed;
    left: calc(var(--sidebar-width) + 32px);
    width: calc(100% - var(--sidebar-width) - 64px);
    max-width: 1000px;
    bottom: 0;
    z-index: 40;
    background: #fff;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.07);
    padding: 12px 28px;
    box-sizing: border-box;
}

.freeze-pane-inner {
    width: 100%;
}

.freeze-pane-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.freeze-pane-row + .freeze-pane-row {
    margin-top: 8px;
}

.freeze-pane-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Reserves room at the bottom of a page/form that adopts the freeze pane, so the pane
   never covers the last field or the final table row. */
.freeze-pane-spacer {
    height: 76px;
}

.book-dropdown {
    position: relative;
}

button.book-dropdown-btn[type="button"] {
    background: #fff !important;
    border: 1px solid var(--border) !important;
    border-radius: 6px;
    padding: 8px 14px !important;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

button.book-dropdown-btn[type="button"]:hover {
    border-color: var(--green) !important;
}

.book-dropdown-caret {
    color: #6b7b87;
    font-size: 11px;
}

.book-dropdown-list {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
    padding: 10px 14px;
    min-width: 180px;
    z-index: 50;
}

.book-dropdown-list .book-check-label {
    padding: 4px 0;
}

.login-brand-content {
    position: relative;
    z-index: 1;
    max-width: 380px;
}

.login-mark {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--green);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.login-mark svg {
    width: 28px;
    height: 28px;
    color: #fff;
}

.login-brand-content h1 {
    font-size: 26px;
    font-weight: 700;
    margin: 0 0 12px 0;
    line-height: 1.25;
}

.login-tagline {
    color: var(--sidebar-text);
    font-size: 14.5px;
    line-height: 1.6;
    margin: 0 0 32px 0;
}

.login-features {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-features li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--sidebar-text-active);
}

.login-check {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(44, 160, 28, 0.2);
    color: var(--green);
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    background: var(--bg);
}

.login-card {
    width: 100%;
    max-width: 380px;
}

.login-card h2 {
    font-size: 22px;
    margin: 0 0 6px 0;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 13.5px;
    margin: 0 0 28px 0;
}

.login-card button[type="submit"] {
    width: 100%;
    padding: 11px 20px;
    font-size: 14px;
    margin-top: 4px;
}

@media (max-width: 760px) {
    .login-screen {
        flex-direction: column;
        min-height: auto;
    }
    .login-brand {
        flex: none;
        min-width: 0;
        padding: 36px 28px;
    }
    .login-brand-content h1 {
        font-size: 21px;
    }
    .login-features {
        display: none;
    }
    .login-panel {
        padding: 40px 24px 56px;
    }
}

/* ---------- Login topbar (Restore a Company + Help) ---------- */

.login-topbar {
    position: fixed;
    top: 16px;
    right: 20px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
}

.support-widget-standalone-inline {
    position: relative;
}

/* ---------- Account chip (remembered email + switch account) ---------- */

.account-chip {
    position: relative;
    margin-bottom: 20px;
}

.account-chip-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    cursor: pointer;
}

.account-chip-row:hover {
    border-color: var(--green);
}

.account-avatar {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--green);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.account-avatar.small {
    width: 24px;
    height: 24px;
    font-size: 11px;
}

.account-chip-email {
    flex: 1;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-chip-chevron {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.account-chip-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 6px;
    display: none;
    z-index: 20;
}

.account-chip-dropdown.open {
    display: block;
}

.account-chip-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.account-chip-option:hover {
    background: var(--bg);
}

.account-chip-option-email {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.account-chip-new {
    color: var(--green-dark);
    font-weight: 600;
}

.account-remove {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
}

.account-remove:hover {
    color: var(--danger);
}

.account-chip-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 4px;
}

.account-switch-back {
    margin: -8px 0 16px 0;
    font-size: 12.5px;
}

.account-switch-back a {
    color: var(--text-muted);
    text-decoration: none;
}

.account-switch-back a:hover {
    color: var(--green-dark);
    text-decoration: underline;
}

.login-forgot-password {
    margin: 14px 0 0 0;
    font-size: 12.5px;
    text-align: center;
}

.login-forgot-password a {
    color: var(--text-muted);
    text-decoration: none;
}

.login-forgot-password a:hover {
    color: var(--green-dark);
    text-decoration: underline;
}
