/* ==========================================================================
   سنجاقک — سیستم طراحی  v4
   نسخه: 2026-08-07   (اگر این خط را در مرورگر نمی‌بینی، فایل قدیمی سرو می‌شود)

   بازطراحی موبایل‌محور: پوسته اپ‌مانند، نوار پایین، کشوی کناری،
   ناحیه امن گوشی‌های ناچ‌دار، آماده برای خروجی PWA.
   ========================================================================== */

@font-face {
    font-family: 'Yekan';
    src: url('../fonts/YekanNewFaceD4.ttf') format('truetype');
    font-weight: 100 900;
    font-display: swap;
}

/* --------------------------------------------------------------------------
   توکن‌ها — حالت روشن
   -------------------------------------------------------------------------- */

:root {
    --teal:        #2BA8A2;
    --teal-light:  #3CC4BD;
    --teal-dark:   #1E8C86;
    --teal-bg:     #E8F6F5;

    --gold:        #FFD23F;
    --gold-light:  #FFE47A;
    --gold-dark:   #E6B800;

    --coral:       #EF6C4A;
    --coral-light: #FF8A6A;
    --coral-dark:  #D45233;

    --cream:       #FFF8E7;
    --sky:         #5DADE2;

    --surface:     #EFF8F7;
    --card:        #FFFFFF;
    --raised:      #F7FCFB;

    --success:     #27AE60;
    --error:       #E74C3C;

    --ink:         #143433;
    --ink-soft:    #40605E;
    --muted:       #7A918F;
    --line:        #D7E9E7;

    --nav-bg:      #1E8C86;
    --nav-ink:     #FFFFFF;
    --nav-ink-dim: rgba(255, 255, 255, .78);
    --nav-hover:   rgba(255, 255, 255, .12);
    --nav-line:    rgba(255, 255, 255, .18);

    /* نوار پایین — روی موبایل سفید است تا از محتوا جدا بماند */
    --tab-bg:      rgba(255, 255, 255, .92);
    --tab-ink:     #7A918F;
    --tab-active:  #1E8C86;
    --tab-line:    #D7E9E7;

    --badge-ok-bg:    #E4F6EC;  --badge-ok-fg:    #1E8449;
    --badge-warn-bg:  #FFF3D1;  --badge-warn-fg:  #9A7300;
    --badge-err-bg:   #FDE6E3;  --badge-err-fg:   #B4372A;
    --badge-info-bg:  #E4F1FA;  --badge-info-fg:  #2E7BA6;
    --badge-gray-bg:  #EDF2F2;  --badge-gray-fg:  #7A918F;

    --r-pill: 999px;
    --r-lg:   20px;
    --r-md:   14px;
    --r-sm:   10px;

    --sh-sm:      0 2px 6px rgba(30, 140, 134, .10);
    --sh-md:      0 6px 18px rgba(30, 140, 134, .12);
    --sh-lg:      0 14px 34px rgba(30, 140, 134, .16);
    --sh-card:    0 4px 0 var(--teal-bg), 0 8px 22px rgba(30, 140, 134, .10);
    --glow-teal:  0 6px 20px rgba(43, 168, 162, .38);
    --glow-coral: 0 6px 20px rgba(239, 108, 74, .35);
    --glow-gold:  0 6px 20px rgba(255, 210, 63, .45);
    --glow-sky:   0 6px 20px rgba(93, 173, 226, .35);
    --focus:      0 0 0 4px rgba(43, 168, 162, .30);

    --sidebar-w:  252px;
    --tap:        44px;

    /* ارتفاع‌های پوسته — همه‌جا از همین‌ها استفاده می‌شود */
    --topbar-h:   58px;
    --tabbar-h:   62px;

    /* ناحیه امن گوشی‌های ناچ‌دار؛ روی دسکتاپ صفر است */
    --safe-top:    env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    color-scheme: light;
}

/* --------------------------------------------------------------------------
   توکن‌ها — حالت تاریک
   -------------------------------------------------------------------------- */

