/*
 * FormYad — design system (same tokens and components as the CRM theme).
 *
 * Structure:
 *   1. Font + design tokens (the only place raw colors/sizes live)
 *   2. Base & typography
 *   3. App shell: topbar, page container, auth shell
 *   4. Components: cards, buttons, forms, tables, badges, tabs, lists,
 *      modals, lightbox, alerts
 *   5. Utilities (also replace the old inline style="" attributes)
 *   6. Page parts: hotspot editor, print preview
 *   7. Kiosk theme (large touch UI) + on-screen keyboard
 *   8. Responsive
 *
 * The legacy class names used by the page scripts (.hidden, .secondary,
 * .small, .tab-btn.active, .badge-active, .profile-item …) are all
 * defined here, so the scripts did not have to change to get the new look.
 * Direction: logical properties only (inline/block, start/end).
 */

@font-face {
    font-family: "Vazirmatn";
    src: url("../fonts/vazirmatn/Vazirmatn-Variable.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

/* ===================================================================
   1. Design tokens
   =================================================================== */
:root {
    --brand-50: #eef3ff;
    --brand-100: #dce6fe;
    --brand-200: #bccffd;
    --brand-500: #4673ee;
    --brand-600: #2f5fd6;
    --brand-700: #2449b0;
    --brand-800: #1c3a8c;

    --gray-0: #ffffff;
    --gray-25: #fbfcfd;
    --gray-50: #f6f7f9;
    --gray-100: #eef0f4;
    --gray-200: #e3e6ec;
    --gray-300: #cdd3dc;
    --gray-400: #98a2b3;
    --gray-500: #667085;
    --gray-600: #475467;
    --gray-700: #344054;
    --gray-800: #1d2939;
    --gray-900: #101828;

    --success-50: #ecfdf3; --success-200: #abefc6; --success-600: #067647; --success-700: #05603a;
    --warning-50: #fffaeb; --warning-200: #fedf89; --warning-600: #b54708; --warning-700: #93370d;
    --danger-50: #fef3f2;  --danger-200: #fecdca;  --danger-600: #d92d20;  --danger-700: #b42318;
    --info-50: #eff8ff;    --info-200: #b2ddff;    --info-600: #1570c7;    --info-700: #175cd3;
    --violet-50: #f4f3ff;  --violet-600: #6938ef;

    --color-bg: var(--gray-50);
    --color-surface: var(--gray-0);
    --color-text: var(--gray-900);
    --color-muted: var(--gray-500);
    --color-border: var(--gray-200);
    --color-border-strong: var(--gray-300);
    --color-focus: rgba(47, 95, 214, 0.35);
    --color-overlay: rgba(16, 24, 40, 0.6);

    --font-sans: "Vazirmatn", "Segoe UI", Tahoma, system-ui, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-base: 0.875rem;
    --text-md: 0.9375rem;
    --text-lg: 1.0625rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --weight-regular: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;
    --leading-tight: 1.3;
    --leading-normal: 1.65;

    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 999px;
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
    --shadow-lg: 0 12px 24px -4px rgba(16, 24, 40, 0.12), 0 4px 8px -4px rgba(16, 24, 40, 0.06);
    --shadow-up: 0 -8px 24px -6px rgba(16, 24, 40, 0.18);

    --control-h: 2.5rem;
    --control-h-sm: 2rem;
    --field-sm: 12rem;
    --field-md: 26rem;
    --field-lg: 40rem;

    --topbar-h: 3.75rem;
    --content-max: 72rem;
    --transition: 150ms ease;

    --gradient-brand: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    --mask-chevron-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

    font-family: var(--font-sans);
    color-scheme: light;
}

/* ===================================================================
   2. Base & typography
   =================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
    color: var(--color-text);
    line-height: var(--leading-tight);
    font-weight: var(--weight-semibold);
    margin: 0 0 var(--space-3);
}
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-md); }
:is(h1, h2, h3) > .i { color: var(--brand-600); margin-inline-end: var(--space-2); }

p { margin: 0 0 var(--space-3); }
p:last-child { margin-bottom: 0; }
b, strong { font-weight: var(--weight-semibold); }

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

img { max-width: 100%; }
::selection { background: var(--brand-100); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; border-radius: 4px; }

/* ===================================================================
   3. App shell
   =================================================================== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--color-border);
}
.topbar__inner {
    max-width: var(--content-max);
    margin: 0 auto;
    min-height: var(--topbar-h);
    padding: var(--space-2) var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--color-text);
    font-weight: var(--weight-bold);
    font-size: var(--text-lg);
}
.brand:hover { color: var(--color-text); text-decoration: none; }
.brand__mark {
    display: inline-grid;
    place-items: center;
    inline-size: 2.25rem;
    block-size: 2.25rem;
    border-radius: var(--radius-md);
    background: var(--gradient-brand);
    color: #fff;
    font-weight: var(--weight-bold);
    font-size: var(--text-lg);
    box-shadow: var(--shadow-sm);
}
.topbar__title {
    color: var(--color-muted);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    padding-inline-start: var(--space-4);
    border-inline-start: 1px solid var(--color-border);
}
.topbar__actions {
    margin-inline-start: auto;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}
.topbar__actions :is(button, .btn) { margin-top: 0; }

.page {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--space-6) var(--space-5) var(--space-12);
    display: grid;
    gap: var(--space-5);
    align-content: start;
}
.page > * { min-width: 0; }
.page--narrow { max-width: 52rem; }
.view { display: grid; gap: var(--space-5); align-content: start; min-width: 0; }
.view > * { min-width: 0; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head p { margin: var(--space-1) 0 0; color: var(--color-muted); }

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-surface);
    color: var(--gray-700);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
}
.user-chip .i { color: var(--brand-600); }

/* ---- Main menu: inline in the topbar on wide screens, drawer on phones ---- */
.menu-btn {
    display: none;
    inline-size: 2.5rem;
    min-height: 2.5rem;
    margin: 0;
    padding: 0;
    font-size: 1.25rem;
}
.topnav { display: flex; align-items: center; gap: var(--space-1); margin-inline-start: var(--space-4); }
.topnav__link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--gray-600);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    white-space: nowrap;
}
.topnav__link:hover { background: var(--gray-50); color: var(--gray-900); text-decoration: none; }
.topnav__link.is-active { background: var(--brand-50); color: var(--brand-700); }

.drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: var(--color-overlay);
}
.drawer {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 100;
    inline-size: min(19rem, 85vw);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-4);
    background: var(--color-surface);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 220ms ease, visibility 220ms;
}
[dir="ltr"] .drawer { transform: translateX(-100%); }
.drawer.is-open { transform: none; visibility: visible; }
.drawer__head { display: flex; align-items: center; justify-content: space-between; padding-bottom: var(--space-3); border-bottom: 1px solid var(--color-border); }
.drawer__close { margin: 0; inline-size: 2.25rem; padding: 0; }
.drawer__user { display: flex; align-items: center; gap: var(--space-2); margin: var(--space-2) 0 0; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); background: var(--gray-50); color: var(--gray-700); font-size: var(--text-sm); }
.drawer__user .i { color: var(--brand-600); }
.drawer__nav { display: grid; gap: var(--space-1); margin-top: var(--space-2); }
.drawer__link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 3rem;
    padding: 0 var(--space-3);
    border-radius: var(--radius-md);
    color: var(--gray-700);
    font-size: var(--text-md);
    font-weight: var(--weight-semibold);
}
.drawer__link .i { color: var(--gray-400); font-size: 1.15rem; }
.drawer__link:hover { background: var(--gray-50); color: var(--gray-900); text-decoration: none; }
.drawer__link.is-active { background: var(--brand-50); color: var(--brand-700); }
.drawer__link.is-active .i { color: var(--brand-600); }
.drawer__logout { margin-top: auto; width: 100%; min-height: 3rem; }
body.no-scroll { overflow: hidden; }

@media (max-width: 959px) {
    .menu-btn { display: inline-flex; }
    .topnav, .topnav-logout, .topbar .user-chip { display: none; }
}
@media (min-width: 960px) {
    .drawer, .drawer-backdrop { display: none; }
}

/* ---- Card header (title + small action) ---- */
.card__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-2); }
.card__header h3 { display: flex; align-items: center; gap: var(--space-2); margin: 0; font-size: var(--text-lg); }
.card__header button { margin: 0; }

/* ---- Panel load status (loading / error with retry) ---- */
.status-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    padding: var(--space-5);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-muted);
}
.status-card .spinner { margin: 0; }
.status-card > span { flex: 1 1 12rem; }
.status-card__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.status-card__actions button { margin: 0; }

/* ---- Empty state ---- */
.empty-state { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-8) var(--space-4); text-align: center; color: var(--color-muted); }
.empty-state p { margin: 0; }
.empty-state__icon { display: grid; place-items: center; inline-size: 3rem; block-size: 3rem; border-radius: var(--radius-full); background: var(--brand-50); color: var(--brand-600); font-size: 1.4rem; }
.empty-state button { margin-top: var(--space-2); }

/* ---- Profile cards (panel home) ---- */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: var(--space-3); margin-top: var(--space-2); }
.profile-grid .profile-item { margin: 0; display: grid; gap: var(--space-3); align-content: start; }
.profile-item__head { display: flex; align-items: center; gap: var(--space-3); }
.profile-item__avatar { display: grid; place-items: center; flex: none; inline-size: 2.5rem; block-size: 2.5rem; border-radius: var(--radius-full); background: var(--brand-50); color: var(--brand-600); font-size: 1.15rem; }
.profile-item__title { display: grid; min-width: 0; flex: 1; }
.profile-item__title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-item__facts { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); font-size: var(--text-sm); }
.profile-item__actions { display: flex; flex-wrap: wrap; gap: var(--space-1); padding-top: var(--space-3); border-top: 1px solid var(--color-border); }
.profile-item__actions button.small { margin: 0; }

