/* ── پنل Gateway ─────────────────────────────────────────────
   بدون مرحلهٔ ساخت: یک فایل CSS، تا ایمیج سبک بماند و تغییر ظاهر
   نیاز به Node نداشته باشد. */

@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #F6F5F2;
    --surface: #FFFFFF;
    --surface-2: #FBFAF8;
    --ink: #1A1714;
    --muted: #6B655C;
    --faint: #9A938A;
    --line: #E8E4DD;
    --line-strong: #D9D3C9;

    --accent: #B45309;
    --accent-soft: #FEF3E2;

    --ok: #15803D;      --ok-soft: #E8F5EC;
    --warn: #B45309;    --warn-soft: #FEF3E2;
    --bad: #B91C1C;     --bad-soft: #FDECEC;
    --info: #1D4ED8;    --info-soft: #EAF0FD;
    --idle: #6B655C;    --idle-soft: #F0EEEA;

    --radius: 14px;
    --shadow: 0 1px 2px rgba(26, 23, 20, .04), 0 4px 16px rgba(26, 23, 20, .04);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121110;
        --surface: #1B1A18;
        --surface-2: #211F1D;
        --ink: #F1EDE7;
        --muted: #A8A196;
        --faint: #7A746B;
        --line: #2C2A27;
        --line-strong: #3A3733;

        --accent: #F0A04B;
        --accent-soft: #2E2214;
        --ok: #4ADE80;      --ok-soft: #12261A;
        --warn: #F0A04B;    --warn-soft: #2E2214;
        --bad: #F87171;     --bad-soft: #2E1515;
        --info: #93B4FD;    --info-soft: #152039;
        --idle: #A8A196;    --idle-soft: #23211F;

        --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
    font-family: Vazirmatn, system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ── چیدمان ───────────────────────────────────────────────── */

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.side {
    background: var(--surface);
    border-left: 1px solid var(--line);
    padding: 24px 16px;
    display: flex; flex-direction: column; gap: 4px;
    position: sticky; top: 0; height: 100vh;
}

.brand {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 10px 22px;
    font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em;
}
.brand-mark {
    width: 30px; height: 30px; border-radius: 9px;
    background: var(--accent); color: #fff;
    display: grid; place-items: center; font-size: .85rem; font-weight: 800;
}
.brand small { display: block; font-size: .72rem; color: var(--muted); font-weight: 500; }

.nav a {
    display: flex; align-items: center; justify-content: space-between;
    padding: 9px 12px; border-radius: 10px;
    color: var(--muted); font-weight: 500;
    transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .count {
    font-size: .75rem; font-weight: 700; min-width: 22px; height: 22px; padding: 0 7px;
    border-radius: 11px; display: grid; place-items: center;
    background: var(--warn); color: #fff;
}

.side-foot { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid var(--line); font-size: .85rem; color: var(--muted); }
.side-foot .who { color: var(--ink); font-weight: 600; }
.side-foot button {
    margin-top: 8px; background: none; border: 0; color: var(--muted);
    font: inherit; cursor: pointer; padding: 0;
}
.side-foot button:hover { color: var(--bad); }

.main { padding: 32px 40px 64px; max-width: 1180px; width: 100%; }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.head h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.4; }
.head p { color: var(--muted); margin-top: 2px; }

