/* ==========================================================================
   فر دیزاین — base.css: tokens + shared components (docs/06).
   Provenance: component rules (.btn, .seg, .menu, fields, toasts, tooltip, dialog, tabs, kbd)
   are extracted from the legacy plan-editor.html; the paper/ink palette and panel patterns come
   from legacy app/house-3d.html. Since IN-039 the palette is navy ink + drafting blue, a rose CTA and pastel tones.
   Legacy variable names (--text, --border, --accent-2 …) stay as aliases so the ported editor works.
   ========================================================================== */

/* Vazirmatn (OFL, assets/fonts/OFL.txt): one variable file covers weights 100–900 (IN-039) */
@font-face { font-family: "Vazirmatn"; font-weight: 100 900; font-style: normal; font-display: swap; src: url("../fonts/Vazirmatn-Variable.woff2") format("woff2"); }

/* ---------- tokens: light ---------- */
:root {
  color-scheme: light dark;
  --bg: #F5F7FA; --surface: #FFFFFF; --surface-2: #EEF1F6; --surface-3: #E2E8F1;
  --ink: #1B2B45; --muted: #56627A; --faint: #737E92;
  --line: #E2E8F1; --line-strong: #CFD7E3;
  --accent: #2F5288; --accent-hover: #23406C; --accent-soft: #E8EEF8; --accent-ring: rgba(47, 82, 136, .28); --on-accent: #FFFFFF;
  --primary: #1B2B45; --primary-hover: #2A3D5E; --on-primary: #FFFFFF;
  --cta: #CC2F6C; --cta-hover: #B42660; --on-cta: #FFFFFF;
  --success: #26805A; --success-soft: #E2F4EA;
  --warning: #8E6C10; --warning-soft: #FFF4D2;
  --danger: #B42318; --danger-soft: #FDECEA;
  --info: #3464C8; --info-soft: #E4EEFF;
  --lav: #EEEAFF; --lav-2: #DCD5FF; --lav-d: #5F4FD1; --mint: #E2F4EA; --mint-d: #26805A; --peach: #FFEAE0; --peach-d: #BF5A35;
  --sky: #E4EEFF; --sky-d: #3464C8; --butter: #FFF4D2; --butter-d: #8E6C10;
  --focus: #2F5288;
  --hover: rgba(27, 43, 69, .05);
  --paper-grid: #E2E8F1;
  --stage: #EEF1F6; --seg-bg: #EEF1F6; --seg-on: #FFFFFF;
  --inv-bg: rgba(27, 43, 69, .94); --inv-text: #FFFFFF; --inv-btn: rgba(255, 255, 255, .14);
  --shadow-1: 0 1px 2px rgba(27, 43, 69, .06);
  --shadow-2: 0 1px 2px rgba(27, 43, 69, .05), 0 14px 32px -18px rgba(27, 43, 69, .28);
  --shadow-3: 0 2px 6px rgba(27, 43, 69, .05), 0 40px 80px -40px rgba(27, 43, 69, .4);
  --r-xs: 6px; --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-pill: 999px;
  --h: 40px; --h-sm: 32px; --h-lg: 48px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px;
  --space-7: 32px; --space-8: 40px; --space-9: 48px; --space-10: 64px; --space-11: 80px;
  --w-page: 1200px; --w-article: 760px; --w-form: 420px;
  --ease: cubic-bezier(.2, .7, .3, 1);
  --z-dropdown: 40; --z-header: 50; --z-drawer: 60; --z-dialog: 70; --z-toast: 80; --z-tooltip: 90;

  /* legacy aliases (ported editor + extracted components) */
  --r: var(--r-sm); --r-lg-legacy: var(--r-md);
  --text: var(--ink); --text-2: var(--muted); --text-3: var(--faint);
  --border: var(--line); --border-2: var(--line-strong);
  --accent-2: var(--accent-hover);
  --ok: var(--success); --ok-soft: var(--success-soft);
  --warn: var(--warning); --warn-soft: var(--warning-soft);
  --paper: var(--bg); --card: var(--surface);

  /* plan canvas colors (SVG export + editor); theme-aware */
  --wall: #2A2A2E; --dim: #C2412D; --glass: #BFE0F2; --item: #F4F1EA; --sheet: #FFFFFF;
  --grid: rgba(0, 0, 0, .06); --gridM: rgba(0, 0, 0, .15);

  --font: "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
}