/* ---- Auth shell (login / register) ---- */
.auth-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(60rem 30rem at 50% -10%, var(--brand-100), transparent 70%),
        var(--color-bg);
}
.auth-shell__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-6);
}
.auth-shell__main {
    flex: 1;
    width: 100%;
    max-width: 29rem;
    margin: 0 auto;
    padding: var(--space-6) var(--space-4) var(--space-12);
    display: grid;
    align-content: center;
    gap: var(--space-4);
}
.auth-card { padding: var(--space-8); box-shadow: var(--shadow-md); }
.auth-card__head { text-align: center; margin-bottom: var(--space-6); }
.auth-card__head h1 { font-size: var(--text-2xl); margin-bottom: var(--space-2); }
.auth-card__head p { color: var(--color-muted); margin: 0; }
.auth-card__icon {
    display: inline-grid;
    place-items: center;
    inline-size: 3.25rem;
    block-size: 3.25rem;
    margin-bottom: var(--space-4);
    border-radius: var(--radius-full);
    background: var(--brand-50);
    color: var(--brand-600);
    font-size: 1.5rem;
}
.auth-card :is(input, select) { max-width: none; }
.auth-card button:not(.small) { width: 100%; }
.auth-switch { text-align: center; color: var(--color-muted); font-size: var(--text-sm); }
.auth-step { margin-top: var(--space-5); padding-top: var(--space-5); border-top: 1px dashed var(--color-border); }
.auth-step > label:first-child { margin-top: 0; }
.auth-footer { text-align: center; color: var(--color-muted); font-size: var(--text-xs); }

/* ===================================================================
   4. Components
   =================================================================== */

/* ---- Cards ---- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-xs);
    min-width: 0;
}
.card > :is(h2, h3):first-child { margin-top: 0; }
.card > h3 {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-lg);
}
.card > h3 > .i { margin: 0; }
/* A heading after content starts a new section of the same card */
.card > * + h3,
.card div > * + h3 {
    margin-top: var(--space-6);
    padding-top: var(--space-5);
    border-top: 1px solid var(--color-border);
}
.card h3 + :is(.hint, p) { margin-top: calc(-1 * var(--space-1)); }

/* ---- Buttons ----
   A bare <button> is the primary action; .secondary / .danger / .success
   / .ghost change its tone, .small its size (classes used by the scripts). */
:where(button), .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--control-h);
    margin-top: var(--space-4);
    padding: 0 var(--space-5);
    border: 1px solid var(--brand-600);
    border-radius: var(--radius-md);
    background: var(--brand-600);
    color: #fff;
    font: inherit;
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
    transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition);
}
:where(button):hover, .btn:hover { background: var(--brand-700); border-color: var(--brand-700); color: #fff; text-decoration: none; }
:where(button):active, .btn:active { transform: translateY(1px); }
:where(button):focus-visible, .btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--color-focus); }

button.secondary, .btn.secondary {
    background: var(--color-surface);
    border-color: var(--color-border-strong);
    color: var(--gray-700);
}
button.secondary:hover, .btn.secondary:hover { background: var(--gray-50); color: var(--gray-900); border-color: var(--gray-400); }

button.danger, .btn.danger {
    background: var(--color-surface);
    border-color: var(--danger-200);
    color: var(--danger-700);
}
button.danger:hover, .btn.danger:hover { background: var(--danger-50); color: var(--danger-700); border-color: var(--danger-600); }

button.success, .btn.success, a.bale-link, a.btn-success {
    background: var(--success-600);
    border-color: var(--success-600);
    color: #fff;
}
button.success:hover, .btn.success:hover, a.bale-link:hover, a.btn-success:hover { background: var(--success-700); border-color: var(--success-700); color: #fff; }

button.violet { background: var(--violet-600); border-color: var(--violet-600); }
button.violet:hover { background: var(--brand-700); }

button.ghost, .btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--gray-600); }
button.ghost:hover, .btn.ghost:hover { background: var(--gray-100); color: var(--gray-900); }

button.small, .btn.small {
    min-height: var(--control-h-sm);
    padding: 0 var(--space-3);
    font-size: var(--text-sm);
    margin: var(--space-1) 0 0;
    margin-inline-end: var(--space-1);
}

button:disabled, .btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}
button:disabled:hover { background: inherit; }
button.secondary:disabled:hover { background: var(--color-surface); color: var(--gray-700); }

a.bale-link, a.btn-success {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 2.875rem;
    margin-top: var(--space-4);
    padding: var(--space-2) var(--space-5);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-weight: var(--weight-semibold);
    text-decoration: none;
    box-shadow: var(--shadow-xs);
}

.link-sm, .link-button {
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    min-height: 0;
    box-shadow: none;
    color: var(--brand-600);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    cursor: pointer;
}
.link-sm:hover, .link-button:hover { color: var(--brand-700); background: none; text-decoration: underline; }

/* Rows of buttons / inline controls */
.row-buttons, .row {
    display: flex;
    gap: var(--space-2);
    align-items: stretch;
}
.row-buttons { margin-top: var(--space-4); flex-wrap: wrap; }
.row-buttons > button, .row > button { margin-top: 0; }
.row > :is(input, select) { margin: 0; }

/* ---- Forms ---- */
label {
    display: block;
    margin: var(--space-4) 0 var(--space-1);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--gray-700);
}
label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-base);
    font-weight: var(--weight-regular);
    color: var(--color-text);
    cursor: pointer;
}

:where(input:not([type="checkbox"], [type="radio"], [type="hidden"], [type="file"], [type="range"], [type="color"]), select, textarea) {
    display: block;
    width: 100%;
    min-height: var(--control-h);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    background-color: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: var(--text-base);
    line-height: 1.4;
    box-shadow: var(--shadow-xs);
    transition: border-color var(--transition), box-shadow var(--transition);
}
:where(textarea) { min-height: 5.5rem; resize: vertical; }
:where(select) {
    appearance: none;
    -webkit-appearance: none;
    padding-inline-end: 2.25rem;
    background-image: var(--mask-chevron-down);
    background-repeat: no-repeat;
    background-size: 1rem;
    background-position: left 0.75rem center;
    cursor: pointer;
}
[dir="ltr"] :where(select) { background-position: right 0.75rem center; }
:where(input, select, textarea)::placeholder { color: var(--gray-400); opacity: 1; }
:where(input, select, textarea):hover:not(:disabled) { border-color: var(--gray-400); }
:where(input, select, textarea):focus,
:where(input, select, textarea):focus-visible {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px var(--color-focus);
}
:where(input, select, textarea):disabled,
:where(input, textarea)[readonly] {
    background-color: var(--gray-50);
    color: var(--gray-500);
    cursor: not-allowed;
}

