/* ==========================================================================
   Robin Admin — سیستم طراحی
   ========================================================================== */

:root {
    color-scheme: light;

    --font-sans: "Vazirmatn", "Segoe UI", Tahoma, sans-serif;

    --sidebar-w: 16.5rem;
    --topbar-h: 4.25rem;
    --page-max: 1180px;

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-pill: 999px;

    --brand-1: #5b8cff;
    --brand-2: #2348e6;
    --brand-3: #17b6d8;

    --bg: #eceff8;
    --surface: #ffffff;
    --surface-2: #f6f8fd;
    --surface-3: #eaeffa;
    --glass: rgba(255, 255, 255, 0.72);

    --ink: #0e1628;
    --ink-2: #32405d;
    --muted: #6a7794;
    --faint: #94a1bd;

    --line: #e3e8f4;
    --line-strong: #ccd6ea;

    --accent: #2a55ee;
    --accent-strong: #1c3fce;
    --accent-soft: #e9eeff;
    --accent-ink: #1e3dba;

    --success: #0d7a56;
    --success-soft: #e0f6ed;
    --success-line: #b3e5d1;

    --danger: #c02a2a;
    --danger-soft: #fdecec;
    --danger-line: #f4c6c6;

    --warning: #9a6209;
    --warning-soft: #fdf2dd;
    --warning-line: #f0dcae;

    --shadow-xs: 0 1px 2px rgba(14, 22, 40, 0.06);
    --shadow-sm: 0 2px 6px rgba(14, 22, 40, 0.06), 0 1px 2px rgba(14, 22, 40, 0.04);
    --shadow-md: 0 14px 34px -16px rgba(14, 22, 40, 0.28), 0 2px 8px rgba(14, 22, 40, 0.05);
    --shadow-lg: 0 30px 70px -30px rgba(14, 22, 40, 0.45);
    --ring: 0 0 0 3px rgba(42, 85, 238, 0.18);

    /* نام‌های قدیمی برای سازگاری با استایل‌های درون‌خطی */
    --accent-soft-legacy: var(--accent-soft);
    --shadow: var(--shadow-md);
}

[data-theme="dark"] {
    color-scheme: dark;

    --bg: #070b16;
    --surface: #101829;
    --surface-2: #141d31;
    --surface-3: #1b263e;
    --glass: rgba(16, 24, 41, 0.78);

    --ink: #e9eefb;
    --ink-2: #c3cde3;
    --muted: #8e9cba;
    --faint: #6d7c9c;

    --line: rgba(255, 255, 255, 0.09);
    --line-strong: rgba(255, 255, 255, 0.16);

    --accent: #6f93ff;
    --accent-strong: #8aa8ff;
    --accent-soft: rgba(111, 147, 255, 0.16);
    --accent-ink: #b7c9ff;

    --success: #4fd1a1;
    --success-soft: rgba(79, 209, 161, 0.14);
    --success-line: rgba(79, 209, 161, 0.3);

    --danger: #ff8080;
    --danger-soft: rgba(255, 128, 128, 0.14);
    --danger-line: rgba(255, 128, 128, 0.3);

    --warning: #f2c063;
    --warning-soft: rgba(242, 192, 99, 0.14);
    --warning-line: rgba(242, 192, 99, 0.3);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 18px 40px -20px rgba(0, 0, 0, 0.75), 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 34px 80px -34px rgba(0, 0, 0, 0.9);
    --ring: 0 0 0 3px rgba(111, 147, 255, 0.28);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    direction: rtl;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--bg);
    background-image:
        radial-gradient(60rem 32rem at 100% -8%, rgba(91, 140, 255, 0.18), transparent 60%),
        radial-gradient(48rem 30rem at -10% 8%, rgba(23, 182, 216, 0.14), transparent 62%);
    background-attachment: fixed;
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
}

[data-theme="dark"] body {
    background-image:
        radial-gradient(60rem 32rem at 100% -8%, rgba(53, 90, 200, 0.28), transparent 60%),
        radial-gradient(48rem 30rem at -10% 8%, rgba(15, 118, 145, 0.22), transparent 62%);
}

a {
    color: inherit;
    text-decoration: none;
}

h1,
h2,
h3 {
    letter-spacing: -0.01em;
}

