/* ══════════════════════════════════════════════════════════════
   DesignBase — Design Tokens & Global Styles
══════════════════════════════════════════════════════════════ */

/* ── Dark Theme (default) ─────────────────────────────────── */
:root {
    --bg-base:          #070B14;
    --bg-surface:       #0D1321;
    --bg-elevated:      #131B2E;

    --glass-bg:         rgba(255,255,255,0.04);
    --glass-bg-hover:   rgba(255,255,255,0.07);
    --glass-border:     rgba(255,255,255,0.08);
    --glass-blur:       16px;
    --glass-shadow:     0 8px 32px rgba(0,0,0,0.45);
    --glass-glow:       0 0 0 1px rgba(99,102,241,0.2), 0 8px 32px rgba(0,0,0,0.45);

    --clr-primary:      #6366F1;
    --clr-primary-rgb:  99,102,241;
    --clr-secondary:    #818CF8;
    --clr-accent:       #10B981;
    --clr-accent-rgb:   16,185,129;
    --clr-warning:      #F59E0B;
    --clr-danger:       #EF4444;
    --clr-info:         #06B6D4;
    --clr-fatal:        #A855F7;

    --text-primary:     #F1F5F9;
    --text-secondary:   #94A3B8;
    /* #475569 on #070B14 was 2.6:1; section labels, info-row labels and the empty state are set in
       it, and 4.5:1 is the AA floor for small text. #6C7A93 measures 4.55:1. (v2) */
    --text-muted:       #6C7A93;

    --navbar-bg:        rgba(7,11,20,0.82);
    --navbar-border:    rgba(255,255,255,0.06);

    --badge-pending-bg:    rgba(245,158,11,0.15);
    --badge-pending-clr:   #F59E0B;
    --badge-processing-bg: rgba(99,102,241,0.15);
    --badge-processing-clr:#818CF8;
    --badge-completed-bg:  rgba(16,185,129,0.15);
    --badge-completed-clr: #10B981;
    --badge-failed-bg:     rgba(239,68,68,0.15);
    --badge-failed-clr:    #EF4444;

    --blob-1-clr:   rgba(99,102,241,0.18);
    --blob-2-clr:   rgba(16,185,129,0.12);
    --blob-3-clr:   rgba(129,140,248,0.10);

    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms cubic-bezier(.22,1,.36,1);

    --radius-sm:  8px;
    --radius-md:  14px;
    --radius-lg:  20px;
    --radius-xl:  28px;
}

/* ── Light Theme ──────────────────────────────────────────── */
[data-theme="light"] {
    --bg-base:          #EEEEFF;
    --bg-surface:       #F5F3FF;
    --bg-elevated:      #FFFFFF;

    --glass-bg:         rgba(255,255,255,0.72);
    --glass-bg-hover:   rgba(255,255,255,0.90);
    --glass-border:     rgba(99,102,241,0.14);
    --glass-blur:       16px;
    --glass-shadow:     0 4px 24px rgba(99,102,241,0.10);
    --glass-glow:       0 0 0 1px rgba(99,102,241,0.22), 0 4px 24px rgba(99,102,241,0.14);

    --clr-primary:      #4F46E5;
    --clr-primary-rgb:  79,70,229;
    --clr-secondary:    #6366F1;
    --clr-accent:       #059669;
    --clr-accent-rgb:   5,150,105;
    --clr-warning:      #D97706;
    --clr-danger:       #DC2626;
    --clr-info:         #0284C7;
    --clr-fatal:        #7E22CE;

    --text-primary:     #1E1B4B;
    --text-secondary:   #4B5563;
    --text-muted:       #5B6472;   /* v2: 4.5:1 on the light surfaces too */

    --navbar-bg:        rgba(238,238,255,0.88);
    --navbar-border:    rgba(99,102,241,0.12);

    --badge-pending-bg:    rgba(217,119,6,0.12);
    --badge-pending-clr:   #92400E;
    --badge-processing-bg: rgba(79,70,229,0.12);
    --badge-processing-clr:#4338CA;
    --badge-completed-bg:  rgba(5,150,105,0.12);
    --badge-completed-clr: #065F46;
    --badge-failed-bg:     rgba(220,38,38,0.12);
    --badge-failed-clr:    #991B1B;

    --blob-1-clr:   rgba(99,102,241,0.10);
    --blob-2-clr:   rgba(16,185,129,0.07);
    --blob-3-clr:   rgba(129,140,248,0.08);
}

/* ── Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
    font-size: 14px;
    scroll-behavior: smooth;
}
@media (min-width: 768px) { html { font-size: 16px; } }

body {
    font-family: 'IRANSansX', Tahoma, sans-serif;
    direction: rtl;
    text-align: right;
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.3s ease;
    margin-bottom: 0;
    line-height: 1.65;
}

/* Form controls don't inherit font-family by browser default, and Tailwind
   preflight is disabled — force them to use the app font (IRANSansX). */
button, input, select, textarea, optgroup {
    font-family: inherit;
    font-size: 100%;
    line-height: 1.15;
}
button, [type="button"], [type="submit"], [type="reset"] {
    -webkit-appearance: button;
}

/* ── Page Progress Bar ────────────────────────────────────── */
#page-progress {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--clr-primary), var(--clr-accent));
    z-index: 10000;
    transform-origin: right;
    animation: progressLoad .9s ease forwards;
}
@keyframes progressLoad {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}

/* ── Scroll Progress ──────────────────────────────────────── */
#scroll-progress {
    position: fixed;
    top: 0; left: 0;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, var(--clr-primary), var(--clr-accent));
    z-index: 10001;
    border-radius: 0 2px 2px 0;
    transition: width .12s linear;
    pointer-events: none;
}

