/* ══════════════════════════════════════════════════════════════════════
   Global form design system
   ══════════════════════════════════════════════════════════════════════

   One system for every form in the CRM — create, edit, filter, search,
   settings, profile, modal. Before this, 144 blade files carried forms and
   each page brought its own sizing: 48px inputs next to 34px ones, four
   different border greys, three focus colours, labels from 12px to 18px.

   Two ways in, deliberately:

     1. The Bootstrap primitives every page already uses — .form-control,
        .form-select, .form-label, .form-group, .btn. Restyling those means
        ~105 of the 144 files pick this up without a line of markup changing.

     2. The .f-* classes below, for forms laid out properly with the grid.

   Selectors carry an element name (input.form-control rather than bare
   .form-control) purely to win against a page's own <style> block, which
   sits later in the document. Anything genuinely more specific still wins,
   so a screen with a real reason to differ is not fought.

   Tokens come from leads-panel.css; the fallbacks let this sheet stand alone.
   ══════════════════════════════════════════════════════════════════════ */

:root {
    /* ── Softmark CRM theme ──────────────────────────────────────
       The product's palette, in one place. Everything below reads
       these, so re-skinning the app is a change to this block. */
    --f-ink:         #1b1d2b;   /* headings and body            */
    --f-ink-2:       #5a5f76;   /* secondary text, descriptions */
    --f-ink-3:       #9297ab;   /* placeholders, hints          */
    --f-line:        #e6e8f0;   /* card and control borders     */
    --f-page:        #f5f6fb;   /* page background              */
    --f-fill:        #fbfbfe;   /* control fill                 */

    --f-violet:      var(--accent);   /* primary action, focus, checked */
    --f-switch-on:   #0b76d1;   /* toggle "on" — blue, not violet */
    --f-violet-dk:   var(--accent-d);
    --f-orange:      #ff7a45;   /* brand mark, required marker    */
    --f-orange-lt:   #ffb088;

    --f-navy:        #14152b;   /* sidebar                        */
    --f-navy-hov:    #1c1d3a;
    --f-navy-act:    #23244a;

    --f-border:      var(--f-line);
    --f-border-hov:  #d4d7e6;
    --f-text:        var(--f-ink);
    --f-muted:       var(--f-ink-2);
    --f-subtle:      var(--f-ink-3);
    --f-primary:     var(--f-violet);
    --f-primary-dk:  var(--f-violet-dk);
    --f-red:         #e5484d;
    --f-green:       #30a46c;
    --f-bg:          var(--f-fill);

    /* One control height for the whole app. 36px is the dense-dashboard
       size — what Linear and Stripe use in settings — and it is what lets a
       three-section form finish inside one screen. Below this a control
       starts to feel fiddly to hit, so it does not go smaller. */
    --f-height:      36px;
    --f-radius:      9px;   /* controls; cards use 12px */
    --f-gap-x:       16px;   /* between columns            */
    --f-gap-y:       16px;   /* between rows               */
    --f-label-gap:   6px;    /* label to its control       */
    --f-section-gap: 22px;   /* between sections           */
    --f-font:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* ── Weight scale ───────────────────────────────────────────
       Three steps, and the top one is 600 — not 700.

       Inter is a sturdy face: at 700 a 15px heading reads as shouting,
       and the app was using 700 for panel titles, table headers and KPI
       numbers all at once, so nothing stood out because everything was
       heavy. 600 for the heaviest thing on a screen, 500 for emphasis
       and labels, 400 for prose is enough hierarchy — the contrast comes
       from size and colour, which cost the eye less than weight.

       Every sheet reads these, so the whole app's typography is this
       block. Literal fallbacks let the component sheets stand alone. */
    --f-w-bold:   600;   /* page + panel titles, totals, KPI figures */
    --f-w-semi:   500;   /* labels, buttons, emphasis, table headers */
    --f-w-normal: 400;   /* body                                     */
}


/* ══ 0. TYPOGRAPHY ══════════════════════════════════════════════════ */

/*
   Grayscale antialiasing, app-wide.

   This is the single biggest reason the CRM read as "too bold" on a Mac.
   Chrome's default on macOS is subpixel antialiasing, which lays colour
   fringes along every stem and visually fattens the glyph — Inter at 400
   comes out looking like 500, and 600 looks like 700. Switching to
   grayscale renders the weight that was actually asked for. It changes
   nothing on Windows or Linux, where this is already the behaviour.
*/
html, body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/*
   <strong> is emphasis, not a heading.

   The browser default is 700, and the app leans on <strong> for ordinary
   emphasis — a product name in a list, a figure in a summary row. Against
   400 body text, 500 is already clearly emphasised; 700 next to 400 is
   the jump that made list rows look like headings. Anything that needs
   real weight asks for it by class.
*/
strong, b { font-weight: var(--f-w-semi, 500); }

/*
   Bootstrap's and AdminLTE's bold utilities, brought onto the same scale.

   They ship as `font-weight: 700 !important`, so a single class on a span
   re-opens exactly the gap this section closes — and AdminLTE's own widgets
   use them internally, where the markup is not ours to edit. Matching their
   !important is the only way to own the weight scale; a page with a real
   reason to go heavier can still say so with a more specific selector.
*/
.font-weight-bold, .fw-bold,
.font-weight-bolder, .fw-bolder { font-weight: var(--f-w-bold, 600) !important; }
.font-weight-normal, .fw-normal { font-weight: var(--f-w-normal, 400) !important; }


/* ══ 1. CONTAINER ═══════════════════════════════════════════════════ */

.f-form { font-family: var(--f-font); color: var(--f-text); }
.f-form *, .f-form *::before, .f-form *::after { box-sizing: border-box; }

/* Card. Subtle border, small radius, barely-there shadow — the form should
   read as part of the page, not as a box dropped on top of it. */
.f-card {
    background: #fff;
    border: 1px solid var(--f-border);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.f-card + .f-card { margin-top: 16px; }
.f-card-body { padding: 20px 22px 22px; }

/* Forms are read left to right across a line; past ~1200px that line gets
   tiring, so the content stops there and the dashboard keeps the rest. */
.f-form--narrow { max-width: 760px; }
.f-form--wide   { max-width: 1200px; }


/* ══ 2. SECTIONS ════════════════════════════════════════════════════ */

.f-section + .f-section { margin-top: var(--f-section-gap); }

.f-section-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--f-border);
}
.f-section-title {
    margin: 0;
    font-size: 15px;
    font-weight: var(--f-w-bold, 600);
    letter-spacing: -0.01em;
    color: var(--f-text);
}
.f-section-hint { font-size: 12.5px; color: var(--f-muted); }


/* ══ 3. GRID ════════════════════════════════════════════════════════

   12 columns. A field says how much of the row it wants; the breakpoints
   below collapse 3-up to 2-up to 1-up so nothing is ever squeezed thin. */

.f-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--f-gap-y) var(--f-gap-x);
    align-items: start;
}

