/* ============================================================
   استایل پنل مدیریت لابراتوار سروش
   منبع طراحی: dashboard.html — پورت‌شده به پروژهٔ MVC، تماماً سلف‌هاست
   ============================================================ */

/* ===================== متغیرهای پایه ===================== */
:root {
    /* پالت رنگ — تم روشن */
    --bg: #FAF8F5;
    --surface: #FFFFFF;
    --surface-2: #F4F1EB;
    --border: #E8E4DD;
    --border-strong: #D4CDC0;
    --text: #1A1F2E;
    --text-secondary: #5C6675;
    --text-muted: #94A0B0;

    --primary: #0F766E;
    --primary-hover: #115E59;
    --primary-soft: #CCFBF1;
    --primary-soft-hover: #B5F2E5;

    --accent: #C2410C;
    --accent-soft: #FFEDD5;
    --success: #15803D;
    --success-soft: #DCFCE7;
    --warning: #B45309;
    --warning-soft: #FEF3C7;
    --danger: #B91C1C;
    --danger-soft: #FEE2E2;
    --info: #1D4ED8;
    --info-soft: #DBEAFE;

    /* ابعاد */
    --sidebar-w: 264px;
    --topbar-h: 68px;
    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;

    /* سایه‌ها */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.03);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 16px 48px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);

    /* تایپوگرافی */
    --font: 'Vazirmatn', system-ui, sans-serif;
}

/* تم تاریک */
[data-theme="dark"] {
    --bg: #0E1218;
    --surface: #161B22;
    --surface-2: #1F2630;
    --border: #2A3340;
    --border-strong: #3A4452;
    --text: #F0EBE3;
    --text-secondary: #A8B2C1;
    --text-muted: #6B7689;

    --primary: #2DD4BF;
    --primary-hover: #5EEAD4;
    --primary-soft: rgba(45, 212, 191, 0.12);
    --primary-soft-hover: rgba(45, 212, 191, 0.2);

    --accent: #FB923C;
    --accent-soft: rgba(251, 146, 60, 0.12);
    --success: #4ADE80;
    --success-soft: rgba(74, 222, 128, 0.12);
    --warning: #FCD34D;
    --warning-soft: rgba(252, 211, 77, 0.12);
    --danger: #F87171;
    --danger-soft: rgba(248, 113, 113, 0.12);
    --info: #60A5FA;
    --info-soft: rgba(96, 165, 250, 0.12);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
}

/* ===================== ریست و پایه ===================== */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    transition: background 0.3s ease, color 0.3s ease;
    font-feature-settings: 'ss01' on;
}

/* اعداد لاتین با هم‌خوانی بهتر */
.num-latin { font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: transparent; }
a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===================== چیدمان کلی ===================== */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

/* ===================== سایدبار ===================== */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
    padding: 22px 22px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    display: grid;
    place-items: center;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.25);
}
[data-theme="dark"] .brand-mark { box-shadow: 0 4px 12px rgba(45, 212, 191, 0.2); }

.brand-mark i { font-size: 22px; }

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}
.brand-tagline {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 18px 12px;
}

.nav-section + .nav-section { margin-top: 18px; }

.nav-label {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 12px 8px;
    letter-spacing: 0.08em;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 2px;
    position: relative;
    transition: all 0.15s ease;
}

.nav-item:hover { background: var(--surface-2); color: var(--text); }

.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}

.nav-item.active::before {
    content: "";
    position: absolute;
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 22px;
    background: var(--primary);
    border-radius: 3px 0 0 3px;
}

.nav-item i { font-size: 18px; flex-shrink: 0; }

.nav-badge {
    margin-right: auto;
    font-size: 11px;
    font-weight: 700;
    background: var(--accent-soft);
    color: var(--accent);
    padding: 2px 7px;
    border-radius: 999px;
    min-width: 22px;
    text-align: center;
}