[data-theme='dark'] {
    --teal:        #35BDB6;
    --teal-light:  #4FD6CE;
    --teal-dark:   #2AA098;
    --teal-bg:     #16332F;

    --gold:        #F5C63A;
    --gold-light:  #FFDA6B;
    --gold-dark:   #D9A81F;

    --coral:       #F07E5C;
    --coral-light: #FF9878;
    --coral-dark:  #D9603E;

    --cream:       #1B3330;
    --sky:         #6FB9E8;

    --surface:     #0E1E1D;
    --card:        #152927;
    --raised:      #1B3230;

    --success:     #37C173;
    --error:       #F26B5B;

    --ink:         #E9F5F3;
    --ink-soft:    #C0D6D3;
    --muted:       #89A5A2;
    --line:        #26433F;

    --nav-bg:      #0B1817;
    --nav-ink:     #EAF6F4;
    --nav-ink-dim: rgba(234, 246, 244, .70);
    --nav-hover:   rgba(255, 255, 255, .07);
    --nav-line:    rgba(255, 255, 255, .10);

    --tab-bg:      rgba(21, 41, 39, .94);
    --tab-ink:     #89A5A2;
    --tab-active:  #4FD6CE;
    --tab-line:    #26433F;

    --badge-ok-bg:    #16382A;  --badge-ok-fg:    #5FD696;
    --badge-warn-bg:  #3A3016;  --badge-warn-fg:  #F0C74D;
    --badge-err-bg:   #3D211C;  --badge-err-fg:   #F79383;
    --badge-info-bg:  #17313F;  --badge-info-fg:  #7CC3EC;
    --badge-gray-bg:  #21322F;  --badge-gray-fg:  #96AEAB;

    --sh-sm:      0 2px 6px rgba(0, 0, 0, .40);
    --sh-md:      0 6px 18px rgba(0, 0, 0, .45);
    --sh-lg:      0 14px 34px rgba(0, 0, 0, .55);
    --sh-card:    0 4px 0 rgba(53, 189, 182, .10), 0 8px 22px rgba(0, 0, 0, .38);
    --glow-teal:  0 6px 18px rgba(53, 189, 182, .30);
    --glow-coral: 0 6px 18px rgba(240, 126, 92, .28);
    --glow-gold:  0 6px 18px rgba(245, 198, 58, .30);
    --glow-sky:   0 6px 18px rgba(111, 185, 232, .28);
    --focus:      0 0 0 4px rgba(53, 189, 182, .35);

    color-scheme: dark;
}

/* --------------------------------------------------------------------------
   پایه
   -------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: 'Yekan', system-ui, 'Segoe UI', Tahoma, sans-serif;
    background: var(--surface);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.75;
    direction: rtl;
    overflow-x: hidden;
    transition: background-color .2s, color .2s;

    /* حس اپ: انتخاب متن و منوی طولانی‌فشار روی موبایل مزاحم است */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* ولی داخل محتوا و ورودی‌ها باید بشود متن را انتخاب کرد */
p, li, td, th, h1, h2, h3, h4, .prose, .selectable,
input, textarea, code, pre {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}

img, svg, video { max-width: 100%; height: auto; }

h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 800; line-height: 1.4; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p  { margin: 0 0 .8em; }

a { color: var(--teal-dark); text-decoration: none; }
a:hover { color: var(--teal); }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }

.muted    { color: var(--muted); }
.text-sm  { font-size: .85rem; }
.text-xs  { font-size: .76rem; }
.nowrap   { white-space: nowrap; }
.mono     { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.center   { text-align: center; }
.stack > * + * { margin-top: 14px; }

.only-mobile  { display: none; }
.only-desktop { display: initial; }

/* ==========================================================================
   پوسته اپ
   ========================================================================== */

.shell { display: flex; min-height: 100vh; min-height: 100dvh; }

/* --------------------------------------------------------------------------
   کشوی کناری

   ⚠️ باگی که منو را وسط صفحه می‌انداخت:

   نسخه قبلی از `inset-inline-end: 0` به‌همراه `translateX(105%)` استفاده
   می‌کرد. مشکل اینجاست که این دو با هم نمی‌خوانند:

     • inset-inline-end در RTL به لبه **چپ** فیزیکی نگاشت می‌شود
     • ولی transform هیچ‌وقت جهت‌آگاه نیست — translateX مثبت همیشه
       به راست فیزیکی حرکت می‌کند

   نتیجه: منو به لبه چپ می‌چسبید و بعد ۱۰۵٪ به راست هل داده می‌شد،
   یعنی دقیقاً وسط صفحه.

   راه‌حل: هر دو را فیزیکی بنویس. کشو از راست می‌آید (طبیعی برای RTL)،
   پس `right: 0` و `translateX(100%)`.
   -------------------------------------------------------------------------- */

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--nav-bg);
    color: var(--nav-ink);
    padding: calc(18px + var(--safe-top)) 12px calc(24px + var(--safe-bottom));
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;

    scrollbar-width: thin;
    scrollbar-color: var(--nav-line) transparent;
}