/* ── Decorative Blobs ─────────────────────────────────────── */
.blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(90px);
    pointer-events: none;
    z-index: 0;
    will-change: transform;
    transition: background-color 0.5s ease;
}
.blob-1 {
    width: 520px; height: 520px;
    top: -120px; right: -80px;
    background: var(--blob-1-clr);
    animation: blobFloat1 14s ease-in-out infinite;
}
.blob-2 {
    width: 420px; height: 420px;
    bottom: 8%; left: -70px;
    background: var(--blob-2-clr);
    animation: blobFloat2 17s ease-in-out infinite;
}
.blob-3 {
    width: 360px; height: 360px;
    top: 40%; right: 38%;
    background: var(--blob-3-clr);
    animation: blobFloat3 20s ease-in-out infinite;
}
@keyframes blobFloat1 {
    0%,100% { transform: translate(0,0) scale(1); }
    50%      { transform: translate(-28px,44px) scale(1.07); }
}
@keyframes blobFloat2 {
    0%,100% { transform: translate(0,0) scale(1); }
    50%      { transform: translate(38px,-28px) scale(1.06); }
}
@keyframes blobFloat3 {
    0%,100% { transform: translate(0,0) scale(1); }
    50%      { transform: translate(-18px,22px) scale(0.94); }
}

/* ── Toast System ─────────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 2rem; left: 50%;
    transform: translateX(-50%);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .6rem;
    pointer-events: none;
}
.toast-msg {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .7rem 1.5rem;
    border-radius: 50px;
    font-size: .875rem;
    font-weight: 600;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid;
    pointer-events: auto;
    animation: toastIn .3s ease-out forwards;
    box-shadow: 0 8px 32px rgba(0,0,0,.28);
    white-space: nowrap;
}
.toast-success { background:rgba(16,185,129,.15);  border-color:rgba(16,185,129,.35);  color:#10B981; }
.toast-error   { background:rgba(239,68,68,.15);   border-color:rgba(239,68,68,.35);   color:#EF4444; }
.toast-info    { background:rgba(99,102,241,.15);  border-color:rgba(99,102,241,.35);  color:#818CF8; }
.toast-warning { background:rgba(245,158,11,.15);  border-color:rgba(245,158,11,.35);  color:#F59E0B; }
.toast-msg.fade-out { animation: toastOut .3s ease-in forwards; }

[data-theme="light"] .toast-info    { color: #4338CA; }
[data-theme="light"] .toast-success { color: #065F46; }
[data-theme="light"] .toast-error   { color: #991B1B; }
[data-theme="light"] .toast-warning { color: #92400E; }

@keyframes toastIn  { from { transform:translateY(18px); opacity:0; } to { transform:translateY(0); opacity:1; } }
@keyframes toastOut { from { transform:translateY(0); opacity:1; } to { transform:translateY(18px); opacity:0; } }

/* ── Scroll Entrance Animations ───────────────────────────── */
/* Hide only when JS is active (html.js). Without JS — or before it
   runs — content stays fully visible, so a script error or slow load
   can never leave the page blank. */
.js .animate-in, .js .animate-scale, .js .animate-left, .js .animate-blur, .js .animate-flip3d {
    opacity: 0;
    will-change: opacity, transform;
}
.animate-in, .animate-scale, .animate-left, .animate-blur, .animate-flip3d {
    transition: opacity .55s var(--transition-slow), transform .55s var(--transition-slow);
}
.js .animate-in    { transform: translateY(24px); }
.js .animate-scale { transform: scale(.93); }
.js .animate-left  { transform: translateX(26px); }
.js .animate-blur  {
    transform: translateY(14px);
    filter: blur(8px);
    transition: opacity .5s ease, transform .5s ease, filter .5s ease;
}
/* 3D flip-in — perspective is embedded in the transform value itself,
   so no parent `perspective` property is needed. */
.js .animate-flip3d { transform: perspective(1200px) rotateY(-28deg) scale(.94); }
.animate-in.visible,
.animate-scale.visible,
.animate-left.visible,
.animate-flip3d.visible { opacity: 1; transform: none; }
.animate-blur.visible  { opacity: 1; transform: none; filter: blur(0); }

/* ── Counter Flash ────────────────────────────────────────── */
@keyframes numberFlash {
    0%   { color: var(--text-primary); }
    50%  { color: var(--clr-accent); }
    100% { color: var(--text-primary); }
}

/* ── Ripple ───────────────────────────────────────────────── */
.btn-ripple-host { position: relative; overflow: hidden; }
.ripple-circle {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,.22);
    animation: rippleAnim .55s ease-out forwards;
    pointer-events: none;
    transform: scale(0);
}
@keyframes rippleAnim { to { transform: scale(1); opacity: 0; } }

/* ── Badge Bounce ─────────────────────────────────────────── */
.badge {
    animation: badgeBounce .4s cubic-bezier(.175,.885,.32,1.275) both;
}
@keyframes badgeBounce {
    from { transform: scale(0.5); opacity:0; }
    to   { transform: scale(1);   opacity:1; }
}

/* ── Bootstrap Card Override ──────────────────────────────── */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--glass-shadow);
    color: var(--text-primary);
    transition: background var(--transition-base), box-shadow var(--transition-base);
}
.card-header {
    background: rgba(var(--clr-primary-rgb), 0.06) !important;
    border-bottom: 1px solid var(--glass-border) !important;
    color: var(--text-primary) !important;
    font-weight: 600;
}
.card-body { color: var(--text-primary); }

/* ── Tables ───────────────────────────────────────────────── */
.table {
    --bs-table-color: var(--text-primary);
    --bs-table-bg: transparent;
    --bs-table-accent-bg: transparent;
}
.table th, .table td {
    text-align: right;
    vertical-align: middle;
    border-color: var(--glass-border);
}
.table th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: .84rem;
    letter-spacing: .02em;
    text-transform: uppercase;
    white-space: nowrap;
}
.table-dark {
    --bs-table-bg: rgba(0,0,0,0.22);
    --bs-table-color: var(--text-secondary);
    --bs-table-border-color: var(--glass-border);
}
[data-theme="light"] .table-dark {
    --bs-table-bg: rgba(var(--clr-primary-rgb),0.06);
    --bs-table-color: var(--text-secondary);
}
.table-hover tbody tr:hover {
    --bs-table-accent-bg: rgba(var(--clr-primary-rgb), 0.07);
}

/* ── Forms ────────────────────────────────────────────────── */
.form-control, .form-select {
    background: var(--glass-bg) !important;
    border-color: var(--glass-border) !important;
    color: var(--text-primary) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: var(--radius-sm) !important;
    transition: border-color var(--transition-base),
                box-shadow var(--transition-base),
                transform var(--transition-base);
}
.form-control:focus, .form-select:focus {
    background: var(--glass-bg-hover) !important;
    border-color: var(--clr-primary) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 0 0 3px rgba(var(--clr-primary-rgb), 0.22) !important;
    outline: none;
}
.form-control::placeholder { color: var(--text-muted); text-align: end; }
.form-control:focus::placeholder { text-align: start; }
.form-label { color: var(--text-secondary); font-size: .9rem; }

