/* ==========================================================================
   HX Console — design system, second edition
   Bold type, stronger colour, light and dark. No build step.
   Every class name from the first edition is preserved, so all 55 screens
   inherit this without being touched.
   ========================================================================== */

/* --- Fonts, self-hosted so nothing is fetched at page load ---------------- */

@font-face { font-family: 'Jakarta'; src: url('../fonts/plus-jakarta-sans-latin-400-normal.woff2') format('woff2');
             font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Jakarta'; src: url('../fonts/plus-jakarta-sans-latin-500-normal.woff2') format('woff2');
             font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Jakarta'; src: url('../fonts/plus-jakarta-sans-latin-600-normal.woff2') format('woff2');
             font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Jakarta'; src: url('../fonts/plus-jakarta-sans-latin-700-normal.woff2') format('woff2');
             font-weight: 700; font-style: normal; font-display: swap; }

/* Bengali names render identically on every machine, not only where the
   operating system happens to ship a Bengali face. */
@font-face { font-family: 'Bangla'; src: url('../fonts/noto-sans-bengali-bengali-400-normal.woff2') format('woff2');
             font-weight: 400; font-style: normal; font-display: swap;
             unicode-range: U+0980-09FF, U+200C-200D, U+25CC; }
@font-face { font-family: 'Bangla'; src: url('../fonts/noto-sans-bengali-bengali-600-normal.woff2') format('woff2');
             font-weight: 600 700; font-style: normal; font-display: swap;
             unicode-range: U+0980-09FF, U+200C-200D, U+25CC; }

@font-face { font-family: 'Figures'; src: url('../fonts/jetbrains-mono-latin-400-normal.woff2') format('woff2');
             font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Figures'; src: url('../fonts/jetbrains-mono-latin-500-normal.woff2') format('woff2');
             font-weight: 500 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Figures'; src: url('../fonts/jetbrains-mono-latin-700-normal.woff2') format('woff2');
             font-weight: 700; font-style: normal; font-display: swap; }

/* ==========================================================================
   Tokens — light
   ========================================================================== */

:root {
    --ink:            #080C16;
    --ink-2:          #131A2A;
    --ink-3:          #223049;
    --ink-text:       #A9BAD0;
    --ink-text-dim:   #6C7F99;

    --brand:          #00B27A;
    --brand-hover:    #009868;
    --brand-soft:     #E1F7EF;
    --brand-line:     #9FE3C8;
    --brand-contrast: #FFFFFF;

    --canvas:         #F2F5FA;
    --surface:        #FFFFFF;
    --surface-2:      #F7F9FC;
    --surface-3:      #EDF1F7;
    --line:           #E1E7F0;
    --line-strong:    #C9D3E2;

    --text:           #0B1220;
    --text-2:         #47566C;
    --text-3:         #7A8AA0;
    --text-on-brand:  #FFFFFF;

    --pos:            #00996A;
    --neg:            #E03131;
    --warn:           #C2740A;
    --info:           #2563EB;
    --pos-soft:       #E1F7EF;
    --neg-soft:       #FDECEC;
    --warn-soft:      #FEF4E2;
    --info-soft:      #E8EFFE;

    --strip-bg:       #FFFFFF;

    --font: 'Jakarta', 'Bangla', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: 'Figures', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

    --t-xs:   11.5px;
    --t-sm:   13px;
    --t-base: 14.5px;
    --t-md:   16px;
    --t-lg:   19px;
    --t-xl:   24px;
    --t-2xl:  30px;
    --t-3xl:  38px;

    --rail:      286px;
    --rail-min:  76px;
    --topbar:    64px;
    --r-sm:      8px;
    --r:         12px;
    --r-lg:      18px;
    --r-pill:    999px;
    --tap:       42px;

    --shadow-sm:    0 1px 2px rgba(11, 18, 32, .05);
    --shadow:       0 2px 4px rgba(11, 18, 32, .05), 0 12px 28px -14px rgba(11, 18, 32, .22);
    --shadow-lg:    0 32px 70px -22px rgba(11, 18, 32, .40);
    --shadow-brand: 0 6px 18px -6px rgba(0, 178, 122, .55);

    --ease: cubic-bezier(.2, .7, .3, 1);
    color-scheme: light;
}

/* ==========================================================================
   Tokens — dark
   ========================================================================== */

:root[data-theme='dark'] {
    --ink:            #0A101C;
    --ink-2:          #141C2C;
    --ink-3:          #26324A;
    --ink-text:       #B6C6DC;
    --ink-text-dim:   #7286A2;

    --brand:          #16D08F;
    --brand-hover:    #35DCA0;
    --brand-soft:     #10352A;
    --brand-line:     #1D5C46;
    --brand-contrast: #04150E;

    --canvas:         #080D17;
    --surface:        #111926;
    --surface-2:      #16202F;
    --surface-3:      #1D2939;
    --line:           #222E42;
    --line-strong:    #33425C;

    --text:           #E9EFF8;
    --text-2:         #A7B6CB;
    --text-3:         #7688A0;
    --text-on-brand:  #04150E;

    --pos:            #2BD69B;
    --neg:            #FF6B6B;
    --warn:           #F5A524;
    --info:           #5B8DEF;
    --pos-soft:       #0F3227;
    --neg-soft:       #3A1A1C;
    --warn-soft:      #372513;
    --info-soft:      #16233F;

    --strip-bg:       #131C2A;

    --shadow-sm:    0 1px 2px rgba(0, 0, 0, .5);
    --shadow:       0 2px 6px rgba(0, 0, 0, .45), 0 16px 34px -18px rgba(0, 0, 0, .8);
    --shadow-lg:    0 34px 80px -20px rgba(0, 0, 0, .85);
    --shadow-brand: 0 6px 18px -6px rgba(22, 208, 143, .45);

    color-scheme: dark;
}