code {
    padding: 0.1em 0.4em;
    border-radius: 6px;
    background: var(--surface-3);
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.86em;
    direction: ltr;
    display: inline-block;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 6px;
}

::selection {
    background: var(--accent-soft);
    color: var(--accent-ink);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border: 3px solid transparent;
    background-clip: content-box;
    border-radius: var(--radius-pill);
}

.skip-link {
    position: fixed;
    top: 0.75rem;
    right: 50%;
    transform: translate(50%, -160%);
    z-index: 100;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    transition: transform 0.18s ease;
}

.skip-link:focus-visible {
    transform: translate(50%, 0);
}

/* ==========================================================================
   چیدمان اصلی
   ========================================================================== */

.app-shell {
    min-height: 100vh;
}

.app-main {
    min-height: 100vh;
    /* مقدار فیزیکی به‌عنوان پشتیبان مرورگرهای قدیمی (سند همیشه راست‌به‌چپ است) */
    margin-right: var(--sidebar-w);
    margin-inline-start: var(--sidebar-w);
    display: flex;
    flex-direction: column;
}

.scrim {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 45;
    background: rgba(8, 13, 26, 0.5);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

body.nav-open .scrim {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   نوار کناری
   ========================================================================== */

.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 50;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.1rem 0.85rem 1rem;
    background: var(--surface);
    border-left: 1px solid var(--line);
    border-inline-end: 1px solid var(--line);
    overflow-y: auto;
    overscroll-behavior: contain;
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.15rem 0.35rem 0.9rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.brand-mark {
    display: grid;
    place-items: center;
    flex: none;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 13px;
    background: linear-gradient(140deg, var(--brand-1), var(--brand-2) 62%, var(--brand-3));
    color: #fff;
    box-shadow: 0 8px 20px -8px rgba(35, 72, 230, 0.8);
}

.brand-mark svg {
    width: 1.25rem;
    height: 1.25rem;
}

.brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.35;
}

.brand-text strong {
    font-size: 1.02rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-text small {
    color: var(--muted);
    font-size: 0.73rem;
    letter-spacing: 0.02em;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
    flex: 1;
}

.nav-group-title {
    margin: 0 0 0.4rem;
    padding-inline: 0.7rem;
    color: var(--faint);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.56rem 0.7rem;
    border-radius: var(--radius-md);
    color: var(--ink-2);
    font-size: 0.93rem;
    font-weight: 500;
    transition: background 0.16s ease, color 0.16s ease;
}

.nav-link svg {
    flex: none;
    width: 1.15rem;
    height: 1.15rem;
    opacity: 0.75;
    transition: opacity 0.16s ease;
}

.nav-link:hover {
    background: var(--surface-3);
    color: var(--ink);
}

.nav-link:hover svg {
    opacity: 1;
}

.nav-link.is-active,
.nav-link.active {
    background: var(--accent-soft);
    color: var(--accent-ink);
    font-weight: 700;
}

.nav-link.is-active svg,
.nav-link.active svg {
    opacity: 1;
}

.nav-link.is-active::before,
.nav-link.active::before {
    content: "";
    position: absolute;
    right: -0.85rem;
    top: 0.42rem;
    bottom: 0.42rem;
    inset-inline-start: -0.85rem;
    inset-block: 0.42rem;
    width: 3px;
    border-radius: var(--radius-pill);
    background: linear-gradient(180deg, var(--brand-1), var(--brand-2));
}

.sidebar-foot {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--line);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    border: 1px solid var(--line);
}

.avatar {
    display: grid;
    place-items: center;
    flex: none;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 50%;
    background: linear-gradient(140deg, var(--brand-1), var(--brand-2));
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
}

.user-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.4;
}

.user-meta strong {
    font-size: 0.88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-meta small {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--muted);
    font-size: 0.72rem;
}

.user-meta small::before {
    content: "";
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px var(--success-soft);
}

.nav-logout {
    color: var(--danger);
}

.nav-logout:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

/* ==========================================================================
   نوار بالا
   ========================================================================== */

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: var(--topbar-h);
    padding: 0.6rem clamp(1rem, 3vw, 2rem);
    background: var(--glass);
    border-bottom: 1px solid var(--line);
    backdrop-filter: saturate(160%) blur(14px);
}