.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--nav-line); border-radius: 3px; }

.brand {
    display: flex; align-items: center; gap: 10px;
    padding: 0 8px 16px;
    margin-bottom: 4px;
    border-bottom: 1px dashed var(--nav-line);
}

.brand-mark {
    width: 42px; height: 42px; flex: none;
    display: grid; place-items: center;
    background: var(--gold);
    color: #143433;
    border-radius: 13px;
    font-weight: 900; font-size: 1.15rem;
    transform: rotate(-8deg);
    box-shadow: var(--glow-gold);
}

.brand-name { font-weight: 800; font-size: 1.06rem; color: var(--nav-ink); }
.brand-sub  { font-size: .7rem; color: var(--nav-ink-dim); margin-top: -3px; }

.sidebar-close {
    display: none;
    margin-inline-start: auto;
    background: var(--nav-hover);
    color: var(--nav-ink);
    border: none;
    width: 36px; height: 36px;
    border-radius: var(--r-sm);
    font-size: 1.1rem;
    cursor: pointer;
}

.nav-group { margin-top: 16px; }

.nav-label {
    font-size: .68rem;
    letter-spacing: .05em;
    color: var(--nav-ink-dim);
    padding: 0 10px 5px;
    margin-bottom: 6px;
}

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    min-height: 38px;
    border-radius: var(--r-pill);
    color: var(--nav-ink-dim);
    font-size: .9rem;
    margin-bottom: 2px;
    transition: background .15s, color .15s;
    position: relative;
}
.nav-item:hover  { background: var(--nav-hover); color: var(--nav-ink); }
.nav-item.active { background: var(--gold); color: #143433; font-weight: 700; }
.nav-item .ico   { width: 20px; flex: none; display: grid; place-items: center; opacity: .95; }
.nav-item .ico svg { width: 18px; height: 18px; }

/* نشان عدد کنار آیتم منو */
.nav-item .pill {
    margin-inline-start: auto;
    background: var(--coral); color: #fff;
    font-size: .68rem; font-weight: 800;
    min-width: 20px; height: 20px;
    border-radius: var(--r-pill);
    display: grid; place-items: center;
    padding: 0 6px;
}

/* --------------------------------------------------------------------------
   ستون اصلی
   -------------------------------------------------------------------------- */

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    padding: 0 18px;
    padding-top: var(--safe-top);
    height: calc(var(--topbar-h) + var(--safe-top));
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 30;
}

.topbar-title {
    min-width: 0;
    font-weight: 800;
    font-size: 1.02rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.topbar .who { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; }
.topbar .who-text { line-height: 1.35; text-align: left; }
.topbar .who-name { font-weight: 700; font-size: .85rem; }
.topbar .who-role { color: var(--muted); font-size: .72rem; }

.avatar {
    width: 36px; height: 36px; flex: none; border-radius: 50%;
    background: var(--teal-bg); color: var(--teal-dark);
    display: grid; place-items: center; font-weight: 800; font-size: .85rem;
}

.icon-btn {
    background: var(--teal-bg); color: var(--teal-dark);
    border: none; border-radius: var(--r-sm);
    width: 38px; height: 38px; flex: none;
    font-size: 1.05rem; cursor: pointer;
    display: grid; place-items: center;
    transition: background .15s;
}
.icon-btn:hover { background: var(--teal); color: #fff; }
.icon-btn svg, .btn svg { pointer-events: none; }

.menu-toggle, .back-btn { display: none; }

.theme-toggle .sun  { display: none; }
[data-theme='dark'] .theme-toggle .sun  { display: block; }
[data-theme='dark'] .theme-toggle .moon { display: none; }

.content { padding: 22px; flex: 1; }
.container { max-width: 1180px; margin: 0 auto; }
.container-narrow { max-width: 780px; margin: 0 auto; }

.scrim {
    position: fixed; inset: 0;
    background: rgba(10, 26, 25, .55);
    backdrop-filter: blur(3px);
    z-index: 55; display: none;
    opacity: 0;
    transition: opacity .22s ease;
}
.scrim.open { display: block; opacity: 1; }

/* --------------------------------------------------------------------------
   نوار پایین — فقط موبایل
   -------------------------------------------------------------------------- */

.tabbar {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    background: var(--tab-bg);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--tab-line);
    padding-bottom: var(--safe-bottom);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, .07);
}