.f-col-4    { grid-column: span 3; }   /* four across   */
.f-col-3    { grid-column: span 4; }   /* three across  */
.f-col-2    { grid-column: span 6; }   /* two across    */
.f-col-full { grid-column: 1 / -1; }   /* address, notes, description */

@media (max-width: 1399px) {
    .f-col-4 { grid-column: span 4; }             /* 4-up becomes 3-up */
}
@media (max-width: 1199px) {
    .f-col-4, .f-col-3 { grid-column: span 6; }   /* then 2-up */
}
@media (max-width: 767px) {
    .f-col-4, .f-col-3, .f-col-2 { grid-column: 1 / -1; }
    .f-grid { gap: 14px; }
}


/* ══ 4. FIELD + LABEL ═══════════════════════════════════════════════ */

.f-field { display: flex; flex-direction: column; min-width: 0; }

/*
   :not() matters here. .f-segment-opt, .f-check and .f-drop are all <label>
   elements too, and this rule — being one class plus an element — was
   winning against their own single-class rules. That turned the Yes/No
   control into a full-width block with its dots collapsed, and would have
   done the same to the upload zone.

   .f-as-control is the general form of those three exclusions: a label that
   *is* the control rather than the caption above one. It was added because
   this rule was silently breaking the invoice-theme switches — at four
   classes and a type it outranks .it-toggle's own `display: flex` by a mile,
   so every .it-switch inside one stopped being a flex item, and width and
   height do not apply to an inline non-replaced box. The switches rendered
   0x0: present in the DOM, invisible on the page. Put the class on any label
   that carries its own layout, and this rule will leave it alone.
*/
.f-label,
.f-form label:not(.f-segment-opt):not(.f-check):not(.f-drop):not(.f-as-control),
label.form-label,
.form-group > label {
    display: block;
    margin-bottom: var(--f-label-gap);
    font-family: var(--f-font);
    font-size: 12.5px;
    font-weight: var(--f-w-semi, 500);
    line-height: 1.3;
    color: var(--f-muted);
    /* A long label wraps instead of pushing its column wider. */
    overflow-wrap: anywhere;
}

/* Subtle, not shouting. */
.f-label .req,
.f-req,
.f-label--req::after { color: var(--f-orange); font-weight: var(--f-w-semi, 500); }
.f-label--req::after { content: ' *'; }


/* ══ 5. CONTROLS ════════════════════════════════════════════════════ */

.f-input, .f-select, .f-textarea,
input.form-control,
select.form-control,
select.form-select,
textarea.form-control,
.f-form input[type="text"],
.f-form input[type="number"],
.f-form input[type="email"],
.f-form input[type="tel"],
.f-form input[type="url"],
.f-form input[type="password"],
.f-form input[type="date"],
.f-form input[type="time"],
.f-form input[type="datetime-local"],
.f-form input[type="search"],
.f-form select,
.f-form textarea {
    width: 100%;
    height: var(--f-height);
    padding: 0 12px;
    border: 1.5px solid var(--f-border);
    border-radius: var(--f-radius);
    background-color: var(--f-fill);
    font-family: var(--f-font);
    font-size: 14px;
    line-height: 1.4;
    color: var(--f-text);
    box-shadow: none;
    transition: border-color .12s ease, box-shadow .12s ease, background-color .12s ease;
}

/* Height is a line-height trick on inputs; a textarea needs real box sizing. */
.f-textarea,
textarea.form-control,
.f-form textarea {
    height: auto;
    min-height: 76px;
    padding: 9px 12px;
    resize: vertical;
}
.f-textarea--tall,
textarea.form-control.f-textarea--tall { min-height: 128px; }

/*
   For the short free-text fields — an address, a one-line note. Two lines
   visible, and `resize: vertical` above means anyone with a longer address
   can drag it open. The default 76px was reserving a third line that most
   of these never use, which pushed the panel below it down the page.
*/
/* 60px, not 56: box-sizing is border-box here, so the height has to carry
   3px of border and 18px of padding on top of the text. 60 leaves exactly
   two 19.6px lines; 56 clipped the second one. */
.f-textarea--sm,
textarea.form-control.f-textarea--sm { min-height: 60px; }

::placeholder { color: var(--f-subtle); opacity: 1; }


/* ── States ─────────────────────────────────────────────────────── */

.f-input:hover, .f-select:hover, .f-textarea:hover,
input.form-control:hover, select.form-select:hover, textarea.form-control:hover {
    border-color: var(--f-border-hov);
}

/* Restrained: a 3px ring at 12% rather than a bright glow. */
.f-input:focus, .f-select:focus, .f-textarea:focus,
input.form-control:focus,
select.form-control:focus,
select.form-select:focus,
textarea.form-control:focus,
.f-form input:focus, .f-form select:focus, .f-form textarea:focus {
    border-color: var(--f-primary);
    box-shadow: 0 0 0 3px rgba(109, 95, 253, .16);
    outline: none;
}

.f-input:disabled, .f-select:disabled, .f-textarea:disabled,
input.form-control:disabled, select.form-select:disabled, textarea.form-control:disabled,
input.form-control[readonly], textarea.form-control[readonly] {
    background-color: var(--f-bg);
    color: var(--f-muted);
    cursor: not-allowed;
    border-color: var(--f-border);
}

.f-field.is-error .f-input,
.f-field.is-error .f-select,
.f-field.is-error .f-textarea,
input.form-control.is-invalid, input.form-control.is-error,
select.form-select.is-invalid,
textarea.form-control.is-invalid { border-color: var(--f-red); }

.f-field.is-error .f-input:focus,
input.form-control.is-invalid:focus,
select.form-select.is-invalid:focus,
textarea.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, .12);
}

.f-field.is-success .f-input,
input.form-control.is-valid { border-color: var(--f-green); }


/* ── Select chevron ─────────────────────────────────────────────── */

.f-select,
select.form-select,
select.form-control,
.f-form select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2364748b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    /* Centred against the control's own height, whatever that height is. */
    background-position: right 12px center;
    background-size: 12px 8px;
}

/* Number spinners are noise on money and quantity fields. */
.f-form input[type="number"]::-webkit-outer-spin-button,
.f-form input[type="number"]::-webkit-inner-spin-button,
input.form-control[type="number"]::-webkit-outer-spin-button,
input.form-control[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none; margin: 0;
}
.f-form input[type="number"] { -moz-appearance: textfield; }


/* ── Input with a leading unit or icon (₹, %, search) ───────────── */

.f-input-group { display: flex; align-items: stretch; }
.f-input-group > .f-addon {
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--f-border);
    background: var(--f-bg);
    color: var(--f-muted);
    font-size: 13.5px;
    white-space: nowrap;
}
.f-input-group > .f-addon:first-child {
    border-right: 0;
    border-radius: var(--f-radius) 0 0 var(--f-radius);
}
.f-input-group > .f-addon:last-child {
    border-left: 0;
    border-radius: 0 var(--f-radius) var(--f-radius) 0;
}
.f-input-group > .f-input:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.f-input-group > .f-input:not(:last-child)  { border-top-right-radius: 0; border-bottom-right-radius: 0; }
/* The ring belongs to the whole group, not the bare input inside it. */
.f-input-group:focus-within > .f-addon { border-color: var(--f-primary); }