/* Native <option> popups can't render the translucent glass bg — without a solid color they
   fall back to white while our light text stays light, making options invisible in dark mode. */
.form-select option,
.form-select optgroup {
    background-color: var(--bg-elevated);
    color: var(--text-primary);
}

/* ── Buttons ──────────────────────────────────────────────── */

/* Geometry belongs to .btn and the size modifiers — never to a variant. A variant class carries
   colour and nothing else. When .btn-grad and .btn-glass each declared their own padding, two
   things broke at once: .btn-sm was silently cancelled (same specificity, and this file loads
   after app.css, so the variant won), and .btn-danger-soft — which declares no padding — came out
   a different size from the button beside it. Both are §11.1 failures. Keep size in one place.

   vertical-align: an inline-flex box takes its baseline from its *first flex item*, so a button
   starting with a Font Awesome <i> and one starting with text sat on two different baselines —
   1.39px apart in the Publishers table. middle removes the dependency on the content entirely.

   min-height: a Font Awesome glyph makes a shorter line box than a run of IRANSansX, so without a
   floor an icon-only trash button rendered 25px next to a 45px "ویرایش".

   40px is the height of .field .form-control and of the Select2 box (vendor-theme.css), and it is
   px for the same reason they are: the root font is 14px below 768px, so a rem floor would put the
   button and the field at two different heights on a phone. A filter row aligns its items at the
   bottom, so equal heights is also what gives it one vertical centre — at the old 2.75rem plus
   .7rem padding the button came out 48px, its centre 4px above the search box beside it (eCaaS,
   1405/08/07). The smaller font is what lets the label sit in the shorter box without crowding. */
.btn {
    vertical-align: middle;
    min-height: 40px;
    padding: .4rem 1.5rem;
    font-size: .9rem;
    border-radius: 50px;
}
.btn-sm {
    min-height: 2rem;
    padding: .3rem 1.1rem;
    font-size: .85rem;
}
/* Restated here because .btn above now sets font-size, which would otherwise silently cancel
   app.css's .btn-lg (same specificity, this file loads later). For a lone call to action only —
   never beside a field. */
.btn-lg {
    min-height: 48px;
    padding: .6rem 2rem;
    font-size: 1rem;
}

/* Standing rule (docs/UI-Conventions.md §11.2): a button inside a table is never large. Enforced in
   CSS rather than trusting every view to remember .btn-sm — the row of oversized pills in
   Publishers is what the rule was written for, and a rule that must be remembered gets forgotten. */
.table .btn {
    min-height: 2rem;
    padding: .3rem 1.1rem;
    font-size: .85rem;
}

.btn-primary {
    background: var(--clr-primary) !important;
    border-color: var(--clr-primary) !important;
    color: #fff !important;
}
.btn-primary:hover {
    background: var(--clr-secondary) !important;
    border-color: var(--clr-secondary) !important;
    box-shadow: 0 4px 20px rgba(var(--clr-primary-rgb), 0.4) !important;
}
.btn-grad {
    background: linear-gradient(135deg, var(--clr-primary), var(--clr-secondary));
    /* transparent, not none: .btn-glass and .btn-danger-soft carry a real 1px border, so `none`
       here made every gradient button 2px shorter than the button next to it. The gradient paints
       under the transparent border, so this costs nothing visually. */
    border: 1px solid transparent;
    color: #fff;
    font-weight: 600;
    transition: box-shadow var(--transition-base), transform var(--transition-slow);
    box-shadow: 0 4px 20px rgba(var(--clr-primary-rgb), 0.35);
    cursor: pointer;
}
.btn-grad:hover {
    box-shadow: 0 6px 30px rgba(var(--clr-primary-rgb), 0.5);
    color: #fff;
}
.btn-glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-weight: 600;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all var(--transition-base);
    cursor: pointer;
}
.btn-glass:hover {
    background: var(--glass-bg-hover);
    border-color: rgba(var(--clr-primary-rgb), 0.4);
    color: var(--clr-primary);
}
.btn:focus, .btn:active:focus,
.form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(var(--clr-primary-rgb), 0.28) !important;
    outline: none;
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
    border-radius: var(--radius-sm) !important;
    backdrop-filter: blur(8px);
}
.alert-info    { background:rgba(6,182,212,.08)  !important; border-color:rgba(6,182,212,.22)  !important; color:var(--clr-info)    !important; }
.alert-danger  { background:rgba(239,68,68,.08)  !important; border-color:rgba(239,68,68,.22)  !important; color:var(--clr-danger)  !important; }
.alert-success { background:rgba(16,185,129,.08) !important; border-color:rgba(16,185,129,.22) !important; color:var(--clr-accent)  !important; }
.alert-warning { background:rgba(245,158,11,.08) !important; border-color:rgba(245,158,11,.22) !important; color:var(--clr-warning) !important; }
[data-theme="light"] .alert-info    { color:var(--clr-info)    !important; }
[data-theme="light"] .alert-danger  { color:var(--clr-danger)  !important; }
[data-theme="light"] .alert-success { color:var(--clr-accent)  !important; }
[data-theme="light"] .alert-warning { color:var(--clr-warning) !important; }

/* ── Misc ─────────────────────────────────────────────────── */
.text-muted  { color: var(--text-secondary) !important; }
.text-primary-clr { color: var(--clr-primary) !important; }
code.small {
    color: var(--clr-secondary);
    background: rgba(var(--clr-primary-rgb),.1);
    padding: .15em .45em;
    border-radius: 4px;
    font-size: .82em;
}
hr { border-color: var(--glass-border); opacity: 1; }
a { color: var(--clr-secondary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--clr-primary); }
.list-group-item {
    background: var(--glass-bg) !important;
    border-color: var(--glass-border) !important;
    color: var(--text-primary) !important;
    transition: background var(--transition-fast);
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 576px) {
    .blob { opacity: .6; }
}