input[type="checkbox"], input[type="radio"] {
    width: 1.05rem;
    height: 1.05rem;
    margin: 0;
    accent-color: var(--brand-600);
    cursor: pointer;
}
input[type="file"] {
    display: block;
    width: 100%;
    font: inherit;
    font-size: var(--text-sm);
    color: var(--gray-600);
    padding: var(--space-2);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-md);
    background: var(--gray-25);
}
input[type="file"]::file-selector-button {
    font: inherit;
    font-weight: var(--weight-semibold);
    margin-inline-end: var(--space-3);
    padding: var(--space-1) var(--space-3);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--gray-700);
    cursor: pointer;
}

/* Numbers, phones, codes and emails read left-to-right even in RTL */
input[type="email"], input[type="url"], input[type="tel"], input[type="number"],
input[inputmode="numeric"], input[type="password"], input[type="datetime-local"] { direction: ltr; text-align: right; }

/* Field widths inside cards: sized to the data, never stretched across a wide card */
.card :is(input, select):not(.row > *, td *, .modal-card *, .auth-card *, .w-auto) { max-width: var(--field-md); }
.card textarea { max-width: var(--field-lg); }
.card input[type="file"] { max-width: var(--field-lg); }
.row > :is(input, select) { flex: 1; min-width: 0; }
.row > div { flex: 1; min-width: 0; }
.row + #pdfWrapper { margin-top: var(--space-3); }

/* Admin / org sign-in card: centered, same look as the auth pages */
.login-card { width: 100%; max-width: 29rem; margin-inline: auto; }
.login-card > h3:first-child { justify-content: center; font-size: var(--text-xl); }

/* Multi-column label/control groups for long forms (profiles):
   each .field holds one label + its control. */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: var(--space-1) var(--space-5);
}
.field { min-width: 0; }
.field > label { margin-top: var(--space-4); }
.form-grid :is(input, select, textarea) { max-width: none !important; } /* fields fill their grid cell */
.field:has(textarea) { grid-column: 1 / -1; }

/* ---- Tables (built by the page scripts as plain <table>) ---- */
.card table, .table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: var(--space-4) 0 0;
    font-size: var(--text-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}
.card tr:first-child > th:first-child { border-start-start-radius: var(--radius-md); }
.card tr:first-child > th:last-child { border-start-end-radius: var(--radius-md); }
.card th, .card td, .table th, .table td {
    text-align: start;
    padding: var(--space-3);
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}
.card th, .table th {
    background: var(--gray-50);
    color: var(--gray-600);
    font-weight: var(--weight-semibold);
    font-size: var(--text-xs);
    white-space: nowrap;
}
.card tr:last-child > td, .table tr:last-child > td { border-bottom: 0; }
.card tr:hover > td, .table tr:hover > td { background: var(--gray-25); }
.card td :is(select, input:not([type="checkbox"], [type="radio"])) {
    min-height: var(--control-h-sm);
    padding-block: var(--space-1);
    font-size: var(--text-sm);
    width: auto;
    max-width: 12rem;
    display: inline-block;
}
.card td button.small { white-space: nowrap; }
.card td input.input-xs { width: 7.5rem; }
.card td input.input-sm { width: 8.5rem; }
.card td input.input-md { width: 11rem; }

/* Row actions in admin tables: main actions inline, the rest in a menu */
.cell-actions { display: flex; align-items: center; gap: var(--space-1); flex-wrap: nowrap; }
.cell-actions > button.small, .cell-actions .btn.small { margin: 0; }
.row-menu { position: relative; }
.row-menu > summary { list-style: none; cursor: pointer; }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu[open] > summary { background: var(--gray-100); }
.row-menu__panel {
    position: absolute;
    inset-inline-end: 0;
    top: calc(100% + var(--space-1));
    z-index: 20;
    display: grid;
    gap: var(--space-1);
    min-width: 15rem;
    padding: var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    box-shadow: var(--shadow-lg);
}
.row-menu__panel > button.small { margin: 0; justify-content: flex-start; width: 100%; }
.row-menu__pass { display: flex; gap: var(--space-1); padding-block: var(--space-1); border-block: 1px solid var(--color-border); }
.card td .row-menu__pass input { width: 8rem; max-width: none; }
.row-menu__pass button.small { margin: 0; }
/* The open menu must not be clipped by the scrolling table box */
[id$="TableBox"]:has(.row-menu[open]) { overflow: visible; }
/* Containers the scripts render lists into: scroll sideways on small screens */
[id$="TableBox"], #formsListBox, #profilesList, .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
[id$="TableBox"] table { min-width: 36rem; }
.scroll-box { max-height: 26rem; overflow-y: auto; }

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 0.125rem 0.625rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--brand-200);
    background: var(--brand-50);
    color: var(--brand-700);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    line-height: 1.6;
    white-space: nowrap;
}
.badge-admin { background: var(--violet-50); border-color: var(--brand-200); color: var(--violet-600); }
.badge-user { background: var(--gray-50); border-color: var(--color-border); color: var(--gray-700); }
.badge-active { background: var(--success-50); border-color: var(--success-200); color: var(--success-700); }
.badge-pending { background: var(--warning-50); border-color: var(--warning-200); color: var(--warning-700); }
.badge-blocked { background: var(--danger-50); border-color: var(--danger-200); color: var(--danger-700); }
.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    margin: 0.125rem;
    border-radius: var(--radius-full);
    background: var(--gray-100);
    color: var(--gray-700);
    font-size: var(--text-xs);
}