/* ---------- tokens: dark ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1520; --surface: #161E2B; --surface-2: #1D2735; --surface-3: #263246;
    --ink: #E8EDF5; --muted: #A9B4C6; --faint: #8592A8;
    --line: #243046; --line-strong: #33415C;
    --accent: #8FB0E8; --accent-hover: #AFC7F0; --accent-soft: #1E2A44; --accent-ring: rgba(143, 176, 232, .34); --on-accent: #0F1520;
    --primary: #E8EDF5; --primary-hover: #FFFFFF; --on-primary: #1B2B45;
    --cta: #E0558D; --cta-hover: #EC6FA0; --on-cta: #FFFFFF;
    --success: #6FD3A2; --success-soft: #18291F; --warning: #E9C46A; --warning-soft: #2C2614;
    --danger: #FF8A7A; --danger-soft: #33201D; --info: #8FB2FF; --info-soft: #1B2235;
    --lav: #2A2645; --lav-2: #3A3363; --lav-d: #B7ABFF; --mint: #183027; --mint-d: #7FD9AA; --peach: #33231C; --peach-d: #FFAD8C;
    --sky: #1B2640; --sky-d: #9DBBFF; --butter: #2F2814; --butter-d: #EBC86A;
    --focus: #8FB0E8; --hover: rgba(255, 255, 255, .05); --paper-grid: rgba(255, 255, 255, .045);
    --stage: #0B1018; --seg-bg: #161E2B; --seg-on: #263246;
    --inv-bg: rgba(232, 237, 245, .95); --inv-text: #1B2B45; --inv-btn: rgba(0, 0, 0, .08);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .5);
    --shadow-3: 0 18px 48px rgba(0, 0, 0, .6), 0 2px 8px rgba(0, 0, 0, .35);
    --wall: #D8D6CF; --dim: #FF8A7D; --glass: #3B6A85; --item: #2F3136; --sheet: #1F2024;
    --grid: rgba(255, 255, 255, .06); --gridM: rgba(255, 255, 255, .14);
  }
}
:root[data-theme="dark"] {
    --bg: #0F1520; --surface: #161E2B; --surface-2: #1D2735; --surface-3: #263246;
    --ink: #E8EDF5; --muted: #A9B4C6; --faint: #8592A8;
    --line: #243046; --line-strong: #33415C;
    --accent: #8FB0E8; --accent-hover: #AFC7F0; --accent-soft: #1E2A44; --accent-ring: rgba(143, 176, 232, .34); --on-accent: #0F1520;
    --primary: #E8EDF5; --primary-hover: #FFFFFF; --on-primary: #1B2B45;
    --cta: #E0558D; --cta-hover: #EC6FA0; --on-cta: #FFFFFF;
    --success: #6FD3A2; --success-soft: #18291F; --warning: #E9C46A; --warning-soft: #2C2614;
    --danger: #FF8A7A; --danger-soft: #33201D; --info: #8FB2FF; --info-soft: #1B2235;
    --lav: #2A2645; --lav-2: #3A3363; --lav-d: #B7ABFF; --mint: #183027; --mint-d: #7FD9AA; --peach: #33231C; --peach-d: #FFAD8C;
    --sky: #1B2640; --sky-d: #9DBBFF; --butter: #2F2814; --butter-d: #EBC86A;
    --focus: #8FB0E8; --hover: rgba(255, 255, 255, .05); --paper-grid: rgba(255, 255, 255, .045);
    --stage: #0B1018; --seg-bg: #161E2B; --seg-on: #263246;
    --inv-bg: rgba(232, 237, 245, .95); --inv-text: #1B2B45; --inv-btn: rgba(0, 0, 0, .08);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .5);
    --shadow-3: 0 18px 48px rgba(0, 0, 0, .6), 0 2px 8px rgba(0, 0, 0, .35);
  --wall: #D8D6CF; --dim: #FF8A7D; --glass: #3B6A85; --item: #2F3136; --sheet: #1F2024;
  --grid: rgba(255, 255, 255, .06); --gridM: rgba(255, 255, 255, .14);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* ---------- reset + typography ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font: 400 1rem/1.75 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg, video, canvas { max-width: 100%; }
img { height: auto; }
h1, h2, h3, h4 { margin: 1.5em 0 .5em; line-height: 1.4; font-weight: 600; color: var(--ink); }
h1 { font-size: 2.25rem; font-weight: 700; margin-top: 0; }
h2 { font-size: 1.5rem; } h3 { font-size: 1.25rem; } h4 { font-size: 1.0625rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--space-6) 0; }
small { font-size: .875em; }
code, kbd, pre { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; }
code { padding: .1em .35em; background: var(--surface-2); border-radius: var(--r-xs); direction: ltr; unicode-bidi: isolate; }
.ltr { direction: ltr; unicode-bidi: isolate; text-align: left; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--accent-soft); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; inset-inline-start: 8px; top: -60px; z-index: 200; padding: 8px 16px; background: var(--ink); color: var(--bg); border-radius: var(--r-sm); text-decoration: none; }
.skip-link:focus { top: 8px; color: var(--bg); }
.container { width: 100%; max-width: var(--w-page); margin-inline: auto; padding-inline: var(--space-4); }
@media (min-width: 768px) { .container { padding-inline: var(--space-6); } }
@media (min-width: 1024px) { .container { padding-inline: var(--space-7); } }

/* ---------- brand mark (header, sidebar, auth, errors) ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.0625rem; }
.brand:hover { color: var(--ink); text-decoration: none; }
.brand__mark { display: grid; place-items: center; width: 34px; height: 34px; color: var(--ink); }
.brand__mark .icon { width: 34px; height: 34px; vertical-align: 0; }

/* ---------- icons + kbd ---------- */
.icon, .ico { width: 1.25em; height: 1.25em; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.25em; }
.icon--sm { width: 1em; height: 1em; }
[dir="rtl"] .icon--directional { transform: scaleX(-1); }
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px; font: 500 11px/1 var(--font); color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; direction: ltr; white-space: nowrap; }