.sidebar-footer {
    padding: 14px;
    border-top: 1px solid var(--border);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px;
    border-radius: 12px;
    transition: background 0.15s ease;
    cursor: pointer;
}
.user-card:hover { background: var(--surface-2); }

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #C2410C, #EA580C);
    display: grid;
    place-items: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    border: 2px solid var(--surface);
    box-shadow: var(--shadow-sm);
}

.user-info { flex: 1; min-width: 0; }
.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role { font-size: 11px; color: var(--text-muted); }

/* ===================== محتوای اصلی ===================== */
.main {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* نوار بالا */
.topbar {
    height: var(--topbar-h);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
    background: color-mix(in srgb, var(--bg) 80%, transparent);
}

.menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    place-items: center;
}
.menu-toggle i { font-size: 22px; }

.page-title-group { display: flex; flex-direction: column; }
.breadcrumb {
    font-size: 11.5px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.02em;
}
.page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-top: 2px;
}

.topbar-actions {
    margin-right: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 12px;
    height: 40px;
    width: 260px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.search-box i { color: var(--text-muted); font-size: 17px; }
.search-box input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 13px;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-box kbd {
    font-family: ui-monospace, monospace;
    font-size: 10px;
    padding: 2px 6px;
    background: var(--surface-2);
    border-radius: 4px;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    position: relative;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}
.icon-btn:hover {
    color: var(--text);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}
.icon-btn i { font-size: 19px; }

.icon-btn .dot {
    position: absolute;
    top: 9px;
    left: 9px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--surface);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 40px;
    padding: 0 16px;
    border-radius: 10px;
    background: var(--primary);
    color: white;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.15s ease;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 30%, transparent);
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 40%, transparent);
}
.btn-primary i { font-size: 18px; }
[data-theme="dark"] .btn-primary { color: var(--surface); }

/* ===================== محتوای پیشخوان ===================== */
.content {
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* بنر خوش‌آمد */
.welcome {
    background:
        radial-gradient(ellipse 80% 60% at 100% 0%, color-mix(in srgb, var(--primary) 12%, transparent), transparent),
        radial-gradient(ellipse 60% 80% at 0% 100%, color-mix(in srgb, var(--accent) 8%, transparent), transparent),
        var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
    overflow: hidden;
}

.welcome::after {
    content: "";
    position: absolute;
    left: -40px;
    bottom: -40px;
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, color-mix(in srgb, var(--primary) 14%, transparent), transparent 65%);
    border-radius: 50%;
    pointer-events: none;
}

.welcome-content { flex: 1; position: relative; z-index: 1; }
.welcome-date {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 6px;
}
.welcome-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}
.welcome-title span { color: var(--primary); }
.welcome-subtitle {
    font-size: 13.5px;
    color: var(--text-secondary);
    max-width: 540px;
}

.welcome-meta {
    display: flex;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}
.meta-pill i { color: var(--primary); font-size: 14px; }

/* کارت‌های آمار */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

.stat-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
}
.stat-icon i { font-size: 19px; }

.stat-icon.teal { background: var(--primary-soft); color: var(--primary); }
.stat-icon.amber { background: var(--warning-soft); color: var(--warning); }
.stat-icon.coral { background: var(--accent-soft); color: var(--accent); }
.stat-icon.green { background: var(--success-soft); color: var(--success); }
.stat-icon.rose { background: var(--danger-soft); color: var(--danger); }

.stat-trend {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11.5px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
}
.stat-trend i { font-size: 13px; }
.stat-trend.up { background: var(--success-soft); color: var(--success); }
.stat-trend.down { background: var(--danger-soft); color: var(--danger); }
.stat-trend.neutral { background: var(--surface-2); color: var(--text-muted); }

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.stat-label {
    font-size: 12.5px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 4px;
}

/* ردیف ابزارها — گردش کار و آمار */
.row {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 18px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.panel-title-group { display: flex; flex-direction: column; gap: 3px; }
.panel-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}
.panel-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

.panel-actions { display: flex; gap: 6px; }