/* ── Reduced Motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    /* The confirm dialog is not listed: its entrance is already wrapped in a
       prefers-reduced-motion: no-preference query at the bottom of this file. */
    .blob, #page-progress, .ripple-circle, .badge,
    .animate-in, .animate-scale, .animate-left, .animate-blur, .animate-flip3d { animation: none !important; }
    * { transition-duration: .01ms !important; }
}

/* ── Confirm dialog ───────────────────────────────────────── */
/* Standing rule (docs/UI-Conventions.md §11.4): never window.confirm/alert. The native <dialog> is used
   rather than a hand-rolled overlay because showModal() gives the top layer, the focus trap, Esc
   and inertness of the page behind for free — all the parts a bespoke modal gets wrong. */
.confirm-dialog {
    width: min(30rem, calc(100vw - 2rem));
    padding: 0;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
    color: var(--text-primary);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
.confirm-dialog::backdrop {
    background: rgba(3, 7, 18, .62);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.confirm-dialog__head {
    display: flex; align-items: center; gap: .6rem;
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--glass-border);
    font-weight: 700;
}
.confirm-dialog__icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 2.2rem; height: 2.2rem; flex: 0 0 auto;
    border-radius: 50%;
    background: rgba(var(--clr-primary-rgb), .14);
    color: var(--clr-primary);
}
.confirm-dialog--danger .confirm-dialog__icon {
    background: rgba(239, 68, 68, .14);
    color: var(--clr-danger);
}
.confirm-dialog__body {
    padding: 1.3rem 1.4rem;
    color: var(--text-secondary);
    line-height: 1.9;
}
.confirm-dialog__foot {
    display: flex; align-items: center; justify-content: flex-start; gap: .6rem;
    padding: 1rem 1.4rem;
    border-top: 1px solid var(--glass-border);
}
/* The dialog is appended to <body>, outside .table, so the table sizing rule cannot reach it —
   these buttons are deliberately full size. */
.confirm-dialog__foot .btn { min-height: 40px; }
/* Three answers (the period's send dialog) are wider than the dialog: they wrap instead of giving the
   dialog a horizontal scrollbar. */
.confirm-dialog__foot { flex-wrap: wrap; }

/* A form in a dialog (the ledger's «ثبت پرداخت»): taller than a short laptop screen, so only the
   body scrolls and the title and the submit button stay in view. Left to itself the whole dialog
   scrolled with the browser's light scrollbar, and select2's dropdown, positioned inside the
   dialog, came out shifted by that scrollbar's width on an RTL page. */
.confirm-dialog--form { width: min(34rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); overflow: hidden; }
.confirm-dialog--form > form { display: flex; flex-direction: column; max-height: calc(100dvh - 2rem); }
.confirm-dialog--form .confirm-dialog__body {
    flex: 1 1 auto; min-height: 0; overflow-y: auto;
    scrollbar-width: thin; scrollbar-color: var(--glass-border) transparent;
}

/* prefers-reduced-motion is honoured: the entrance is decoration, and a confirm dialog that
   animates for a user who asked it not to is a bug, not a flourish. */
@media (prefers-reduced-motion: no-preference) {
    .confirm-dialog[open] { animation: confirm-dialog-in var(--transition-slow) both; }
    @keyframes confirm-dialog-in {
        from { opacity: 0; transform: translateY(-8px) scale(.97); }
        to   { opacity: 1; transform: none; }
    }
}


/* ══════════════════════════════════════════════════════════════
   v2 (1405/08/07) — tokens, accessibility, forms, feedback.
   Additive: every class the v1 panel used still exists above. The
   demo that decided each block is demos/admin-panel-v2.html; the
   migration notes are docs/Admin-Panel-Upgrade.md.
══════════════════════════════════════════════════════════════ */

/* ── Tokens added in v2 ───────────────────────────────────── */
:root {
    --focus-ring:     0 0 0 2px var(--bg-base), 0 0 0 4px var(--clr-primary);
    --surface-sticky: rgba(13,19,33,.92);
    --row-hover:      rgba(var(--clr-primary-rgb), .07);
    --row-selected:   rgba(var(--clr-primary-rgb), .12);
    --sidebar-w:      264px;
    --sidebar-rail-w: 76px;
    --topbar-h:       64px;
    /* Density: <html data-density="compact"> tightens tables and cards (~40% shorter rows). */
    --cell-py:  .7rem;
    --cell-px:  .9rem;
    --card-pad: 1.25rem;
}
[data-theme="light"] { --surface-sticky: rgba(245,243,255,.94); }
[data-density="compact"] { --cell-py: .42rem; --cell-px: .7rem; --card-pad: .9rem; }

/* ── Persian typography (RTL) ─────────────────────────────── */
/* letter-spacing opens gaps between joined Arabic-script letters and text-transform does nothing
   to Persian; both were on the table headers and the sidebar section labels. Tabular numerals so
   a column of amounts lines up; the FaNum font supports the feature. */
.table th { letter-spacing: 0; text-transform: none; font-weight: 600; font-size: .8rem; }
.admin-sidebar__section { letter-spacing: 0; text-transform: none; font-weight: 600; }
.num, .table td[data-type="number"], .metric-value, .kpi__value {
    font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1;
}
/* The placeholder no longer jumps from the end to the start of the field on focus. */
.form-control::placeholder { text-align: start; }
.form-control:focus::placeholder { text-align: start; }

/* ── Keyboard focus and skip link ─────────────────────────── */
/* A two-ring focus (page colour, then brand colour) is visible on every background, glass included. */
:focus-visible { outline: none; box-shadow: var(--focus-ring) !important; border-radius: var(--radius-sm); }
.skip-link {
    position: fixed; top: -100px; inset-inline-start: 1rem; z-index: 10002;
    padding: .6rem 1rem; border-radius: var(--radius-sm);
    background: var(--clr-primary); color: #fff; font-weight: 600; transition: top var(--transition-fast);
}
.skip-link:focus { top: 1rem; }

/* ── Calm motion (admin) ──────────────────────────────────── */
/* <html data-motion="calm">: animations.js skips blobs and tilt; this keeps a card flat even if a
   stale script set an inline transform, and shows entrance elements at once after the first page
   of the session (html.seen is stamped by animations.js). */