/* ══ 6. CHECKBOX / RADIO ════════════════════════════════════════════ */

.f-check,
label.f-check {
    display: inline-flex;
    align-items: center;      /* box and its words on one baseline */
    gap: 8px;
    min-height: var(--f-height);
    font-size: 13.5px;
    color: var(--f-text);
    cursor: pointer;
}
.f-check input[type="checkbox"],
.f-check input[type="radio"],
.f-form input[type="checkbox"],
.f-form input[type="radio"] {
    width: 16px;
    height: 16px;
    margin: 0;
    flex: 0 0 auto;
    accent-color: var(--f-primary);
    cursor: pointer;
}
.f-check--stack { min-height: 0; align-items: flex-start; }
.f-check--stack input { margin-top: 2px; }


/* ══ 7. HELPER / ERROR TEXT ═════════════════════════════════════════ */

.f-help, .f-error, .f-success {
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.45;
}
.f-help    { color: var(--f-muted); }
.f-error,
.f-form .invalid-feedback,
.f-form .text-danger { color: var(--f-red); }
.f-success { color: var(--f-green); }

/* Reserving no space keeps the grid still until a message actually appears,
   and because each field is its own flex column the row does not jump. */
.f-error:empty, .f-help:empty { display: none; }


/* ══ 8. BUTTONS ═════════════════════════════════════════════════════ */

.f-btn,
.f-form .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: var(--f-height);
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--f-radius);
    font-family: var(--f-font);
    font-size: 13.5px;
    font-weight: var(--f-w-semi, 500);
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.f-btn i, .f-form .btn i { font-size: .95em; }

.f-btn--primary,
.f-form .btn-primary {
    background: var(--f-primary);
    border-color: var(--f-primary);
    color: #fff;
}
.f-btn--primary:hover,
.f-form .btn-primary:hover { background: var(--f-primary-dk); border-color: var(--f-primary-dk); color: #fff; }

.f-btn--ghost,
.f-form .btn-secondary,
.f-form .btn-light,
.f-form .btn-outline-secondary {
    background: #fff;
    border-color: var(--f-border);
    color: var(--f-text);
}
.f-btn--ghost:hover,
.f-form .btn-secondary:hover,
.f-form .btn-light:hover,
.f-form .btn-outline-secondary:hover { background: var(--f-bg); color: var(--f-text); }

.f-btn--danger, .f-form .btn-danger { background: var(--f-red); border-color: var(--f-red); color: #fff; }
.f-btn--sm { height: 32px; padding: 0 11px; font-size: 12.5px; }

.f-btn:disabled, .f-form .btn:disabled, .f-btn.is-busy { opacity: .6; cursor: default; }


/* ══ 9. FORM ACTIONS ════════════════════════════════════════════════ */

/* Primary on the right, where the eye finishes the form. */
.f-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: var(--f-section-gap);
    padding-top: 16px;
    border-top: 1px solid var(--f-border);
}
.f-actions--start { justify-content: flex-start; }
.f-actions-left { margin-right: auto; }   /* Delete, and other left-hand actions */

@media (max-width: 575px) {
    .f-actions { flex-direction: column-reverse; align-items: stretch; }
    .f-actions .f-btn, .f-actions .btn { width: 100%; }
}


/* ══ 10. BOOTSTRAP BRIDGE ═══════════════════════════════════════════

   The pages that never opted in still use .form-group and Bootstrap rows.
   Giving those the same rhythm is what stops the app looking like two
   different products depending on which screen you are on. */

.form-group { margin-bottom: var(--f-gap-y); }
.form-group:last-child { margin-bottom: 0; }


/* ══ 11. LEGACY NAMESPACES ══════════════════════════════════════════

   Twenty-six screens style their own controls in a page <style> block, each
   under its own prefix — customer-*, bs-*, inventory-*, lp-input. Those
   blocks sit later in the document than this file, so plain class selectors
   would lose to them.

   Qualifying by element (input.customer-input rather than .customer-input)
   adds an element to the specificity and wins, while still leaving anything
   genuinely more specific free to override. No page markup has to change,
   and no page has to be rewritten to join the system.

   These pages keep their own layout; only the control sizing, typography,
   borders and focus are brought into line. */

label.customer-label,
label.bs-label,
.inventory-field > label,
.inventory-full > label {
    margin-bottom: var(--f-label-gap);
    font-family: var(--f-font);
    font-size: 13px;
    font-weight: var(--f-w-semi, 500);
    line-height: 1.35;
    color: var(--f-muted);
}

input.customer-input,
select.customer-select,
input.bs-input,
select.bs-select,
input.inventory-input,
.inventory-field input[type="text"],
.inventory-field input[type="number"],
.inventory-field input[type="date"],
.inventory-field select,
input.lp-input,
select.lp-input {
    height: var(--f-height);
    padding: 0 12px;
    border: 1px solid var(--f-border);
    border-radius: var(--f-radius);
    font-family: var(--f-font);
    font-size: 14px;
    color: var(--f-text);
    background-color: #fff;
    box-shadow: none;
    transition: border-color .12s ease, box-shadow .12s ease;
}

textarea.customer-textarea,
textarea.bs-input,
textarea.inventory-textarea,
textarea.lp-input {
    min-height: 96px;
    height: auto;
    padding: 10px 12px;
    border: 1px solid var(--f-border);
    border-radius: var(--f-radius);
    font-family: var(--f-font);
    font-size: 14px;
    color: var(--f-text);
    resize: vertical;
}

input.customer-input:hover,
select.customer-select:hover,
input.bs-input:hover,
input.inventory-input:hover,
input.lp-input:hover { border-color: var(--f-border-hov); }

input.customer-input:focus,
select.customer-select:focus,
textarea.customer-textarea:focus,
input.bs-input:focus,
select.bs-select:focus,
textarea.bs-input:focus,
input.inventory-input:focus,
.inventory-field input:focus,
.inventory-field select:focus,
input.lp-input:focus,
select.lp-input:focus,
textarea.lp-input:focus {
    border-color: var(--f-primary);
    box-shadow: 0 0 0 3px rgba(109, 95, 253, .16);
    outline: none;
}

/* Section headings and card padding on those pages are billing.css's, which
   is loaded on exactly the screens that have them. Only the form controls
   are the bridge's business. */

/* The row gap these pages set by hand, made to match the system. */
.customer-row { margin-bottom: var(--f-gap-y); }

/* .inventory-radio-box and .inventory-modal-footer used to be bridged here
   too. inventory-modal.css owns them properly now — it is loaded wherever
   that modal is — and two files styling one class is exactly the drift this
   bridge exists to end. */
.customer-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    color: var(--f-text);
}

.customer-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--f-border);
}