.chip-group {
    display: flex;
    background: var(--surface-2);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}
.chip-group button {
    padding: 5px 11px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
}
.chip-group button.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-xs);
}

/* بصری‌سازی گردش کار — ۱۰ مرحله */
.workflow {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stage {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    align-items: center;
    gap: 14px;
}

.stage-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--surface-2);
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.stage-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stage-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}
.stage-name { font-size: 13px; font-weight: 600; color: var(--text); }
.stage-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.stage-bar {
    height: 6px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
}
.stage-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary), var(--primary-hover));
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.stage-bar-fill.warning { background: linear-gradient(90deg, var(--warning), #D97706); }
.stage-bar-fill.accent { background: linear-gradient(90deg, var(--accent), #DC2626); }

.stage-meta {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* نمودار عملکرد */
.chart-wrap {
    height: 280px;
    position: relative;
}

.legend {
    display: flex;
    gap: 14px;
    margin-top: 14px;
    flex-wrap: wrap;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: var(--text-secondary);
}
.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

/* جدول سفارش‌های اخیر */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.table-wrap .panel-head { padding: 22px 22px 0; margin-bottom: 16px; }

.table-scroll { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 760px;
}

thead th {
    text-align: right;
    padding: 10px 22px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--surface-2);
    border-block: 1px solid var(--border);
}

tbody td {
    padding: 14px 22px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: var(--surface-2); }

.order-id {
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.order-id-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.customer {
    display: flex;
    align-items: center;
    gap: 10px;
}
.customer-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}
.customer-name { font-weight: 600; color: var(--text); font-size: 13px; }
.customer-clinic { font-size: 11px; color: var(--text-muted); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
}
.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.badge.teal { background: var(--primary-soft); color: var(--primary); }
.badge.teal .badge-dot { background: var(--primary); }
.badge.amber { background: var(--warning-soft); color: var(--warning); }
.badge.amber .badge-dot { background: var(--warning); }
.badge.coral { background: var(--accent-soft); color: var(--accent); }
.badge.coral .badge-dot { background: var(--accent); }
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.green .badge-dot { background: var(--success); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.info .badge-dot { background: var(--info); }

.priority-flag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    padding: 3px 8px;
    background: var(--accent-soft);
    border-radius: 6px;
}
.priority-flag i { font-size: 13px; }

/* سمت چپ — هشدارها و فعالیت‌ها */
.side-stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.alert-list { display: flex; flex-direction: column; gap: 10px; }

.alert {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: 11px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    transition: all 0.15s ease;
}
.alert:hover { background: var(--surface); border-color: var(--border-strong); }

.alert-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.alert-icon i { font-size: 17px; }

.alert-body { flex: 1; min-width: 0; }
.alert-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}
.alert-text {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.alert-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

/* فعالیت‌های اخیر */
.activity-list { display: flex; flex-direction: column; gap: 0; }

.activity {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    position: relative;
}

.activity-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.activity:not(:last-child)::before {
    content: "";
    position: absolute;
    right: 13px;
    top: 30px;
    bottom: -10px;
    width: 2px;
    background: var(--border);
}

.activity-content { flex: 1; min-width: 0; padding-top: 4px; }
.activity-text {
    font-size: 12.5px;
    color: var(--text);
    line-height: 1.5;
}
.activity-text strong { font-weight: 700; }
.activity-text .ref { color: var(--primary); font-weight: 600; }
.activity-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
}

/* ===================== ریسپانسیو ===================== */
@media (max-width: 1280px) {
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
    .stat-grid .stat-card:nth-child(4),
    .stat-grid .stat-card:nth-child(5) { grid-column: span 1; }
    .stat-grid .stat-card:nth-child(4) { grid-column: 1 / 3; }
    .stat-grid .stat-card:nth-child(5) { grid-column: 3; }
}

@media (max-width: 1100px) {
    .row { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    :root { --sidebar-w: 100%; }

    .app { grid-template-columns: 1fr; }

    .sidebar {
        transform: translateX(100%);
        width: 300px;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }

    .main { grid-column: 1; }

    .menu-toggle { display: grid; }

    .search-box { width: 200px; }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 99;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }
    .sidebar-overlay.show { opacity: 1; pointer-events: all; }
}

@media (max-width: 720px) {
    .topbar { padding: 0 16px; gap: 10px; }
    .content { padding: 16px; gap: 16px; }
    .search-box { display: none; }
    .page-title { font-size: 16px; }
    .breadcrumb { display: none; }

    .welcome {
        flex-direction: column;
        align-items: flex-start;
        padding: 20px;
    }
    .welcome-title { font-size: 18px; }
    .welcome-meta { flex-wrap: wrap; }

    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-grid .stat-card:nth-child(n) { grid-column: span 1; }
    .stat-grid .stat-card:nth-child(5) { grid-column: 1 / -1; }

    .panel { padding: 18px; }
    .panel-head { flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }

    thead th, tbody td { padding: 12px 16px; }
    .table-wrap .panel-head { padding: 18px 16px 0; }

    .stat-value { font-size: 24px; }
}

@media (max-width: 420px) {
    .stat-grid { grid-template-columns: 1fr; }
    .stat-grid .stat-card:nth-child(5) { grid-column: span 1; }
    .topbar-actions .btn-primary span { display: none; }
    .btn-primary { padding: 0 10px; }
}

/* ===================== انیمیشن ===================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.content > * {
    animation: fadeIn 0.4s ease backwards;
}
.content > *:nth-child(1) { animation-delay: 0ms; }
.content > *:nth-child(2) { animation-delay: 60ms; }
.content > *:nth-child(3) { animation-delay: 120ms; }
.content > *:nth-child(4) { animation-delay: 180ms; }

/* تمرکز قابل دسترسی */
button:focus-visible, a:focus-visible, input:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 6px;
}

/* پیشگیری از پرش هنگام تغییر تم */
body, .sidebar, .topbar, .panel, .stat-card, .table-wrap, .welcome, .alert {
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

/* ===================== صفحهٔ ورود / احراز هویت ===================== */
.auth-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    background:
        radial-gradient(ellipse 70% 60% at 100% 0%, color-mix(in srgb, var(--primary) 12%, transparent), transparent),
        radial-gradient(ellipse 60% 70% at 0% 100%, color-mix(in srgb, var(--accent) 8%, transparent), transparent),
        var(--bg);
}

.auth-wrap { width: 100%; max-width: 420px; }

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px 28px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
}

.auth-head { margin-bottom: 22px; }
.auth-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}
.auth-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
}