/* ---------- buttons (.btn--x BEM + legacy .btn.x) ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--h); padding: 0 var(--space-4); border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-sm); font-size: .9375rem; font-weight: 500; line-height: 1; white-space: nowrap; color: var(--ink); text-decoration: none; box-shadow: var(--shadow-1); transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease), opacity .15s; }
.btn:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--surface-2); border-color: var(--line-strong); color: var(--ink); text-decoration: none; }
.btn:active:not(:disabled) { background: var(--surface-3); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn .icon, .btn .ico { width: 1.1em; height: 1.1em; }
.btn--primary, .btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 8px 18px -10px rgba(23, 24, 31, .6); }
.btn--primary:hover:not(:disabled), .btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn--secondary { background: var(--surface); }
.btn--ghost, .btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn--ghost:hover:not(:disabled), .btn.ghost:hover:not(:disabled) { background: var(--hover); border-color: transparent; color: var(--ink); }
.btn--danger, .btn.danger { color: var(--danger); }
.btn--danger:hover:not(:disabled), .btn.danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn--danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger-solid:hover:not(:disabled) { background: #8f1f1a; border-color: #8f1f1a; color: #fff; }
.btn--link { height: auto; padding: 0; border: 0; background: none; box-shadow: none; color: var(--accent); font-weight: 500; }
.btn--link:hover:not(:disabled) { background: none; text-decoration: underline; color: var(--accent-hover); }
.btn--sm, .btn.sm { height: var(--h-sm); padding: 0 var(--space-3); font-size: .8125rem; border-radius: 8px; }
.btn--lg { height: var(--h-lg); padding: 0 var(--space-6); font-size: 1rem; }
.btn--cta { background: var(--cta); border-color: var(--cta); color: var(--on-cta); border-radius: var(--r-pill); box-shadow: 0 10px 24px -12px color-mix(in srgb, var(--cta) 70%, transparent); }
.btn--cta:hover:not(:disabled) { background: var(--cta-hover); border-color: var(--cta-hover); color: var(--on-cta); }
.btn--cta.btn--lg { padding: 0 var(--space-8); }
.btn--block, .btn.block { display: flex; width: 100%; }
.btn--icon, .btn.ibtn { width: var(--h); padding: 0; }
.btn--sm.btn--icon, .btn.sm.ibtn { width: var(--h-sm); }
.btn .chev { width: 14px; height: 14px; opacity: .65; margin-inline-start: -2px; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; color: var(--on-accent); animation: spin .7s linear infinite; }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- segmented control ---------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--seg-bg); border: 1px solid var(--line); border-radius: 12px; }
.seg button, .seg a { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 var(--space-3); border: 0; background: transparent; border-radius: 9px; font-size: .8125rem; font-weight: 500; color: var(--muted); white-space: nowrap; text-decoration: none; transition: background .15s, color .15s, box-shadow .15s; }
.seg button .ico, .seg a .icon { width: 16px; height: 16px; }
.seg button:hover:not(.on):not(:disabled), .seg a:hover:not(.on) { color: var(--ink); text-decoration: none; }
.seg button.on, .seg a.on, .seg a[aria-current="true"] { background: var(--seg-on); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .05); }
.seg button.on .ico, .seg a.on .icon { color: var(--accent); }
.seg button:disabled { opacity: .4; cursor: default; }

/* ---------- menu (details based; works without JS) ---------- */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary.btn--ghost, .menu[open] > summary.btn.ghost { background: var(--hover); color: var(--ink); }
.menubox { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: var(--z-dropdown); min-width: 224px; padding: 6px; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-3); animation: pop .14s ease-out; }
.menubox > a, .menubox > button, .menubox form button { display: flex; align-items: center; gap: 10px; width: 100%; height: 38px; padding: 0 10px; border: 0; background: transparent; border-radius: 8px; font-size: .875rem; text-align: start; white-space: nowrap; color: var(--ink); text-decoration: none; }
.menubox .icon, .menubox .ico { width: 17px; height: 17px; color: var(--muted); }
.menubox > a:hover, .menubox > button:hover, .menubox form button:hover { background: var(--hover); text-decoration: none; color: var(--ink); }
.menubox .is-danger, .menubox .is-danger .icon { color: var(--danger); }
.menubox kbd, .menubox small { margin-inline-start: auto; }
.menubox small { font-size: .6875rem; color: var(--faint); }
.menubox .mh { padding: 6px 10px 3px; font-size: .6875rem; font-weight: 600; color: var(--faint); }
.menubox hr { margin: 5px 0; }
.menubox form { margin: 0; }

