/* ===== ریست ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== تم روشن: Aurora Indigo ===== */
:root {
    --primary:        #4f46e5;
    --primary-rgb:    79,70,229;
    --primary-dark:   #4338ca;
    --primary-light:  #e7e6fd;
    --success:        #059669;
    --success-rgb:    5,150,105;
    --success-bg:     #d3f5e7;
    --success-glow:        0 2px 12px rgba(5,150,105,.18);
    --success-glow-hover:  0 4px 18px rgba(5,150,105,.28);
    --danger:         #e11d48;
    --danger-rgb:     225,29,72;
    --danger-bg:      #ffe1e8;
    --warning:        #d97706;
    --warning-rgb:    217,119,6;
    --warning-bg:     #fef1d6;
    --purple:         #9333ea;
    --purple-bg:      #f1e4fd;
    --teal:           #0891b2;
    --teal-bg:        #d3f4fa;
    --gray:           #475569;
    --gray-bg:        #eef1f6;
    --gold:           #b45309;
    --gold-bg:        #fdecc8;

    --gradient-page:        linear-gradient(160deg, #f5f6fd 0%, #eceffc 45%, #f1eefb 100%);
    --gradient-sidebar:     linear-gradient(180deg, #1e1b4b 0%, #221c5c 45%, #171339 100%);
    --gradient-card:        linear-gradient(150deg, #ffffff 0%, #f8f8ff 100%);

    --bg-page:        #f3f4f9;
    --bg-card:        #ffffff;
    --bg-input:       #ffffff;
    --bg-table-head:  #f7f7fc;
    --bg-table-row:   #f7f7fc;
    --bg-modal:       #ffffff;
    --bg-btn-outline: #ffffff;

    --sidebar-bg:         #1e1b4b;
    --sidebar-hover:      #2c2768;
    --sidebar-active-bg:  #4f46e5;
    --sidebar-text:       #b3aee0;
    --sidebar-text-head:  #ffffff;
    --sidebar-border:     rgba(255,255,255,.08);
    --sidebar-section-bg: rgba(255,255,255,.05);
    --sidebar-width:      248px;
    --sidebar-width-collapsed: 76px;

    --topbar-bg:      #ffffff;
    --topbar-border:  #e7e7f3;

    --border:         #e7e7f3;
    --border-input:   #d7d8e7;
    --text-main:      #16192e;
    --text-muted:     #6b7089;
    --text-label:     #3c405c;
    --text-th:        #6b7089;

    --shadow-sm: 0 1px 3px rgba(30,27,75,.08);
    --shadow:    0 4px 14px rgba(30,27,75,.09);
    --shadow-lg: 0 12px 32px rgba(30,27,75,.16);
    --radius:    10px;
    --radius-lg: 16px;
    --modal-overlay-bg: rgba(15,13,40,.5);
    --scrollbar-thumb: #cfd0e6;
}

/* ===== تم تاریک: Midnight Aurora ===== */
[data-theme="dark"] {
    --primary:        #818cf8;
    --primary-rgb:    129,140,248;
    --primary-dark:   #6366f1;
    --primary-light:  rgba(129,140,248,.18);
    --success:        #34d399;
    --success-rgb:    52,211,153;
    --success-bg:     rgba(52,211,153,.15);
    --success-glow:        0 2px 12px rgba(52,211,153,.22);
    --success-glow-hover:  0 4px 18px rgba(52,211,153,.32);
    --danger:         #fb7185;
    --danger-rgb:     251,113,133;
    --danger-bg:      rgba(251,113,133,.15);
    --warning:        #fbbf24;
    --warning-rgb:    251,191,36;
    --warning-bg:     rgba(251,191,36,.16);
    --purple:         #c4b5fd;
    --purple-bg:      rgba(167,139,250,.2);
    --teal:           #5eead4;
    --teal-bg:        rgba(94,234,212,.16);
    --gray:           #a3a7c2;
    --gray-bg:        rgba(163,167,194,.14);
    --gold:           #fbbf24;
    --gold-bg:        rgba(251,191,36,.18);

    --gradient-page:        linear-gradient(160deg, #0a0a2e 0%, #12103c 50%, #0a0a2e 100%);
    --gradient-sidebar:     linear-gradient(180deg, #14123a 0%, #100e30 55%, #0b0924 100%);
    --gradient-card:        linear-gradient(150deg, #1a1850 0%, #201d5c 100%);

    --bg-page:        #0a0a2e;
    --bg-card:        #1a1850;
    --bg-input:       #15134a;
    --bg-table-head:  #15134a;
    --bg-table-row:   #221f63;
    --bg-modal:       #1a1850;
    --bg-btn-outline: #1a1850;

    --sidebar-bg:         #14123a;
    --sidebar-hover:      #221f63;
    --sidebar-active-bg:  #6366f1;
    --sidebar-text:       #a7abd6;
    --sidebar-text-head:  #ffffff;
    --sidebar-border:     rgba(255,255,255,.07);
    --sidebar-section-bg: rgba(255,255,255,.04);

    --topbar-bg:      #14123a;
    --topbar-border:  #221f63;

    --border:         rgba(255,255,255,.08);
    --border-input:   rgba(255,255,255,.14);
    --text-main:      #ecebfb;
    --text-muted:     #a7abd6;
    --text-label:     #a7abd6;
    --text-th:        #a7abd6;

    --shadow-sm: 0 2px 6px rgba(0,0,0,.20);
    --shadow:    0 4px 16px rgba(0,0,0,.28);
    --shadow-lg: 0 10px 36px rgba(0,0,0,.4);
    --modal-overlay-bg: rgba(6,5,26,.75);
    --scrollbar-thumb: #2c2a6e;
}

/* ===== پایه ===== */
html { background: var(--sidebar-bg); }
body {
    font-family: 'Vazirmatn', sans-serif;
    background: var(--bg-page);
    color: var(--text-main);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.6;
}

[data-theme="dark"] .stat-card {
    box-shadow: 0 0 40px 0 rgba(0,0,20,.45);
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 99px; }

/* ===== LAYOUT ===== */
.page-container {
    background: var(--gradient-page);
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-right .25s ease;
    display: flex;
    justify-content: center;
}
.main-content {
    padding: 1.75rem 1.75rem 2rem;
    width: 100%;
    max-width: clamp(1200px, 96vw, 2200px);
}
.topbar { display: none; }

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--gradient-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 200;
    overflow: hidden;
    transition: transform .25s ease;
    border-left: 1px solid var(--sidebar-border);
}

/* لوگو */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.1rem 1rem;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}
.sidebar-logo-icon .mi {
    width: 2rem; height: 2rem;
    color: var(--primary);
}
.sidebar-logo-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--sidebar-text-head);
    display: block;
    line-height: 1.2;
}
.sidebar-logo-sub {
    font-size: .7rem;
    color: var(--sidebar-text);
    display: block;
}
.sidebar-close-btn {
    display: none;
    margin-right: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--sidebar-text);
    padding: .3rem;
    border-radius: 6px;
}
.sidebar-close-btn:hover { background: var(--sidebar-hover); }
.sidebar-close-btn .mi { width: 1.2rem; height: 1.2rem; }

/* ناوبار sidebar */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: .75rem 0;
}