.field-input {
    display: flex;
    align-items: center;
    gap: 9px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 12px;
    height: 46px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.field-input:focus-within {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.field-input i { color: var(--text-muted); font-size: 19px; flex-shrink: 0; }
.field-input input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    min-width: 0;
}
.field-input input::placeholder { color: var(--text-muted); font-size: 13px; }

.pw-toggle {
    display: grid;
    place-items: center;
    color: var(--text-muted);
    padding: 4px;
}
.pw-toggle:hover { color: var(--text-secondary); }

.field-error {
    font-size: 11.5px;
    color: var(--danger);
    font-weight: 500;
}

.field-row { display: flex; align-items: center; justify-content: space-between; }

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}
.checkbox input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

.auth-error {
    background: var(--danger-soft);
    color: var(--danger);
    border-radius: 10px;
    padding: 11px 13px;
    font-size: 12.5px;
    font-weight: 500;
}
.auth-error:empty { display: none; }
.auth-error ul { list-style: none; margin: 0; padding: 0; }

.auth-submit {
    width: 100%;
    justify-content: center;
    height: 46px;
    margin-top: 4px;
    font-size: 14px;
}

.auth-foot {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 11.5px;
    color: var(--text-muted);
}

/* ===================== فرم‌ها و صفحات سفارش ===================== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 18px;
}
.form-field { display: flex; flex-direction: column; gap: 7px; }
.form-field.col-span-2 { grid-column: 1 / -1; }
.form-label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }

.form-control {
    width: 100%;
    height: 44px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 10px;
    padding: 0 12px;
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
textarea.form-control { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.form-control:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-control::placeholder { color: var(--text-muted); font-size: 13px; }
select.form-control { cursor: pointer; }
input[type="file"].form-control { padding: 9px 12px; height: auto; line-height: 1.5; }

.form-hint { font-size: 11px; color: var(--text-muted); }

.check-row { display: flex; flex-wrap: wrap; gap: 18px; padding: 4px 0; }

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 40px;
    padding: 0 16px;
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13px;
    border: 1px solid var(--border);
    transition: all 0.15s ease;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); }
.btn-ghost i { font-size: 17px; }
.btn-ghost-danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 40px;
    padding: 0 16px;
    border-radius: 10px;
    background: var(--danger);
    color: white;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.15s ease;
}
.btn-danger:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-danger i { font-size: 17px; }
[data-theme="dark"] .btn-danger { color: var(--surface); }

/* حالت خالی فهرست */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 56px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 44px; }
.empty-state p { font-size: 14px; }