[data-motion="calm"] .metric-card, [data-motion="calm"] .kpi { transform: none !important; }
[data-motion="calm"] .blob { display: none; }
html.seen .animate-in, html.seen .animate-scale, html.seen .animate-left, html.seen .animate-blur, html.seen .animate-flip3d {
    opacity: 1; transform: none; filter: none; transition: none;
}

/* ── Tooltips without a library: data-tip="…" (+ data-tip-pos="bottom") ── */
[data-tip] { position: relative; }
[data-tip]::after {
    content: attr(data-tip);
    position: absolute; top: 50%; inset-inline-end: calc(100% + 10px); transform: translate(-6px, -50%);
    padding: .3rem .6rem; border-radius: 6px;
    background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow); font-size: .75rem; font-weight: 500; white-space: nowrap;
    font-family: 'IRANSansX', Tahoma, sans-serif;
    pointer-events: none; opacity: 0; transition: opacity var(--transition-fast), transform var(--transition-fast); z-index: 1050;
}
[data-tip][data-tip-pos="bottom"]::after { top: calc(100% + 8px); inset-inline-end: 50%; transform: translate(50%, -4px); }
[data-tip][data-tip-pos="bottom"]:hover::after, [data-tip][data-tip-pos="bottom"]:focus-visible::after { opacity: 1; transform: translate(50%, 0); }
.table [data-tip]:hover::after, .table [data-tip]:focus-visible::after,
.repeater [data-tip]:hover::after { opacity: 1; transform: translate(0, -50%); }

/* ── Icon-only button (needs data-tip or aria-label) ─────── */
.icon-btn {
    width: 36px; height: 36px; min-height: 36px !important; padding: 0 !important;
    border-radius: var(--radius-sm) !important; display: inline-grid; place-items: center;
    background: var(--glass-bg); border: 1px solid var(--glass-border); color: var(--text-secondary); cursor: pointer;
}
.icon-btn:hover { color: var(--clr-primary); border-color: rgba(var(--clr-primary-rgb), .4); background: var(--glass-bg-hover); }
.icon-btn--danger:hover { color: var(--clr-danger); border-color: rgba(239,68,68,.4); }
.table .icon-btn { width: 32px; height: 32px; min-height: 32px !important; }

/* ── Keyboard key ─────────────────────────────────────────── */
.kbd {
    font-family: inherit; font-size: .7rem; padding: .05rem .4rem; border-radius: 4px;
    border: 1px solid var(--glass-border); color: var(--text-muted); direction: ltr; display: inline-block;
}
.kbd--onbtn { opacity: .75; margin-inline-start: .3rem; color: inherit; border-color: rgba(255,255,255,.35); }

/* ── Status = icon + text, never colour alone ─────────────── */
.status { display: inline-flex; align-items: center; gap: .35rem; }
.status::before { font-family: 'Font Awesome 7 Pro', 'Font Awesome 6 Free'; font-weight: 900; font-size: .65rem; }
.status--success::before { content: '\f00c'; }
.status--warning::before { content: '\f071'; }
.status--error::before   { content: '\f00d'; }
.status--info::before    { content: '\f017'; }
.chip-success { background: rgba(var(--clr-accent-rgb),.15); color: var(--clr-accent); border-color: rgba(var(--clr-accent-rgb),.3); }
/* hidden must beat the display of these inline-flex elements. */
.chip[hidden], .btn[hidden], .link-btn[hidden], .draft-status[hidden] { display: none !important; }
.chip-btn { cursor: pointer; }
.chip-btn:hover { border-color: var(--clr-primary); color: var(--clr-primary); }
.link-btn { border: 0; background: none; color: var(--clr-primary); font-size: .8rem; font-weight: 600; cursor: pointer; display: inline-flex; gap: .3rem; align-items: center; }

/* ── Validation (jquery-validation-unobtrusive) ───────────── */
/* These are the classes the real panel emits through <span asp-validation-for> and
   <div asp-validation-summary>; until v2 nothing styled them. */
.input-validation-error,
.field:has(.input-validation-error) .select2-selection--single,
.field:has(.input-validation-error) .select2-selection--multiple {
    border-color: var(--clr-danger) !important; box-shadow: 0 0 0 3px rgba(239,68,68,.15) !important;
}
.field-validation-error { display: flex; align-items: center; gap: .3rem; margin-top: .3rem; font-size: .76rem; color: var(--clr-danger); }
.field-validation-error::before { content: '\f06a'; font-family: 'Font Awesome 7 Pro', 'Font Awesome 6 Free'; font-weight: 900; font-size: .7rem; }
.field-validation-valid { display: none; }
.val-summary, .validation-summary-errors {
    display: none; margin: var(--card-pad); margin-bottom: 0; padding: .85rem 1rem; border-radius: var(--radius-sm);
    background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.25);
}
.validation-summary-errors { display: block; animation: menuIn .18s ease both; }
.validation-summary-valid { display: none; }
.val-summary__head { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--clr-danger); margin-bottom: .35rem; }
.val-summary ul, .validation-summary-errors ul { margin: 0; padding-inline-start: 1.4rem; font-size: .82rem; color: var(--text-secondary); line-height: 1.9; }
.val-summary ul a { color: var(--text-primary); text-decoration: underline dotted; text-underline-offset: 3px; }
.val-summary ul a:hover { color: var(--clr-danger); }
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ── Forms v2 ─────────────────────────────────────────────── */
.fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.fieldset:disabled { opacity: .6; pointer-events: none; }
.form-section { padding: var(--card-pad); border-bottom: 1px solid var(--glass-border); }
.form-section:last-of-type { border-bottom: 0; }
.form-section__title { display: flex; align-items: baseline; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.form-section__title h3 { font-size: 1rem; font-weight: 700; margin: 0; }
.form-section__title small { color: var(--text-muted); font-size: .78rem; }
.form-section__title .ms-auto { margin-inline-start: auto; }
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 1rem; }
.form-grid > * { grid-column: span 12; }
@media (min-width: 768px) {
    .form-grid .span-3 { grid-column: span 3; } .form-grid .span-4 { grid-column: span 4; } .form-grid .span-5 { grid-column: span 5; }
    .form-grid .span-6 { grid-column: span 6; } .form-grid .span-8 { grid-column: span 8; } .form-grid .span-12 { grid-column: span 12; }
}
.field label { display: block; font-size: .8rem; color: var(--text-secondary); margin-bottom: .3rem; font-weight: 500; }
.field .form-control { height: 40px; }
.field textarea.form-control { height: auto; }
.field .req::after { content: ' *'; color: var(--clr-danger); font-weight: 700; }
.field .help { display: block; margin-top: .3rem; font-size: .75rem; color: var(--text-muted); }
.field .err { display: none; margin-top: .3rem; font-size: .76rem; color: var(--clr-danger); align-items: center; gap: .3rem; }
.field .counter { float: inline-end; font-size: .72rem; color: var(--text-muted); }
.field .counter.warn { color: var(--clr-warning); }
.field .counter.over { color: var(--clr-danger); font-weight: 700; }
textarea.autogrow { resize: none; overflow: hidden; min-height: 2.6rem; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-start: .8rem; color: var(--text-muted); font-size: .85rem; pointer-events: none; }
.input-icon > .form-control { padding-inline-start: 2.2rem; }
/* A green tick inside a required field once jquery-validate marks it .valid. */
.input-wrap { position: relative; }
.input-wrap .field-tick { position: absolute; top: 50%; inset-inline-start: .7rem; transform: translateY(-50%); color: var(--clr-accent); font-size: .85rem; opacity: 0; transition: opacity var(--transition-fast); pointer-events: none; }
.input-wrap:has(> .form-control.valid:not(:placeholder-shown)) .field-tick { opacity: 1; }
.input-wrap:has(> .form-control.valid:not(:placeholder-shown)) .form-control { padding-inline-start: 2rem; }
.form-control.is-locked { color: var(--text-muted); background: rgba(148,163,184,.06) !important; cursor: not-allowed; }
.locked-ico { font-size: .7rem; color: var(--text-muted); margin-inline-start: .3rem; }