/* لینک مستقیم (داشبورد) */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .6rem 1rem;
    margin: .1rem .6rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: .875rem;
    transition: background .15s, color .15s;
}
.sidebar-link:hover  { background: var(--sidebar-hover); color: var(--sidebar-text-head); }
.sidebar-link.active { background: var(--sidebar-active-bg); color: #fff; }
.sidebar-link-icon .mi { width: 1.1rem; height: 1.1rem; flex-shrink: 0; }

/* جداکننده گروه‌های سایدبار */
.sidebar-divider {
    height: 1px;
    margin: .5rem 1rem;
    background: var(--border);
    opacity: .6;
}

/* سکشن با accordion */
.sidebar-section { margin: .25rem 0; }

.sidebar-section-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem 1rem;
    margin: 0 .6rem;
    width: calc(100% - 1.2rem);
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: var(--sidebar-text);
    font-family: inherit;
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    transition: background .15s, color .15s;
}
.sidebar-section-header:hover { background: var(--sidebar-hover); color: var(--sidebar-text-head); }
.sidebar-section-icon .mi { width: 1rem; height: 1rem; flex-shrink: 0; }
.sidebar-section-title { flex: 1; text-align: right; }
.sidebar-section-chevron .mi {
    width: .9rem; height: .9rem;
    transition: transform .2s;
    flex-shrink: 0;
}
.sidebar-section-header.open .sidebar-section-chevron .mi {
    transform: rotate(-90deg);
}