.row-link {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: var(--text-muted);
    transition: all 0.15s ease;
}
.row-link:hover { background: var(--primary-soft); color: var(--primary); }

/* سرصفحهٔ جزئیات سفارش */
.order-detail-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}
.order-detail-badges { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* شبکهٔ اطلاعات */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 18px;
}
.info-item { display: flex; flex-direction: column; gap: 3px; }
.info-label { font-size: 11.5px; color: var(--text-muted); font-weight: 600; }
.info-value { font-size: 13.5px; color: var(--text); font-weight: 500; }

.files-block { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.file-list { display: flex; flex-wrap: wrap; gap: 8px; }
.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 12.5px;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}
.file-chip:hover { border-color: var(--primary); color: var(--primary); }
.file-chip i { font-size: 17px; }
.file-ver { color: var(--text-muted); font-size: 11px; }

/* کنترل گردش کار */
.wf-action { margin-bottom: 12px; display: flex; flex-direction: column; gap: 8px; }
.wf-action:last-child { margin-bottom: 0; }
.wf-reject {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
}

/* جعبه‌های پیام (callout) */
.callout {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 11px;
    font-size: 12.5px;
    line-height: 1.6;
    margin-top: 14px;
}
.callout i { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.callout-danger { background: var(--danger-soft); color: var(--danger); }
.callout-success { background: var(--success-soft); color: var(--success); }
.callout-warning { background: var(--warning-soft); color: var(--warning); }

/* پیام‌های فلش (TempData) */
.flash-wrap { padding: 16px 28px 0; display: flex; flex-direction: column; gap: 10px; }
.flash {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 12px 15px;
    border-radius: 11px;
    font-size: 13px;
    font-weight: 500;
}
.flash i { font-size: 18px; }
.flash-success { background: var(--success-soft); color: var(--success); }
.flash-error { background: var(--danger-soft); color: var(--danger); }

@media (max-width: 720px) {
    .form-grid, .info-grid { grid-template-columns: 1fr; }
    .flash-wrap { padding: 16px 16px 0; }
}

/* چیپ نقش‌ها (فهرست کاربران) و شبکهٔ انتخاب نقش (فرم) */
.role-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.role-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: var(--primary-soft);
    color: var(--primary);
}

.role-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px 16px;
    padding: 4px 0;
}
.role-check {
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    transition: border-color 0.15s ease, background 0.15s ease;
}
.role-check:hover { border-color: var(--border-strong); }
.role-check:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}

/* دکمهٔ خروج در کارت کاربر سایدبار */
.logout-btn {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: all 0.15s ease;
}
.logout-btn:hover { background: var(--danger-soft); color: var(--danger); }
.logout-btn i { font-size: 18px; }