.crumbs {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.crumbs strong {
    color: var(--ink);
    font-size: 0.97rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crumb-sep {
    color: var(--faint);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-right: auto;
    margin-inline-start: auto;
}

.icon-btn {
    display: grid;
    place-items: center;
    flex: none;
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--ink-2);
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.icon-btn svg {
    width: 1.15rem;
    height: 1.15rem;
}

.icon-btn:hover {
    background: var(--surface-3);
    border-color: var(--line-strong);
    color: var(--ink);
}

.menu-btn,
.sidebar-close {
    display: none;
}

.theme-toggle .icon-moon {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: none;
}

/* ==========================================================================
   محتوای صفحه
   ========================================================================== */

.page {
    flex: 1;
    width: min(var(--page-max), 100%);
    margin-inline: auto;
    padding: clamp(1.25rem, 3vw, 2.15rem) clamp(1rem, 3vw, 2rem) 3.5rem;
}

.page > h1 {
    margin: 0 0 0.3rem;
    font-size: clamp(1.45rem, 2.6vw, 1.85rem);
    font-weight: 700;
    line-height: 1.35;
}

.page > .lead {
    margin: 0 0 1.6rem;
    max-width: 62ch;
    color: var(--muted);
    font-size: 0.95rem;
}

.page h2 {
    margin: 0 0 0.85rem;
    font-size: 1.08rem;
    font-weight: 700;
}

.page h3 {
    font-size: 1rem;
}

.section {
    margin-top: 1.85rem;
}

.section-head h2 {
    margin-bottom: 0.25rem;
}

.section-head .muted {
    margin: 0 0 1rem;
}

.muted {
    color: var(--muted);
}

.mono {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    direction: ltr;
    text-align: right;
    white-space: nowrap;
}

/* ==========================================================================
   کارت‌ها و آمار
   ========================================================================== */

.card {
    padding: 1.3rem 1.4rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card + .card {
    margin-top: 1rem;
}

.card p:last-child {
    margin-bottom: 0;
}

.stats,
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr));
    gap: 0.9rem;
    margin-bottom: 1.85rem;
}

.card .stats,
.card .stats-grid {
    margin-bottom: 0;
}

.stat-card {
    position: relative;
    overflow: hidden;
    padding: 1.1rem 1.2rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.stat-card::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--brand-3), var(--brand-1), var(--brand-2));
}

.stat-card::after {
    content: "";
    position: absolute;
    top: -3.5rem;
    right: -2.5rem;
    width: 9rem;
    height: 9rem;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-soft), transparent 68%);
    pointer-events: none;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--line-strong);
    box-shadow: var(--shadow-md);
}