/* Input groups: prefix/suffix addons and addon buttons share the control's height and border.
   Corners are PHYSICAL and decided by the group's direction: logical corner properties resolve
   against each child's own direction, and a dir="ltr" input inside an RTL group then rounds the
   wrong side (seen on the password field). */
.input-group { display: flex; align-items: stretch; width: 100%; }
.input-group > .form-control, .input-group > .input-wrap { flex: 1 1 auto; min-width: 0; width: auto; }
.input-group > .form-control, .input-group > .input-wrap > .form-control { height: 40px; }
.input-group:not([dir="ltr"]) > :not(:first-child), .input-group:not([dir="ltr"]) > .input-wrap:not(:first-child) > .form-control { border-top-right-radius: 0 !important; border-bottom-right-radius: 0 !important; }
.input-group:not([dir="ltr"]) > :not(:last-child),  .input-group:not([dir="ltr"]) > .input-wrap:not(:last-child) > .form-control  { border-top-left-radius: 0 !important; border-bottom-left-radius: 0 !important; }
.input-group[dir="ltr"] > :not(:first-child), .input-group[dir="ltr"] > .input-wrap:not(:first-child) > .form-control { border-top-left-radius: 0 !important; border-bottom-left-radius: 0 !important; }
.input-group[dir="ltr"] > :not(:last-child),  .input-group[dir="ltr"] > .input-wrap:not(:last-child) > .form-control  { border-top-right-radius: 0 !important; border-bottom-right-radius: 0 !important; }
.input-group > .form-control:focus, .input-group > .input-wrap > .form-control:focus { position: relative; z-index: 1; }
.addon { display: inline-flex; align-items: center; padding: 0 .75rem; height: 40px; border: 1px solid var(--glass-border); background: rgba(var(--clr-primary-rgb), .06); color: var(--text-secondary); font-size: .85rem; white-space: nowrap; border-radius: var(--radius-sm); }
.addon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--glass-border); background: var(--glass-bg); color: var(--text-secondary); cursor: pointer; border-radius: var(--radius-sm); flex: 0 0 auto; }
.addon-btn:hover { color: var(--clr-primary); background: var(--glass-bg-hover); }
.addon-btn[aria-pressed="true"] { color: var(--clr-warning); }
.addon-btn--danger:hover { color: var(--clr-danger); }
.input-group > * + * { margin-inline-start: -1px; }

/* Stepper: never type=number (the wheel edits it); a text control with inputmode and two buttons. */
.stepper { display: inline-flex; align-items: stretch; width: 100%; }
.stepper .form-control { text-align: center; height: 40px; border-radius: 0 !important; margin-inline: -1px; min-width: 0; }
.stepper__btn { width: 40px; height: 40px; flex: 0 0 auto; border: 1px solid var(--glass-border); background: var(--glass-bg); color: var(--text-secondary); cursor: pointer; display: grid; place-items: center; }
.stepper__btn:first-child { border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }
.stepper__btn:last-child  { border-top-left-radius: var(--radius-sm); border-bottom-left-radius: var(--radius-sm); }
.stepper__btn:hover { color: var(--clr-primary); background: var(--glass-bg-hover); }
.stepper__btn:disabled { opacity: .35; cursor: not-allowed; }
.stepper--sm, .stepper--sm .form-control { height: 32px; }
.stepper--sm .form-control { width: 3.2rem; padding: 0; }
.stepper--sm .stepper__btn { width: 30px; height: 32px; }