/* ══ 12. SETTINGS PAGE SHELL ════════════════════════════════════════

   The layout the settings screens share: a sticky bar carrying the title and
   the Cancel/Save pair, and a reading column under it. 880px is the width a
   two-column form stays comfortable at — past that the eye has to travel too
   far from a label on the left to its field on the right. */

.f-page { background: var(--f-page); min-height: 100vh; }

.f-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 9px 20px;
    border-bottom: 1px solid var(--f-line);
    /* Translucent so the cards scroll under it rather than vanishing at a
       hard edge; the fallback colour covers browsers without backdrop-filter. */
    background: rgba(245, 246, 251, .82);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}
.f-topbar-title { margin: 0; font-size: 17px; font-weight: var(--f-w-bold, 600); color: var(--f-ink); }
.f-topbar-sub   { margin: 2px 0 0; font-size: 13px; color: var(--f-ink-2); }
.f-topbar-actions { display: flex; align-items: center; gap: 10px; }

/* Full width: the dashboard already gives the form a sidebar's worth of
   margin on the left, and a capped column left a band of empty page on the
   right at every size above a laptop. */
.f-column { width: 100%; padding: 18px 24px 36px; }

/* Card with a heading and a one-line description, per section. */
.f-panel {
    background: #fff;
    border: 1px solid var(--f-line);
    border-radius: 12px;
    padding: 18px 20px 20px;
}
.f-panel + .f-panel { margin-top: 14px; }

/*
   Panels laid across the page rather than stacked.

   Once the form went full width the sections were still a single tall
   column, so the page scrolled while two thirds of the screen sat empty.
   Laid out on the same 12-column grid the fields use, a three-section
   settings form finishes inside one screen on a laptop.
*/
.f-panels {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
}
.f-panels > .f-panel { margin-top: 0; }
.f-panels > .f-panel + .f-panel { margin-top: 0; }

@media (max-width: 1099px) {
    /* Two panels side by side stop being readable before the fields do. */
    .f-panels > .f-panel { grid-column: 1 / -1 !important; }
}
.f-panel-head { margin-bottom: 15px; }
.f-panel-title { margin: 0; font-size: 15px; font-weight: var(--f-w-bold, 600); color: var(--f-ink); }
.f-panel-desc  { margin: 3px 0 0; font-size: 12.5px; color: var(--f-ink-2); }


/* ══ 13. SEGMENTED CONTROL (Yes / No) ═══════════════════════════════

   Two buttons joined into one control, so the pair reads as a single
   either/or rather than two unrelated boxes. The native radio stays in the
   markup and keeps its name and value — only the presentation changes. */

.f-segment {
    /* align-self, because .f-field is a flex column and would otherwise
       stretch this to the full width of the column. */
    align-self: flex-start;
    display: inline-flex;
    border: 1.5px solid var(--f-line);
    border-radius: var(--f-radius);
    overflow: hidden;
    background: #fff;
}
.f-segment-opt,
label.f-segment-opt {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 0 18px;
    height: var(--f-height);
    font-size: 13.5px;
    font-weight: var(--f-w-semi, 500);
    color: var(--f-ink-2);
    cursor: pointer;
    margin: 0;
    transition: background-color .15s ease, color .15s ease;
}
.f-segment-opt + .f-segment-opt { border-left: 1.5px solid var(--f-line); }
.f-segment-opt input { position: absolute; opacity: 0; pointer-events: none; }

/* The dot is drawn, not a styled native radio, so it looks the same
   everywhere. */
.f-segment-dot {
    width: 15px; height: 15px;
    border: 1.5px solid var(--f-border-hov);
    border-radius: 50%;
    position: relative;
    flex: 0 0 auto;
    transition: border-color .15s ease;
}
.f-segment-opt:has(input:checked) { background: rgba(109, 95, 253, .09); color: var(--f-violet); }
.f-segment-opt:has(input:checked) .f-segment-dot { border-color: var(--f-violet); }
.f-segment-opt:has(input:checked) .f-segment-dot::after {
    content: '';
    position: absolute;
    inset: 2.5px;
    border-radius: 50%;
    background: var(--f-violet);
}
.f-segment-opt:has(input:focus-visible) { box-shadow: inset 0 0 0 2px rgba(109, 95, 253, .35); }


/* ══ 14. CONDITIONAL REVEAL ═════════════════════════════════════════

   Opens and closes rather than appearing from nowhere, so it is obvious the
   field belongs to the choice just made. max-height is animatable where
   height:auto is not; the value only has to be larger than the content. */

.f-reveal {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height .25s ease, opacity .2s ease, margin-top .25s ease;
    margin-top: 0;
}
.f-reveal.is-open { max-height: 320px; opacity: 1; margin-top: 16px; }

/*
   Plain show/hide for a grid cell.

   .f-reveal above animates max-height, which is right for a block that
   slides open but wrong for a cell inside .f-grid: a max-height on a grid
   item fights the row sizing, and its margin-top pushes the whole row out
   of alignment. A field that is simply not applicable takes this instead.
*/
.f-field.is-hidden { display: none; }


/* ══ 15. UPLOAD DROPZONE ════════════════════════════════════════════ */

.f-drop,
label.f-drop {
    /* 180px squared was taller than the three fields beside it, so the
       logo read as the main event on a page about company details. */
    width: 96px;
    height: 96px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px;
    border: 1.5px dashed var(--f-border-hov);
    border-radius: 12px;
    background: var(--f-fill);
    color: var(--f-ink-2);
    text-align: center;
    cursor: pointer;
    overflow: hidden;
    transition: border-color .15s ease, background-color .15s ease;
}
.f-drop:hover { border-color: var(--f-violet); background: rgba(109, 95, 253, .04); }
.f-drop-icon  { font-size: 19px; color: var(--f-ink-3); }
.f-drop-label { font-size: 12px; font-weight: var(--f-w-semi, 500); color: var(--f-ink); }
.f-drop-hint  { font-size: 10.5px; color: var(--f-ink-3); line-height: 1.3; }
/* The preview fills the zone once a file is chosen. */
.f-drop img   { width: 100%; height: 100%; object-fit: contain; }


/* ══ 16. TOAST ══════════════════════════════════════════════════════ */

.f-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 3000;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 11px 18px;
    border-radius: 10px;
    background: var(--f-navy);
    color: #fff;
    font-size: 13.5px;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(20, 21, 43, .3);
    /* Parked below the fold and lifted in, so it arrives from the edge
       rather than blinking into the middle of the screen. */
    transform: translate(-50%, 20px);
    opacity: 0;
    pointer-events: none;
    transition: transform .22s ease, opacity .22s ease;
}
.f-toast.is-shown { transform: translate(-50%, 0); opacity: 1; }
.f-toast i { color: var(--f-orange-lt); }


/* ── Settings shell on small screens ────────────────────────────── */

@media (max-width: 720px) {
    .f-topbar { padding: 12px 16px; }
    .f-topbar-actions { width: 100%; }
    .f-topbar-actions .f-btn { flex: 1 1 0; }
    .f-column { padding: 16px 14px 44px; }
    .f-panel  { padding: 16px; }
    /* Logo stacks above the fields and centres, rather than sitting in a
       column too narrow to hold it. */
    .f-drop   { margin: 0 auto; }
    .f-segment { width: 100%; }
    .f-segment-opt { flex: 1 1 0; justify-content: center; }
}