/* ---- Tabs (admin / org dashboards) ---- */
.tabs {
    display: flex;
    gap: var(--space-1);
    overflow-x: auto;
    padding: var(--space-1);
    margin-bottom: var(--space-5);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    scrollbar-width: thin;
}
.tab-btn {
    flex: 1 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    color: var(--gray-600);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition), color var(--transition);
}
.tab-btn:hover { background: var(--gray-50); color: var(--gray-900); }
.tab-btn.active { background: var(--brand-50); color: var(--brand-700); }
.tab-btn .i { pointer-events: none; }

/* ---- List items (profiles, forms) ---- */
.profile-item, .form-item, .list-item {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-top: var(--space-3);
    background: var(--color-surface);
    font-size: var(--text-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}
:is(.profile-item, .form-item, .list-item):hover { border-color: var(--brand-200); box-shadow: var(--shadow-sm); }
:is(.profile-item, .form-item) b:first-child { font-size: var(--text-md); }
.form-item img { max-width: 100%; border-radius: var(--radius-sm); margin-top: var(--space-2); }
.list-item--row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-3); }
.thumb { block-size: 3.75rem; border-radius: var(--radius-sm); vertical-align: middle; border: 1px solid var(--color-border); margin-inline-end: var(--space-2); }

/* ---- Info icon next to a label ---- */
.info-icon {
    display: inline-grid;
    place-items: center;
    inline-size: 1.375rem;
    block-size: 1.375rem;
    margin-inline-start: var(--space-1);
    border-radius: var(--radius-full);
    background: var(--brand-50);
    color: var(--brand-600);
    font-size: var(--text-sm);
    vertical-align: middle;
    cursor: pointer;
}
.info-icon:hover { background: var(--brand-100); }

/* ---- Status text ---- */
.status-ok { color: var(--success-700); font-weight: var(--weight-semibold); }
.status-fail { color: var(--danger-700); font-weight: var(--weight-semibold); }
.status-line { text-align: center; color: var(--color-muted); font-size: var(--text-sm); margin-top: var(--space-3); }

/* ---- Alerts / notices ---- */
.alert, .denied {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    border: 1px solid var(--info-200);
    border-radius: var(--radius-md);
    background: var(--info-50);
    color: var(--info-700);
    font-size: var(--text-sm);
}
.alert .i { margin-top: 0.15em; }
.alert--warning { border-color: var(--warning-200); background: var(--warning-50); color: var(--warning-700); }
.alert--danger, .denied { border-color: var(--danger-200); background: var(--danger-50); color: var(--danger-700); }
.alert--success { border-color: var(--success-200); background: var(--success-50); color: var(--success-700); }
.denied { justify-content: center; padding: var(--space-8) var(--space-5); font-size: var(--text-md); font-weight: var(--weight-medium); }

/* ---- Modals ---- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: var(--color-overlay);
    backdrop-filter: blur(2px);
}
.modal-backdrop--top { z-index: 250; }
.modal-card {
    width: 100%;
    max-width: 34rem;
    max-height: min(90vh, 100%);
    overflow-y: auto;
    padding: var(--space-6);
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    box-shadow: var(--shadow-lg);
}
.modal-card--sm { max-width: 24rem; }
.modal-card > h3:first-child { margin-top: 0; }

/* Image guide (lightbox) */
.lightbox { position: relative; max-width: 90vw; max-height: 85vh; }
.lightbox__img { display: block; max-width: 100%; max-height: 85vh; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.lightbox__close {
    position: absolute;
    top: -0.875rem;
    inset-inline-start: -0.875rem;
    inline-size: 2.25rem;
    block-size: 2.25rem;
    min-height: 0;
    margin: 0;
    padding: 0;
    border-radius: var(--radius-full);
    background: var(--color-surface);
    border-color: var(--color-border);
    color: var(--gray-700);
    box-shadow: var(--shadow-md);
}
.lightbox__close:hover { background: var(--gray-100); color: var(--gray-900); border-color: var(--color-border); }
.lightbox__missing { padding: var(--space-6); border-radius: var(--radius-lg); background: var(--color-surface); text-align: center; color: var(--color-muted); }

/* Spinner */
.spinner {
    display: inline-block;
    inline-size: 1.25rem;
    block-size: 1.25rem;
    border: 3px solid var(--brand-100);
    border-top-color: var(--brand-600);
    border-radius: 50%;
    vertical-align: middle;
    margin-inline-start: var(--space-2);
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Error bar from ui/guard.js: always reachable, even if the page script died */
.error-bar {
    position: sticky;
    top: 0;
    z-index: 500;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--danger-50);
    border-bottom: 1px solid var(--danger-200);
    color: var(--danger-700);
    font-size: var(--text-sm);
}
.error-bar p { flex: 1 1 16rem; margin: 0; overflow-wrap: anywhere; }
.error-bar button { margin: 0; min-height: var(--control-h-sm); }

/* ===================================================================
   5. Utilities
   =================================================================== */
/* .hidden must beat any component display (the scripts toggle it on everything) */
.hidden { display: none !important; } /* utility: must win over component rules */
.hint { font-size: var(--text-sm); color: var(--color-muted); }
.meta { font-size: var(--text-xs); color: var(--color-muted); }
.text-sm { font-size: var(--text-sm); }
.text-center { text-align: center; }
.text-danger { color: var(--danger-700); }
.text-warning { color: var(--warning-700); }
.text-success { color: var(--success-700); }
.text-brand { color: var(--brand-600); }
.fw-bold { font-weight: var(--weight-bold); }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-2); }
.mt-2 { margin-top: var(--space-3); }
.mt-3 { margin-top: var(--space-4); }
.mb-1 { margin-bottom: var(--space-1); }
.m-0 { margin: 0; }
.grow { flex: 1; }
.half { min-width: 45%; }
.wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-auto { width: auto; display: inline-block; }
.w-full { width: 100%; }
.pointer { cursor: pointer; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.input-xs { width: 6rem; }
.input-sm { width: 7rem; }
.input-md { width: 8.5rem; }

/* ===================================================================
   6. Page parts
   =================================================================== */
a.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--gray-600);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
}
a.back-link:hover { color: var(--brand-700); text-decoration: none; }