.stat-label {
    display: block;
    position: relative;
    margin-bottom: 0.25rem;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.stat-value {
    display: block;
    position: relative;
    font-size: 1.85rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

/* ==========================================================================
   نوار ابزار و صفحه‌بندی
   ========================================================================== */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 1.1rem;
    padding: 0.95rem 1.05rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

.toolbar .form-field {
    margin-bottom: 0;
    min-width: min(100%, 16rem);
    flex: 1 1 14rem;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    font-size: 0.9rem;
}

/* ==========================================================================
   جدول‌ها
   ========================================================================== */

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 640px;
}

th,
td {
    padding: 0.8rem 1.1rem;
    border-bottom: 1px solid var(--line);
    text-align: right;
    vertical-align: middle;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.79rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr {
    transition: background 0.14s ease;
}

tbody tr:hover td {
    background: var(--surface-2);
}

/* ==========================================================================
   دکمه‌ها
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1.05rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 600;
    font-size: 0.92rem;
    line-height: 1.5;
    white-space: nowrap;
    cursor: pointer;
    transition: transform 0.14s ease, box-shadow 0.16s ease, background 0.16s ease,
        border-color 0.16s ease, opacity 0.16s ease;
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
    color: #fff;
    box-shadow: 0 8px 18px -10px rgba(35, 72, 230, 0.9);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 12px 24px -10px rgba(35, 72, 230, 0.95);
    filter: brightness(1.05);
}

.btn-secondary {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--ink);
    box-shadow: var(--shadow-xs);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--surface-3);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 8px 18px -10px rgba(192, 42, 42, 0.8);
}

[data-theme="dark"] .btn-danger {
    color: #2a0b0b;
}

.btn-danger:hover:not(:disabled) {
    filter: brightness(1.06);
}

.btn-small {
    padding: 0.32rem 0.75rem;
    font-size: 0.84rem;
}

/* ==========================================================================
   فرم‌ها
   ========================================================================== */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 0 1rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1.05rem;
    min-width: 0;
}

label {
    color: var(--ink-2);
    font-size: 0.87rem;
    font-weight: 600;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--ink);
    font: inherit;
    font-size: 0.93rem;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

select {
    appearance: none;
    /* فلش سفارشی سمت چپ فیلد (جهت راست‌به‌چپ) */
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: left 12px center, left 17px center;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-inline-end: 2.1rem;
    cursor: pointer;
}

textarea {
    min-height: 7rem;
    resize: vertical;
}

input:not([type="checkbox"]):not([type="radio"]):hover:not(:focus),
select:hover:not(:focus),
textarea:hover:not(:focus) {
    border-color: var(--muted);
}

input:focus,
select:focus,
textarea:focus {
    background: var(--surface);
    border-color: var(--accent);
    outline: none;
    box-shadow: var(--ring);
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
    background: none;
    box-shadow: var(--ring);
}

::placeholder {
    color: var(--faint);
}

.input-ltr {
    direction: ltr;
    text-align: left;
}

.check-line {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0 0 1rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-weight: 500;
    cursor: pointer;
}

.check-line input {
    flex: none;
    width: 1.05rem;
    height: 1.05rem;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ==========================================================================
   هشدارها، نشان‌ها و حالت خالی
   ========================================================================== */

.alert {
    position: relative;
    margin-bottom: 1.1rem;
    padding: 0.9rem 1.1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    border-inline-start-width: 3px;
}

.alert p {
    margin: 0 0 0.7rem;
}

.alert p:last-child,
.alert form:last-child {
    margin-bottom: 0;
}

.alert-danger {
    background: var(--danger-soft);
    border-color: var(--danger-line);
    border-inline-start-color: var(--danger);
    color: var(--danger);
}

.alert-success {
    background: var(--success-soft);
    border-color: var(--success-line);
    border-inline-start-color: var(--success);
    color: var(--success);
}

.alert-warning {
    background: var(--warning-soft);
    border-color: var(--warning-line);
    border-inline-start-color: var(--warning);
    color: var(--warning);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.14rem 0.6rem;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    font-size: 0.77rem;
    font-weight: 700;
    line-height: 1.65;
    white-space: nowrap;
}

.badge::before {
    content: "";
    width: 0.38rem;
    height: 0.38rem;
    border-radius: 50%;
    background: currentColor;
}

.badge-success {
    background: var(--success-soft);
    border-color: var(--success-line);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-soft);
    border-color: var(--warning-line);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-soft);
    border-color: var(--danger-line);
    color: var(--danger);
}

.badge-neutral {
    background: var(--surface-3);
    border-color: var(--line);
    color: var(--muted);
}

.empty-state {
    padding: 3rem 1.25rem;
    text-align: center;
    color: var(--muted);
    background: var(--surface);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-lg);
}

.rating-up {
    color: var(--success);
    font-weight: 700;
}

.rating-down {
    color: var(--danger);
    font-weight: 700;
}

/* ==========================================================================
   صفحه کلیدهای هوش مصنوعی
   ========================================================================== */

.route-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: 0.8rem;
}

.route-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-height: 6.6rem;
    padding: 1rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.route-card:hover {
    transform: translateY(-2px);
    border-color: var(--line-strong);
    box-shadow: var(--shadow-md);
}

.route-card.is-current {
    border-color: var(--accent);
    box-shadow: var(--ring);
}