/* ══ 17. LIST PAGE ══════════════════════════════════════════════════

   A table page inside the same shell as a settings page: the topbar and
   .f-column above, a panel holding a toolbar and the rows. Lives here so a
   second list screen does not have to invent its own. */

.f-table-wrap { overflow-x: auto; }

.f-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.f-table thead th {
    padding: 10px 16px;
    background: var(--f-fill);
    border-bottom: 1px solid var(--f-line);
    font-size: 11px;
    font-weight: var(--f-w-semi, 500);
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--f-ink-2);
    text-align: left;
    white-space: nowrap;
}
.f-table tbody td {
    padding: 9px 16px;
    border-bottom: 1px solid #f1f2f7;
    color: var(--f-ink);
    vertical-align: middle;
}
.f-table tbody tr:last-child td { border-bottom: 0; }
.f-table tbody tr:hover td      { background: #fafbfe; }
/* Money and counts line up when they share one figure width. */
.f-table td:nth-child(n+4) { font-variant-numeric: tabular-nums; }

/*
   Row actions are an icon, not a form button.

   .f-form .btn gives every button the 36px control height, which is right
   inside a form and wrong in a table cell: with 11px of padding above and
   below it made every row 60px tall, and eight products filled the screen.
   A 28px icon button brings the row back to ~46px.
*/
.f-table td .btn,
.f-table td .dropdown > .btn {
    height: 28px;
    min-height: 0;
    width: 28px;
    padding: 0;
    border: 1px solid var(--f-line);
    background: #fff;
    color: var(--f-ink-2);
    border-radius: var(--f-radius);
}
.f-table td .btn:hover { background: var(--f-fill); color: var(--f-ink); }

/* Row checkboxes sit on the text baseline, not floating above it. */
.f-table td input[type="checkbox"],
.f-table th input[type="checkbox"] { display: block; margin: 0; }

.f-table-empty {
    text-align: center;
    padding: 40px 16px !important;
    color: var(--f-ink-3);
    font-size: 13px;
}
.f-table-empty i { display: block; font-size: 22px; margin-bottom: 8px; }


/* ── Toolbar above a table ──────────────────────────────────────── */

.inv-toolbar {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-bottom: 1px solid var(--f-line);
}
/* The search box takes the room, the buttons keep their size. */
.inv-toolbar .inventory-search-box { flex: 1 1 260px; min-width: 200px; }
.inv-toolbar .f-btn { flex: 0 0 auto; }

.inventory-search-box {
    display: flex;
    align-items: center;
    gap: 9px;
    height: var(--f-height);
    padding: 0 12px;
    border: 1.5px solid var(--f-line);
    border-radius: var(--f-radius);
    background: var(--f-fill);
}
.inventory-search-box:focus-within {
    border-color: var(--f-violet);
    box-shadow: 0 0 0 3px rgba(109, 95, 253, .16);
}
.inventory-search-box > i     { color: var(--f-ink-3); font-size: 12.5px; }
.inventory-search-box input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    font-family: var(--f-font);
    font-size: 14px;
    color: var(--f-ink);
}
#clearInventorySearch { cursor: pointer; color: var(--f-ink-3); font-size: 17px; line-height: 1; }
#clearInventorySearch:hover { color: var(--f-ink); }


/* ── Stat tiles ─────────────────────────────────────────────────── */

.inv-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}
.inv-kpi {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 13px 16px;
    background: #fff;
    border: 1px solid var(--f-line);
    border-radius: 12px;
}
.inv-kpi-label {
    font-size: 11px;
    font-weight: var(--f-w-semi, 500);
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--f-ink-2);
}
.inv-kpi-value {
    font-size: 20px;
    font-weight: var(--f-w-bold, 600);
    color: var(--f-ink);
    font-variant-numeric: tabular-nums;
}



/* ══ 15. BILLING DASHBOARD ══════════════════════════════════════════
   The module's home screen. Everything structural above is reused —
   .f-page, .f-topbar, .f-panels, .f-panel, .inv-kpi, .f-table — so these
   are only the pieces that page genuinely introduces: the sales chart and
   the two ranked lists.                                                */

/* KPI cards: a third line under the figure, and a tint on the two that
   carry a verdict. Money owed to you is good news, money late is not. */