/* Hotspot editor */
#pdfWrapper {
    position: relative;
    width: 100%;
    overflow: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--gray-100);
    touch-action: none;
}
#pdfCanvas { display: block; width: 100%; height: auto; }
.hotspot-box {
    position: absolute;
    border: 2px solid var(--brand-600);
    background: rgba(47, 95, 214, 0.14);
    font-size: 10px;
    color: var(--brand-800);
    overflow: hidden;
    cursor: pointer;
    padding: 1px 3px;
    white-space: nowrap;
    border-radius: 3px;
}
.hotspot-box.selected { border-color: var(--danger-600); background: rgba(217, 45, 32, 0.14); color: var(--danger-700); }
.draw-temp {
    position: absolute;
    border: 2px dashed var(--success-600);
    background: rgba(6, 118, 71, 0.14);
    pointer-events: none;
}
.page-nav { display: flex; align-items: center; gap: var(--space-2); }
.page-nav > span { flex: 1; text-align: center; font-size: var(--text-sm); color: var(--color-muted); }
.page-nav button { margin-top: 0; }

/* ===================================================================
   7. Kiosk theme — large touch UI
   Root font-size scales with the screen, so every rem-sized control,
   text and gap grows on a big touch display.
   =================================================================== */
html.kiosk { font-size: clamp(17px, 0.55vw + 0.9vh + 6px, 30px); }
body.kiosk {
    min-height: 100vh;
    background:
        radial-gradient(70rem 30rem at 50% -12%, var(--brand-100), transparent 70%),
        var(--color-bg);
    font-size: var(--text-md);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    padding-bottom: var(--kb-space, 0px);
    transition: padding-bottom 200ms ease;
}
body.kiosk :is(input, textarea) { user-select: text; }
.kiosk {
    --control-h: 3.5rem;
    --control-h-sm: 2.75rem;
}
.kiosk .wrap { width: 100%; max-width: 42rem; margin: 0 auto; padding: var(--space-6) var(--space-5) var(--space-12); }
.kiosk .wrap--wide { max-width: 64rem; }
.kiosk .header { text-align: center; margin-bottom: var(--space-6); }
.kiosk .header h1 { font-size: var(--text-3xl); margin: 0 0 var(--space-2); display: inline-flex; align-items: center; gap: var(--space-3); }
.kiosk .header h1 .i { color: var(--brand-600); margin: 0; }
.kiosk .header p { color: var(--color-muted); font-size: var(--text-lg); margin: 0; }
.kiosk .card { padding: var(--space-6); border-radius: var(--radius-xl); box-shadow: var(--shadow-sm); }
.kiosk label { font-size: var(--text-md); margin-top: var(--space-5); }
.kiosk :where(input:not([type="checkbox"], [type="radio"], [type="hidden"], [type="file"]), select, textarea) {
    font-size: var(--text-xl);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    border-width: 2px;
}
.kiosk .card :is(input, select) { max-width: none; }
.kiosk :where(button), .kiosk .btn {
    min-height: 3.75rem;
    font-size: var(--text-lg);
    border-radius: var(--radius-lg);
    padding-inline: var(--space-6);
}
.kiosk .card > button, .kiosk .final-buttons button, .kiosk .stack-buttons button { width: 100%; }
.kiosk button.big-yes { background: var(--success-600); border-color: var(--success-600); }
.kiosk button.big-yes:hover { background: var(--success-700); }
.kiosk button.big-no { background: var(--color-surface); border-color: var(--danger-200); color: var(--danger-700); }
.kiosk button.big-no:hover { background: var(--danger-50); }
.kiosk a.bale-link { min-height: 3.75rem; font-size: var(--text-lg); border-radius: var(--radius-lg); }
.kiosk .back-link { font-size: var(--text-md); margin-bottom: var(--space-4); }
.kiosk .card + .card { margin-top: var(--space-4); }
.kiosk .card.danger { background: var(--danger-50); border-color: var(--danger-200); color: var(--danger-700); }
.kiosk .card .row-buttons > button { flex: 1; }
/* Step pages (print guide): the step's buttons fill the width */
.kiosk .wrap > div > button, .kiosk .final-question > button { width: 100%; }
.kiosk .wrap > div > button + button { margin-top: var(--space-3); }
.kiosk .header h1 .hint { font-size: var(--text-lg); font-weight: var(--weight-regular); }
body.kiosk > .header { padding: var(--space-8) var(--space-6) var(--space-2); }