/* آیتم‌های سکشن */
.sidebar-section-items {
    overflow: hidden;
    max-height: 0;
    transition: max-height .25s ease;
}
.sidebar-section-items.open {
    max-height: 400px;
}
.sidebar-sublink {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .5rem 1rem .5rem 1.5rem;
    margin: .05rem .6rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--sidebar-text);
    font-size: .845rem;
    font-weight: 400;
    transition: background .15s, color .15s;
}
.sidebar-sublink:hover  { background: var(--sidebar-hover); color: var(--sidebar-text-head); }
.sidebar-sublink.active { background: var(--sidebar-active-bg); color: #fff; font-weight: 600; }
.sidebar-sublink .mi { width: 1rem; height: 1rem; flex-shrink: 0; }
.sidebar-sublink-nested {
    padding-right: 2.5rem;
    font-size: .78rem;
    position: relative;
}
.sidebar-sublink-nested::before {
    content: '';
    position: absolute;
    right: 1.9rem;
    top: 50%;
    width: .4rem;
    height: 1px;
    background: var(--sidebar-border);
}

/* زیرسکشن تودرتو (مثلا پروژه‌های یک ابزار) - accordion مستقل از سکشن‌های اصلی */
.sidebar-nested-toggle {
    width: calc(100% - 1.2rem);
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .5rem 1rem .5rem 1.5rem;
    margin: .05rem .6rem;
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: var(--sidebar-text);
    font-family: inherit;
    font-size: .78rem;
    font-weight: 600;
    transition: background .15s, color .15s;
}
.sidebar-nested-toggle:hover { background: var(--sidebar-hover); color: var(--sidebar-text-head); }
.sidebar-nested-toggle .sidebar-section-chevron { margin-right: auto; }
.sidebar-nested-toggle.open .sidebar-section-chevron .mi { transform: rotate(-90deg); }
.sidebar-nested-items {
    overflow: hidden;
    max-height: 0;
    transition: max-height .25s ease;
}
.sidebar-nested-items.open { max-height: 400px; }

/* نسخه‌ی تودرتوی سطح بالا (مثلا مدیریت پروژه) - باید دقیقاً شبیه بقیه‌ی تیترهای سکشن باشه */
.sidebar-nested-toggle-top {
    text-decoration: none;
    padding: .55rem 1rem;
    margin: 0 .6rem;
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.sidebar-nested-toggle-top.active { background: var(--sidebar-active-bg); color: #fff; }

.sidebar-badge {
    margin-right: auto;
    background: var(--danger);
    color: #fff;
    border-radius: 99px;
    font-size: .65rem;
    padding: .1rem .4rem;
    font-weight: 700;
}

/* پایین sidebar */
.sidebar-footer {
    border-top: 1px solid var(--sidebar-border);
    padding: .85rem 1rem;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: .65rem;
}
.sidebar-user-icon .mi { width: 1.2rem; height: 1.2rem; color: var(--sidebar-text); }
.sidebar-user-name {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: var(--sidebar-text-head);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}
.sidebar-user-role { display: block; font-size: .7rem; color: var(--sidebar-text); }
.sidebar-footer-actions {
    display: flex;
    gap: .5rem;
}
.sidebar-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    border-radius: 8px;
    border: 1px solid var(--sidebar-border);
    background: var(--sidebar-section-bg);
    color: var(--sidebar-text);
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, color .15s;
    flex-shrink: 0;
}
.sidebar-icon-btn:hover { background: var(--sidebar-hover); color: var(--sidebar-text-head); }
.sidebar-icon-btn .mi { width: 1.1rem; height: 1.1rem; }

/* overlay موبایل */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 199;
}

/* ===== جمع‌شدن سایدبار به حالت آیکون (فقط دسکتاپ) ===== */
.sidebar-collapse-btn {
    position: fixed;
    top: 2.3rem;
    right: var(--sidebar-width);
    transform: translate(50%, -50%);
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    background: var(--sidebar-hover);
    border: 1px solid var(--sidebar-border);
    border-radius: 50%;
    color: var(--sidebar-text-head);
    cursor: pointer;
    z-index: 201;
    transition: right .25s ease, background .15s;
}
.sidebar-collapse-btn:hover { background: var(--sidebar-active-bg); }
.sidebar-collapse-btn .mi { width: .75rem; height: .75rem; transition: transform .25s ease; }
html[data-sidebar="collapsed"] .sidebar-collapse-btn { right: var(--sidebar-width-collapsed); }
html[data-sidebar="collapsed"] .sidebar-collapse-btn .mi { transform: rotate(180deg); }

@media (max-width: 900px) { .sidebar-collapse-btn { display: none; } }

@media (min-width: 901px) {
    html[data-sidebar="collapsed"] .page-container { margin-right: var(--sidebar-width-collapsed); }
    html[data-sidebar="collapsed"] .sidebar { width: var(--sidebar-width-collapsed); overflow: visible; }
    /* flyout ها باید بتونن از مرز افقی سایدبار/nav بیرون بزنن، ولی اسکرول عمودی لیست حفظ بشه */
    html[data-sidebar="collapsed"] .sidebar-nav { overflow-x: visible; overflow-y: auto; }

    html[data-sidebar="collapsed"] .sidebar-logo { padding: 1.1rem .5rem; justify-content: center; }
    html[data-sidebar="collapsed"] .sidebar-logo-text { display: none; }

    html[data-sidebar="collapsed"] .sidebar-link,
    html[data-sidebar="collapsed"] .sidebar-section-header,
    html[data-sidebar="collapsed"] .sidebar-nested-toggle-top,
    html[data-sidebar="collapsed"] .sidebar-footer-link {
        justify-content: center;
        padding-left: .5rem; padding-right: .5rem;
        gap: 0;
    }
    html[data-sidebar="collapsed"] .sidebar-link-text,
    html[data-sidebar="collapsed"] .sidebar-section-title,
    html[data-sidebar="collapsed"] .sidebar-section-chevron,
    html[data-sidebar="collapsed"] .sidebar-badge {
        display: none;
    }

    /* بخش‌های accordion موقع جمع‌بودن به‌صورت flyout روی هاور باز می‌شن، نه به‌صورت درون‌خطی */
    html[data-sidebar="collapsed"] .sidebar-section,
    html[data-sidebar="collapsed"] .sidebar-nested-wrap {
        position: relative;
    }
    html[data-sidebar="collapsed"] .sidebar-section-items,
    html[data-sidebar="collapsed"] .sidebar-nested-items {
        max-height: 0 !important;
    }
    html[data-sidebar="collapsed"] .sidebar-section:hover > .sidebar-section-items,
    html[data-sidebar="collapsed"] .sidebar-nested-wrap:hover > .sidebar-nested-items {
        display: flex; flex-direction: column;
        max-height: none !important;
        position: absolute;
        top: 0; right: 100%;
        width: 210px;
        margin-right: .5rem;
        background: var(--sidebar-bg);
        border: 1px solid var(--sidebar-border);
        border-radius: var(--radius);
        box-shadow: var(--shadow-lg);
        padding: .4rem;
        z-index: 250;
    }
    /* زیرمنوی تودرتوی سطح دو (مثلا پروژه‌های EEPROM) داخل flyout ساده‌سازی می‌شه و باز نمی‌شه */
    html[data-sidebar="collapsed"] .sidebar-section-items .sidebar-nested-items {
        display: none !important;
    }

    html[data-sidebar="collapsed"] .sidebar-user { justify-content: center; }
    html[data-sidebar="collapsed"] .sidebar-user-info { display: none; }
    html[data-sidebar="collapsed"] .sidebar-footer-actions { justify-content: center; }
}

/* ===== TOPBAR موبایل ===== */
.topbar {
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    height: 56px;
    display: none;
    align-items: center;
    padding: 0 1rem;
    gap: .75rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}
.topbar-menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    display: flex; align-items: center;
    padding: .3rem;
    border-radius: 6px;
}
.topbar-menu-btn:hover { background: var(--bg-table-head); }
.topbar-menu-btn .mi { width: 1.4rem; height: 1.4rem; }
.topbar-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-main);
}