.tabbar-inner {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    height: var(--tabbar-h);
    max-width: 560px;
    margin: 0 auto;
}

.tab {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px;
    color: var(--tab-ink);
    font-size: .66rem; font-weight: 700;
    position: relative;
    transition: color .18s;
    -webkit-tap-highlight-color: transparent;
}
.tab:hover { color: var(--tab-active); }

.tab .ico {
    width: 26px; height: 26px;
    display: grid; place-items: center;
    transition: transform .22s cubic-bezier(.34, 1.56, .64, 1);
}
.tab .ico svg { width: 23px; height: 23px; }

.tab.active { color: var(--tab-active); }
.tab.active .ico { transform: translateY(-2px) scale(1.08); }

/* خط کوچک بالای تب فعال */
.tab.active::before {
    content: '';
    position: absolute;
    top: 0;
    width: 26px; height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--tab-active);
}

/* نشان عدد روی تب */
.tab .dot {
    position: absolute;
    top: 6px;
    inset-inline-end: calc(50% - 18px);
    min-width: 16px; height: 16px;
    padding: 0 4px;
    border-radius: var(--r-pill);
    background: var(--coral); color: #fff;
    font-size: .6rem; font-weight: 900;
    display: grid; place-items: center;
    border: 2px solid var(--card);
}

/* تب وسط برجسته — دکمه اصلی اپ */
.tab.tab-primary .ico {
    width: 46px; height: 46px;
    margin-top: -18px;
    border-radius: 16px;
    background: linear-gradient(150deg, var(--teal-light), var(--teal-dark));
    color: #fff;
    box-shadow: var(--glow-teal);
    border: 3px solid var(--card);
}
.tab.tab-primary.active .ico { transform: translateY(-2px) scale(1.05); }
.tab.tab-primary::before { display: none; }

/* ==========================================================================
   سربرگ صفحه
   ========================================================================== */

.page-head {
    display: flex; align-items: flex-end; gap: 12px;
    flex-wrap: wrap; margin-bottom: 20px;
}