/* Radio cards: each option carries an icon and a one-line consequence. */
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; }
.radio-cards--inline { grid-template-columns: repeat(2, 1fr); }
.radio-card { position: relative; }
.radio-card input { position: absolute; opacity: 0; width: 0; height: 0; }
.radio-card__box { display: flex; flex-direction: column; gap: .2rem; padding: .85rem 1rem; border-radius: var(--radius-md); border: 1px solid var(--glass-border); background: var(--glass-bg); cursor: pointer; transition: border-color var(--transition-fast), background var(--transition-fast); position: relative; }
.radio-card__box i { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: .2rem; }
.radio-card__box small { color: var(--text-muted); font-size: .72rem; }
.radio-card:hover .radio-card__box { border-color: rgba(var(--clr-primary-rgb), .4); }
.radio-card input:checked + .radio-card__box { border-color: var(--clr-primary); background: rgba(var(--clr-primary-rgb), .1); }
.radio-card input:checked + .radio-card__box i { color: var(--clr-primary); }
.radio-card input:checked + .radio-card__box::after { content: '\f00c'; font-family: 'Font Awesome 7 Pro', 'Font Awesome 6 Free'; font-weight: 900; position: absolute; top: .6rem; inset-inline-end: .7rem; font-size: .7rem; color: #fff; background: var(--clr-primary); width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; }
.radio-card input:focus-visible + .radio-card__box { box-shadow: var(--focus-ring); }
.cond[hidden] { display: none; }
.cond--indent { padding: .5rem 0 .5rem 0; margin-inline-start: 1rem; border-inline-start: 2px solid rgba(var(--clr-primary-rgb), .25); padding-inline-start: 1rem; }

/* Check pills and switch rows */
.check { width: 18px; height: 18px; accent-color: var(--clr-primary); cursor: pointer; }
.check-group { display: flex; flex-wrap: wrap; gap: .5rem; }
.check-pill { display: inline-flex; align-items: center; gap: .5rem; padding: .45rem .85rem; border-radius: 50px; border: 1px solid var(--glass-border); background: var(--glass-bg); cursor: pointer; font-size: .85rem; transition: border-color var(--transition-fast), background var(--transition-fast); }
.check-pill span { display: inline-flex; align-items: center; gap: .4rem; }
.check-pill span i { color: var(--text-secondary); font-size: .8rem; }
.check-pill:has(input:checked) { border-color: rgba(var(--clr-primary-rgb), .5); background: rgba(var(--clr-primary-rgb), .1); }
.check-pill.select-all { border-style: dashed; }
.check-pill--block { border-radius: var(--radius-sm); width: 100%; padding: .7rem .9rem; }
.check-pill:has(input:focus-visible) { box-shadow: var(--focus-ring); }
.switch { position: relative; width: 42px; height: 24px; border-radius: 50px; background: var(--glass-border); border: 0; cursor: pointer; transition: background var(--transition-fast); flex: 0 0 auto; padding: 0; }
.switch::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform var(--transition-fast); }
.switch[aria-checked="true"] { background: var(--clr-primary); }
.switch[aria-checked="true"]::after { transform: translateX(-18px); }
html[dir="ltr"] .switch[aria-checked="true"]::after { transform: translateX(18px); }
.check-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 0; border-bottom: 1px dashed var(--glass-border); }
.check-row:last-child { border-bottom: 0; }
.check-row small { display: block; color: var(--text-muted); font-size: .75rem; }
.chip-row { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }

/* Drop zones */
.dropzone { position: relative; border: 1.5px dashed var(--glass-border); border-radius: var(--radius-md); background: var(--glass-bg); padding: 1.25rem; text-align: center; cursor: pointer; transition: border-color var(--transition-fast), background var(--transition-fast); min-height: 112px; display: grid; place-items: center; }
.dropzone:hover, .dropzone:focus-visible { border-color: rgba(var(--clr-primary-rgb), .5); }
.dropzone.is-over { border-color: var(--clr-primary); background: rgba(var(--clr-primary-rgb), .1); }
.dropzone__empty { display: flex; flex-direction: column; align-items: center; gap: .3rem; color: var(--text-secondary); font-size: .85rem; }
.dropzone__empty i { font-size: 1.5rem; color: var(--clr-primary); opacity: .8; }
.dropzone__empty small { color: var(--text-muted); font-size: .72rem; }
.dropzone__empty[hidden] { display: none; }
.dropzone--image { aspect-ratio: 1; min-height: 0; padding: .75rem; }
.dropzone__preview { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; }
.dropzone__preview[hidden] { display: none; }
.dropzone__preview img { width: 100%; height: 100%; object-fit: cover; }
.dropzone__preview .icon-btn { position: absolute; top: .5rem; inset-inline-end: .5rem; background: rgba(7,11,20,.7); color: #fff; border-color: transparent; }
.file-list { list-style: none; margin: .6rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.file-item { display: grid; grid-template-columns: 34px 1fr auto auto; align-items: center; gap: .6rem; padding: .5rem .7rem; border-radius: var(--radius-sm); border: 1px solid var(--glass-border); background: var(--glass-bg); font-size: .82rem; }
.file-item__ico { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: rgba(var(--clr-primary-rgb), .12); color: var(--clr-primary); }
.file-item__meta { min-width: 0; }
.file-item__meta b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: end; font-weight: 600; }
.file-item__meta small { color: var(--text-muted); }
.file-item__bar { height: 4px; border-radius: 4px; background: var(--glass-border); overflow: hidden; margin-top: .3rem; }
.file-item__bar span { display: block; height: 100%; background: var(--clr-primary); width: 0; transition: width .25s linear; }
.file-item.is-done .file-item__bar span { background: var(--clr-accent); }
.file-item__state { font-size: .72rem; color: var(--text-muted); white-space: nowrap; }
.file-item.is-done .file-item__state { color: var(--clr-accent); }

/* Repeater: rows of fields named Name[i].Field, reordered with buttons (no drag library). */
.repeater__head { display: grid; grid-template-columns: 1fr 1fr 96px; gap: .6rem; padding: 0 .25rem .35rem; font-size: .75rem; color: var(--text-muted); }
.repeater__rows { display: flex; flex-direction: column; gap: .5rem; }
.repeater__row { display: grid; grid-template-columns: 1fr 1fr 96px; gap: .6rem; align-items: start; padding: .5rem; border-radius: var(--radius-sm); border: 1px solid var(--glass-border); background: var(--glass-bg); animation: menuIn .16s ease both; }
.repeater__row .form-control { height: 36px; }
.repeater__row .stepper .form-control, .repeater__row .stepper__btn { height: 36px; }
.repeater__row .stepper__btn { width: 32px; }
.repeater__tools { display: flex; gap: .25rem; justify-content: flex-end; }
.repeater__tools .icon-btn { width: 30px; height: 30px; min-height: 30px !important; }
.repeater__row .line-total { display: flex; align-items: center; height: 36px; font-weight: 700; padding-inline: .3rem; }
.repeater__empty { padding: 1.25rem; text-align: center; color: var(--text-muted); font-size: .85rem; border: 1px dashed var(--glass-border); border-radius: var(--radius-sm); }
.repeater__empty i { display: block; font-size: 1.3rem; opacity: .4; margin-bottom: .3rem; }
.repeater__empty[hidden] { display: none; }
.repeater .select2-container--default .select2-selection--single { min-height: 36px; }
.repeater .select2-selection__rendered { line-height: 34px !important; }
.repeater .select2-selection__arrow { height: 34px !important; }
/* Column templates are set per repeater with --repeater-cols (head and rows share it). */
.repeater[style*="--repeater-cols"] .repeater__head, .repeater[style*="--repeater-cols"] .repeater__row { grid-template-columns: var(--repeater-cols); }
@media (max-width: 640px) {
    .repeater__head { display: none; }
    .repeater__row, .repeater[style*="--repeater-cols"] .repeater__row { grid-template-columns: 1fr 1fr; }
    .repeater__row > .repeater__tools { grid-column: span 2; }
}

/* Password strength: four segments, data-score="0..4". */
.strength { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: .3rem; align-items: center; margin-top: .45rem; }
.strength span { height: 4px; border-radius: 4px; background: var(--glass-border); }
.strength em { font-style: normal; font-size: .72rem; color: var(--text-muted); min-width: 3rem; text-align: end; }
.strength[data-score="1"] span:nth-child(-n+1) { background: var(--clr-danger); }
.strength[data-score="2"] span:nth-child(-n+2) { background: var(--clr-warning); }
.strength[data-score="3"] span:nth-child(-n+3) { background: var(--clr-info); }
.strength[data-score="4"] span:nth-child(-n+4) { background: var(--clr-accent); }

/* Collapsible "advanced" block on a native <details>. */
.adv { margin-top: 1rem; border-top: 1px dashed var(--glass-border); padding-top: .75rem; }
.adv summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: .5rem; font-weight: 600; color: var(--text-secondary); font-size: .9rem; }
.adv summary::-webkit-details-marker { display: none; }
.adv summary i { transition: transform var(--transition-fast); font-size: .7rem; }
.adv[open] summary i { transform: rotate(180deg); }
.adv summary small { font-weight: 400; color: var(--text-muted); font-size: .75rem; }