/* ===== عناوین صفحه ===== */
.page-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    color: var(--text-main);
}

/* ===== هشدارها ===== */
.alert {
    padding: .85rem 1.2rem;
    border-radius: var(--radius);
    margin-bottom: 1.2rem;
    font-weight: 500;
}
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success); border-right: 4px solid var(--success); }
.alert-error   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger);  border-right: 4px solid var(--danger); }

/* ===== کارت‌ها ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: box-shadow .2s;
}
.card:hover { box-shadow: var(--shadow-lg); }

/* ===== کارت «حضور به‌موقع» =====
   کمی درخشان‌تر از بقیه‌ی کارت‌ها تا وقت‌شناسی حس پاداش بده.
   رنگ‌ها از --success-rgb میان، پس توی تم روشن و تاریک خودش هماهنگ می‌شه. */
.att-ontime {
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(135deg,
            rgba(var(--success-rgb), .20) 0%,
            rgba(var(--success-rgb), .06) 45%,
            rgba(var(--success-rgb), .22) 100%),
        var(--success-bg);
    border: 1px solid rgba(var(--success-rgb), .32);
    /* box-shadow از transition عمومی .card بیرون گذاشته می‌شه: وقتی تم عوض
       می‌شه، box-shadowِ در حال ترنزیشن روی همون رنگ قبلی گیر می‌کنه و با
       سوییچ تم رفرش نمی‌شه، چون فقط متغیر CSS پشتش عوض شده نه خودِ declaration */
    transition: none;
    box-shadow: var(--success-glow);
}
.att-ontime:hover { box-shadow: var(--success-glow-hover); }