.ribbon {
    position: relative;
    background: var(--teal);
    color: #fff;
    padding: 9px 22px;
    border-radius: var(--r-sm);
    font-weight: 800;
    font-size: 1.15rem;
    box-shadow: var(--glow-teal);
    max-width: 100%;
    overflow-wrap: anywhere;
}
.ribbon::after {
    content: '';
    position: absolute;
    inset-inline-end: -9px; bottom: -6px;
    width: 18px; height: 18px;
    background: var(--teal-dark);
    clip-path: polygon(0 0, 100% 0, 0 100%);
    border-end-start-radius: 3px;
}
.ribbon.gold  { background: var(--gold);  color: #143433; box-shadow: var(--glow-gold); }
.ribbon.gold::after  { background: var(--gold-dark); }
.ribbon.coral { background: var(--coral); color: #fff; box-shadow: var(--glow-coral); }
.ribbon.coral::after { background: var(--coral-dark); }

.page-head .sub { color: var(--muted); font-size: .88rem; padding-bottom: 4px; }
.page-head .spacer { margin-inline-start: auto; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-inline-start: auto; }

/* ==========================================================================
   کارت، شبکه، آمار
   ========================================================================== */

.card {
    background: var(--card);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-card);
    padding: 18px;
    margin-bottom: 18px;
}
.card.flat { box-shadow: var(--sh-sm); }

.card-head {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding-bottom: 12px; margin-bottom: 14px;
    border-bottom: 2px dashed var(--line);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { margin-inline-start: auto; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.stat {
    background: var(--card);
    border-radius: var(--r-lg);
    padding: 16px 18px;
    box-shadow: var(--sh-card);
    border-top: 5px solid var(--teal);
    color: inherit;
}
.stat .n { font-size: 2rem; font-weight: 900; line-height: 1.2; color: var(--teal-dark); }
.stat .l { color: var(--muted); font-size: .85rem; }
.stat.gold  { border-top-color: var(--gold); }
.stat.gold .n  { color: var(--gold-dark); }
.stat.coral { border-top-color: var(--coral); }
.stat.coral .n { color: var(--coral-dark); }
.stat.sky   { border-top-color: var(--sky); }
.stat.sky .n   { color: var(--sky); }

/* ==========================================================================
   دکمه‌ها
   ========================================================================== */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font-family: inherit; font-size: .88rem; font-weight: 700;
    padding: 9px 20px;
    min-height: 38px;
    border: none; border-radius: var(--r-pill);
    background: var(--teal); color: #fff;
    cursor: pointer;
    box-shadow: var(--glow-teal);
    transition: transform .12s, box-shadow .12s, background .12s;
    text-decoration: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}
.btn:hover  { background: var(--teal-light); color: #fff; transform: translateY(-1px); }
.btn:active { transform: translateY(1px); box-shadow: var(--sh-sm); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; }

.btn-gold  { background: var(--gold);  color: #143433; box-shadow: var(--glow-gold); }
.btn-gold:hover  { background: var(--gold-light); color: #143433; }
.btn-coral { background: var(--coral); color: #fff; box-shadow: var(--glow-coral); }
.btn-coral:hover { background: var(--coral-light); color: #fff; }
.btn-sky   { background: var(--sky);   color: #fff; box-shadow: var(--glow-sky); }
.btn-sky:hover   { background: var(--sky); filter: brightness(1.1); color: #fff; }
.btn-ghost {
    background: transparent; color: var(--teal-dark);
    border: 2px solid var(--line); box-shadow: none;
}
.btn-ghost:hover { background: var(--teal-bg); color: var(--teal-dark); }

.btn-sm { padding: 5px 13px; font-size: .78rem; min-height: 32px; }
.btn-block { width: 100%; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ==========================================================================
   نشان
   ========================================================================== */

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 12px;
    border-radius: var(--r-pill);
    font-size: .74rem; font-weight: 700;
    background: var(--teal-bg); color: var(--teal-dark);
    white-space: nowrap;
}
.badge.ok    { background: var(--badge-ok-bg);   color: var(--badge-ok-fg); }
.badge.warn  { background: var(--badge-warn-bg); color: var(--badge-warn-fg); }
.badge.err   { background: var(--badge-err-bg);  color: var(--badge-err-fg); }
.badge.info  { background: var(--badge-info-bg); color: var(--badge-info-fg); }
.badge.gray  { background: var(--badge-gray-bg); color: var(--badge-gray-fg); }
.badge.coral { background: var(--badge-err-bg);  color: var(--coral-dark); }

/* ==========================================================================
   فرم
   ========================================================================== */

.field { margin-bottom: 14px; min-width: 0; }
.field > label,
.form-label {
    display: block;
    font-size: .82rem; font-weight: 700;
    color: var(--ink-soft);
    margin-bottom: 5px;
}
.req::after { content: ' *'; color: var(--coral); }

.input, .select, .textarea,
input[type=text], input[type=number], input[type=url], input[type=date],
input[type=datetime-local], input[type=password], input[type=email], input[type=search],
input[type=tel], select, textarea {
    width: 100%;
    max-width: 100%;
    font-family: inherit;
    font-size: 16px;              /* جلوگیری از زوم خودکار iOS */
    color: var(--ink);
    background: var(--cream);
    border: 2px solid transparent;
    border-radius: var(--r-md);
    padding: 10px 14px;
    min-height: var(--tap);
    transition: border-color .15s, box-shadow .15s, background-color .2s;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.8; }

@media (min-width: 700px) {
    .input, .select, .textarea,
    input[type=text], input[type=number], input[type=url], input[type=date],
    input[type=datetime-local], input[type=password], input[type=email], input[type=search],
    input[type=tel], select, textarea { font-size: .92rem; min-height: 40px; }
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--teal-light);
    box-shadow: var(--focus);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }

input[type=file] {
    background: var(--cream); border: 2px dashed var(--line);
    border-radius: var(--r-md); padding: 12px 14px; width: 100%;
    font-family: inherit; font-size: .85rem; color: var(--ink);
}

select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                      linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: 14px calc(50% - 2px), 19px calc(50% - 2px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-inline-start: 34px;
}

.check {
    display: flex; align-items: center; gap: 8px;
    font-size: .88rem; cursor: pointer;
    min-height: 32px;
}
.check input { width: 20px; height: 20px; accent-color: var(--teal); flex: none; }

.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.form-error { color: var(--error); font-size: .78rem; margin-top: 4px; font-weight: 600; }

.filters {
    display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
    margin-bottom: 16px;
}
.filters .field { margin: 0; min-width: 160px; flex: 1 1 160px; }
.filters .btn { flex: none; }

/* ==========================================================================
   جدول
   ========================================================================== */

.table-wrap {
    overflow-x: auto;
    border-radius: var(--r-md);
    -webkit-overflow-scrolling: touch;
}

table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }

table.tbl th {
    background: var(--teal-bg);
    color: var(--teal-dark);
    font-weight: 800; font-size: .8rem;
    padding: 11px 12px;
    text-align: right;
    white-space: nowrap;
}
table.tbl th:first-child { border-start-end-radius: var(--r-md); }
table.tbl th:last-child  { border-start-start-radius: var(--r-md); }

table.tbl td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
table.tbl tbody tr:hover { background: var(--raised); }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl td.actions { white-space: nowrap; }
table.tbl td.actions .btn { margin-inline-start: 4px; }

.sub-row { display: none; background: var(--cream); }
.sub-row.open { display: table-row; }
.sub-row td { padding: 14px 18px; }

.collapsible { display: none; }
.collapsible.open { display: block; }

/* ==========================================================================
   حالت خالی، پیام، توست
   ========================================================================== */

.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty .mark {
    width: 62px; height: 62px; margin: 0 auto 12px;
    border-radius: 18px;
    background: var(--teal-bg); color: var(--teal);
    display: grid; place-items: center; font-size: 1.6rem;
    transform: rotate(-6deg);
}
.empty h3 { color: var(--ink-soft); }

.alert {
    border-radius: var(--r-md);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-weight: 600; font-size: .88rem;
    border-inline-start: 5px solid;
}
.alert.ok  { background: var(--badge-ok-bg);  color: var(--badge-ok-fg);  border-color: var(--success); }
.alert.err { background: var(--badge-err-bg); color: var(--badge-err-fg); border-color: var(--error); }
.alert ul  { margin: 6px 0 0; padding-inline-start: 18px; }

.toast-host {
    position: fixed;
    inset-block-start: calc(16px + var(--safe-top));
    inset-inline-start: 16px;
    z-index: 90; display: flex; flex-direction: column; gap: 8px;
    max-width: calc(100vw - 32px);
}
.toast {
    background: var(--teal-dark); color: #fff;
    padding: 10px 18px; border-radius: var(--r-pill);
    font-size: .85rem; font-weight: 600;
    box-shadow: var(--sh-lg);
    animation: toast-in .25s ease;
}
.toast.err { background: var(--coral-dark); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* ==========================================================================
   آکاردئون، انتخابگر، کارت دوره، برنامه هفتگی
   ========================================================================== */

.acc {
    border-radius: var(--r-lg); background: var(--card);
    box-shadow: var(--sh-card); margin-bottom: 12px; overflow: hidden;
}
.acc-head {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 18px; cursor: pointer; font-weight: 800;
    background: var(--card); color: var(--ink);
    border: none; width: 100%; font-family: inherit;
    font-size: .98rem; text-align: right; min-height: var(--tap);
}
.acc-head:hover { background: var(--teal-bg); }
.acc-head .arrow { margin-inline-start: auto; transition: transform .2s; color: var(--teal); }
.acc.open .acc-head .arrow { transform: rotate(180deg); }
.acc-body { display: none; padding: 4px 14px 16px; }
.acc.open .acc-body { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.pick {
    text-align: right;
    background: var(--cream);
    border: 2px solid transparent;
    border-radius: var(--r-md);
    padding: 12px 14px;
    cursor: pointer;
    font-family: inherit; font-size: .9rem; color: var(--ink);
    display: flex; flex-direction: column; gap: 6px;
    transition: border-color .15s, box-shadow .15s;
}
.pick:hover { border-color: var(--teal-light); }
.pick.active { border-color: var(--teal); box-shadow: var(--glow-teal); background: var(--card); }
.pick .row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pick .name { font-weight: 700; }
.pick .spacer { margin-inline-start: auto; }

.course-card {
    background: var(--card);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-card);
    padding: 16px 18px;
    display: flex; flex-direction: column; gap: 8px;
    border-top: 5px solid var(--teal);
    transition: transform .15s, box-shadow .15s;
}
.course-card:hover { transform: translateY(-3px); box-shadow: var(--sh-lg); }
.course-card h3 { margin: 0; font-size: 1rem; color: var(--ink); }
.course-card .meta { color: var(--muted); font-size: .82rem; display: flex; gap: 10px; flex-wrap: wrap; }
.course-card .foot {
    margin-top: auto; padding-top: 10px;
    border-top: 2px dashed var(--line);
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

.week { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.day { background: var(--card); border-radius: var(--r-md); box-shadow: var(--sh-sm); overflow: hidden; }
.day > h4 {
    margin: 0; padding: 9px 12px; font-size: .85rem;
    background: var(--teal-bg); color: var(--teal-dark);
}
.day .slots { padding: 10px; display: grid; gap: 8px; }
.slot { background: var(--cream); border-radius: var(--r-sm); padding: 9px 11px; font-size: .82rem; }
.slot .t { font-weight: 800; color: var(--teal-dark); }
.slot .n { font-weight: 700; }
.day .none { padding: 16px 12px; text-align: center; color: var(--muted); font-size: .8rem; }

/* ==========================================================================
   صفحه‌بندی
   ========================================================================== */

.pager { display: flex; justify-content: center; gap: 5px; margin-top: 18px; flex-wrap: wrap; }
.pager a, .pager span {
    min-width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0 10px;
    border-radius: var(--r-pill);
    background: var(--card); color: var(--ink-soft);
    font-size: .85rem; box-shadow: var(--sh-sm);
}
.pager .current { background: var(--teal); color: #fff; font-weight: 700; box-shadow: var(--glow-teal); }
.pager .disabled { opacity: .4; }

/* ==========================================================================
   صفحه‌های مهمان
   ========================================================================== */

.auth-wrap {
    min-height: 100vh; min-height: 100dvh;
    display: grid; place-items: center;
    padding: calc(24px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
    background:
        radial-gradient(1100px 480px at 15% -10%, var(--teal-bg), transparent 60%),
        radial-gradient(760px 420px at 100% 100%, var(--cream), transparent 60%),
        var(--surface);
}
.auth-card {
    width: 100%; max-width: 400px;
    background: var(--card);
    border-radius: 26px;
    box-shadow: var(--sh-lg);
    padding: 32px 26px;
}
.auth-mark {
    width: 68px; height: 68px; margin: 0 auto 14px;
    background: var(--gold); color: #143433;
    border-radius: 21px;
    display: grid; place-items: center;
    font-weight: 900; font-size: 1.5rem;
    transform: rotate(-8deg);
    box-shadow: var(--glow-gold);
}

.theme-float {
    position: fixed;
    inset-block-start: calc(16px + var(--safe-top));
    inset-inline-start: 16px;
    z-index: 40;
    background: var(--card);
    box-shadow: var(--sh-md);
}

/* ==========================================================================
   ریسپانسیو
   ========================================================================== */

@media (max-width: 1100px) {
    :root { --sidebar-w: 224px; }
    .content { padding: 18px; }
}

/* ---------------- موبایل و تبلت کوچک ---------------- */

@media (max-width: 900px) {

    .only-mobile  { display: initial; }
    .only-desktop { display: none !important; }

    /* ---- کشو ----
       فیزیکی: از راست می‌آید. ترکیب inset-inline-* با transform
       همان باگی بود که منو را وسط می‌انداخت. */
    .sidebar {
        position: fixed;
        top: 0; bottom: 0;
        right: 0;
        left: auto;
        width: min(82vw, 310px);
        flex: none;
        height: 100dvh;
        z-index: 60;
        transform: translateX(100%);
        transition: transform .26s cubic-bezier(.22, 1, .36, 1);
        box-shadow: -14px 0 40px rgba(0, 0, 0, .3);
        border-start-start-radius: 22px;
        border-end-start-radius: 22px;
    }
    .sidebar.open { transform: translateX(0); }

    .sidebar-close { display: grid; place-items: center; }

    .menu-toggle { display: grid; }

    /* ---- تاپ‌بار ---- */
    .topbar { padding: 0 12px; padding-top: var(--safe-top); gap: 8px; }
    .topbar .who-text { display: none; }
    .topbar-title { font-size: .98rem; }

    /* ---- نوار پایین ---- */
    .tabbar { display: block; }

    /* محتوا نباید زیر نوار پایین گم شود */
    .content {
        padding: 16px 14px calc(var(--tabbar-h) + var(--safe-bottom) + 22px);
    }

    .toast-host { inset-block-start: calc(12px + var(--safe-top)); inset-inline: 12px; }

    /* ---- سربرگ ---- */
    .page-head { gap: 10px; }
    .page-head .ribbon { font-size: 1.05rem; padding: 8px 18px; }
    .page-actions { width: 100%; margin-inline-start: 0; }
    .page-actions .btn { flex: 1 1 auto; }

    .card { padding: 15px 14px; border-radius: var(--r-md); }
    .card-head .spacer { width: 100%; margin-inline-start: 0; }

    .week { grid-template-columns: 1fr 1fr; }

    /* ---- جدول به کارت ----
       برچسب هر سلول از thead خوانده و در data-label گذاشته می‌شود
       (کار sanjagak.js). پس هیچ بلیدی لازم نیست عوض شود. */
    table.tbl.stackable { display: block; }
    table.tbl.stackable thead { display: none; }
    table.tbl.stackable tbody { display: block; }

    table.tbl.stackable tbody tr {
        display: block;
        background: var(--cream);
        border-radius: var(--r-md);
        padding: 10px 12px;
        margin-bottom: 10px;
    }
    table.tbl.stackable tbody tr:hover { background: var(--cream); }

    table.tbl.stackable tbody td {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 5px 0;
        border: none;
        border-bottom: 1px dashed var(--line);
    }
    table.tbl.stackable tbody tr td:last-child { border-bottom: none; }

    table.tbl.stackable tbody td::before {
        content: attr(data-label);
        flex: 0 0 38%;
        max-width: 38%;
        font-size: .74rem;
        font-weight: 800;
        color: var(--muted);
    }
    table.tbl.stackable tbody td[data-label='']::before,
    table.tbl.stackable tbody td.no-label::before { content: none; }

    table.tbl.stackable tbody td.actions { flex-wrap: wrap; padding-top: 9px; }
    table.tbl.stackable tbody td.actions .btn { margin: 0; flex: 1 1 auto; }

    table.tbl.stackable tbody tr.sub-row { background: var(--card); }
    table.tbl.stackable tbody tr.sub-row td { display: block; }
    table.tbl.stackable tbody tr.sub-row td::before { content: none; }
}

@media (max-width: 560px) {
    body { font-size: 14.5px; }

    h1 { font-size: 1.32rem; }
    .ribbon { font-size: 1rem; }

    .content { padding: 14px 12px calc(var(--tabbar-h) + var(--safe-bottom) + 20px); }

    .grid { gap: 12px; }
    .g2, .g3, .g4 { grid-template-columns: 1fr; }

    .stat { padding: 14px 16px; }
    .stat .n { font-size: 1.7rem; }

    .filters { gap: 8px; }
    .filters .field { flex: 1 1 100%; min-width: 0; }
    .filters .btn { flex: 1 1 auto; }

    .form-grid { grid-template-columns: 1fr; }
    .acc.open .acc-body { grid-template-columns: 1fr; }
    .week { grid-template-columns: 1fr; }

    .btn { padding: 10px 18px; }
    .page-actions .btn { flex: 1 1 100%; }

    .auth-card { padding: 26px 20px; border-radius: 22px; }
}

/* ==========================================================================
   چاپ
   ========================================================================== */

@media print {
    :root, [data-theme='dark'] {
        --surface: #fff; --card: #fff; --cream: #fff;
        --ink: #000; --ink-soft: #222; --muted: #555; --line: #bbb;
        color-scheme: light;
    }
    .sidebar, .topbar, .tabbar, .scrim, .page-actions,
    .btn, .pager, .icon-btn, .toast-host { display: none !important; }
    body { background: #fff; color: #000; }
    .card { box-shadow: none; border: 1px solid #ccc; }
    .shell { display: block; }
    .content { padding: 0 !important; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