.dash-kpis { margin-bottom: 12px; }
.dash-kpi-foot { font-size: 11.5px; color: var(--f-ink-3); }
.dash-kpi--good { border-color: #bbf7d0; background: #f4fdf7; }
.dash-kpi--good .inv-kpi-value { color: var(--f-green); }
.dash-kpi--bad  { border-color: #fecaca; background: #fff5f5; }
.dash-kpi--bad  .inv-kpi-value { color: var(--f-red); }
.dash-kpis .inv-kpi-label i { margin-right: 5px; opacity: .75; }

/* ── Sales chart ── */
.dash-chart-row {
    display: flex;
    align-items: stretch;
    gap: 20px;
}
.dash-chart { position: relative; flex: 1 1 auto; min-width: 0; }

/* preserveAspectRatio="none" in the markup is what lets a fixed 700x170
   viewBox fill whatever width the panel ends up with, so the chart is
   responsive with no measuring in JS. */
.dash-chart-svg { display: block; width: 100%; height: 170px; }

.dash-grid { stroke: var(--f-line); stroke-width: 1; }
.dash-line { fill: none; stroke: var(--f-violet); stroke-width: 2;
             vector-effect: non-scaling-stroke; }
.dash-dot  { fill: #fff; stroke: var(--f-violet); stroke-width: 2;
             vector-effect: non-scaling-stroke; }
/* vector-effect above matters: without it the non-uniform stretch of the
   viewBox would squash the stroke horizontally and the line would read
   thinner at one end than the other. */

.dash-hit { fill: transparent; cursor: default; }
.dash-hit:hover { fill: rgba(109, 95, 253, .05); }

.dash-axis {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    margin-top: 2px;
}
.dash-axis span {
    text-align: center;
    font-size: 10.5px;
    color: var(--f-ink-3);
}

.dash-tip {
    position: absolute;
    top: 4px;
    transform: translateX(-50%);
    padding: 4px 9px;
    border-radius: 7px;
    background: var(--f-navy);
    color: #fff;
    font-size: 11.5px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 3;
}

/* The three figures beside the chart. */
.dash-chart-side {
    flex: 0 0 150px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
    padding-left: 20px;
    border-left: 1px solid var(--f-line);
    text-align: right;
}
.dash-stat { display: flex; flex-direction: column; gap: 2px; }
.dash-stat-label { font-size: 11.5px; color: var(--f-ink-2); }
.dash-stat-value {
    font-size: 18px;
    font-weight: var(--f-w-bold, 600);
    color: var(--f-ink);
    font-variant-numeric: tabular-nums;
}

@media (max-width: 991px) {
    .dash-chart-row { flex-direction: column; }
    .dash-chart-side {
        flex: 0 0 auto;
        flex-direction: row;
        justify-content: space-between;
        padding: 14px 0 0;
        border-left: 0;
        border-top: 1px solid var(--f-line);
        text-align: left;
    }
}

/* ── Ranked lists (who owes the most, running low) ──
   Name takes the slack and truncates; the figure keeps its own column so
   the numbers line up down the list. */
.dash-rank { list-style: none; margin: 0; padding: 0; }
.dash-rank li {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "name value" "meta value";
    align-items: center;
    gap: 0 12px;
    padding: 9px 0;
    border-bottom: 1px solid #f1f2f7;
}
.dash-rank li:last-child { border-bottom: 0; padding-bottom: 0; }
.dash-rank-name {
    grid-area: name;
    min-width: 0;
    font-size: 13px;
    font-weight: var(--f-w-semi, 500);
    color: var(--f-ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dash-rank-meta  { grid-area: meta; font-size: 11px; color: var(--f-ink-3); }
.dash-rank-value {
    grid-area: value;
    font-size: 13.5px;
    font-weight: var(--f-w-semi, 500);
    color: var(--f-ink);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.dash-due  { color: var(--f-red); }
.dash-paid { color: var(--f-green); font-size: 12.5px; }

.dash-empty {
    margin: 0;
    padding: 14px 0 2px;
    font-size: 12.5px;
    color: var(--f-ink-2);
}
.dash-empty i { color: var(--f-green); margin-right: 5px; }

@media (max-width: 1199px) {
    .f-panels > .f-panel[style*="span 8"],
    .f-panels > .f-panel[style*="span 4"] { grid-column: 1 / -1 !important; }
}


/* ══ 16. INVOICE THEME SETTINGS ═════════════════════════════════════
   The settings screen for the invoice template. Panels, buttons, grid and
   fields all come from the sections above; these are the pieces this screen
   introduces — the template gallery, the swatch row, the switches, and the
   sheet the server-rendered preview is dropped into.                    */

/*
   Stacked, not side by side.

   Two columns left the preview about 580px wide. The invoice it has to draw
   is a ten-column GST document — HSN, qty, rate, discount, taxable, CGST,
   SGST, amount — which needs roughly 750px before the first column gets any
   room at all, so the item names were clipped off the left edge entirely.
   Nothing about the styling could fix that; the panel was simply too narrow
   for the document. Full width, one above the other.
*/
.it-stack { display: block; }
.it-controls > .f-panel + .f-panel,
.it-controls > .it-row3 { margin-top: 10px; }

/*
   Colour, typeface + background, and the switches, side by side.

   Stacked full-width they came to four panels and about two screens, and the
   preview — the one thing being changed — sat below all of it. None of the
   three needs the width, so the whole block finishes in one band and the
   sheet stays in view.
*/
.it-row3 {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, .95fr) minmax(0, .9fr);
    gap: 10px;
    align-items: start;
}
.it-row3 > .f-panel { padding: 12px 13px; }
.it-row3 .f-panel-head { margin-bottom: 8px; }
.it-row3 .f-panel-desc { font-size: 10.5px; line-height: 1.4; }

.it-preview-wrap { margin-top: 10px; }
.it-preview-panel { padding-bottom: 14px; }
.it-spin { color: var(--f-ink-3); font-size: 12px; }

/* The sheet.
   Centred and capped near A4's printable width — past that the columns just
   stretch and the document stops looking like the thing that comes out of
   the printer. The tint behind it is what makes the white read as paper. */
.it-paper {
    border: 1px solid var(--f-line);
    border-radius: 9px;
    background: #eef1f5;
    padding: 18px;
    overflow-x: auto;
}

/*
   The paper chrome lives on its own wrapper, NOT on .inv.

   It used to be `.it-paper > .inv { background: #fff; padding: 22px 24px }`,
   and both halves of that were wrong once themes gained backgrounds:

     - `background` is a shorthand, so it reset the theme's own
       background-image to none, and at two classes it outranked the
       renderer's own `.inv` rule. Every page background and every tinted
       layout came out plain white in the preview while printing correctly —
       so the preview was showing a document the PDF would not produce,
       which is the one thing it exists not to do.

     - the padding was inside .inv, which pushed the full-bleed colour bands
       in off the document edge and left white gutters inside them.

   The sheet is preview chrome; .inv is the document. They are separate
   elements now, so neither can style the other by accident.
*/
.it-sheet,
.it-paper .invoice-page {
    max-width: 860px;
    margin: 0 auto;
    background: #fff;
    padding: 22px 24px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .12), 0 8px 24px rgba(15, 23, 42, .07);
}
.it-loading {
    margin: 0;
    padding: 56px 0;
    text-align: center;
    font-size: 12.5px;
    color: var(--f-ink-2);
}

/* ── Template gallery ── */
.it-gallery {
    display: grid;
    /* auto-fit rather than auto-fill: at full width the six cards spread to
       fill the row instead of leaving a gap where a seventh would go. */
    grid-template-columns: repeat(auto-fit, minmax(122px, 1fr));
    gap: 8px;
}
.it-card {
    display: block;
    margin: 0;
    padding: 6px;
    border: 1.5px solid var(--f-line);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: border-color .14s, box-shadow .14s;
}
.it-card:hover { border-color: var(--f-border-hov); }
.it-card.is-on {
    border-color: var(--f-violet);
    box-shadow: 0 0 0 3px rgba(109, 95, 253, .13);
}
/* The radio is the state; the card is the control. */
.it-card input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }

.it-card-name {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-top: 5px;
    font-size: 11.5px;
    font-weight: var(--f-w-semi, 500);
    color: var(--f-ink);
}
/* Clamped to two lines. The blurbs vary from six words to twenty, and left
   to run they set every card in the row to the height of the longest one. */
.it-card-blurb {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 1px;
    font-size: 9.5px;
    line-height: 1.3;
    color: var(--f-ink-3);
}
.it-tick { color: var(--f-violet); font-size: 12px; opacity: 0; }
.it-card.is-on .it-tick { opacity: 1; }

/* ── Thumbnails ──
   Drawn from the same four bands in every theme; only the weights and the
   ink change. That is exactly what differs between the layouts, so the
   thumbnail cannot claim a difference the template does not have. */
.it-thumb {
    display: block;
    height: 56px;
    padding: 5px;
    border: 1px solid var(--f-line);
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
}
.it-thumb-head, .it-thumb-meta, .it-thumb-rows, .it-thumb-tot { display: block; }
.it-thumb-head { height: 9px; background: #d8dce8; margin-bottom: 4px; }
.it-thumb-meta { height: 4px; background: #eceef6; margin-bottom: 4px; width: 62%; }
.it-thumb-rows {
    height: 19px;
    background:
        repeating-linear-gradient(to bottom, #eceef6 0 1px, transparent 1px 7px);
    border-top: 1.5px solid #b9bfd2;
    margin-bottom: 5px;
}
.it-thumb-tot { height: 5px; width: 44%; margin-left: 56%; background: #b9bfd2; }

.it-thumb--classic_gst .it-thumb-rows { border: 1px solid #b9bfd2; }
.it-thumb--classic_gst .it-thumb-head { background: #1b1d2b; }

.it-thumb--banded .it-thumb-head { height: 16px; background: #0b76d1; margin-bottom: 6px; }
.it-thumb--banded .it-thumb-tot  { background: #0b76d1; }

.it-thumb--minimal .it-thumb-head { background: #eceef6; }
.it-thumb--minimal .it-thumb-rows { border-top-color: #dfe3ee; }
.it-thumb--minimal .it-thumb-meta { width: 40%; }

.it-thumb--boxed .it-thumb-meta {
    width: 100%; height: 13px; background: #fff;
    border: 1px solid #b9bfd2;
}
.it-thumb--boxed .it-thumb-rows { border: 1px solid #b9bfd2; }
.it-thumb--boxed .it-thumb-head { background: #0f7b6c; }

.it-thumb--formal .it-thumb-head { background: #b45309; height: 9px; width: 52%; }
.it-thumb--formal .it-thumb-tot  { border-top: 3px double #b45309; background: transparent; height: 8px; }

/* ── The designed layouts ──
   These four differ from the first five in composition, not just weight, so
   their thumbnails have to as well: a title block, a full-bleed band, a
   footer. The thumbnail is a claim about the template and has to be one the
   document actually honours. */

/* Studio: the wordmark centred over hairlines, closed by a dark band. */
.it-thumb--studio { position: relative; }
.it-thumb--studio .it-thumb-head {
    height: 14px;
    width: 54%;
    margin: 2px auto 6px;
    background: #1b1d2b;
    border-radius: 1px;
}
.it-thumb--studio .it-thumb-meta { width: 74%; margin-left: 13%; background: #e5e7eb; }
.it-thumb--studio .it-thumb-rows { border-top-color: #d4d6dd; }
.it-thumb--studio .it-thumb-tot {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    width: auto; height: 13px;
    margin: 0;
    background: #1b1d2b;
}

/* Boutique: tinted page, logo panel, solid title bar, closing band. */
.it-thumb--boutique { position: relative; background: #f6f8f5; padding-top: 0; }
.it-thumb--boutique .it-thumb-head {
    height: 17px;
    margin: 0 -7px 0;
    background: #dde7d9;
    border-bottom: 6px solid #6f8c6a;
}
.it-thumb--boutique .it-thumb-meta { width: 58%; margin-top: 7px; background: #e3ebe0; }
.it-thumb--boutique .it-thumb-rows {
    height: 20px;
    border-top-color: #c4d3c0;
    background: repeating-linear-gradient(to bottom, #e3ebe0 0 1px, transparent 1px 7px);
}
.it-thumb--boutique .it-thumb-tot {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    width: auto; height: 13px;
    margin: 0;
    background: #6f8c6a;
}

/* Elegant: the solid title block left, letterhead right, dark column bar. */
.it-thumb--elegant .it-thumb-head {
    height: 14px;
    width: 40%;
    margin-bottom: 7px;
    background: #111827;
}
.it-thumb--elegant .it-thumb-meta {
    width: 100%;
    height: 9px;
    background: #111827;
    margin-bottom: 5px;
}
.it-thumb--elegant .it-thumb-rows { border: 1px solid #c3c6cc; }
.it-thumb--elegant .it-thumb-tot { background: #f6dcd8; border-left: 3px solid #111827; }

/* Geometric: bands top and bottom with the second-colour stripe, solid
   total bar. The curve is a border-radius here; the document draws it as an
   SVG, which a 74px thumbnail could not show the shape of anyway. */
.it-thumb--geometric { position: relative; padding-top: 15px; }
.it-thumb--geometric::before,
.it-thumb--geometric::after {
    content: "";
    position: absolute;
    left: 0; right: 0;
    height: 12px;
    background: #16244d;
}
.it-thumb--geometric::before {
    top: 0;
    border-bottom: 3px solid #f2b418;
    border-bottom-left-radius: 40px 9px;
    border-bottom-right-radius: 40px 9px;
}
.it-thumb--geometric::after {
    bottom: 0;
    border-top: 3px solid #f2b418;
    border-top-left-radius: 40px 9px;
    border-top-right-radius: 40px 9px;
}
.it-thumb--geometric .it-thumb-head { height: 9px; width: 46%; background: #16244d; }
.it-thumb--geometric .it-thumb-meta { width: 100%; height: 7px; background: #16244d; }
.it-thumb--geometric .it-thumb-rows {
    height: 15px;
    border-top-color: #b9bfd2;
    margin-bottom: 4px;
}
.it-thumb--geometric .it-thumb-tot { background: #16244d; height: 8px; }

/* ── Colour combinations ──
   A pair of colours per chip, because a combination is two colours and a
   single square could not tell two of them apart. */
.it-sub {
    margin: 11px 0 5px;
    font-size: 11px;
    font-weight: var(--f-w-semi, 500);
    letter-spacing: .4px;
    text-transform: uppercase;
    color: var(--f-ink-3);
}
.it-sub:first-of-type { margin-top: 2px; }

.it-combos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
    gap: 6px;
}
.it-combo {
    display: block;
    padding: 4px;
    border: 1.5px solid var(--f-line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    text-align: left;
}
.it-combo:hover { border-color: var(--f-ink-3); }
.it-combo.is-on {
    border-color: var(--f-violet);
    box-shadow: 0 0 0 3px rgba(109, 95, 253, .18);
}
.it-combo-swatch {
    display: flex;
    height: 16px;
    border-radius: 4px;
    overflow: hidden;
}
/* Two thirds to the accent: it is the colour doing most of the work on the
   page, and an even split read as two equal choices. */
.it-combo-swatch > span:first-child { flex: 2; }
.it-combo-swatch > span:last-child  { flex: 1; }
.it-combo-name {
    display: block;
    margin-top: 3px;
    font-size: 9.5px;
    color: var(--f-ink-2, var(--f-ink));
}

/* ── Typeface ── */
.it-fonts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 6px;
}
.it-font {
    display: block;
    padding: 6px 7px;
    border: 1.5px solid var(--f-line);
    border-radius: 8px;
    cursor: pointer;
}
.it-font:hover { border-color: var(--f-ink-3); }
.it-font input { position: absolute; opacity: 0; pointer-events: none; }
.it-font.is-on {
    border-color: var(--f-violet);
    box-shadow: 0 0 0 3px rgba(109, 95, 253, .18);
}
/* The specimen is set in the face it offers — a font picker that names
   fonts without showing them makes the user save and look. */
.it-font-spec { display: block; font-size: 12.5px; line-height: 1.2; white-space: nowrap; }
.it-font--sans  .it-font-spec { font-family: "DejaVu Sans", Arial, Helvetica, sans-serif; }
.it-font--serif .it-font-spec { font-family: "DejaVu Serif", Georgia, "Times New Roman", serif; }
.it-font--mono  .it-font-spec { font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace; }
.it-font-name {
    display: block;
    margin-top: 2px;
    font-size: 10.5px;
    font-weight: var(--f-w-semi, 500);
    color: var(--f-ink);
}
.it-font-hint {
    display: block;
    margin-top: 1px;
    font-size: 10px;
    line-height: 1.35;
    color: var(--f-ink-3);
}

/* ── Page background ──
   Each chip previews its style in the two chosen colours, which arrive as
   --a and --b on the element. colour-mix keeps them as faint here as the
   generated PNG makes them on the document, so the chip is not promising a
   stronger background than the invoice will get. */
.it-bgs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}
.it-bg { display: block; cursor: pointer; }
.it-bg input { position: absolute; opacity: 0; pointer-events: none; }
.it-bg-chip {
    display: block;
    height: 42px;
    border: 1.5px solid var(--f-line);
    border-radius: 7px;
    background: #fff;
    overflow: hidden;
}
.it-bg:hover .it-bg-chip { border-color: var(--f-ink-3); }
.it-bg.is-on .it-bg-chip {
    border-color: var(--f-violet);
    box-shadow: 0 0 0 3px rgba(109, 95, 253, .18);
}
.it-bg-name {
    display: block;
    margin-top: 3px;
    font-size: 9.5px;
    text-align: center;
    color: var(--f-ink-3);
}
.it-bg.is-on .it-bg-name { color: var(--f-ink); }

/* Soft wash: two radial fades, opposite corners. */
.it-bg--wash .it-bg-chip {
    background:
        radial-gradient(circle at 88% 6%,
            color-mix(in srgb, var(--b) 48%, #fff) 0%, transparent 62%),
        radial-gradient(circle at 8% 96%,
            color-mix(in srgb, var(--a) 18%, #fff) 0%, transparent 58%),
        #fff;
}
/* Corners: angled wedges, top-left and bottom-right. */
.it-bg--corners .it-bg-chip {
    background:
        linear-gradient(135deg,
            color-mix(in srgb, var(--a) 16%, #fff) 0 18%,
            color-mix(in srgb, var(--b) 38%, #fff) 18% 34%,
            transparent 34%),
        linear-gradient(315deg,
            color-mix(in srgb, var(--a) 16%, #fff) 0 18%,
            color-mix(in srgb, var(--b) 38%, #fff) 18% 34%,
            transparent 34%),
        #fff;
}
/* Ribbon: one diagonal band across the top-right. */
.it-bg--ribbon .it-bg-chip {
    background:
        linear-gradient(198deg,
            transparent 0 28%,
            color-mix(in srgb, var(--b) 40%, #fff) 28% 56%,
            transparent 56%),
        #fff;
}

.it-thumb--custom {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--f-violet);
    font-size: 20px;
    background: rgba(109, 95, 253, .05);
    border-style: dashed;
}

/* Two switches to a row inside the narrower column, so five of them plus
   the three blocked ones do not set the height of the whole band. */
.it-row3 .it-toggles,
.it-row3 .it-blocked { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.it-row3 .it-toggle { padding: 4px 0; }
.it-row3 .it-toggle-hint {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Swatches ── */
.it-swatches { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.it-swatch {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1.5px solid rgba(0, 0, 0, .12);
    border-radius: 6px;
    cursor: pointer;
}
.it-swatch.is-on {
    box-shadow: 0 0 0 3px rgba(109, 95, 253, .35);
    border-color: #fff;
}
.it-custom-colour { display: inline-flex; align-items: center; gap: 7px; margin-left: 4px; }
.it-custom-colour input[type="color"] {
    width: 34px;
    height: 28px;
    padding: 0;
    border: 1.5px solid var(--f-line);
    border-radius: 7px;
    background: #fff;
    cursor: pointer;
}
.it-custom-colour .f-help { font-variant-numeric: tabular-nums; text-transform: uppercase; }

/* ── Custom theme fields ── */
.it-custom {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--f-line);
}
.it-custom.is-hidden { display: none; }

/* ── Switches ── */
/* Two columns at width, one when there is not room. The border-bottom
   separators are per-item, so they still read correctly either way. */
.it-toggles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0 22px;
}
.it-toggle {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    padding: 9px 0;
    border-bottom: 1px solid #f1f2f7;
    cursor: pointer;
    font-weight: var(--f-w-normal, 400);
}
.it-toggle:last-child { border-bottom: 0; }
.it-toggle input { position: absolute; opacity: 0; pointer-events: none; }

.it-switch {
    position: relative;
    flex: 0 0 auto;
    width: 34px;
    height: 20px;
    margin-top: 1px;
    border-radius: 20px;
    /* An outline as well as a fill: on the panel's own tinted background the
       flat grey track was very nearly the same value as the paper behind it,
       so an "off" switch read as empty space. */
    border: 1px solid #c2c7da;
    background: #e7e9f2;
    transition: background .16s, border-color .16s;
}
.it-switch::after {
    content: '';
    position: absolute;
    /* 1px each side for the track's border. */
    top: 1px;
    left: 1px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .22);
    transition: transform .16s;
}
/* Blue rather than the product violet, as asked. Named so the switches and
   anything else that wants the same "on" cannot drift apart. */
.it-toggle input:checked + .it-switch { background: var(--f-switch-on); }
.it-toggle input:checked + .it-switch { border-color: var(--f-switch-on); }
.it-toggle input:checked + .it-switch::after { transform: translateX(14px); }

.it-toggle-text { min-width: 0; }
.it-toggle-name {
    display: block;
    font-size: 13px;
    font-weight: var(--f-w-semi, 500);
    color: var(--f-ink);
}
.it-toggle-hint {
    display: block;
    margin-top: 1px;
    font-size: 11px;
    line-height: 1.4;
    color: var(--f-ink-3);
}

/* A switch that cannot be turned on has to look like it, or it reads as a
   bug rather than as work not yet done. */
.it-toggle.is-disabled { cursor: not-allowed; opacity: .62; }
.it-toggle.is-disabled .it-switch { border-color: #dcdfea; background: #eef0f6; }

.it-blocked {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0 22px;
    margin-top: 14px;
    padding: 10px 12px 4px;
    border: 1px dashed var(--f-line);
    border-radius: 9px;
    background: var(--f-fill);
}
.it-blocked-head {
    grid-column: 1 / -1;
    margin: 0 0 2px;
    font-size: 11px;
    font-weight: var(--f-w-semi, 500);
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--f-ink-3);
}
.it-blocked .it-toggle:last-child { border-bottom: 0; }

/* Two steps down, not one. Three columns need about 1100px before the
   swatch rows start wrapping to one swatch per line; below that two columns
   still beat a single stack. */
@media (max-width: 1140px) {
    .it-row3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .it-bgs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
    .it-row3 { grid-template-columns: minmax(0, 1fr); }
    .it-paper { padding: 10px; }
    .it-sheet,
    .it-paper .invoice-page { padding: 14px; }
}