/* ── اجزا ─────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
}
.card + .card { margin-top: 16px; }
.card h2 { font-size: 1.02rem; font-weight: 700; margin-bottom: 14px; }

.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.mt { margin-top: 16px; }
.mt-lg { margin-top: 28px; }

/* بنر وضعیت — اولین چیزی که مشتری می‌بیند */
.status {
    display: flex; gap: 18px; align-items: flex-start;
    border-radius: var(--radius); padding: 22px 26px;
    border: 1px solid transparent;
}
.status .dot { width: 14px; height: 14px; border-radius: 50%; margin-top: 9px; flex: none; box-shadow: 0 0 0 5px rgba(0,0,0,.04); }
.status h2 { font-size: 1.25rem; font-weight: 800; margin-bottom: 2px; }
.status p { color: var(--ink); opacity: .82; }
.status.ok     { background: var(--ok-soft);   border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.status.ok .dot     { background: var(--ok); }
.status.action { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.status.action .dot { background: var(--warn); }
.status.down, .status.silent { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.status.down .dot, .status.silent .dot { background: var(--bad); animation: pulse 2s infinite; }
.status.never  { background: var(--idle-soft); }
.status.never .dot  { background: var(--idle); }
@keyframes pulse { 50% { opacity: .35; } }

.stat .label { color: var(--muted); font-size: .88rem; }
.stat .value { font-size: 1.75rem; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; line-height: 1.3; }
.stat .sub { color: var(--muted); font-size: .85rem; margin-top: 2px; }

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .78rem; font-weight: 600; padding: 3px 10px; border-radius: 999px;
    white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.idle { background: var(--idle-soft); color: var(--idle); }

.checks { list-style: none; display: grid; gap: 10px; }
.checks li { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.checks .name { font-weight: 500; }
.checks .detail { color: var(--muted); font-size: .85rem; }

/* کارت مشکل */
.issue { border-right: 4px solid var(--warn); }
.issue.operator { border-right-color: var(--info); }
.issue-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.issue h3 { font-size: 1.08rem; font-weight: 700; }
.issue .count { font-size: 1.6rem; font-weight: 800; color: var(--warn); line-height: 1; }
.issue.operator .count { color: var(--info); }
.issue .count small { display: block; font-size: .75rem; color: var(--muted); font-weight: 500; margin-top: 4px; text-align: center; }
.issue .detail { color: var(--muted); margin-top: 8px; }
.action {
    margin-top: 14px; padding: 12px 16px; border-radius: 10px;
    background: var(--surface-2); border: 1px dashed var(--line-strong);
}
.action b { color: var(--ink); }
.issue.operator .action { border-style: solid; }
.meta-line { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 12px; color: var(--muted); font-size: .86rem; }

details.docs { margin-top: 12px; }
details.docs summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .9rem; list-style: none; }
details.docs summary::-webkit-details-marker { display: none; }
details.docs summary::before { content: '‹ '; display: inline-block; transition: transform .15s; }
details.docs[open] summary::before { transform: rotate(-90deg); }

/* جدول */
.table-wrap { overflow-x: auto; margin: 0 -24px -22px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th {
    text-align: right; font-weight: 600; color: var(--muted); font-size: .82rem;
    padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--surface-2);
    white-space: nowrap;
}
td { padding: 13px 24px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: left; direction: ltr; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .sub { color: var(--muted); font-size: .82rem; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; direction: ltr; unicode-bidi: isolate; font-size: .85em; }

.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty .big { font-size: 2rem; margin-bottom: 6px; }

/* فرم */
.search { display: flex; gap: 8px; }
input[type=text], input[type=email], input[type=password], input[type=search] {
    font: inherit; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line-strong);
    border-radius: 10px; padding: 9px 14px; min-width: 0;
    transition: border-color .15s, box-shadow .15s;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn {
    font: inherit; font-weight: 600; cursor: pointer;
    background: var(--accent); color: #fff; border: 0;
    border-radius: 10px; padding: 9px 18px;
}
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); }

.pager { display: flex; justify-content: center; gap: 6px; margin-top: 18px; flex-wrap: wrap; }
.pager a, .pager span {
    padding: 6px 13px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface);
    font-size: .88rem;
}
.pager .on { background: var(--accent); color: #fff; border-color: var(--accent); }
.pager .off { color: var(--faint); }

.note { color: var(--muted); font-size: .86rem; }

/* ورود */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-box { width: 100%; max-width: 400px; }
.auth-box .brand { justify-content: center; padding-bottom: 26px; font-size: 1.4rem; }
.auth-box .brand-mark { width: 38px; height: 38px; font-size: 1rem; }
.auth-box .card { padding: 30px; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: .9rem; }
.field input { width: 100%; }
.error { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 10px 14px; font-size: .9rem; margin-bottom: 16px; }

/* ── موبایل ───────────────────────────────────────────────── */

@media (max-width: 960px) {
    .g4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
    html { font-size: 14px; }
    .shell { grid-template-columns: 1fr; }
    .side {
        position: sticky; top: 0; z-index: 5; height: auto;
        flex-direction: row; align-items: center; gap: 2px;
        padding: 10px 12px; border-left: 0; border-bottom: 1px solid var(--line);
        overflow-x: auto;
    }
    .brand { padding: 0 6px 0 10px; }
    .brand small, .side-foot { display: none; }
    .nav { display: flex; gap: 2px; }
    .nav a { white-space: nowrap; padding: 7px 11px; gap: 6px; }
    .main { padding: 20px 16px 48px; }
    .g4 { grid-template-columns: 1fr 1fr; }
    .g2 { grid-template-columns: 1fr; }   /* کارت‌های محتوایی در موبایل تمام‌عرض */
    .head h1 { font-size: 1.35rem; }
    .card { padding: 18px; }
    .table-wrap { margin: 0 -18px -18px; }
    th, td { padding: 11px 18px; }
    .issue-top { flex-direction: column; }
}

/* شرح فاکتور مهم‌ترین ستون است؛ در صفحه‌ی تنگ جدول اسکرول بخورد، نه اینکه شرح له شود */
td.wide { min-width: 230px; }