.route-kicker {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.route-card.is-current .route-kicker {
    color: var(--accent);
}

.route-card strong {
    font-size: 1rem;
    line-height: 1.45;
}

.route-model {
    color: var(--faint);
    font-size: 0.77rem;
    direction: ltr;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.catalog-note {
    margin: 0.9rem 0 0;
    font-size: 0.89rem;
}

.slot-card {
    border-inline-start: 3px solid var(--line-strong);
}

.slot-card.is-live {
    border-color: var(--success-line);
    border-inline-start-color: var(--success);
}

.slot-card.is-off {
    background: var(--surface-2);
    border-inline-start-color: var(--line);
}

.slot-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.slot-card h3 {
    margin: 0;
    font-size: 1.02rem;
}

.slot-summary {
    margin: 0.15rem 0 0;
    font-size: 0.88rem;
}

.key-hint {
    margin: 0.85rem 0;
    padding: 0.55rem 0.8rem;
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    color: var(--muted);
    font-size: 0.85rem;
}

.slot-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.slot-actions form {
    margin: 0;
}

.slot-edit {
    margin-top: 0.95rem;
    padding-top: 0.85rem;
    border-top: 1px dashed var(--line);
}

.slot-edit summary {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--accent);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    list-style: none;
}

.slot-edit summary::-webkit-details-marker {
    display: none;
}

.slot-edit summary::before {
    content: "+";
    display: grid;
    place-items: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: var(--accent-soft);
    font-size: 0.95rem;
    line-height: 1;
}

.slot-edit[open] summary {
    margin-bottom: 0.95rem;
}

.slot-edit[open] summary::before {
    content: "−";
}

.preset-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 1.1rem;
}

.check-line {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0 0 0.75rem;
    font-weight: 600;
}

.check-line input {
    width: 1rem;
    height: 1rem;
}

/* ==========================================================================
   صفحه ورود
   ========================================================================== */

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.login-card {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    width: min(100%, 54rem);
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.login-aside {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 2rem;
    padding: 2.4rem 2.2rem;
    background: linear-gradient(150deg, var(--brand-1), var(--brand-2) 58%, #16277d);
    color: #fff;
    overflow: hidden;
}

.login-aside::after {
    content: "";
    position: absolute;
    bottom: -7rem;
    right: -5rem;
    width: 18rem;
    height: 18rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(92, 239, 255, 0.35), transparent 65%);
}

.login-aside > * {
    position: relative;
    z-index: 1;
}

.login-aside .brand-mark {
    background: rgba(255, 255, 255, 0.18);
    box-shadow: none;
    backdrop-filter: blur(6px);
}

.login-aside .brand-text small {
    color: rgba(255, 255, 255, 0.72);
}

.login-tagline {
    margin: 0;
    font-size: 1.32rem;
    font-weight: 700;
    line-height: 1.7;
}

.login-points {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
}

.login-points li {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.login-points svg {
    flex: none;
    width: 1.05rem;
    height: 1.05rem;
    opacity: 0.9;
}

.login-form-side {
    padding: 2.4rem 2.2rem;
}

.login-brand {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--accent);
    font-size: 1.35rem;
    font-weight: 700;
}

.login-title {
    margin: 0 0 0.35rem;
    font-size: 1.32rem;
    font-weight: 700;
}

.login-subtitle {
    margin: 0 0 1.6rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.btn-block {
    width: 100%;
    margin-top: 0.35rem;
    padding-block: 0.65rem;
}

.login-foot {
    margin: 1.4rem 0 0;
    color: var(--faint);
    font-size: 0.8rem;
    text-align: center;
}

/* ==========================================================================
   واکنش‌گرایی
   ========================================================================== */

@media (max-width: 1000px) {
    .app-main {
        margin-right: 0;
        margin-inline-start: 0;
    }

    .sidebar {
        transform: translateX(100%);
        box-shadow: var(--shadow-lg);
    }

    body.nav-open {
        overflow: hidden;
    }

    body.nav-open .sidebar {
        transform: translateX(0);
    }

    .menu-btn,
    .sidebar-close {
        display: grid;
    }
}

@media (max-width: 860px) {
    .login-card {
        grid-template-columns: 1fr;
    }

    .login-aside {
        padding: 1.8rem;
        gap: 1.4rem;
    }

    .login-points {
        display: none;
    }

    .login-form-side {
        padding: 1.8rem;
    }
}

@media (max-width: 720px) {
    body {
        font-size: 14.5px;
    }

    .crumb-home {
        display: none;
    }

    .crumbs strong {
        font-size: 0.92rem;
    }

    table {
        min-width: 560px;
    }

    .pagination {
        justify-content: center;
        text-align: center;
    }
}

@media (max-width: 420px) {
    .sidebar {
        width: min(88vw, var(--sidebar-w));
    }

    .stat-value {
        font-size: 1.6rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

@media print {
    .sidebar,
    .topbar,
    .scrim,
    .skip-link {
        display: none !important;
    }

    .app-main {
        margin-right: 0;
        margin-inline-start: 0;
    }

    body {
        background: #fff;
    }
}