.kiosk-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-6);
}
.kiosk-bar .brand { font-size: var(--text-xl); }
.kiosk-bar .brand__mark { inline-size: 2.75rem; block-size: 2.75rem; font-size: var(--text-xl); }

/* Form picker (kiosk.html) */
.kiosk .org-logo-lg img, .org-header-fallback {
    inline-size: 4.5rem;
    block-size: 4.5rem;
    object-fit: contain;
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    margin: 0 auto var(--space-3);
}
#orgHeaderLogo img { inline-size: 4.5rem; block-size: 4.5rem; object-fit: contain; border-radius: var(--radius-lg); background: var(--color-surface); border: 1px solid var(--color-border); margin-bottom: var(--space-3); }
.org-header-fallback { display: grid; place-items: center; color: var(--brand-600); font-size: 2rem; }
.org-bar, .category-bar {
    display: flex;
    gap: var(--space-3);
    overflow-x: auto;
    padding: var(--space-2) var(--space-6) var(--space-4);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.org-chip {
    flex: 0 0 auto;
    min-width: 8.5rem;
    padding: var(--space-4) var(--space-5);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    text-align: center;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
    transition: border-color var(--transition), background var(--transition), transform var(--transition);
}
.org-chip:active { transform: scale(0.97); }
.org-chip.active { border-color: var(--brand-600); background: var(--brand-50); }
.org-chip img { inline-size: 3.25rem; block-size: 3.25rem; object-fit: contain; border-radius: var(--radius-md); margin-bottom: var(--space-2); }
.org-chip .org-icon-fallback { inline-size: 3.25rem; block-size: 3.25rem; margin: 0 auto var(--space-2); border-radius: var(--radius-md); background: var(--brand-50); color: var(--brand-600); display: grid; place-items: center; font-size: 1.5rem; }
.org-chip .org-name { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.category-chip {
    flex: 0 0 auto;
    padding: var(--space-3) var(--space-6);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-surface);
    color: var(--gray-700);
    font-size: var(--text-md);
    font-weight: var(--weight-medium);
    cursor: pointer;
}
.category-chip.active { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.forms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: var(--space-5);
    padding: var(--space-3) var(--space-6) var(--space-12);
}
.form-card {
    overflow: hidden;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    text-align: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 120ms ease, border-color var(--transition), box-shadow var(--transition);
}
.form-card:hover { border-color: var(--brand-200); box-shadow: var(--shadow-md); }
.form-card:active { transform: scale(0.97); border-color: var(--brand-600); }
.form-thumb { width: 100%; aspect-ratio: 3 / 4; background: var(--gray-100); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.form-thumb img { width: 100%; height: 100%; object-fit: cover; }
.form-thumb .pdf-fallback { font-size: 3rem; color: var(--gray-400); }
.form-title { padding: var(--space-3); font-size: var(--text-md); font-weight: var(--weight-semibold); min-height: 3.5rem; display: flex; align-items: center; justify-content: center; }
.empty-msg, .loading-msg { text-align: center; padding: var(--space-12) var(--space-5); color: var(--color-muted); font-size: var(--text-lg); }

/* Profile picker (kiosk_profiles.html) */
.profile-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-3);
    padding: var(--space-5) var(--space-6);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    box-shadow: var(--shadow-xs);
    cursor: pointer;
    transition: transform 120ms ease, border-color var(--transition);
}
.profile-card:hover { border-color: var(--brand-200); }
.profile-card:active { transform: scale(0.98); border-color: var(--brand-600); }
.profile-info .name { font-size: var(--text-lg); font-weight: var(--weight-semibold); margin-bottom: var(--space-1); }
.profile-info .meta { font-size: var(--text-sm); }
.profile-tag { padding: var(--space-1) var(--space-3); border-radius: var(--radius-full); background: var(--brand-50); color: var(--brand-700); font-size: var(--text-sm); white-space: nowrap; }
.arrow { color: var(--brand-600); font-size: var(--text-xl); }
.add-profile-btn {
    width: 100%;
    margin-top: var(--space-2);
    border: 2px dashed var(--color-border-strong);
    border-radius: var(--radius-xl);
    background: transparent;
    color: var(--gray-600);
    box-shadow: none;
}
.add-profile-btn:hover { background: var(--brand-50); border-color: var(--brand-500); color: var(--brand-700); }
.modal-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: var(--space-5); background: var(--color-overlay); }
.modal-box { width: 100%; max-width: 36rem; max-height: min(85vh, 100%); overflow-y: auto; padding: var(--space-6); border-radius: var(--radius-xl); background: var(--color-surface); box-shadow: var(--shadow-lg); }
.modal-box h3 { margin-top: 0; }
.modal-actions { display: flex; gap: var(--space-3); margin-top: var(--space-5); }
.modal-actions button { flex: 1; margin-top: 0; }
.btn-primary { background: var(--brand-600); color: #fff; }
.btn-cancel { background: var(--color-surface); border-color: var(--color-border-strong); color: var(--gray-700); }
.btn-cancel:hover { background: var(--gray-50); color: var(--gray-900); }

/* Print guide / preview (kiosk_print_guide.html) */
.guide-img { width: 100%; border-radius: var(--radius-lg); margin-bottom: var(--space-4); border: 1px solid var(--color-border); }
.guide-text { text-align: center; font-size: var(--text-lg); line-height: 1.8; }
.field-row { display: flex; gap: var(--space-3); }
.field-row > div { flex: 1; min-width: 0; }
.preview-wrapper { position: relative; width: 100%; border-radius: var(--radius-lg); overflow: hidden; background: var(--gray-100); border: 1px solid var(--color-border); }
.preview-wrapper img.bg-img, .preview-wrapper canvas { width: 100%; display: block; }
.preview-field { position: absolute; font-family: Tahoma, Arial, sans-serif; color: #000; background: rgba(255, 255, 255, 0.6); line-height: 1.2; overflow: hidden; white-space: pre-wrap; word-break: break-word; }
.align-right { text-align: right; }
.align-center { text-align: center; }
.align-left { text-align: left; }
.final-question h2 { text-align: center; font-size: var(--text-2xl); margin-bottom: var(--space-6); }
.final-buttons { display: flex; gap: var(--space-3); }
.final-buttons button { flex: 1; }
.channel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); margin-top: var(--space-3); }
.channel-grid button { margin-top: 0; width: 100%; }