/* یک برقِ ملایم که فقط یک‌بار موقع باز شدن صفحه رد می‌شه - نه حلقه‌ی بی‌پایان،
   چون چیزی که همیشه تکون بخوره بعد از چند روز آزاردهنده می‌شه */
.att-ontime::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -55%;
    width: 42%;
    background: linear-gradient(100deg, transparent, rgba(255,255,255,.55), transparent);
    transform: skewX(-18deg);
    animation: attOnTimeSheen 1.6s ease-out .3s 1 both;
    pointer-events: none;
}
[data-theme="dark"] .att-ontime::before {
    background: linear-gradient(100deg, transparent, rgba(255,255,255,.16), transparent);
}
@keyframes attOnTimeSheen {
    from { transform: skewX(-18deg) translateX(0);    opacity: 0; }
    25%  { opacity: 1; }
    to   { transform: skewX(-18deg) translateX(400%); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .att-ontime::before { animation: none; opacity: 0; }
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.card-title { font-size: .95rem; font-weight: 700; color: var(--text-main); }
.card-body { padding: 1.5rem; }

/* ===== stats ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--gradient-card);
    border-radius: var(--radius-lg);
    padding: 1.2rem 1.4rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: box-shadow .2s, transform .2s;
}
.stat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.stat-icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-icon.blue   { background: var(--primary-light); color: var(--primary); }
.stat-icon.green  { background: var(--success-bg);    color: var(--success); }
.stat-icon.red    { background: var(--danger-bg);     color: var(--danger); }
.stat-icon.purple { background: var(--purple-bg);     color: var(--purple); }
.stat-icon .mi { width: 1.4rem; height: 1.4rem; }
.stat-label { font-size: .75rem; color: var(--text-muted); margin-bottom: .15rem; }
.stat-value { font-size: 1.1rem; font-weight: 700; color: var(--text-main); }
.stat-value.green { color: var(--success); }
.stat-value.red   { color: var(--danger); }
.stat-unit { font-size: .7rem; color: var(--text-muted); }

/* ===== جداول ===== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    background: var(--bg-table-head);
    padding: .7rem 1rem;
    text-align: right;
    font-weight: 600;
    font-size: .78rem;
    color: var(--text-th);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: .875rem;
    color: var(--text-main);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-table-row); }
tfoot td { color: var(--text-main); }

/* ===== بج‌ها ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .6rem;
    border-radius: 99px;
    font-size: .73rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-payment  { background: var(--danger-bg);      color: var(--danger); }
.badge-deposit  { background: var(--success-bg);     color: var(--success); }
.badge-creditor { background: var(--success-bg);     color: var(--success); }
.badge-debtor   { background: var(--danger-bg);      color: var(--danger); }
.badge-settled  { background: var(--bg-table-head);  color: var(--text-muted); }
.badge-type     { background: var(--primary-light);  color: var(--primary); }
.badge-warning  { background: var(--warning-bg);     color: var(--warning); }

/* ===== Pipeline فرصت فروش CRM: بورد و درگ استایل ترلو ===== */
.crm-board {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    overflow-x: auto;
    padding-bottom: .5rem;
}
.crm-stage-col {
    flex: 1 1 0;
    min-width: 220px;
    max-width: 320px;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    background: var(--bg-table-head);
    border-radius: var(--radius-lg);
    border-top: 3px solid;
    padding: .75rem;
    transition: background .15s;
}
.crm-stage-col-over { background: var(--primary-light); }
.crm-stage-col-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: .85rem;
    padding: 0 .2rem .1rem;
}
.crm-stage-count {
    background: var(--bg-card);
    color: var(--text-muted);
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    padding: .05rem .55rem;
}
.crm-deal-card { padding: .85rem; cursor: grab; transition: box-shadow .15s, transform .15s; }
.crm-deal-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.crm-drag-handle { color: var(--text-muted); flex-shrink: 0; cursor: grab; margin-top: .15rem; }
.crm-deal-card.crm-dragging {
    position: fixed;
    z-index: 500;
    pointer-events: none;
    box-shadow: var(--shadow-lg);
    cursor: grabbing;
    will-change: transform;
}
.crm-deal-placeholder {
    border: 2px dashed var(--border-input);
    border-radius: var(--radius-lg);
    background: rgba(0,0,0,.04);
    pointer-events: none;
}
body.crm-drag-active { user-select: none; cursor: grabbing; }

.crm-tabs { display: flex; gap: .35rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.crm-tab {
    padding: .55rem 1.1rem;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color .15s, border-color .15s;
}
.crm-tab:hover { color: var(--text-main); }
.crm-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ===== دکمه‌ها ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1.1rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: .875rem;
    font-weight: 600;
    text-decoration: none;
    transition: all .15s;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.08); }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover  { filter: brightness(1.08); }