/* ---------- forms ---------- */
.field { margin-bottom: var(--space-4); }
.field > label, .field > .label { display: block; margin-bottom: 6px; font-size: .875rem; font-weight: 500; }
.field .req { color: var(--danger); font-weight: 400; font-size: .8125rem; }
.field .hint { margin: 6px 0 0; font-size: .8125rem; color: var(--muted); line-height: 1.6; }
.field .error { display: flex; gap: 6px; align-items: flex-start; margin: 6px 0 0; font-size: .8125rem; color: var(--danger); }
.input, .select, .textarea { display: block; width: 100%; min-height: 44px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm); font-size: 1rem; line-height: 1.6; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
@media (min-width: 1024px) { .input, .select { min-height: var(--h); } }
.textarea { min-height: 110px; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-2); cursor: not-allowed; }
.input[dir="ltr"], .input.ltr { text-align: left; }
.select { appearance: none; padding-inline-end: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238d8d96' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 12px center; background-size: 16px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: .9375rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: .4em; flex: 0 0 auto; accent-color: var(--accent); }
fieldset { margin: 0 0 var(--space-4); padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 6px; font-weight: 600; }
.counter { margin-inline-start: auto; font-size: .75rem; color: var(--faint); }
.hp { position: absolute; inset-inline-start: -9999px; width: 1px; height: 1px; overflow: hidden; }
.input-group { display: flex; gap: var(--space-2); }
.input-group > .input { flex: 1; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; margin-top: var(--space-6); }
.form-error-summary { margin-bottom: var(--space-4); }

/* ---------- alerts, badges, chips ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; margin-bottom: var(--space-4); border: 1px solid transparent; border-radius: var(--r-sm); font-size: .9375rem; line-height: 1.7; }
.alert .icon { margin-top: .25em; }
.alert__body { flex: 1; min-width: 0; }
.alert--success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.alert--warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.alert--danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert--info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.alert a { color: inherit; font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 10px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--muted); font-size: .75rem; font-weight: 500; white-space: nowrap; }
.badge--accent { background: var(--accent-soft); color: var(--accent-hover); }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--info { background: var(--info-soft); color: var(--info); }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 12px; border-radius: var(--r-pill); background: var(--surface-2); font-size: .8125rem; color: var(--muted); text-decoration: none; }
a.chip:hover { background: var(--accent-soft); color: var(--accent-hover); text-decoration: none; }

/* ---------- cards, tables, pagination, breadcrumbs ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--space-5); box-shadow: var(--shadow-1); }
.card--interactive { transition: border-color .15s, box-shadow .15s, transform .15s; }
.card--interactive:hover { border-color: var(--accent); box-shadow: var(--shadow-2); transform: translateY(-2px); }
.card__title { margin: 0 0 var(--space-2); font-size: 1.0625rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table caption { text-align: start; padding: var(--space-3) var(--space-4); font-weight: 600; }
.table th { padding: 10px var(--space-3); text-align: start; font-weight: 600; font-size: .8125rem; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px var(--space-3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--hover); }
.table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: end; white-space: nowrap; }
.pagination { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; margin: var(--space-7) 0 0; padding: 0; list-style: none; }
.pagination a, .pagination span { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); text-decoration: none; font-size: .875rem; }
.pagination a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pagination [aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.pagination .is-disabled { opacity: .4; }
.breadcrumbs { margin: 0 0 var(--space-4); font-size: .8125rem; color: var(--muted); }
.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.breadcrumbs li + li::before { content: "‹"; margin-inline-end: 6px; color: var(--faint); }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs [aria-current="page"] { color: var(--ink); }
.empty-state { padding: var(--space-9) var(--space-5); text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--r-md); color: var(--muted); background: var(--surface); }
.empty-state .icon { width: 44px; height: 44px; color: var(--faint); margin-bottom: var(--space-3); }
.empty-state h2, .empty-state h3 { margin: 0 0 6px; font-size: 1.125rem; color: var(--ink); }
.empty-state p { max-width: 46ch; margin-inline: auto; }
.progress { height: 8px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--line); }
.tabs button, .tabs a { position: relative; flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: 44px; padding: 0 4px; border: 0; background: transparent; font-size: .8125rem; font-weight: 500; color: var(--muted); white-space: nowrap; text-decoration: none; transition: color .15s; }
.tabs button:hover, .tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs button.on, .tabs a.on, .tabs [aria-selected="true"] { color: var(--ink); font-weight: 600; }
.tabs button.on::after, .tabs a.on::after, .tabs [aria-selected="true"]::after { content: ""; position: absolute; inset-inline: 6px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--accent); }

/* ---------- toasts + tooltip ---------- */
#toasts { position: fixed; bottom: 22px; inset-inline: 0; margin-inline: auto; width: max-content; max-width: 92vw; z-index: var(--z-toast); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; min-height: 42px; max-width: min(520px, 92vw); padding: 6px 8px; padding-inline-start: 14px; border-radius: var(--r-md); background: var(--inv-bg); color: var(--inv-text); font-size: .8125rem; pointer-events: auto; box-shadow: var(--shadow-3); animation: rise .2s ease-out; transition: opacity .2s, transform .2s; }
.toast > .ico, .toast > .icon { color: #4ade80; }
.toast.err > .ico, .toast.err > .icon { color: #f87171; }
.toast span { flex: 1; padding-inline: 6px; }
.toast button { height: 30px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--inv-btn); color: inherit; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.toast.out { opacity: 0; transform: translateY(6px); }
#tip { position: fixed; z-index: var(--z-tooltip); max-width: 270px; padding: 7px 10px; border-radius: 8px; background: var(--inv-bg); color: var(--inv-text); font-size: .75rem; line-height: 1.55; pointer-events: none; opacity: 0; box-shadow: var(--shadow-2); transition: opacity .12s; }
#tip.show { opacity: 1; }
#tip b { font-weight: 600; }
#tip kbd { height: 18px; margin-inline-start: 8px; border-color: transparent; background: var(--inv-btn); color: inherit; }
#tip small { display: block; margin-top: 2px; font-size: .72rem; opacity: .75; }

/* ---------- dialog ---------- */
dialog { width: min(560px, 94vw); padding: 0; border: 0; border-radius: var(--r-lg); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3); }
dialog::backdrop { background: rgba(10, 10, 14, .5); }
dialog[open] { animation: rise .2s ease-out; }
.dialog__head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.dialog__head h2 { margin: 0; font-size: 1.0625rem; }
.dialog__body { max-height: 74vh; overflow-y: auto; padding: 16px 20px 20px; }
.dialog__foot { display: flex; gap: var(--space-3); justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--line); }
.dh { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.dh h2 { margin: 0; font-size: 1rem; }
.dh form { margin: 0; }
.db { max-height: 74vh; overflow-y: auto; padding: 16px 20px 20px; }

/* ---------- misc layout helpers ---------- */
.stack > * + * { margin-top: var(--space-4); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.grid { display: grid; gap: var(--space-5); }
.grid--2 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.muted { color: var(--muted); }
.u-mt-0 { margin-top: 0 !important; } .u-mt-4 { margin-top: var(--space-4); } .u-mt-6 { margin-top: var(--space-6); } .u-mt-8 { margin-top: var(--space-8); }
.u-mb-0 { margin-bottom: 0 !important; } .u-text-center { text-align: center; }
.noscript-msg { padding: var(--space-4); background: var(--warning-soft); color: var(--warning); text-align: center; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
@media print {
  :root { --bg: #fff; --surface: #fff; --ink: #000; --muted: #333; --line: #bbb; }
  .no-print, header.site-header, footer.site-footer, .skip-link, #toasts { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  a { color: #000; text-decoration: underline; }
}

/* ---------- password field with show/hide ---------- */
.pw-wrap { position: relative; }
.pw-wrap .input { padding-left: 44px; } /* the page is always RTL: the toggle sits on the physical left */
.pw-toggle { position: absolute; inset-inline-end: 4px; top: 50%; translate: 0 -50%; display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--faint); cursor: pointer; }
.pw-toggle[hidden] { display: none; }
.pw-toggle:hover { background: var(--hover); color: var(--ink); }
.pw-toggle .icon { width: 18px; height: 18px; }

/* ---------- animated spot illustrations (partials/illus.php, IN-038) ---------- */
:root {
  --il-ink: #2B2D3A; --il-white: #FFFFFF; --il-line: #D6D1C6; --il-grid: #F0EEE9; --il-shadow: rgba(23, 24, 31, .07);
  --il-wall: #F4F1FF; --il-floor: #EFE7DA;
  --il-lav: #E6E0FF; --il-lav-dk: #6E5EE0; --il-sofa: #9C8CF0; --il-sofa-lt: #B4A7F5; --il-sofa-dk: #7F6DE3;
  --il-mint: #D7F0E3; --il-plant: #3FA67A; --il-plant-dk: #2E8B62; --il-plant-lt: #5DBE93;
  --il-peach: #F4A988; --il-peach-lt: #FFE3D6; --il-rose: #F2A7B5; --il-rug: #FFE3D6;
  --il-butter: #F2C14E; --il-butter-lt: #FFF1C6; --il-butter-dk: #C8962B; --il-tea: #C8643C;
  --il-sky: #DCE9FF; --il-wood: #CF9A66; --il-wood-lt: #E2B888; --il-wood-dk: #A8733F; --il-pot: #E08E6D; --il-pot-dk: #C9704E;
}
.ill { display: block; width: 100%; height: auto; overflow: visible; }
.ill-swing { animation: il-swing 4s ease-in-out infinite; }
@keyframes il-swing { 0%, 100% { transform: rotate(-2.5deg); } 50% { transform: rotate(2.5deg); } }
.ill-sway { animation: il-sway 4.2s ease-in-out infinite; }
@keyframes il-sway { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
.ill-glow { animation: il-glow 3.4s ease-in-out infinite; }
@keyframes il-glow { 0%, 100% { opacity: .7; } 50% { opacity: 1; } }
.ill-steam path { animation: il-rise 3s ease-in-out infinite; opacity: 0; }
.ill-steam path + path { animation-delay: 1.3s; }
@keyframes il-rise { 0% { opacity: 0; transform: translateY(5px); } 40% { opacity: .9; } 100% { opacity: 0; transform: translateY(-9px); } }
.ill-tw { animation: il-tw 2.6s ease-in-out infinite; }
.ill-tw + .ill-tw { animation-delay: 1.1s; }
@keyframes il-tw { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.ill-draw { stroke-dasharray: 900; animation: il-draw 6s ease-in-out infinite; }
@keyframes il-draw { 0% { stroke-dashoffset: 900; } 45%, 85% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -900; } }
.ill-bob { animation: il-bob 2.6s ease-in-out infinite; }
@keyframes il-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.ill-roll { animation: il-roll 3.2s ease-in-out infinite; }
@keyframes il-roll { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(78px); } }
.ill-stripe { animation: il-stripe 3.2s ease-in-out infinite; }
@keyframes il-stripe { 0%, 100% { transform: scaleY(.18); } 50% { transform: scaleY(1); } }
.ill-drip { animation: il-drip 3.2s ease-in infinite; opacity: 0; }
@keyframes il-drip { 0%, 55% { opacity: 0; transform: translateY(0); } 60% { opacity: 1; } 100% { opacity: 0; transform: translateY(70px); } }
.ill-breath { animation: il-breath 3s ease-in-out infinite; }
@keyframes il-breath { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(1.04); } }
.ill-tail { animation: il-tail 3.2s ease-in-out infinite; }
@keyframes il-tail { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-10deg); } }
.ill-zz text { animation: il-zz 3s ease-in-out infinite; opacity: 0; }
.ill-zz text:nth-child(2) { animation-delay: 1s; } .ill-zz text:nth-child(3) { animation-delay: 2s; }
@keyframes il-zz { 0% { opacity: 0; transform: translate(0, 4px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(-6px, -8px); } }
.ill-door { animation: il-door 5s ease-in-out infinite; }
@keyframes il-door { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(.86); } }
.ill-flap { animation: il-flap 3.6s ease-in-out infinite; }
.ill-flap--b { animation-delay: .4s; }
@keyframes il-flap { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-6deg); } }
.ill-flap--b { animation-name: il-flap-b; } @keyframes il-flap-b { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(6deg); } }
.ill-tape { animation: il-tape 3.6s ease-in-out infinite; }
@keyframes il-tape { 0%, 100% { transform: scaleX(.15); } 55%, 80% { transform: scaleX(1); } }
.ill-slide { animation: il-slide 3.8s ease-in-out infinite; }
@keyframes il-slide { 0%, 15% { transform: translate(-70px, 34px); } 60%, 100% { transform: translate(0, 0); } }
.ill-cursor { animation: il-cursor 3.8s ease-in-out infinite; }
@keyframes il-cursor { 0%, 15% { transform: translate(-64px, 22px); } 60%, 100% { transform: translate(0, 0); } }
.ill-sun { animation: il-sun 6s ease-in-out infinite; }
@keyframes il-sun { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-18px, 8px); } }
.ill-walk { animation: il-walk 5s ease-in-out infinite; }
@keyframes il-walk { 0%, 100% { transform: translate(-14px, 6px); } 50% { transform: translate(14px, -4px); } }
.ill-swing, .ill-sway, .ill-steam path, .ill-tw, .ill-bob, .ill-roll, .ill-stripe, .ill-drip, .ill-breath, .ill-tail, .ill-zz text, .ill-door, .ill-flap, .ill-tape, .ill-slide, .ill-cursor, .ill-sun, .ill-walk { transform-box: view-box; }
@media (prefers-reduced-motion: reduce) {
  .ill * { animation: none !important; }
  .ill-steam path, .ill-zz text { opacity: .8; }
  .ill-draw { stroke-dasharray: none; }
}
.ill-empty { display: grid; justify-items: center; gap: var(--space-2); text-align: center; padding: var(--space-6) var(--space-4); }
.ill-empty .ill { max-width: 280px; }
.ill-empty h2 { margin: var(--space-2) 0 0; font-size: 1.125rem; }
.ill-empty p { margin: 0; color: var(--muted); max-width: 40ch; }
.empty-state--art { border-style: solid; border-color: var(--line); background: linear-gradient(180deg, var(--surface), var(--surface-2)); padding-block: var(--space-7); }
.empty-state--art .ill { max-width: 240px; margin: 0 auto var(--space-4); }
.empty-state--art .btn-row, .empty-state--art > .btn { margin-top: var(--space-4); }
/* pastel tones for icon chips and tiles (IN-038): set --tone/--tone-d and paint with them */
.tone-lav { --tone: var(--lav); --tone-d: var(--lav-d); } .tone-mint { --tone: var(--mint); --tone-d: var(--mint-d); }
.tone-peach { --tone: var(--peach); --tone-d: var(--peach-d); } .tone-sky { --tone: var(--sky); --tone-d: var(--sky-d); }
.tone-butter { --tone: var(--butter); --tone-d: var(--butter-d); }