/* ---- On-screen keyboard (ui/kiosk-keyboard.js) ---- */
.vk {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 400;
    padding: var(--space-3) var(--space-4) var(--space-4);
    background: var(--gray-100);
    border-top: 1px solid var(--color-border-strong);
    box-shadow: var(--shadow-up);
    transform: translateY(105%);
    transition: transform 200ms ease;
    user-select: none;
    touch-action: manipulation;
    direction: ltr;
}
.vk.is-open { transform: translateY(0); }
.vk__inner { max-width: 72rem; margin: 0 auto; display: grid; gap: var(--space-2); }
.vk--numeric .vk__inner { max-width: 26rem; }
.vk__row { display: flex; gap: var(--space-2); justify-content: center; }
/* Overlays end above the keyboard so their content can scroll into view */
body.kiosk :is(.modal-overlay, .modal-backdrop) { bottom: var(--kb-space, 0px); transition: bottom 200ms ease; }
.vk__key {
    flex: 1 1 0;
    min-width: 0;
    min-height: clamp(2.6rem, 6.2vh, 3.6rem);
    margin: 0;
    padding: 0 var(--space-1);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--gray-900);
    font-size: var(--text-xl);
    font-weight: var(--weight-medium);
    box-shadow: 0 2px 0 var(--gray-300);
}
.vk__key:hover { background: var(--color-surface); color: var(--gray-900); border-color: var(--color-border-strong); }
.vk__key:active, .vk__key.is-pressed { background: var(--brand-50); border-color: var(--brand-500); transform: translateY(2px); box-shadow: none; }
.vk__key--fn { background: var(--gray-200); font-size: var(--text-md); font-weight: var(--weight-semibold); }
.vk__key--fn:hover { background: var(--gray-200); }
.vk__key--wide { flex-grow: 1.6; }
.vk__key--space { flex-grow: 6; }
.vk__key--accent { background: var(--brand-600); border-color: var(--brand-600); color: #fff; box-shadow: 0 2px 0 var(--brand-800); }
.vk__key--accent:hover { background: var(--brand-600); color: #fff; border-color: var(--brand-600); }
.vk__key--accent:active { background: var(--brand-700); }
.vk__key.is-on { background: var(--brand-100); border-color: var(--brand-500); color: var(--brand-700); }
.vk--numeric .vk__key { flex: 1 1 0; min-height: clamp(3rem, 8vh, 4.25rem); font-size: var(--text-2xl); }
.vk__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-1); color: var(--gray-600); font-size: var(--text-sm); direction: rtl; }
.vk__bar button { margin: 0; min-height: 2.5rem; font-size: var(--text-sm); }
.vk-toggle {
    position: fixed;
    bottom: var(--space-4);
    inset-inline-start: var(--space-4);
    z-index: 390;
    margin: 0;
    min-height: 3.25rem;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
}

/* ===================================================================
   8. Responsive
   =================================================================== */
@media (max-width: 640px) {
    .page { padding: var(--space-4) var(--space-3) var(--space-10); gap: var(--space-4); }
    .card { padding: var(--space-4); }
    .topbar__inner { padding-inline: var(--space-3); gap: var(--space-2); }
    .topbar__title { display: none; }
    .card :is(input, select, textarea):not(td *) { max-width: none; }
    .card > button:not(.small), .row-buttons > button:not(.small) { width: 100%; }
    .row-buttons > button:not(.small) { flex: 1; }
    .auth-card { padding: var(--space-6) var(--space-5); }
    .channel-grid { grid-template-columns: 1fr; }
    .kiosk .field-row { flex-direction: column; gap: 0; }
    .forms-grid { grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); padding-inline: var(--space-4); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; } /* accessibility: user preference wins */
}

@media print {
    .topbar, .vk, .vk-toggle { display: none !important; } /* print: never print chrome */
}