.btn-outline {
    background: var(--bg-btn-outline);
    color: var(--text-label);
    border: 1px solid var(--border-input);
}
.btn-outline:hover { background: var(--bg-table-row); border-color: var(--primary); }
.btn-sm { padding: .3rem .75rem; font-size: .8rem; }
.btn-icon { padding: .35rem .5rem; }
.btn .mi { width: 1em; height: 1em; }

/* دکمه‌های pill (کپسولی) در تم تاریک */
[data-theme="dark"] .btn { border-radius: 9999px; }

/* ===== فرم‌ها ===== */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-group label { font-size: .8rem; font-weight: 600; color: var(--text-label); }
.form-control {
    width: 100%;
    padding: .55rem .85rem;
    border: 1px solid var(--border-input);
    border-radius: 8px;
    font-family: inherit;
    font-size: .875rem;
    color: var(--text-main);
    background: var(--bg-input);
    transition: border-color .15s, box-shadow .15s;
    appearance: none;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb),.15);
}
.form-control::placeholder { color: var(--text-muted); opacity: .6; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: .75rem; color: var(--text-muted); }

/* ===== مدال ===== */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: var(--modal-overlay-bg);
    backdrop-filter: blur(3px);
    z-index: 300;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--bg-modal);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity:0; } to { transform: translateY(0); opacity:1; } }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 700; font-size: .95rem; color: var(--text-main); }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: .2rem; border-radius: 4px; }
.modal-close:hover { color: var(--danger); }
.modal-close .mi { width: 1.2rem; height: 1.2rem; }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: .75rem; justify-content: flex-end; }

/* ===== فیلتر ===== */
.filter-bar { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1.2rem; }
.filter-bar .form-group { min-width: 155px; }

