/* ═════════ پایه ═════════ */
:root {
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 6px 20px rgba(16, 24, 40, .07);
    --brand-a: #4f46e5;
    --brand-b: #7c3aed;
    --c-new: #f59e0b;
    --c-free: #8d6e63;
    --c-wait: #0ea5e9;
    --c-origin: #e91e63;
    --c-dest: #16a34a;
    --line: var(--mud-palette-divider, rgba(128, 128, 128, .25));
    --muted: var(--mud-palette-text-secondary, #6b7280);
    --safe-b: env(safe-area-inset-bottom, 0px);
}

html, body, .mud-typography, .mud-input, .mud-button-root, button, input, select, textarea {
    font-family: "Vazirmatn", Tahoma, "Segoe UI", Arial, sans-serif !important;
}
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--mud-palette-background, #f3f5fb); color: var(--mud-palette-text-primary, #1f2937); }
.ltr { direction: ltr; unicode-bidi: plaintext; text-align: right; }
/* FocusOnNavigate عنوان صفحه را فوکوس می‌کند؛ کادر فوکوس پیش‌فرض زشت است */
h1:focus, h1:focus-visible { outline: none; }
.muted { color: var(--muted); }
.only-mobile { display: none !important; }

/* ═════════ قاب برنامه + سایدبار ═════════ */
.shell {
    display: grid;
    grid-template-columns: 272px minmax(0, 1fr);
    min-height: 100dvh;
    transition: grid-template-columns .28s cubic-bezier(.4, 0, .2, 1);
}
.shell.is-rail { grid-template-columns: 88px minmax(0, 1fr); }
.shell-main { display: flex; flex-direction: column; min-width: 0; min-height: 100dvh; }
.content { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.sidebar {
    position: sticky;
    top: 0;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-sizing: border-box;
    padding: 16px 14px calc(14px + var(--safe-b));
    overflow: hidden auto;
    border-inline-end: 1px solid color-mix(in srgb, var(--brand-a) 16%, transparent);
    background:
        radial-gradient(120% 55% at 100% 0%, color-mix(in srgb, var(--brand-b) 14%, transparent), transparent 62%),
        linear-gradient(180deg, color-mix(in srgb, var(--brand-a) 6%, var(--mud-palette-surface, #fff)), var(--mud-palette-surface, #fff) 45%);
}

.sb-brand { display: flex; align-items: center; gap: 10px; padding: 2px 4px 4px; }
.sb-logo { display: inline-flex; width: 44px; height: 44px; flex: none; align-items: center; justify-content: center; border-radius: 15px; color: #fff;
    background: linear-gradient(135deg, var(--brand-a), var(--brand-b));
    box-shadow: 0 12px 24px -14px color-mix(in srgb, var(--brand-a) 95%, transparent); }
.sb-logo .mud-icon-root { font-size: 24px; }
.sb-brand-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.sb-brand-text b { font-size: .95rem; white-space: nowrap; }
.sb-brand-text small { font-size: .73rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-collapse { margin-inline-start: auto; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; flex: none;
    border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.sb-collapse:hover { color: var(--brand-a); background: color-mix(in srgb, var(--brand-a) 12%, transparent); }
.sb-collapse .mud-icon-root { font-size: 19px; }

.sb-nav { display: flex; flex-direction: column; gap: 4px; flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
    padding-inline-end: 2px; scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--brand-a) 25%, transparent) transparent; }
.sb-nav::-webkit-scrollbar { width: 6px; }
.sb-nav::-webkit-scrollbar-thumb { border-radius: 99px; background: color-mix(in srgb, var(--brand-a) 25%, transparent); }
.sb-nav::-webkit-scrollbar-track { background: transparent; }
.sb-label { padding: 10px 12px 3px; font-size: .68rem; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.sb-item { position: relative; display: flex; align-items: center; gap: 11px; padding: 8px 9px; border-radius: 13px; text-decoration: none;
    color: var(--mud-palette-text-primary, #1f2937); font-size: .9rem; font-weight: 600; transition: background .16s, color .16s, transform .16s; }
.sb-item .sb-ico { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; flex: none; border-radius: 11px;
    background: color-mix(in srgb, var(--brand-a) 9%, transparent); color: var(--brand-a); transition: background .16s, color .16s; }
.sb-item .sb-ico .mud-icon-root { font-size: 20px; }
.sb-item .sb-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-item:hover { background: color-mix(in srgb, var(--brand-a) 8%, transparent); transform: translateX(-3px); }
.sb-item.active { color: #fff; background: linear-gradient(135deg, var(--brand-a), var(--brand-b));
    box-shadow: 0 14px 26px -18px color-mix(in srgb, var(--brand-a) 100%, transparent); }
.sb-item.active .sb-ico { background: rgba(255, 255, 255, .22); color: #fff; }

.sb-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.sb-user { display: flex; align-items: center; gap: 9px; padding: 9px 10px; overflow: hidden; border-radius: 14px;
    border: 1px solid var(--line); background: color-mix(in srgb, var(--brand-a) 5%, transparent); }
.sb-avatar { display: inline-flex; width: 34px; height: 34px; flex: none; align-items: center; justify-content: center; border-radius: 50%;
    color: #fff; font-size: .86rem; font-weight: 800; background: linear-gradient(135deg, var(--brand-a), var(--brand-b)); }
.sb-user-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.sb-user-text b { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-text small { font-size: .7rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-tools { display: flex; gap: 6px; }
.sb-tool { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 6px; border: 1px solid var(--line);
    border-radius: 12px; background: transparent; color: var(--muted); font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer;
    transition: background .15s, color .15s; }
.sb-tool .mud-icon-root { font-size: 18px; }
.sb-tool:hover { background: color-mix(in srgb, var(--brand-a) 10%, transparent); color: var(--brand-a); }
.sb-tool.danger:hover { background: color-mix(in srgb, var(--mud-palette-error) 12%, transparent); color: var(--mud-palette-error); }

/* حالت جمع‌شده: فقط آیکون‌ها (فقط دسکتاپ؛ روی موبایل سایدبار همیشه کشوی کامل است) */
@media (min-width: 901px) {
    .shell.is-rail .sidebar { padding-inline: 10px; }
    .shell.is-rail .sb-brand { flex-direction: column; gap: 8px; padding-inline: 0; }
    .shell.is-rail .sb-collapse { margin-inline-start: 0; }
    .shell.is-rail .sb-brand-text,
    .shell.is-rail .sb-text,
    .shell.is-rail .sb-label,
    .shell.is-rail .sb-user { display: none; }
    .shell.is-rail .sb-item { justify-content: center; padding: 9px; }
    .shell.is-rail .sb-item:hover { transform: none; }
    .shell.is-rail .sb-tools { flex-direction: column; }
    .shell.is-rail .sb-tool { flex: none; }
}

.sb-scrim { display: none; }
.mobilebar { display: none; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 0; border-radius: 12px;
    background: transparent; color: inherit; cursor: pointer; transition: background .15s; }
.icon-btn:hover { background: rgba(128, 128, 128, .22); }

.bottomnav { display: none; }

/* ═════════ صفحه‌ی تماس‌ها ═════════ */
.home { display: flex; flex-direction: column; gap: 12px; padding: 14px 18px 18px; height: 100dvh; box-sizing: border-box; }

.kpis { position: relative; }
.kpi-inner { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px;
    transition: max-height .4s ease, opacity .35s ease, transform .35s ease, margin .35s ease;
    max-height: 300px; opacity: 1; transform: scaleY(1); transform-origin: top; overflow: hidden; }
.kpis.collapsed .kpi-inner { max-height: 0; opacity: 0; transform: scaleY(0); margin-bottom: -10px; }
.kpi-toggle {
    position: absolute; top: -8px; inset-inline-end: -8px; z-index: 5;
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50%; border: 0;
    background: var(--mud-palette-surface, #fff); color: var(--muted); cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,.12); transition: transform .25s ease, color .2s ease;
}
.kpi-toggle:hover { color: var(--brand-a); }
.kpis.collapsed .kpi-toggle { transform: rotate(180deg); }

.kpi { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-radius: var(--radius);
    background: var(--mud-palette-surface, #fff); box-shadow: var(--shadow); text-decoration: none; color: inherit; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 5px; background: var(--k, #94a3b8); }
.kpi-n { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.kpi-l { font-size: .8rem; color: var(--muted); }
.k-new { --k: var(--c-new); } .k-free { --k: var(--c-free); } .k-wait { --k: var(--c-wait); }
.k-origin { --k: var(--c-origin); } .k-dest { --k: var(--c-dest); } .k-online { --k: var(--brand-a); cursor: pointer; }
a.kpi:hover { transform: translateY(-1px); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius);
    background: var(--mud-palette-surface, #fff); box-shadow: var(--shadow); }
.act-group { display: flex; flex-wrap: wrap; gap: 6px; }
.act-end { margin-inline-start: auto; }
.btn-main { font-weight: 700; }

.main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 12px; }
.main.no-side { grid-template-columns: minmax(0, 1fr); }
.grid-wrap { min-height: 0; overflow: auto; border-radius: var(--radius); background: var(--mud-palette-surface, #fff); box-shadow: var(--shadow); }
.side { min-height: 0; overflow: auto; border-radius: var(--radius); background: var(--mud-palette-surface, #fff); box-shadow: var(--shadow); padding: 10px; }
.side.hide-desktop { display: none; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 8px; }

/* جدول تماس‌ها */
table.calls { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .92rem; }
table.calls th { position: sticky; top: 0; z-index: 1; background: var(--mud-palette-surface, #fff); text-align: start; padding: 10px 12px;
    font-size: .78rem; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; }
table.calls td { padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
table.calls td.c-addr, table.calls td.c-name { white-space: normal; }
table.calls td.c-addr { min-width: 200px; }
table.calls tr.call { cursor: pointer; transition: background .12s; }
table.calls tr.call:hover { background: rgba(128, 128, 128, .09); }
table.calls tr.call.sel { background: color-mix(in srgb, var(--brand-a) 13%, transparent); box-shadow: inset 4px 0 0 var(--brand-a); }
.c-tel { font-variant-numeric: tabular-nums; font-weight: 600; }

.pill { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap;
    background: rgba(128, 128, 128, .18); color: var(--mud-palette-text-primary, #1f2937); }
.pill-info { background: color-mix(in srgb, var(--brand-a) 15%, transparent); color: var(--brand-a); }
.st-0 { background: color-mix(in srgb, var(--c-new) 24%, transparent); }
.st-1, .st-2 { background: color-mix(in srgb, var(--c-wait) 26%, transparent); }
.st-3 { background: color-mix(in srgb, var(--c-origin) 24%, transparent); }
.st-4 { background: color-mix(in srgb, var(--c-dest) 26%, transparent); }
.st-6 { background: color-mix(in srgb, var(--c-free) 38%, transparent); }

.empty-state { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 56px 16px; color: var(--muted); text-align: center; }
.empty-state .mud-icon-root { font-size: 3rem; opacity: .5; }
.empty-state p { margin: 6px 0 0; font-weight: 600; }

/* دکمه‌ی شناور موبایل */
.fab { position: fixed; z-index: 35; inset-inline-end: 18px; bottom: calc(76px + var(--safe-b)); width: 58px; height: 58px; border: 0; border-radius: 50%;
    color: #fff; background: linear-gradient(135deg, var(--brand-a), var(--brand-b)); box-shadow: 0 8px 22px rgba(79, 70, 229, .45); cursor: pointer;
    align-items: center; justify-content: center; }
.fab .mud-icon-root { font-size: 1.9rem; }

/* ═════════ نوار کوچک تماس (داخل دیالوگ‌ها) ═════════ */
.callbar {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 7px 10px; border-radius: 12px;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--mud-palette-surface, #fff) 92%, var(--brand-a) 8%);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
    margin-bottom: 2px;
}
.callbar .cb-ic {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; flex: none; border-radius: 9px;
    color: #fff; background: linear-gradient(135deg, var(--brand-a), var(--brand-b));
}
.callbar .cb-ic .mud-icon-root { font-size: 1.05rem; }
.callbar .cb-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.callbar .cb-text strong { font-size: .86rem; font-weight: 700; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.callbar .cb-text small { font-size: .72rem; color: var(--muted); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.callbar .cb-btn {
    display: inline-flex; align-items: center; gap: 4px; flex: none;
    padding: 6px 11px; border-radius: 9px; border: 1px solid var(--line);
    background: transparent; color: inherit; font: inherit; font-size: .78rem; font-weight: 700;
    cursor: pointer; transition: transform .12s ease, filter .12s ease;
}
.callbar .cb-btn:hover { filter: brightness(.97); transform: translateY(-1px); }
.callbar .cb-btn:active { transform: translateY(0) scale(.97); }
.callbar .cb-btn .mud-icon-root { font-size: .95rem; }
.callbar .cb-btn.ok { color: #fff; border-color: transparent; background: #16a34a; }
.callbar .cb-btn.no { color: #fff; border-color: transparent; background: #dc2626; }

/* تماس ورودی: چشمک ملایم تا اپراتور متوجه شود */
.callbar.ringing {
    border-color: color-mix(in srgb, #16a34a 55%, transparent);
    background: color-mix(in srgb, #16a34a 12%, var(--mud-palette-surface, #fff));
    animation: callbar-ring 1.6s ease-in-out infinite;
}
.callbar.busy {
    border-color: color-mix(in srgb, var(--brand-a) 40%, transparent);
    background: color-mix(in srgb, var(--brand-a) 9%, var(--mud-palette-surface, #fff));
}
@keyframes callbar-ring {
    0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .30); }
    50% { box-shadow: 0 0 0 5px rgba(22, 163, 74, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .callbar.ringing { animation: none; }
}

/* ═════════ آدرس‌های ذخیره‌شده‌ی مشترک (UserAddresses) ═════════ */
.addr-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -4px; }
.addr-chip {
    display: inline-flex; align-items: center; overflow: hidden;
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--mud-palette-surface, #fff);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.addr-chip.sel {
    border-color: var(--brand-a);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-a) 22%, transparent);
}
.addr-pick {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 11px; border: 0; background: transparent; color: inherit;
    font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; max-width: 220px;
}
.addr-pick span, .addr-pick .mud-icon-root { font-size: .95rem; opacity: .75; flex: none; }
.addr-pick .mud-icon-root { color: var(--brand-a); opacity: 1; }
.addr-chip.sel .addr-pick { color: var(--brand-a); }
.addr-del {
    padding: 0 9px; align-self: stretch; border: 0; border-inline-start: 1px solid var(--line);
    background: transparent; color: var(--muted); font-size: 1rem; line-height: 1; cursor: pointer;
}
.addr-del:hover { color: #dc2626; background: color-mix(in srgb, #dc2626 8%, transparent); }
.addr-add {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 11px; border-radius: 999px; border: 1px dashed color-mix(in srgb, var(--brand-a) 45%, transparent);
    background: transparent; color: var(--brand-a); font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer;
}
.addr-add:hover { background: color-mix(in srgb, var(--brand-a) 8%, transparent); }
.addr-add .mud-icon-root { font-size: .95rem; }

.addr-form {
    display: flex; flex-direction: column; gap: 8px;
    padding: 10px; border-radius: 12px; border: 1px solid var(--line);
    background: color-mix(in srgb, var(--mud-palette-surface, #fff) 94%, var(--brand-a) 6%);
}
.addr-presets { display: flex; flex-wrap: wrap; gap: 5px; }
.addr-preset {
    padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
    background: transparent; color: inherit; font: inherit; font-size: .76rem; cursor: pointer;
}
.addr-preset:hover { border-color: var(--brand-a); color: var(--brand-a); }
.addr-form-actions { display: flex; justify-content: flex-end; gap: 6px; }

/* ───── دفترچه‌ی آدرس‌های مشترک (AddressBookDialog) ───── */
.ab-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 4px; }
.ab-title {
    display: inline-flex; align-items: center; gap: 6px;
    font-weight: 800; font-size: .95rem; color: var(--ink, #111827);
}
.ab-title .mud-icon-root { color: var(--brand-a); }
.ab-sub { font-size: .78rem; color: var(--muted); }

.ab-list { display: flex; flex-direction: column; gap: 6px; max-height: 44vh; overflow-y: auto; }
.ab-empty {
    padding: 14px; border-radius: 12px; border: 1px dashed var(--line);
    font-size: .82rem; color: var(--muted); text-align: center;
}
.ab-item {
    display: flex; align-items: stretch; overflow: hidden;
    border: 1px solid var(--line); border-radius: 12px;
    background: var(--mud-palette-surface, #fff);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.ab-item:hover { border-color: color-mix(in srgb, var(--brand-a) 55%, transparent); }
.ab-item.sel {
    border-color: var(--brand-a);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-a) 22%, transparent);
}
.ab-pick {
    flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px;
    padding: 9px 12px; border: 0; background: transparent; color: inherit;
    font: inherit; text-align: start; cursor: pointer;
}
.ab-name { font-size: .84rem; font-weight: 800; color: var(--brand-a); }
.ab-addr { font-size: .82rem; line-height: 1.6; color: var(--ink, #111827); }
.ab-station { font-size: .72rem; color: var(--muted); }
.ab-del {
    padding: 0 11px; border: 0; border-inline-start: 1px solid var(--line);
    background: transparent; color: var(--muted); font-size: 1.05rem; line-height: 1; cursor: pointer;
}
.ab-del:hover { color: #dc2626; background: color-mix(in srgb, #dc2626 8%, transparent); }

.ab-form {
    display: flex; flex-direction: column; gap: 8px;
    padding: 10px; border-radius: 12px; border: 1px solid var(--line);
    background: color-mix(in srgb, var(--mud-palette-surface, #fff) 94%, var(--brand-a) 6%);
}
.ab-presets { display: flex; flex-wrap: wrap; gap: 5px; }
.ab-preset {
    padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
    background: transparent; color: inherit; font: inherit; font-size: .76rem; cursor: pointer;
}
.ab-preset:hover { border-color: var(--brand-a); color: var(--brand-a); }
.ab-actions { display: flex; justify-content: flex-end; gap: 6px; }

/* آیکون آدرس در سلول جدول صفحه اصلی */
.c-addr { position: relative; }
.c-addr .addr-txt { display: inline; }
.c-addr .addr-pin {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 6px; border: 0;
    background: transparent; color: var(--brand-a); cursor: pointer;
    opacity: 0; transition: opacity .15s ease; vertical-align: middle; margin-inline-start: 4px;
}
.c-addr:hover .addr-pin, .call.sel .addr-pin { opacity: 1; }
.c-addr .addr-pin:hover { background: color-mix(in srgb, var(--brand-a) 12%, transparent); }

@media (max-width: 1100px) {
    .c-addr .addr-pin { opacity: 1; } /* روی موبایل همیشه دیده شود */
}

/* آیکون آدرس کنار کادر مبدا در دیالوگ */
.mabda-wrap { position: relative; }
.mabda-wrap .mud-input-control { width: 100%; }
.mabda-wrap .mabda-pin {
    position: absolute; inset-inline-end: 8px; top: 30px;
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 9px; border: 0;
    background: transparent; color: var(--brand-a); cursor: pointer;
    transition: background .15s ease;
}
.mabda-wrap .mabda-pin:hover { background: color-mix(in srgb, var(--brand-a) 12%, transparent); }
.mabda-wrap .mabda-pin .mud-icon-root { font-size: 1.15rem; }

/* ═════════ ایستگاه‌ها ═════════ */
.addbar { display: flex; gap: 6px; margin-bottom: 10px; }
.addbar input, .addbar select { padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: inherit; font-size: .9rem; min-width: 0; }
.addbar input { width: 84px; }
.addbar select { flex: 1; }
.station { margin-bottom: 12px; }
.station-h { display: flex; justify-content: space-between; align-items: center; font-weight: 600; padding: 7px 10px; border-radius: 10px;
    background: color-mix(in srgb, var(--brand-a) 10%, transparent); }
.drv { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.drv .no { width: 20px; color: var(--muted); }
.drv .code { font-weight: 700; min-width: 40px; }
.drv .tm { color: var(--muted); flex: 1; font-size: .8rem; }
.mini { border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 2px 8px; cursor: pointer; color: inherit; line-height: 22px; font-size: .8rem; }
.mini:hover { background: rgba(128, 128, 128, .2); }
.mini.send { color: var(--c-dest); border-color: var(--c-dest); }

/* ═════════ نقشه ═════════ */
.map-page { display: flex; flex-direction: column; gap: 10px; padding: 14px 18px 18px; height: 100dvh; box-sizing: border-box; }
.map-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.map-title { display: flex; align-items: center; gap: 12px; }
.map-title h1 { margin: 0; font-size: 1.15rem; }
.legend { display: flex; gap: 14px; font-size: .85rem; color: var(--muted); }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-inline-end: 4px; vertical-align: -1px; }
.dot.free { background: #1ec8a5; } .dot.busy { background: #e11d48; }
.map-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 12px; }
.drv-list { overflow: auto; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; padding: 10px; border-radius: var(--radius);
    background: var(--mud-palette-surface, #fff); box-shadow: var(--shadow); }
.drv-chip { border: 2px solid transparent; border-radius: 12px; padding: 7px 12px; min-width: 52px; cursor: pointer; font-weight: 700; font-size: .95rem; color: #fff; transition: transform .1s; }
.drv-chip:hover { transform: scale(1.06); }
.drv-chip.free { background: #1ec8a5; } .drv-chip.busy { background: #e11d48; }
.drv-chip.sel { border-color: var(--mud-palette-text-primary, #111); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-a) 35%, transparent); }
.map-canvas { min-height: 320px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); z-index: 0; }

/* مارکر با کد راننده روی آن (مثل نسخه‌ی قبلی) */
.map-icon-wrap { background: transparent; border: 0; }
.map-icon-wrap .map-icon { width: 25px; height: 41px; display: block; }
.map-icon-wrap .map-code { position: absolute; left: 50%; top: -20px; transform: translateX(-50%); padding: 1px 7px; border-radius: 9px;
    background: #fff; color: #111; border: 1px solid rgba(0, 0, 0, .35); font: 700 12px/16px Tahoma, sans-serif; white-space: nowrap; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.map-icon-wrap.selected .map-icon { filter: drop-shadow(0 0 6px #4f46e5); animation: bob .9s ease-in-out infinite; }
.map-icon-wrap.selected .map-code { background: #4f46e5; color: #fff; border-color: #4f46e5; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.leaflet-container { font-family: inherit; }

/* ═════════ جدول‌های دیالوگ و مشترکین ═════════ */
.hist td, .hist th { padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: .88rem; text-align: start; }
.page-pad { padding: 14px 18px; }

/* ═════════ ورود ═════════ */
.login-shell { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; position: relative; overflow: hidden; }
.login-bg { position: absolute; inset: 0; background:
    radial-gradient(60% 60% at 15% 10%, rgba(124, 58, 237, .55), transparent 60%),
    radial-gradient(55% 55% at 90% 90%, rgba(14, 165, 233, .5), transparent 60%),
    linear-gradient(135deg, #312e81, #4f46e5); }
.login-card { position: relative; width: min(380px, 100%); box-sizing: border-box; background: rgba(255, 255, 255, .96); color: #1f2937; padding: 30px 28px; border-radius: 22px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35); display: flex; flex-direction: column; gap: 8px; }
.login-logo { align-self: center; display: inline-flex; width: 64px; height: 64px; align-items: center; justify-content: center; border-radius: 20px; color: #fff;
    background: linear-gradient(135deg, var(--brand-a), var(--brand-b)); box-shadow: 0 10px 24px rgba(79, 70, 229, .45); }
.login-card h1 { margin: 10px 0 0; font-size: 1.35rem; text-align: center; }
.login-sub { margin: 0 0 10px; color: #6b7280; text-align: center; font-size: .9rem; }
.login-card label { font-size: .82rem; color: #4b5563; margin-top: 4px; }
.login-card input { padding: 12px 14px; border: 1px solid #d1d5db; border-radius: 12px; font-size: 1rem; background: #fff; color: #111; }
.login-card input:focus { outline: 2px solid color-mix(in srgb, var(--brand-a) 45%, transparent); border-color: var(--brand-a); }
.login-card button { margin-top: 14px; padding: 13px; border: 0; border-radius: 12px; color: #fff; font-size: 1rem; font-weight: 700; cursor: pointer;
    background: linear-gradient(135deg, var(--brand-a), var(--brand-b)); box-shadow: 0 8px 20px rgba(79, 70, 229, .4); }
.login-error { background: #fef2f2; color: #b91c1c; padding: 9px 12px; border-radius: 10px; font-size: .88rem; }

/* ═════════ تبلت و موبایل ═════════ */
@media (max-width: 1100px) {
    .kpi-inner { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .main { grid-template-columns: minmax(0, 1fr) 300px; }
}

@media (max-width: 900px) {
    .only-desktop { display: none !important; }
    .only-mobile { display: inline-flex !important; }

    /* سایدبار به کشوی موبایل تبدیل می‌شود */
    .shell, .shell.is-rail { display: block; grid-template-columns: none; }
    .sidebar { position: fixed; z-index: 1300; inset-block: 0; inset-inline-start: 0; width: 288px; max-width: 86vw; height: 100dvh;
        transform: translateX(105%); transition: transform .26s cubic-bezier(.4, 0, .2, 1); box-shadow: none; }
    .shell.is-open .sidebar { transform: translateX(0); box-shadow: 0 0 70px rgba(9, 15, 35, .45); }
    .sb-collapse { display: none; } /* جمع‌کردن فقط مخصوص دسکتاپ است */
    .sb-scrim { position: fixed; inset: 0; z-index: 1290; background: rgba(9, 15, 35, .45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
    .shell.is-open .sb-scrim { display: block; }
    .mobilebar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 40; padding: 8px 10px;
        background: color-mix(in srgb, var(--mud-palette-surface, #fff) 86%, transparent);
        -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
    .mb-brand { display: flex; align-items: center; gap: 6px; margin-inline-end: auto; font-size: .92rem; }
    .mb-brand .mud-icon-root { color: var(--brand-a); }

    .bottomnav { display: flex; position: fixed; z-index: 45; inset-inline: 0; bottom: 0; padding: 6px 8px calc(6px + var(--safe-b));
        background: var(--mud-palette-surface, #fff); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(16, 24, 40, .1); }
    .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border-radius: 12px;
        color: var(--muted); text-decoration: none; font-size: .72rem; }
    .bottomnav a.active { color: var(--brand-a); background: color-mix(in srgb, var(--brand-a) 12%, transparent); font-weight: 700; }
    .bottomnav .bn-more { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border: 0;
        border-radius: 12px; background: transparent; color: var(--muted); font: inherit; font-size: .72rem; cursor: pointer; }
    .bottomnav .bn-more:hover { color: var(--brand-a); background: color-mix(in srgb, var(--brand-a) 10%, transparent); }
    .content { padding-bottom: calc(68px + var(--safe-b)); }

    .home, .map-page { height: auto; min-height: calc(100dvh - 122px); padding: 10px 10px 16px; }
    .kpi-inner { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .kpi { padding: 8px 10px; }
    .kpi-n { font-size: 1.3rem; }

    .actions { padding: 6px; gap: 6px; }
    .btn-main { display: none !important; }
    .act-group { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
    .act-end { margin-inline-start: 0; flex-wrap: nowrap; overflow-x: auto; width: 100%; }
    .actions .mud-button-root { flex: none; }
    .actions .lbl { font-size: .78rem; }

    .main { grid-template-columns: minmax(0, 1fr); }
    .grid-wrap { overflow: visible; background: transparent; box-shadow: none; }
    .side { display: none; }
    .side.open { display: block; position: fixed; z-index: 60; inset: 0; border-radius: 0; padding: 12px 12px calc(14px + var(--safe-b)); }
    .side.open.hide-desktop { display: block; }
    .fab { display: inline-flex !important; }
    /* دکمه‌ی سفر جدید باید بالای داک داخلی‌ها بنشیند، نه زیر آن
       (داک: bottom = --sp-dock-bottom و ارتفاع ~۵۲px) */
    .fab { bottom: calc(var(--sp-dock-bottom, 74px) + 62px + var(--safe-b)); }

    /* جدول → کارت */
    table.calls, table.calls tbody { display: block; }
    table.calls thead { display: none; }
    table.calls tr.call { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name status" "tel time" "addr addr" "dest price" "drv line";
        gap: 4px 10px; margin-bottom: 10px; padding: 12px 14px; border-radius: var(--radius); background: var(--mud-palette-surface, #fff); box-shadow: var(--shadow); }
    table.calls tr.call.sel { box-shadow: var(--shadow), inset 4px 0 0 var(--brand-a); }
    table.calls td { display: block; padding: 0; border: 0; white-space: normal; }
    table.calls td:empty { display: none; }
    .c-name { grid-area: name; font-weight: 700; font-size: 1rem; }
    .c-status { grid-area: status; justify-self: end; }
    .c-tel { grid-area: tel; font-size: .95rem; }
    .c-time { grid-area: time; justify-self: end; color: var(--muted); font-size: .8rem; }
    .c-addr { grid-area: addr; min-width: 0 !important; color: var(--muted); }
    .c-dest { grid-area: dest; } .c-price { grid-area: price; justify-self: end; font-weight: 700; }
    .c-drv { grid-area: drv; font-size: .85rem; font-weight: 600; color: var(--brand-a); }
    .c-line { grid-area: line; justify-self: end; color: var(--muted); font-size: .75rem; }

    .map-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
    .drv-list { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; padding: 8px; }
    .drv-chip { flex: none; }
    .map-canvas { min-height: 55dvh; }
}

@media (max-width: 480px) {
    .kpi-inner { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* دیالوگ‌ها روی موبایل تمام‌صفحه */
@media (max-width: 640px) {
    .mud-dialog { margin: 0 !important; width: 100vw !important; max-width: 100vw !important; height: 100dvh; max-height: 100dvh !important; border-radius: 0 !important; display: flex; flex-direction: column; }
    .mud-dialog .mud-dialog-content { flex: 1; overflow: auto; }
    .mud-dialog .mud-dialog-actions { padding-bottom: calc(12px + var(--safe-b)); flex-wrap: wrap; }
    .mud-snackbar-location-bottom-left { bottom: calc(76px + var(--safe-b)) !important; }
}

/* ════════════════════════════════════════════════════════════════
   صفحات مدیریت (رانندگان، مقصدها، گزارش‌ها، کاربران، تنظیمات، ایستگاه‌ها)
   ════════════════════════════════════════════════════════════════ */
.adm { display: flex; flex-direction: column; gap: 14px; padding: 16px 18px 26px; }

/* ── سرصفحه ── */
.adm-head { display: flex; align-items: center; gap: 13px; flex-wrap: wrap; }
.adm-head .ico { display: inline-flex; width: 46px; height: 46px; flex: none; align-items: center; justify-content: center;
    border-radius: 15px; color: #fff; background: linear-gradient(135deg, var(--brand-a), var(--brand-b));
    box-shadow: 0 14px 26px -16px color-mix(in srgb, var(--brand-a) 95%, transparent); }
.adm-head .ico .mud-icon-root { font-size: 24px; }
.adm-head .ttl { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.adm-head h1 { margin: 0; font-size: 1.2rem; font-weight: 800; letter-spacing: -.01em; }
.adm-head p { margin: 0; font-size: .84rem; color: var(--muted); }
.adm-head .spacer { margin-inline-start: auto; }

/* ── کارت آمار ── */
.adm-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 10px; }
.stat { position: relative; padding: 11px 14px 12px; border-radius: 16px; overflow: hidden;
    background: var(--mud-palette-surface, #fff); box-shadow: var(--shadow); }
.stat::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; background: var(--sc, var(--brand-a)); }
.stat::after { content: ""; position: absolute; inset-block-start: -30px; inset-inline-end: -30px; width: 90px; height: 90px; border-radius: 50%;
    background: color-mix(in srgb, var(--sc, var(--brand-a)) 12%, transparent); }
.stat .l { position: relative; font-size: .76rem; font-weight: 600; color: var(--muted); }
.stat .v { position: relative; font-size: 1.32rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.35; }
.stat .s { position: relative; font-size: .72rem; color: var(--muted); }
.stat.ok { --sc: var(--mud-palette-success); }
.stat.warn { --sc: var(--mud-palette-warning); }
.stat.bad { --sc: var(--mud-palette-error); }
.stat.info { --sc: var(--mud-palette-info); }
.stat.neutral { --sc: #8d6e63; }

/* ── نوار فیلتر ── */
.adm-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(146px, 1fr)); gap: 10px; align-items: end;
    padding: 13px 14px; border-radius: 16px; background: var(--mud-palette-surface, #fff); box-shadow: var(--shadow); }
.adm-filters .wide { grid-column: span 2; }
.adm-filters .btns { display: flex; gap: 6px; justify-content: flex-end; }
.adm-hint { grid-column: 1 / -1; font-size: .76rem; color: var(--muted); }

/* ── کارت و جدول ── */
.adm-card { border-radius: 16px; background: var(--mud-palette-surface, #fff); box-shadow: var(--shadow); overflow: hidden; }
.adm-card > .hd { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: .9rem; }
.adm-card > .hd .spacer { margin-inline-start: auto; }
.adm-scroll { overflow: auto; max-height: min(66dvh, 720px); }
table.adm-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .88rem; }
table.adm-table th { position: sticky; top: 0; z-index: 1; padding: 9px 12px; text-align: start; white-space: nowrap;
    font-size: .74rem; font-weight: 700; color: var(--muted); border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--brand-a) 5%, var(--mud-palette-surface, #fff)); }
table.adm-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
table.adm-table tbody tr { transition: background .12s; }
table.adm-table tbody tr:hover { background: color-mix(in srgb, var(--brand-a) 6%, transparent); }
table.adm-table tbody tr:last-child td { border-bottom: 0; }
table.adm-table td.num { font-variant-numeric: tabular-nums; }
table.adm-table td.strong { font-weight: 700; }
table.adm-table td.wrap { white-space: normal; min-width: 170px; }
table.adm-table td.act { text-align: end; }
table.adm-table .row-actions { display: inline-flex; gap: 2px; }
table.adm-table .sub { display: block; font-size: .74rem; color: var(--muted); font-weight: 400; }

/* ── برچسب وضعیت ── */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
    font-size: .72rem; font-weight: 700; white-space: nowrap;
    color: var(--tag-c, var(--mud-palette-text-secondary)); background: color-mix(in srgb, var(--tag-c, #94a3b8) 15%, transparent); }
.tag.ok { --tag-c: var(--mud-palette-success); }
.tag.warn { --tag-c: var(--mud-palette-warning); }
.tag.bad { --tag-c: var(--mud-palette-error); }
.tag.info { --tag-c: var(--brand-a); }
.tag.mute { --tag-c: #94a3b8; }
.tag .mud-icon-root { font-size: 14px; }

.money { font-variant-numeric: tabular-nums; font-weight: 700; }
.money.pos { color: var(--mud-palette-success); }
.money.neg { color: var(--mud-palette-error); }

/* ── حالت خالی ── */
.adm-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 46px 16px; color: var(--muted); text-align: center; }
.adm-empty .mud-icon-root { font-size: 2.6rem; opacity: .45; }
.adm-empty b { font-size: .95rem; color: var(--mud-palette-text-primary); }

/* ── پاصفحه‌ی جدول ── */
.adm-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 14px; border-top: 1px solid var(--line);
    font-size: .78rem; color: var(--muted); }
.adm-foot .spacer { margin-inline-start: auto; }

/* ── فرم داخل دیالوگ/کارت ── */
.fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px 12px; }
.fgrid .full { grid-column: 1 / -1; }
.fsec { display: flex; align-items: center; gap: 8px; grid-column: 1 / -1; margin: 12px 0 0;
    font-size: .82rem; font-weight: 800; color: var(--brand-a); }
.fsec::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, color-mix(in srgb, var(--brand-a) 35%, transparent), transparent); }
.fsec:first-child { margin-top: 0; }
.fhint { grid-column: 1 / -1; font-size: .74rem; color: var(--muted); margin: -2px 0 0; }

/* ── لیست دسترسی‌ها ── */
.perm-group { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.perm-group > h4 { margin: 0 0 6px; font-size: .82rem; font-weight: 800; color: var(--brand-a); }
.perm-items { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 2px 10px; }

/* ── ایستگاه‌ها ── */
.st-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.st-card { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 13px 14px; border-radius: 16px;
    background: var(--mud-palette-surface, #fff); box-shadow: var(--shadow); border: 1px solid transparent; transition: border-color .15s, transform .15s; }
.st-card:hover { border-color: color-mix(in srgb, var(--brand-a) 30%, transparent); transform: translateY(-1px); }
.st-card .top { display: flex; align-items: center; gap: 8px; }
.st-card .code { display: inline-flex; min-width: 34px; height: 34px; align-items: center; justify-content: center; padding: 0 8px;
    border-radius: 11px; font-weight: 800; font-size: .86rem; color: #fff; background: linear-gradient(135deg, var(--brand-a), var(--brand-b)); }
.st-card .nm { font-weight: 700; font-size: .95rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-card .meta { display: flex; gap: 12px; font-size: .76rem; color: var(--muted); }
.st-card .acts { display: flex; gap: 4px; margin-inline-start: auto; }
.st-card .q { font-size: .78rem; color: var(--muted); }
.st-card .q b { color: var(--mud-palette-text-primary); font-size: .95rem; }

/* نشان کد راننده/ایستگاه در سربرگ کارت‌ها */
.st-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 34px; padding: 0 10px;
    border-radius: 11px; font-size: .86rem; font-weight: 800; font-variant-numeric: tabular-nums; color: #fff;
    background: linear-gradient(135deg, var(--brand-a), var(--brand-b)); }


/* ── تنظیمات ── */.set-panel { display: flex; flex-direction: column; gap: 12px; }
.set-block { padding: 14px; border-radius: 16px; background: var(--mud-palette-surface, #fff); box-shadow: var(--shadow); }
.set-block > h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: .9rem; font-weight: 800; }
.set-block > h3 .mud-icon-root { color: var(--brand-a); font-size: 19px; }
.set-block .note { font-size: .76rem; color: var(--muted); margin: 0 0 8px; }
.set-switches { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 4px 14px; }
.set-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-radius: 16px;
    background: color-mix(in srgb, var(--brand-a) 7%, var(--mud-palette-surface, #fff)); border: 1px solid color-mix(in srgb, var(--brand-a) 18%, transparent); }
.set-actions .spacer { margin-inline-start: auto; }

/* ── تبلت و موبایل ── */
@media (max-width: 900px) {
    .adm { padding: 12px 10px 18px; gap: 11px; }
    .adm-head h1 { font-size: 1.05rem; }
    .adm-filters { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); }
    .adm-filters .wide { grid-column: 1 / -1; }
    .adm-filters .btns { grid-column: 1 / -1; justify-content: stretch; }
    .adm-filters .btns .mud-button-root { flex: 1; }
    .adm-scroll { max-height: none; }
    .stat .v { font-size: 1.15rem; }
    .st-cards { grid-template-columns: 1fr; }
}