/* Sticky action bar: save / cancel / reset / delete, plus dirty, draft and error state. */
.form-actions {
    position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
    padding: .85rem var(--card-pad); margin-top: 1rem;
    background: var(--surface-sticky); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--glass-border); border-radius: var(--radius-md);
}
.form-actions__status { margin-inline-start: auto; display: flex; align-items: center; gap: .6rem; font-size: .78rem; }
.form-actions .dirty { font-size: .78rem; color: var(--clr-warning); display: none; align-items: center; gap: .35rem; }
.form-actions.is-dirty .dirty { display: inline-flex; }
.form-actions .only-dirty { display: none; }
.form-actions.is-dirty .only-dirty { display: inline-flex; }
.draft-status { color: var(--text-muted); display: inline-flex; align-items: center; gap: .3rem; }
.btn.is-busy { pointer-events: none; opacity: .85; }
.btn.is-busy > i { display: none; }
.btn .spinner { display: none; width: 1em; height: 1em; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .7s linear infinite; }
.btn.is-busy .spinner { display: inline-block; }
/* A region ajax-form.js is fetching again after a save: dimmed and not clickable until it is swapped. */
.is-refreshing { opacity: .5; pointer-events: none; transition: opacity var(--transition-fast, .15s); }
.btn.is-success { background: var(--clr-accent); box-shadow: 0 4px 20px rgba(var(--clr-accent-rgb), .35); }
@keyframes spin { to { transform: rotate(360deg); } }
.draft-banner { display: flex; align-items: center; gap: .75rem; padding: .7rem 1rem; margin-bottom: 1rem; border-radius: var(--radius-sm); background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); font-size: .88rem; flex-wrap: wrap; }
.draft-banner > i { color: var(--clr-warning); }
.draft-banner[hidden] { display: none; }
/* Sticky section nav beside a long form; .nav-err badges are filled by admin-ui.js. */
.form-nav { position: sticky; top: calc(var(--topbar-h) + 1rem); display: flex; flex-direction: column; gap: .2rem; padding: .5rem; }
.form-nav a { position: relative; padding: .5rem .8rem; border-radius: var(--radius-sm); color: var(--text-secondary); font-size: .85rem; display: flex; align-items: center; gap: .5rem; }
.form-nav a:hover, .form-nav a.active { background: rgba(var(--clr-primary-rgb), .1); color: var(--clr-primary); }
.form-nav .nav-err { margin-inline-start: auto; min-width: 1.25rem; height: 1.15rem; padding: 0 .35rem; border-radius: 50px; display: inline-grid; place-items: center; font-size: .66rem; font-weight: 700; background: rgba(239,68,68,.16); color: var(--clr-danger); }
.form-nav .nav-err[hidden] { display: none; }

/* ── Toast v2 ─────────────────────────────────────────────── */
/* Wraps, has a title, an action, a close button and a time bar; parked under the topbar at the
   inline end. The old pill was white-space:nowrap and a long sentence ran off a phone screen. */
#toast-container { bottom: auto; top: calc(var(--topbar-h) + .75rem); inset-inline-end: 1rem; left: auto; transform: none; align-items: flex-end; max-width: min(420px, calc(100vw - 2rem)); }
.toast-msg { white-space: normal; border-radius: var(--radius-md); padding: .8rem 1rem; align-items: flex-start; line-height: 1.6; position: relative; overflow: hidden; width: 100%; background: var(--bg-elevated) !important; }
.toast-msg > i { margin-top: .2rem; }
.toast-msg .toast-body { flex: 1 1 auto; color: var(--text-primary); font-weight: 500; }
.toast-msg .toast-body strong { display: block; font-weight: 700; }
.toast-msg .toast-act { border: 0; background: rgba(var(--clr-primary-rgb), .14); color: var(--clr-primary); font-weight: 700; font-size: .78rem; padding: .25rem .7rem; border-radius: 50px; cursor: pointer; white-space: nowrap; }
.toast-msg .toast-x { border: 0; background: none; color: var(--text-muted); cursor: pointer; padding: 0 .1rem; }
.toast-msg .toast-bar { position: absolute; bottom: 0; inset-inline-start: 0; height: 3px; width: 100%; background: currentColor; opacity: .5; transform-origin: right; animation: toastBar var(--dur, 4s) linear forwards; }
@keyframes toastBar { to { transform: scaleX(0); } }