/* ===== صفحه‌بندی ===== */
.pagination { display: flex; gap: .4rem; justify-content: center; margin-top: 1.2rem; flex-wrap: wrap; }
.pagination a, .pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    font-size: .85rem;
    border: 1px solid var(--border);
    color: var(--text-label);
    background: var(--bg-card);
    transition: all .15s;
}
.pagination a:hover  { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .disabled { color: var(--text-muted); cursor: default; pointer-events: none; }

/* ===== empty state ===== */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state-icon { margin-bottom: .75rem; }
.empty-state-icon .mi { width: 3rem; height: 3rem; opacity: .3; }
.empty-state p { font-size: .9rem; }

/* ===== فوتر ===== */
.site-footer { text-align: center; padding: 1.5rem; color: var(--text-muted); font-size: .78rem; border-top: 1px solid var(--border); margin-top: 2rem; }

/* ===== ماژول QC: رادیوگروپ نتیجه تست ===== */
.qc-radio-group { display: flex; gap: .5rem; flex-wrap: wrap; }
.qc-radio-group label {
    display: flex; align-items: center; gap: .35rem;
    padding: .35rem .8rem; border: 1px solid var(--border); border-radius: 6px;
    cursor: pointer; font-size: .8rem; color: var(--text-muted); transition: .15s;
}
.qc-radio-group input[type="radio"] { margin: 0; accent-color: var(--primary); }
.qc-radio-group label:has(input:checked) { color: var(--text-main); font-weight: 600; border-color: var(--primary); }
.qc-radio-group label.qc-passed:has(input:checked) { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.qc-radio-group label.qc-failed:has(input:checked)  { background: var(--danger-bg);  border-color: var(--danger);  color: var(--danger); }

/* ===== ماژول QC: آکاردئون ===== */
.qc-accordion { border: 1px solid var(--border); border-radius: 8px; margin-bottom: .75rem; overflow: hidden; }
.qc-accordion-btn {
    width: 100%; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    padding: .7rem 1rem; background: var(--bg-table-head); border: none; cursor: pointer;
    font-weight: 600; font-size: .85rem; color: var(--text-main); font-family: inherit;
}
.qc-accordion-summary { font-size: .75rem; color: var(--text-muted); font-weight: 400; display: flex; gap: .5rem; }
.qc-accordion-chevron { transition: transform .15s; }
.qc-accordion-btn.open .qc-accordion-chevron { transform: rotate(180deg); }
.qc-accordion-body { display: none; padding: 1rem; border-top: 1px solid var(--border); }
.qc-accordion-body.open { display: block; }

/* ===== Material Icons SVG ===== */
.mi { width: 1.1em; height: 1.1em; fill: currentColor; display: inline-block; vertical-align: -0.2em; flex-shrink: 0; }

/* ===== spinner حذف ===== */
input[type=number].row-qty::-webkit-outer-spin-button,
input[type=number].row-qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number].row-qty { -moz-appearance: textfield; }

/* ===== ریسپانسیو ===== */
@media (max-width: 900px) {
    .page-container { margin-right: 0; }
    .topbar { display: flex; }
    .sidebar {
        transform: translateX(100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.open { display: block; }
    .sidebar-close-btn { display: flex; }
    .main-content { padding: 1rem; }
    .hide-sm { display: none !important; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-grid  { grid-template-columns: 1fr; }
    table { font-size: .8rem; }
    thead th, tbody td { padding: .6rem .6rem; }
}
@media (max-width: 360px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* ===== گاوصندوق ===== */
.vault-item {
    transition: box-shadow .2s;
}
.vault-item:hover {
    box-shadow: var(--shadow-lg);
}
.vault-secret {
    letter-spacing: .05em;
}
/* رنگ input color */
input[type="color"].form-control {
    padding: .2rem .4rem;
    cursor: pointer;
}

/* ===== badge نقش‌های کاربری ===== */
.badge-superadmin { background: var(--gold-bg); color: var(--gold); }
.badge-admin      { background: var(--primary-light); color: var(--primary); }
.badge-accountant { background: var(--success-bg); color: var(--success); }
.badge-technical  { background: var(--purple-bg); color: var(--purple); }

/* ===== انتخاب آیکون و رنگ اعلان ===== */
.ann-picker-row { display: flex; flex-wrap: wrap; gap: .45rem; }
.ann-icon-opt {
    width: 2.15rem; height: 2.15rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: border-color .15s, color .15s, background .15s;
}
.ann-icon-opt .mi { width: 1.05rem; height: 1.05rem; }
.ann-icon-opt input { display: none; }
.ann-icon-opt:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}
.ann-color-opt {
    width: 1.9rem; height: 1.9rem;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    padding: 2px;
    display: flex; align-items: center; justify-content: center;
}
.ann-color-opt span {
    width: 100%; height: 100%;
    border-radius: 50%;
    display: block;
}
.ann-color-opt input { display: none; }
.ann-color-opt:has(input:checked) { border-color: var(--text-main); }

/* نمایش/مخفی‌سازی فرم ویرایش درجا (فرصت فروش / تماس) */
.crm-hidden { display: none; }