/* No explicit choice means follow the device. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) {
        --ink: #0A101C; --ink-2: #141C2C; --ink-3: #26324A;
        --ink-text: #B6C6DC; --ink-text-dim: #7286A2;
        --brand: #16D08F; --brand-hover: #35DCA0;
        --brand-soft: #10352A; --brand-line: #1D5C46; --brand-contrast: #04150E;
        --canvas: #080D17; --surface: #111926; --surface-2: #16202F; --surface-3: #1D2939;
        --line: #222E42; --line-strong: #33425C;
        --text: #E9EFF8; --text-2: #A7B6CB; --text-3: #7688A0; --text-on-brand: #04150E;
        --pos: #2BD69B; --neg: #FF6B6B; --warn: #F5A524; --info: #5B8DEF;
        --pos-soft: #0F3227; --neg-soft: #3A1A1C; --warn-soft: #372513; --info-soft: #16233F;
        --strip-bg: #131C2A;
        --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
        --shadow: 0 2px 6px rgba(0,0,0,.45), 0 16px 34px -18px rgba(0,0,0,.8);
        --shadow-lg: 0 34px 80px -20px rgba(0,0,0,.85);
        --shadow-brand: 0 6px 18px -6px rgba(22,208,143,.45);
        color-scheme: dark;
    }
}

/* ==========================================================================
   Reset
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--canvas);
    color: var(--text);
    font-family: var(--font);
    font-size: var(--t-base);
    line-height: 1.55;
    letter-spacing: -.005em;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
    transition: background-color .2s var(--ease), color .2s var(--ease);
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.03em; line-height: 1.2; }
p { margin: 0 0 .75rem; }
:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--brand); color: var(--text-on-brand); }

/* Figures carry the weight in this product, so they get their own face. */
.num, td.num, th.num, .money, .kpi-value, .strip-value {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum' 1;
    letter-spacing: -.02em;
}

.eyebrow {
    font-size: var(--t-xs);
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--text-3);
}

/* ==========================================================================
   Shell
   ========================================================================== */

.hx { min-height: 100vh; }

.hx-rail {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--rail);
    background: var(--ink);
    color: var(--ink-text);
    display: flex;
    flex-direction: column;
    z-index: 60;
    transition: width .2s var(--ease), transform .2s var(--ease);
}
.hx-brand { height: var(--topbar); display: flex; align-items: center; gap: 12px; padding: 0 18px; flex: 0 0 auto; }
.hx-brand img { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; background: var(--ink-2); box-shadow: var(--shadow-brand); }
.hx-brand-copy { min-width: 0; }
.hx-brand-copy strong {
    display: block; color: #fff; font-size: var(--t-md); font-weight: 700;
    letter-spacing: -.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hx-brand-copy small {
    display: block; color: var(--ink-text-dim); font-size: 10px;
    letter-spacing: .16em; text-transform: uppercase; font-weight: 600;
}

.hx-nav { flex: 1 1 auto; overflow-y: auto; padding: 8px 0 28px; scrollbar-width: thin; }
.hx-nav::-webkit-scrollbar { width: 6px; }
.hx-nav::-webkit-scrollbar-thumb { background: var(--ink-3); border-radius: 3px; }

.hx-nav-group { padding: 16px 20px 6px; }

.hx-nav-item { padding: 0 12px; margin-bottom: 2px; }
.hx-nav-link {
    display: flex; align-items: center; gap: 13px;
    width: 100%; min-height: var(--tap);
    padding: 9px 13px;
    border: 0; border-radius: var(--r-sm);
    background: none; color: var(--ink-text);
    font-size: var(--t-base); font-weight: 500;
    text-align: left; cursor: pointer;
    transition: background-color .14s var(--ease), color .14s var(--ease);
}
.hx-nav-link:hover { background: var(--ink-2); color: #fff; text-decoration: none; }
.hx-nav-link.is-active { background: var(--brand); color: var(--brand-contrast); font-weight: 700; box-shadow: var(--shadow-brand); }
.hx-nav-link.is-open { background: var(--ink-2); color: #fff; }
.hx-nav-link svg { width: 19px; height: 19px; flex: 0 0 19px; fill: currentColor; }
.hx-nav-label { flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hx-caret { width: 14px; height: 14px; flex: 0 0 14px; transition: transform .18s var(--ease); opacity: .55; }
.hx-nav-link.is-open .hx-caret { transform: rotate(90deg); }

.hx-sub { display: none; margin: 3px 0 8px 32px; padding-left: 13px; border-left: 2px solid var(--ink-3); }
.hx-sub.is-open { display: block; }
.hx-sub a { display: block; padding: 8px 12px; min-height: 36px; border-radius: var(--r-sm); color: var(--ink-text-dim); font-size: var(--t-sm); font-weight: 500; }
.hx-sub a:hover { background: var(--ink-2); color: #fff; text-decoration: none; }
.hx-sub a.is-active { color: #fff; background: var(--ink-2); font-weight: 700; box-shadow: inset 3px 0 0 var(--brand); }

.hx-rail-foot { flex: 0 0 auto; padding: 12px; border-top: 1px solid var(--ink-3); }

.hx.is-collapsed .hx-rail { width: var(--rail-min); }
.hx.is-collapsed .hx-brand-copy,
.hx.is-collapsed .hx-nav-label,
.hx.is-collapsed .hx-caret,
.hx.is-collapsed .hx-nav-group,
.hx.is-collapsed .hx-sub { display: none; }
.hx.is-collapsed .hx-nav-link { justify-content: center; padding: 9px; }
.hx.is-collapsed .hx-main { margin-left: var(--rail-min); }

/* Main column ------------------------------------------------------------- */
.hx-main { margin-left: var(--rail); min-height: 100vh; display: flex; flex-direction: column; transition: margin .2s var(--ease); }

.hx-topbar {
    position: sticky; top: 0; z-index: 40;
    height: var(--topbar);
    display: flex; align-items: center; gap: 14px;
    padding: 0 22px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.hx-crumbs { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; gap: 9px; }
.hx-crumbs h1 { font-size: var(--t-lg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hx-crumbs .sep { color: var(--text-3); }
.hx-crumbs span { font-size: var(--t-sm); color: var(--text-3); white-space: nowrap; font-weight: 600; }

.hx-search { position: relative; width: min(340px, 32vw); }
.hx-search input { width: 100%; padding-left: 38px; border-radius: var(--r-pill); background: var(--surface-2); }
.hx-search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; fill: var(--text-3); pointer-events: none; }

.hx-content { flex: 1 1 auto; padding: 26px 24px 56px; max-width: 1640px; width: 100%; }

/* Icon button ------------------------------------------------------------- */
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: var(--tap); height: var(--tap);
    border: 1px solid transparent; border-radius: var(--r-sm);
    background: none; cursor: pointer; color: var(--text-2); flex: 0 0 auto;
    transition: background-color .14s var(--ease), color .14s var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; fill: currentColor; }
.hx-rail .icon-btn { color: var(--ink-text); }
.hx-rail .icon-btn:hover { background: var(--ink-2); color: #fff; }

/* ==========================================================================
   Workspace
   ========================================================================== */

.ws-head { display: flex; align-items: flex-start; gap: 18px; flex-wrap: wrap; margin-bottom: 20px; }
.ws-head-copy { flex: 1 1 280px; min-width: 0; }
.ws-head h2 { font-size: var(--t-2xl); letter-spacing: -.04em; }
.ws-head p { color: var(--text-2); font-size: var(--t-base); margin: 6px 0 0; max-width: 68ch; }
.ws-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.ws-tabs {
    display: flex; gap: 4px; overflow-x: auto;
    padding: 5px; margin-bottom: 20px;
    background: var(--surface-3); border-radius: var(--r);
    scrollbar-width: none;
}
.ws-tabs::-webkit-scrollbar { display: none; }
.ws-tab {
    appearance: none; border: 0; background: none; cursor: pointer;
    padding: 9px 16px; min-height: 38px;
    border-radius: var(--r-sm);
    font-size: var(--t-sm); font-weight: 600; color: var(--text-2);
    white-space: nowrap;
    transition: background-color .14s var(--ease), color .14s var(--ease);
}
.ws-tab:hover { color: var(--text); }
.ws-tab.is-active { color: var(--text); background: var(--surface); box-shadow: var(--shadow-sm); }
.ws-tab .count { margin-left: 7px; font-size: var(--t-xs); color: var(--text-3); font-family: var(--mono); }

/* The ledger strip — figures on cards rather than one dark band. */
.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.strip-cell {
    position: relative; padding: 16px 18px 14px;
    background: var(--strip-bg); border: 1px solid var(--line);
    border-radius: var(--r); box-shadow: var(--shadow-sm); overflow: hidden;
}
.strip-cell::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--brand); opacity: .9; }
.strip-label { font-size: var(--t-xs); font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); }
.strip-value { display: block; margin-top: 6px; font-size: var(--t-xl); font-weight: 700; color: var(--text); letter-spacing: -.035em; }
.strip-value.pos  { color: var(--pos); }
.strip-value.neg  { color: var(--neg); }
.strip-value.warn { color: var(--warn); }
.strip-cell:has(.strip-value.pos)::before  { background: var(--pos); }
.strip-cell:has(.strip-value.neg)::before  { background: var(--neg); }
.strip-cell:has(.strip-value.warn)::before { background: var(--warn); }

/* Cards ------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 14px; padding: 17px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h3 { font-size: var(--t-md); flex: 1 1 auto; }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* KPI --------------------------------------------------------------------- */
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.kpi-value { display: block; margin-top: 8px; font-size: var(--t-2xl); font-weight: 700; letter-spacing: -.04em; }
.kpi-foot { margin-top: 6px; font-size: var(--t-sm); color: var(--text-3); }

/* Buttons ----------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: var(--tap); padding: 0 18px;
    border: 1.5px solid var(--line-strong); border-radius: var(--r-sm);
    background: var(--surface); color: var(--text);
    font-size: var(--t-sm); font-weight: 600; cursor: pointer; white-space: nowrap;
    transition: transform .12s var(--ease), background-color .14s var(--ease), border-color .14s var(--ease);
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; fill: currentColor; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--text-on-brand); box-shadow: var(--shadow-brand); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-danger { background: var(--neg); border-color: var(--neg); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-ghost { background: none; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: var(--t-xs); }

/* Forms ------------------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field > label { display: block; margin-bottom: 7px; font-size: var(--t-sm); font-weight: 600; color: var(--text-2); }
.field > label .req { color: var(--neg); margin-left: 3px; }
.input, input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], input[type=tel], input[type=file], select, textarea {
    width: 100%; min-height: var(--tap); padding: 9px 13px;
    border: 1.5px solid var(--line-strong); border-radius: var(--r-sm);
    background: var(--surface); color: var(--text); font-size: var(--t-base);
    transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
input[type=number], input[type=date] { font-family: var(--mono); font-variant-numeric: tabular-nums; }
input[type=file] { padding: 8px 12px; }
textarea { min-height: 88px; resize: vertical; }
select {
    appearance: none; padding-right: 34px;
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%237A8AA0'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 9px center; background-size: 19px;
}
.input:focus, input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent);
}
.field.has-error .input, .field.has-error input, .field.has-error select { border-color: var(--neg); }
.field-error { margin-top: 6px; font-size: var(--t-sm); color: var(--neg); font-weight: 500; }
.field-hint { margin-top: 6px; font-size: var(--t-sm); color: var(--text-3); }
.form-grid { display: grid; gap: 0 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 8px; }

.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); }
.check input { width: 19px; height: 19px; min-height: 0; accent-color: var(--brand); }
.check label { font-size: var(--t-base); margin: 0; font-weight: 500; }

/* Filter bar -------------------------------------------------------------- */
.filters {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
    padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--surface-2);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.filters .field { margin: 0; flex: 0 1 190px; }
.filters .grow { flex: 1 1 220px; }
.filters .spacer { flex: 1 1 auto; }

/* Table ------------------------------------------------------------------- */
.table-wrap { width: 100%; overflow-x: auto; }
table.dt { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
table.dt th, table.dt td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.dt thead th {
    position: sticky; top: 0; z-index: 1;
    background: var(--surface-2); color: var(--text-3);
    font-size: var(--t-xs); font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
    white-space: nowrap; border-bottom: 1.5px solid var(--line-strong);
}
table.dt thead th.sortable { cursor: pointer; user-select: none; }
table.dt thead th.sortable:hover { color: var(--text); }
table.dt thead th .arrow { opacity: .3; margin-left: 5px; }
table.dt thead th.is-sorted { color: var(--brand); }
table.dt thead th.is-sorted .arrow { opacity: 1; }
table.dt tbody tr { transition: background-color .12s var(--ease); }
table.dt tbody tr:hover { background: var(--surface-2); }
table.dt td.num, table.dt th.num { text-align: right; }
table.dt td.actions { text-align: right; white-space: nowrap; }
table.dt tfoot td { padding: 14px 16px; font-weight: 700; background: var(--surface-2); border-top: 1.5px solid var(--line-strong); }
table.dt tbody tr:last-child td { border-bottom: 0; }

.dt-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--line); }
.dt-count { font-size: var(--t-sm); color: var(--text-3); flex: 1 1 auto; font-weight: 500; }
.pager { display: flex; gap: 5px; }
.pager button {
    min-width: 36px; height: 36px; padding: 0 10px;
    border: 1.5px solid var(--line-strong); border-radius: var(--r-sm);
    background: var(--surface); cursor: pointer; font-size: var(--t-sm);
    font-family: var(--mono); font-weight: 600;
}
.pager button:hover:not(:disabled) { background: var(--surface-3); }
.pager button.is-active { background: var(--brand); border-color: var(--brand); color: var(--text-on-brand); }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* Badges ------------------------------------------------------------------ */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 11px; border-radius: var(--r-pill);
    font-size: var(--t-xs); font-weight: 700; letter-spacing: -.01em;
    background: var(--surface-3); color: var(--text-2);
}
.badge.pos  { background: var(--pos-soft);  color: var(--pos); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.neg  { background: var(--neg-soft);  color: var(--neg); }
.badge.info { background: var(--info-soft); color: var(--info); }

.money { font-weight: 600; }
.money.pos { color: var(--pos); }
.money.neg { color: var(--neg); }

/* States ------------------------------------------------------------------ */
.empty { padding: 60px 28px; text-align: center; }
.empty svg { width: 46px; height: 46px; fill: var(--line-strong); }
.empty h4 { margin: 16px 0 6px; font-size: var(--t-md); }
.empty p { color: var(--text-3); font-size: var(--t-base); max-width: 420px; margin: 0 auto 18px; }

.skeleton {
    background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
    background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: 6px; height: 14px;
}
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.spinner {
    width: 18px; height: 18px;
    border: 2.5px solid color-mix(in srgb, currentColor 25%, transparent);
    border-top-color: currentColor; border-radius: 50%;
    animation: spin .65s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal ------------------------------------------------------------------- */
.modal-back {
    position: fixed; inset: 0; background: rgba(4, 8, 16, .62);
    z-index: 200; display: flex; align-items: flex-start; justify-content: center;
    padding: 4vh 16px; overflow-y: auto;
}
.modal {
    width: 100%; max-width: 660px; background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg); animation: rise .2s var(--ease);
}
.modal.wide { max-width: 1020px; }
@keyframes rise { from { transform: translateY(14px) scale(.99); opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: 14px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { flex: 1 1 auto; font-size: var(--t-md); }
.modal-body { padding: 22px; }
.modal-foot {
    display: flex; gap: 10px; justify-content: flex-end;
    padding: 16px 22px; border-top: 1px solid var(--line);
    background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* Toast ------------------------------------------------------------------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 300; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 40px)); }
.toast {
    display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r);
    background: var(--ink); color: #fff; box-shadow: var(--shadow-lg);
    font-size: var(--t-sm); animation: rise .2s var(--ease); border: 1px solid var(--ink-3);
}
.toast .bar { width: 4px; border-radius: 3px; flex: 0 0 4px; background: var(--ink-text-dim); }
.toast.ok .bar   { background: #2BD69B; }
.toast.err .bar  { background: #FF6B6B; }
.toast.warn .bar { background: #F5A524; }
.toast strong { display: block; font-size: var(--t-sm); font-weight: 700; }
.toast span { color: var(--ink-text); font-size: var(--t-sm); }

/* Login ------------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.login-aside {
    background: var(--ink); color: #fff; padding: 56px;
    display: flex; flex-direction: column; justify-content: space-between;
    background-image: radial-gradient(1000px 500px at 15% -10%, color-mix(in srgb, var(--brand) 26%, transparent), transparent 60%);
}
.login-aside h2 { font-size: var(--t-3xl); letter-spacing: -.045em; line-height: 1.08; max-width: 14ch; }
.login-aside p { color: var(--ink-text); max-width: 44ch; margin-top: 16px; font-size: var(--t-md); }
.login-strip { display: flex; gap: 32px; flex-wrap: wrap; margin-top: 32px; }
.login-strip div span { display: block; font-family: var(--mono); font-size: var(--t-lg); font-weight: 700; }
.login-strip div small { color: var(--ink-text-dim); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; font-weight: 600; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-card { width: 100%; max-width: 400px; }
.login-card h1 { font-size: var(--t-2xl); margin-bottom: 6px; }
.login-card > p { color: var(--text-2); margin-bottom: 26px; }
.login-alert { display: none; padding: 12px 14px; border-radius: var(--r-sm); background: var(--neg-soft); color: var(--neg); font-size: var(--t-sm); margin-bottom: 16px; font-weight: 500; }
.login-alert.show { display: block; }

/* Utilities --------------------------------------------------------------- */
.muted { color: var(--text-3); }
.small { font-size: var(--t-sm); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 3px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hidden { display: none !important; }
.scrim { position: fixed; inset: 0; background: rgba(4, 8, 16, .55); z-index: 55; }

/* ==========================================================================
   Responsive
   ========================================================================== */

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

@media (max-width: 1024px) {
    .login-wrap { grid-template-columns: 1fr; }
    .login-aside { display: none; }
    .grid.c3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid.c3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
    :root { --t-2xl: 26px; --t-xl: 21px; }

    .hx-rail { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .hx.is-drawer .hx-rail { transform: none; }
    .hx-main { margin-left: 0 !important; }
    .hx-content { padding: 18px 14px 72px; }
    .hx-search { display: none; }
    .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; }
    .form-grid, .form-grid.c3 { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .strip-cell { padding: 13px 14px 12px; }
    .strip-value { font-size: var(--t-lg); }
    .ws-head h2 { font-size: var(--t-xl); }

    /* A modal on a phone is a full screen, not a floating box. */
    .modal-back { padding: 0; }
    .modal, .modal.wide { max-width: none; min-height: 100vh; border-radius: 0; border: 0; }
    .modal-foot { position: sticky; bottom: 0; }

    /* Wide financial rows become readable records. */
    table.dt.stack-mobile thead { display: none; }
    table.dt.stack-mobile tbody tr {
        display: block; margin-bottom: 12px; padding: 4px 0;
        border: 1px solid var(--line); border-radius: var(--r); background: var(--surface);
        box-shadow: var(--shadow-sm);
    }
    table.dt.stack-mobile tbody td {
        display: flex; justify-content: space-between; gap: 16px;
        border: 0; border-bottom: 1px solid var(--line); padding: 10px 15px; text-align: right;
    }
    table.dt.stack-mobile tbody td:last-child { border-bottom: 0; }
    table.dt.stack-mobile tbody td::before {
        content: attr(data-label);
        font-size: var(--t-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
        color: var(--text-3); text-align: left; flex: 0 0 auto;
    }
    table.dt.stack-mobile tbody td.actions { justify-content: flex-end; }
}

@media (max-width: 440px) {
    .strip { grid-template-columns: 1fr; }
    .ws-actions { width: 100%; }
    .ws-actions .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* Print ------------------------------------------------------------------- */
@media print {
    :root { --canvas: #fff; --surface: #fff; --surface-2: #fff; --text: #000; --line: #999; }
    .hx-rail, .hx-topbar, .ws-tabs, .ws-actions, .filters, .dt-foot, .toasts, .no-print { display: none !important; }
    .hx-main { margin-left: 0 !important; }
    .hx-content { padding: 0; max-width: none; }
    .card { border: 0; box-shadow: none; }
    .strip { display: flex; gap: 0; border: 1px solid #000; }
    .strip-cell { border-right: 1px solid #000; box-shadow: none; border-radius: 0; }
    .strip-cell::before { display: none; }
    body { background: #fff; font-size: 11px; }
    table.dt thead th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ==========================================================================
   Navigation sections
   ========================================================================== */

.hx-nav-group {
    padding: 18px 24px 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--ink-text-dim);
    opacity: .75;
}
.hx-nav-group:first-child { padding-top: 8px; }

/* ==========================================================================
   Command palette
   ========================================================================== */

.cmdk-back {
    position: fixed; inset: 0; z-index: 250;
    background: rgba(4, 8, 16, .55);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 10vh 16px 16px;
}
.cmdk {
    width: 100%; max-width: 640px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: rise .18s var(--ease);
    display: flex; flex-direction: column;
    max-height: min(560px, 78vh);
}
.cmdk-input {
    display: flex; align-items: center; gap: 12px;
    padding: 6px 18px; border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.cmdk-input svg { width: 19px; height: 19px; fill: var(--text-3); flex: 0 0 19px; }
.cmdk-input input {
    flex: 1 1 auto; border: 0; background: none; min-height: 56px;
    font-size: var(--t-md); font-weight: 500; padding: 0;
}
.cmdk-input input:focus { outline: none; box-shadow: none; }

.cmdk-list { overflow-y: auto; flex: 1 1 auto; padding: 8px; }
.cmdk-group {
    padding: 12px 12px 6px;
    font-size: 10px; font-weight: 700; letter-spacing: .16em;
    text-transform: uppercase; color: var(--text-3);
}
.cmdk-item {
    display: flex; align-items: center; gap: 13px;
    width: 100%; padding: 11px 12px;
    border: 0; border-radius: var(--r-sm); background: none;
    text-align: left; cursor: pointer; color: var(--text);
    font-size: var(--t-base);
}
.cmdk-item:hover, .cmdk-item.is-active { background: var(--surface-3); text-decoration: none; }
.cmdk-item.is-active { box-shadow: inset 3px 0 0 var(--brand); }
.cmdk-item svg { width: 18px; height: 18px; fill: var(--text-3); flex: 0 0 18px; }
.cmdk-item.is-active svg { fill: var(--brand); }
.cmdk-item strong { font-weight: 600; }
.cmdk-item .where { margin-left: auto; font-size: var(--t-xs); color: var(--text-3); font-weight: 600; }
.cmdk-empty { padding: 40px 20px; text-align: center; color: var(--text-3); font-size: var(--t-sm); }

.cmdk-foot {
    display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
    padding: 11px 18px; border-top: 1px solid var(--line);
    background: var(--surface-2); font-size: var(--t-xs); color: var(--text-3);
    flex: 0 0 auto;
}
kbd {
    display: inline-block; padding: 2px 7px; margin: 0 3px;
    border: 1px solid var(--line-strong); border-bottom-width: 2px;
    border-radius: 5px; background: var(--surface);
    font-family: var(--mono); font-size: 10.5px; font-weight: 600; color: var(--text-2);
}

/* Topbar palette trigger -------------------------------------------------- */
.cmdk-trigger {
    display: flex; align-items: center; gap: 10px;
    min-height: 40px; padding: 0 12px 0 14px;
    width: min(320px, 30vw);
    border: 1.5px solid var(--line); border-radius: var(--r-pill);
    background: var(--surface-2); color: var(--text-3);
    font-size: var(--t-sm); font-weight: 500; cursor: pointer;
    transition: border-color .14s var(--ease), background-color .14s var(--ease);
}
.cmdk-trigger:hover { border-color: var(--line-strong); background: var(--surface-3); }
.cmdk-trigger svg { width: 16px; height: 16px; fill: var(--text-3); flex: 0 0 16px; }
.cmdk-trigger span { flex: 1 1 auto; text-align: left; }

/* ==========================================================================
   User menu
   ========================================================================== */

.usermenu { position: relative; }
.usermenu-panel {
    position: absolute; bottom: calc(100% + 8px); left: 0; right: 0;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--line); border-radius: var(--r);
    box-shadow: var(--shadow-lg); padding: 6px; z-index: 70;
    animation: rise .14s var(--ease);
}
.usermenu-panel button, .usermenu-panel a {
    display: flex; align-items: center; gap: 11px; width: 100%;
    padding: 10px 12px; border: 0; border-radius: var(--r-sm);
    background: none; color: var(--text); font-size: var(--t-sm); font-weight: 500;
    text-align: left; cursor: pointer;
}
.usermenu-panel button:hover, .usermenu-panel a:hover { background: var(--surface-3); text-decoration: none; }
.usermenu-panel svg { width: 17px; height: 17px; fill: var(--text-3); }
.usermenu-sep { height: 1px; background: var(--line); margin: 5px 0; }

/* ==========================================================================
   Mobile bottom bar
   ========================================================================== */

.hx-bottom { display: none; }

@media (max-width: 860px) {
    .hx-bottom {
        position: fixed; inset: auto 0 0 0; z-index: 50;
        display: grid; grid-template-columns: repeat(5, 1fr);
        background: var(--surface);
        border-top: 1px solid var(--line);
        padding-bottom: env(safe-area-inset-bottom, 0);
        box-shadow: 0 -6px 24px -12px rgba(11, 18, 32, .3);
    }
    .hx-bottom button, .hx-bottom a {
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 3px; min-height: 58px; padding: 8px 4px;
        border: 0; background: none; cursor: pointer;
        color: var(--text-3); font-size: 10.5px; font-weight: 600;
        text-decoration: none;
    }
    .hx-bottom svg { width: 21px; height: 21px; fill: currentColor; }
    .hx-bottom .is-active { color: var(--brand); }
    .hx-bottom .primary svg {
        width: 38px; height: 38px; padding: 9px;
        border-radius: var(--r-pill); background: var(--brand);
        fill: var(--text-on-brand); box-shadow: var(--shadow-brand);
        margin-top: -14px;
    }
    .cmdk-back { padding: 0; align-items: stretch; }
    .cmdk { max-width: none; max-height: none; border-radius: 0; border: 0; }
    .cmdk-foot { display: none; }
}

/* ==========================================================================
   Table — density, sticky column, row expansion, column chooser
   ========================================================================== */

/* Density. Comfortable is the default; compact fits roughly a third more rows. */
table.dt.is-compact th, table.dt.is-compact td { padding: 7px 12px; }
table.dt.is-compact { font-size: var(--t-xs); }
table.dt.is-compact tfoot td { padding: 9px 12px; }

/* The identifying column stays put while wide financial tables scroll. */
table.dt.sticky-first tbody td:first-child,
table.dt.sticky-first thead th:first-child {
    position: sticky; left: 0; z-index: 2;
    background: var(--surface);
    box-shadow: 1px 0 0 var(--line);
}
table.dt.sticky-first thead th:first-child { z-index: 3; background: var(--surface-2); }
table.dt.sticky-first tbody tr:hover td:first-child { background: var(--surface-2); }

/* Row expansion — detail opens under the row instead of in a modal. */
.dt-expander {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; padding: 0;
    border: 1px solid var(--line-strong); border-radius: var(--r-sm);
    background: var(--surface); cursor: pointer; color: var(--text-3);
}
.dt-expander:hover { background: var(--surface-3); color: var(--text); }
.dt-expander svg { width: 14px; height: 14px; fill: currentColor; transition: transform .16s var(--ease); }
.dt-expander.is-open svg { transform: rotate(90deg); }
.dt-expander.is-open { border-color: var(--brand); color: var(--brand); }

tr.dt-detail > td {
    background: var(--surface-2);
    padding: 0 !important;
    border-bottom: 2px solid var(--line-strong);
}
.dt-detail-inner { padding: 18px 20px; animation: unfold .18s var(--ease); }
@keyframes unfold { from { opacity: 0; transform: translateY(-4px); } }
.dt-detail-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 22px;
}
.dt-detail-grid div span {
    display: block; font-size: var(--t-xs); font-weight: 700; letter-spacing: .12em;
    text-transform: uppercase; color: var(--text-3); margin-bottom: 3px;
}
.dt-detail-grid div strong { font-size: var(--t-base); font-weight: 600; }

/* Column chooser ---------------------------------------------------------- */
.dt-cols { position: relative; }
.dt-cols-panel {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
    min-width: 240px; max-height: 340px; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 8px;
    animation: rise .14s var(--ease);
}
.dt-cols-panel label {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--r-sm);
    font-size: var(--t-sm); font-weight: 500; cursor: pointer;
}
.dt-cols-panel label:hover { background: var(--surface-3); }
.dt-cols-panel input { width: 17px; height: 17px; min-height: 0; accent-color: var(--brand); }

/* Skeleton shaped like the table it is standing in for ------------------- */
.dt-skeleton { padding: 0; }
.dt-skeleton-row {
    display: flex; gap: 16px; align-items: center;
    padding: 13px 16px; border-bottom: 1px solid var(--line);
}
.dt-skeleton-row .skeleton { height: 12px; flex: 1 1 auto; }
.dt-skeleton-row .skeleton:first-child { flex: 0 0 22%; }
.dt-skeleton-row .skeleton:last-child { flex: 0 0 14%; }

@media (max-width: 860px) {
    /* A ten-column row becomes a summary card; the rest opens on tap. */
    table.dt.stack-mobile tbody td[data-secondary] { display: none; }
    table.dt.stack-mobile tbody tr.is-expanded td[data-secondary] { display: flex; }
    .dt-more {
        display: block; width: 100%; padding: 9px;
        border: 0; border-top: 1px solid var(--line);
        background: var(--surface-2); color: var(--brand);
        font-size: var(--t-xs); font-weight: 700; letter-spacing: .06em;
        text-transform: uppercase; cursor: pointer;
    }
    table.dt.sticky-first tbody td:first-child,
    table.dt.sticky-first thead th:first-child { position: static; box-shadow: none; }
    .dt-detail-grid { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 861px) {
    .dt-more { display: none; }
}

/* ==========================================================================
   Sheet — the full-page host for entry forms
   A dialog is fine for a confirmation. Anything with line items, a product
   search and a running total needs the whole screen.
   ========================================================================== */

.modal-back.is-sheet {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
    background: rgba(4, 8, 16, .50);
    overflow: hidden;
}

.modal.is-sheet {
    max-width: min(1180px, 100%);
    margin: 0 auto;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    border: 0;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    animation: sheet-in .22s var(--ease);
}
@keyframes sheet-in { from { transform: translateY(22px); opacity: 0; } }

.modal.is-sheet .modal-head {
    flex: 0 0 auto;
    padding: 18px 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.modal.is-sheet .modal-head h3 { font-size: var(--t-lg); }

.modal.is-sheet .modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 26px 28px 32px;
    background: var(--canvas);
}

/* The action bar never scrolls away, so Save is always one reach from where
   you are working. */
.modal.is-sheet .modal-foot {
    flex: 0 0 auto;
    position: sticky;
    bottom: 0;
    padding: 16px 28px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-top: 1px solid var(--line);
    border-radius: 0;
    box-shadow: 0 -8px 24px -16px rgba(11, 18, 32, .35);
}
.modal.is-sheet .modal-foot .btn { min-height: 46px; padding: 0 22px; }

/* Content inside a sheet sits on cards, so long forms have visible structure. */
.modal.is-sheet .modal-body > .form-grid,
.modal.is-sheet .modal-body > .eyebrow + .table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 22px 24px;
    margin-bottom: 16px;
}
.modal.is-sheet .modal-body > .eyebrow { margin: 22px 0 10px; }
.modal.is-sheet .modal-body > .card { box-shadow: var(--shadow-sm); }

@media (max-width: 860px) {
    .modal.is-sheet {
        max-width: none;
        border: 0;
    }
    .modal.is-sheet .modal-head { padding: 14px 16px; }
    .modal.is-sheet .modal-body { padding: 16px 14px 26px; }
    .modal.is-sheet .modal-foot { padding: 12px 14px; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
    .modal.is-sheet .modal-foot .btn { flex: 1 1 auto; }
    .modal.is-sheet .modal-body > .form-grid { padding: 16px; }
}

/* ==========================================================================
   Printable documents
   A screen with the chrome hidden is not a document. This is a document.
   ========================================================================== */

.printdoc { display: none; }

@media print {
    body.is-printing > *:not(.printdoc) { display: none !important; }

    .printdoc {
        display: block;
        background: #fff;
        color: #000;
        font-family: var(--font);
        font-size: 11.5px;
        line-height: 1.5;
    }

    @page { size: A4; margin: 14mm 12mm; }
}

/* Kept visible off-print so the layout can be checked on screen if needed. */
.printdoc-head {
    display: flex; gap: 24px; align-items: flex-start;
    padding-bottom: 14px; border-bottom: 2px solid #000; margin-bottom: 18px;
}
.printdoc-brand { display: flex; gap: 14px; align-items: flex-start; flex: 1 1 auto; }
.printdoc-brand img { width: 54px; height: 54px; object-fit: contain; }
.printdoc-brand h1 { font-size: 19px; letter-spacing: -.02em; margin-bottom: 3px; }
.printdoc-brand p { margin: 0; font-size: 11px; line-height: 1.45; color: #333; }

.printdoc-title { text-align: right; flex: 0 0 auto; }
.printdoc-title h2 {
    font-size: 17px; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 6px;
}
.printdoc-title dl { margin: 0; font-size: 11px; }
.printdoc-title dl div { display: flex; gap: 10px; justify-content: flex-end; }
.printdoc-title dt { color: #555; }
.printdoc-title dd { margin: 0; font-family: var(--mono); font-weight: 600; }

.printdoc-parties { display: flex; gap: 28px; margin-bottom: 16px; }
.printdoc-party { flex: 1 1 0; }
.printdoc-party h3 {
    font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase;
    color: #555; margin-bottom: 5px; font-weight: 700;
}
.printdoc-party strong { display: block; font-size: 13px; }
.printdoc-party p { margin: 2px 0 0; font-size: 11px; color: #333; }

table.printdoc-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-bottom: 14px; }
table.printdoc-table thead th {
    background: #EEE; border-bottom: 1.5px solid #000;
    padding: 7px 9px; text-align: left;
    font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
table.printdoc-table tbody td { padding: 7px 9px; border-bottom: .5px solid #BBB; vertical-align: top; }
table.printdoc-table .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.printdoc-table thead { display: table-header-group; }
table.printdoc-table tr { page-break-inside: avoid; }

.printdoc-totals { display: flex; justify-content: flex-end; margin-bottom: 18px; page-break-inside: avoid; }
.printdoc-totals table { border-collapse: collapse; min-width: 270px; font-size: 11.5px; }
.printdoc-totals td { padding: 5px 10px; }
.printdoc-totals td:last-child { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.printdoc-totals tr.grand td { border-top: 1.5px solid #000; border-bottom: 1.5px solid #000; font-size: 13.5px; font-weight: 700; }

.printdoc-note { font-size: 10.5px; color: #333; border-top: .5px solid #BBB; padding-top: 10px; margin-bottom: 22px; }
.printdoc-sign { display: flex; gap: 40px; justify-content: space-between; margin-top: 40px; page-break-inside: avoid; }
.printdoc-sign div { flex: 1 1 0; border-top: .5px solid #000; padding-top: 6px; font-size: 10px; color: #333; text-align: center; }
.printdoc-foot { margin-top: 22px; padding-top: 8px; border-top: .5px solid #BBB; font-size: 9.5px; color: #666; text-align: center; }

/* ==========================================================================
   Date range control
   ========================================================================== */

.range {
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
    padding: 14px 18px; margin-bottom: 18px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.range-presets { display: flex; flex-wrap: wrap; gap: 5px; }
.range-chip {
    appearance: none; cursor: pointer;
    padding: 8px 14px; min-height: 36px;
    border: 1.5px solid var(--line); border-radius: var(--r-pill);
    background: var(--surface-2); color: var(--text-2);
    font-size: var(--t-sm); font-weight: 600; white-space: nowrap;
    transition: background-color .14s var(--ease), color .14s var(--ease), border-color .14s var(--ease);
}
.range-chip:hover { background: var(--surface-3); color: var(--text); }
.range-chip.is-active {
    background: var(--brand); border-color: var(--brand);
    color: var(--text-on-brand); box-shadow: var(--shadow-brand);
}
.range-custom { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.range-custom label {
    display: flex; align-items: center; gap: 8px;
    font-size: var(--t-sm); font-weight: 600; color: var(--text-2);
}
.range-custom input { width: auto; min-width: 160px; }
.range-label {
    margin-left: auto; font-size: var(--t-sm); font-weight: 700;
    color: var(--text-3); font-family: var(--mono);
}

/* Export cluster ---------------------------------------------------------- */
.export-group { display: flex; gap: 6px; flex-wrap: wrap; }

@media (max-width: 860px) {
    .range { padding: 12px; gap: 10px; }
    .range-label { margin-left: 0; width: 100%; }
    .range-custom input { min-width: 0; flex: 1 1 auto; }
    .range-custom label { flex: 1 1 100%; }
}

/* Screen-wide control slot, above the figures ------------------------------ */
.ws-toolbar { margin-bottom: 18px; }
.ws-toolbar .range { margin-bottom: 0; }

/* ==========================================================================
   Range calendar — pick both ends of a period on one screen
   ========================================================================== */

.rangecal-anchor { position: relative; }

.rangecal {
    position: fixed; z-index: 1200;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
    width: max-content; max-width: calc(100vw - 24px);
    padding: 16px; box-sizing: border-box;
    overflow-x: hidden; overflow-y: auto;
    overscroll-behavior: contain;
    animation: rise .16s var(--ease);
}
.rangecal-months { display: flex; gap: 24px; }
.rangecal-month { width: 250px; min-width: 0; }

.rangecal-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px; min-height: 34px;
}
.rangecal-head strong { font-size: var(--t-sm); font-weight: 700; }
.rangecal-nav {
    width: 30px; height: 30px; padding: 0;
    border: 1px solid var(--line-strong); border-radius: var(--r-sm);
    background: var(--surface); cursor: pointer; color: var(--text-2);
    display: inline-flex; align-items: center; justify-content: center;
}
.rangecal-nav:hover { background: var(--surface-3); color: var(--text); }
.rangecal-nav svg { width: 14px; height: 14px; fill: currentColor; }
.rangecal-nav.back svg { transform: rotate(180deg); }

.rangecal-grid {
    display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
    column-gap: 0; row-gap: 2px;
}
.rangecal-dow {
    text-align: center; font-size: 10px; font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: var(--text-3); padding: 4px 0 6px;
}
.rangecal-day {
    appearance: none; border: 0; cursor: pointer;
    width: 100%; min-width: 0; height: 34px; border-radius: var(--r-sm);
    background: transparent; color: var(--text);
    font-family: var(--mono); font-size: var(--t-sm); font-variant-numeric: tabular-nums;
    transition: background-color .12s var(--ease), color .12s var(--ease), box-shadow .12s var(--ease);
    touch-action: manipulation;
}
.rangecal-day:hover:not(:disabled):not(.is-start):not(.is-end) {
    background: var(--surface-3);
}
.rangecal-day:focus-visible {
    position: relative; z-index: 2;
    outline: 2px solid var(--brand); outline-offset: 1px;
}
.rangecal-day:disabled { color: var(--text-3); opacity: .35; cursor: default; }
.rangecal-day.is-muted { color: var(--text-3); opacity: .55; }
.rangecal-day.is-today { box-shadow: inset 0 0 0 1.5px var(--line-strong); font-weight: 700; }

/* The chosen From date, To date, and full range remain clearly coloured. */
.rangecal-day.is-in-range {
    background: var(--brand-soft);
    color: var(--brand); font-weight: 700;
    border-radius: 0;
}
.rangecal-day.is-start,
.rangecal-day.is-end {
    position: relative; z-index: 1;
    background: var(--brand); color: var(--text-on-brand);
    font-weight: 800; opacity: 1;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .12);
}
.rangecal-day.is-start { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.rangecal-day.is-end { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.rangecal-day.is-start.is-end { border-radius: var(--r-sm); }
.rangecal-day.is-muted.is-start,
.rangecal-day.is-muted.is-end,
.rangecal-day.is-muted.is-in-range { opacity: 1; }

.rangecal-foot {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line);
}
.rangecal-readout {
    flex: 1 1 auto; font-family: var(--mono); font-size: var(--t-sm);
    font-weight: 700; color: var(--text-2);
}
.rangecal-readout.is-picking { color: var(--brand); }

@media (max-width: 860px) {
    .rangecal {
        inset: auto 10px 10px 10px;
        width: auto; max-width: none;
        max-height: calc(100dvh - 20px) !important;
        border-radius: var(--r-lg);
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }
    .rangecal-months { display: block; }
    .rangecal-month { width: 100%; }
    .rangecal-foot .btn { flex: 1 1 auto; }
}

@media (max-width: 480px) {
    .rangecal { inset: auto 6px 6px 6px; padding: 12px; }
    .rangecal-day { height: 36px; font-size: 13px; }
    .rangecal-foot { gap: 8px; margin-top: 10px; padding-top: 10px; }
    .rangecal-readout { flex-basis: 100%; line-height: 1.5; }
}

/* Phase 1 — current-console-only administration -------------------------- */
.quotation-results {
    max-height: 300px; overflow: auto; border: 1px solid var(--line);
    border-radius: var(--r-md); background: var(--surface);
}
.quotation-result {
    width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent;
    color: var(--text); padding: 11px 13px; display: flex; align-items: center;
    justify-content: space-between; gap: 12px; text-align: left; cursor: pointer;
}
.quotation-result:last-child { border-bottom: 0; }
.quotation-result:hover { background: var(--surface-2); }
.quotation-result strong { display: block; }
.quotation-result .small { white-space: nowrap; }
.summary-lines { display: grid; gap: 8px; }
.summary-lines > div { display: flex; justify-content: space-between; gap: 18px; }
.summary-lines .total { padding-top: 10px; border-top: 1px solid var(--line); font-size: var(--t-lg); }
.template-preview { display: block; max-width: 52ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sms-status { margin-bottom: 16px; }
.sms-key-list { display: grid; gap: 10px; }
.sms-key-row {
    display: grid; grid-template-columns: minmax(180px, .8fr) minmax(220px, 1.5fr) auto;
    gap: 10px; align-items: end; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-md);
}
.sms-actions { margin-top: 14px; justify-content: space-between; }
.role-editor .permission-grid, .permission-grid {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
    max-height: min(52vh, 460px); overflow: auto; padding: 2px;
}
.permission-check { padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.permission-check span { text-transform: capitalize; }
.menu-manager-name { padding-left: calc(var(--menu-depth, 0) * 22px); display: flex; align-items: center; gap: 9px; }
.menu-tree-mark { color: var(--text-3); }
.menu-manager-table [data-move="up"] svg { transform: rotate(-90deg); }
.menu-manager-table [data-move="down"] svg { transform: rotate(90deg); }
.register-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.register-grid > div { padding: 13px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.register-grid span { display: block; color: var(--text-3); font-size: var(--t-xs); margin-bottom: 5px; }
.register-grid strong { display: block; font-family: var(--mono); font-size: var(--t-md); }

@media (max-width: 760px) {
    .sms-key-row { grid-template-columns: 1fr auto; }
    .sms-key-row .field:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
    .sms-key-row .icon-btn { grid-column: 2; grid-row: 1; }
    .role-editor .permission-grid, .permission-grid { grid-template-columns: 1fr; }
    .register-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 440px) {
    .register-grid { grid-template-columns: 1fr; }
}

/* Product create: optional variation details ------------------------------ */
.product-create {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.product-form-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
}
.product-form-card > .eyebrow { margin-bottom: 14px; }
.product-variation-toggle-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}
.product-variation-toggle-card .field-hint { margin: 0; text-align: right; }
.product-variation-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 14px;
}
.product-variation-head p { margin: 5px 0 0; }
.product-variation-select {
    flex: 0 1 320px;
    margin: 0;
}
.product-variation-message {
    padding: 11px 13px;
    margin: 0 0 12px;
    border: 1px solid color-mix(in srgb, var(--neg) 35%, var(--line));
    border-radius: var(--r-sm);
    background: var(--neg-soft);
    color: var(--neg);
    font-size: var(--t-sm);
    font-weight: 600;
}
.product-variation-table { min-width: 940px; }
.product-variation-table th { white-space: nowrap; }
.product-variation-table td { padding: 10px 8px; }
.product-variation-table th:first-child,
.product-variation-table td:first-child { width: 56px; text-align: center; }
.product-variation-table th:nth-child(2),
.product-variation-table td:nth-child(2) { min-width: 135px; }
.product-variation-table input[type="text"],
.product-variation-table input[type="number"] {
    min-width: 118px;
    min-height: 40px;
    padding: 7px 9px;
    font-size: var(--t-sm);
}
.product-variation-table input[type="checkbox"] {
    width: 19px;
    height: 19px;
    min-height: 0;
    accent-color: var(--brand);
}
.product-variation-table input.has-error {
    border-color: var(--neg);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--neg) 14%, transparent);
}
.product-variation-table tr.is-disabled { opacity: .55; }

@media (max-width: 860px) {
    .product-form-card { padding: 16px; }
    .product-variation-toggle-card,
    .product-variation-head {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }
    .product-variation-toggle-card .field-hint { text-align: left; }
    .product-variation-select { flex-basis: auto; width: 100%; }
    .product-variation-table-wrap { overflow: visible; }
    .product-variation-table { min-width: 0; }
    .product-variation-table thead { display: none; }
    .product-variation-table tbody { display: grid; gap: 12px; }
    .product-variation-table tbody tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px 12px;
        padding: 14px;
        border: 1px solid var(--line);
        border-radius: var(--r);
        background: var(--surface-2);
    }
    .product-variation-table tbody td {
        display: block;
        padding: 0;
        border: 0;
        min-width: 0 !important;
        text-align: left !important;
    }
    .product-variation-table tbody td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 5px;
        color: var(--text-3);
        font-size: var(--t-xs);
        font-weight: 700;
        letter-spacing: .08em;
        text-transform: uppercase;
    }
    .product-variation-table tbody td:first-child,
    .product-variation-table tbody td:nth-child(2),
    .product-variation-table tbody td:nth-child(3) {
        grid-column: span 2;
    }
    .product-variation-table input[type="text"],
    .product-variation-table input[type="number"] {
        width: 100%;
        min-width: 0;
    }
}
