/* ===== Font (local) ===== */
@font-face {
    font-family: "Vazirmatn";
    src: url("fonts/Vazirmatn-Variable.woff2") format("woff2-variations"),
         url("fonts/Vazirmatn-Variable.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

/* ===== Tokens ===== */
:root {
    --bg: #edf0f5;
    --surface: #ffffff;
    --ink: #172036;
    --muted: #5d6680;
    --line: #d6dce7;
    --line-soft: #e8ecf2;

    --cobalt: #2441a6;
    --cobalt-deep: #1a2f7a;
    --cobalt-soft: #e5eafa;

    --ok: #13795b;
    --ok-soft: #e1f3eb;
    --err: #b3361f;
    --err-soft: #fbe8e3;
    --warn: #8a5a00;

    --r-sm: 6px;
    --r: 10px;
    --focus: 0 0 0 3px rgba(36, 65, 166, .28);

    --font: "Vazirmatn", Tahoma, "Segoe UI", system-ui, sans-serif;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: .9375rem;
    line-height: 1.75;
    color: var(--ink);
    background: var(--bg);
}
h1, h2, h3 { margin: 0; line-height: 1.4; }
h1 { font-size: 1.625rem; font-weight: 780; letter-spacing: -.01em; }
h2 { font-size: 1.0625rem; font-weight: 700; }
h3 { font-size: .9375rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--cobalt); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
[hidden] { display: none !important; }

.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--muted); }
.strong { font-weight: 650; color: var(--ink); }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ===== Brand mark: a tiny server rack ===== */
.brand-mark {
    display: inline-block;
    width: 26px; height: 26px; flex: none;
    background: url("mark.svg") center / contain no-repeat;
}
.brand-mark-lg { width: 52px; height: 52px; }

/* ===== Top bar ===== */
.topbar { background: var(--cobalt); color: #fff; }
.topbar-inner {
    max-width: 1120px; margin: 0 auto;
    padding: 0 24px; min-height: 64px;
    display: flex; align-items: center; gap: 32px;
}
.brand {
    display: flex; align-items: center; gap: 10px;
    color: #fff; font-weight: 800; font-size: 1.0625rem; white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
    color: rgba(255, 255, 255, .78);
    padding: 6px 14px; border-radius: 999px; font-weight: 550;
}
.nav a:hover { color: #fff; text-decoration: none; background: rgba(255, 255, 255, .1); }
.nav a.is-active { color: var(--cobalt-deep); background: #fff; }
.who { display: flex; align-items: center; gap: 12px; font-size: .875rem; }
.who form { margin: 0; }
.who-name { color: rgba(255, 255, 255, .85); }
.who-out {
    font: inherit; color: #fff; cursor: pointer;
    background: transparent; border: 1px solid rgba(255, 255, 255, .45);
    padding: 3px 12px; border-radius: 999px;
}
.who-out:hover { background: rgba(255, 255, 255, .12); }

/* ===== Server identity ===== */
.dot {
    display: inline-block; flex: none;
    width: 9px; height: 9px; border-radius: 50%;
    box-shadow: 0 0 0 1.5px rgba(23, 32, 54, .18);
}
.dot-0 { background: #7fe0b8; }
.dot-1 { background: #ffd166; }
.dot-2 { background: #ff9bb0; }
.dot-3 { background: #8fd3ff; }
.dot-4 { background: #cdb4ff; }
.dot-5 { background: #ffb877; }

.srv { position: relative; }
.srv > summary, .srv-single {
    display: flex; align-items: center; gap: 8px;
    color: #fff; font-weight: 600; font-size: .875rem;
    padding: 5px 14px; border-radius: 999px;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .22);
    white-space: nowrap;
}
.srv > summary { cursor: pointer; list-style: none; }
.srv > summary::-webkit-details-marker { display: none; }
.srv > summary::after {
    content: ""; width: 7px; height: 7px; margin-right: 2px;
    border: solid rgba(255, 255, 255, .8); border-width: 0 1.5px 1.5px 0;
    transform: translateY(-2px) rotate(45deg);
}
.srv[open] > summary { background: #fff; color: var(--cobalt-deep); }
.srv[open] > summary::after { border-color: var(--cobalt-deep); transform: translateY(2px) rotate(-135deg); }
.srv-current { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

.srv-menu {
    position: absolute; top: calc(100% + 8px); left: 0; z-index: 20;
    min-width: 280px; margin: 0; padding: 6px; list-style: none;
    background: var(--surface); border-radius: var(--r);
    box-shadow: 0 18px 48px rgba(23, 32, 54, .24);
}
.srv-menu a {
    display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 10px;
    padding: 8px 12px; border-radius: var(--r-sm); color: var(--ink);
}
.srv-menu a:hover { background: #f3f5fa; text-decoration: none; }
.srv-menu a.is-active { background: var(--cobalt-soft); }
.srv-name { font-weight: 650; }
.srv-host { grid-column: 2; color: var(--muted); font-size: .8125rem; justify-self: start; }

.srv-tag {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: .8125rem; font-weight: 600; color: var(--muted);
    padding: 1px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}

.target {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    margin-bottom: 16px;
}
.target-label { font-weight: 600; font-size: .875rem; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg a {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 5px 14px; border-radius: 999px; font-size: .875rem; font-weight: 550;
    border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.seg a:hover { text-decoration: none; border-color: var(--cobalt); }
.seg a.is-active { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }

/* ===== Layout ===== */
.container { max-width: 1120px; margin: 0 auto; padding: 32px 24px 64px; }
.page-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-head .muted { margin-top: 2px; }

.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack { display: grid; gap: 20px; }

/* ===== Panels ===== */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.panel-head {
    display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
    padding: 16px 20px; border-bottom: 1px solid var(--line-soft);
}
.panel-body { padding: 20px; }
.panel-bar { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.panel-foot {
    display: flex; gap: 10px; padding: 16px 20px;
    border-top: 1px solid var(--line-soft); background: #f8f9fc;
    border-radius: 0 0 var(--r) var(--r);
}
.form-panel { max-width: 860px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; }
.span-2 { grid-column: 1 / -1; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font: inherit; font-weight: 650; font-size: .9375rem;
    min-height: 42px; padding: 0 20px;
    border-radius: var(--r-sm); border: 1px solid var(--cobalt);
    background: var(--cobalt); color: #fff; cursor: pointer; white-space: nowrap;
    transition: background-color .15s, border-color .15s;
}
.btn:hover { background: var(--cobalt-deep); border-color: var(--cobalt-deep); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: var(--surface); color: var(--cobalt); border-color: var(--line); }
.btn-ghost:hover { background: var(--cobalt-soft); border-color: var(--cobalt-soft); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: .8125rem; }
.btn-block { width: 100%; }

.chip {
    font: inherit; font-size: .8125rem; font-weight: 550;
    color: var(--cobalt); background: var(--cobalt-soft);
    border: 0; border-radius: 999px; padding: 3px 12px; cursor: pointer;
}
.chip:hover { background: #d6defa; }
.chip.is-done { color: var(--ok); background: var(--ok-soft); }

/* ===== Forms ===== */
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; font-size: .875rem; margin-bottom: 6px; }
.field-narrow { max-width: 220px; }
.input {
    width: 100%; min-height: 42px;
    font: inherit; color: var(--ink);
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--r-sm);
    transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--cobalt); box-shadow: var(--focus); }
.input.ltr { display: block; text-align: left; }
.input:user-invalid { border-color: var(--err); }
select.input { cursor: pointer; }
.hint { font-size: .8125rem; color: var(--muted); margin-top: 6px; }
.hint-warn { color: var(--warn); }

.pw-tools { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.addr {
    display: flex; width: 100%;
    border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface);
}
.addr:focus-within { border-color: var(--cobalt); box-shadow: var(--focus); }
.addr .input { border: 0; box-shadow: none; min-width: 0; flex: 1; border-radius: var(--r-sm) 0 0 var(--r-sm); }
.addr-domain {
    display: flex; align-items: center; padding: 0 12px;
    color: var(--muted); background: #f5f7fb;
    border-left: 1px solid var(--line-soft); border-radius: 0 var(--r-sm) var(--r-sm) 0;
    white-space: nowrap; max-width: 60%; overflow: hidden; text-overflow: ellipsis;
}

/* ===== Searchable select ===== */
.cb { position: relative; }
.cb-native {
    position: absolute; inset: 0; width: 100%; height: 100%;
    opacity: 0; pointer-events: none;
}
.cb-btn {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    text-align: right; cursor: pointer;
}
.cb-btn::after {
    content: ""; flex: none; width: 7px; height: 7px;
    border: solid var(--muted); border-width: 0 1.5px 1.5px 0;
    transform: translateY(-2px) rotate(45deg);
}
.cb-btn[aria-expanded="true"] { border-color: var(--cobalt); box-shadow: var(--focus); }
.cb-btn.is-placeholder .cb-value { color: var(--muted); }
.cb-btn.is-invalid { border-color: var(--err); }
.cb-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-value[dir="ltr"] { font-weight: 600; }

.cb-pop {
    position: absolute; top: calc(100% + 6px); right: 0; left: 0; z-index: 30;
    min-width: 260px; padding: 8px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
    box-shadow: 0 18px 48px rgba(23, 32, 54, .2);
}
.cb-search { min-height: 38px; margin-bottom: 6px; }
.cb-list {
    list-style: none; margin: 0; padding: 0;
    max-height: 300px; overflow-y: auto; overscroll-behavior: contain;
}
.cb-group {
    position: sticky; top: 0; z-index: 1;
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 10px 4px; background: var(--surface);
    font-size: .75rem; font-weight: 700; color: var(--muted);
    border-bottom: 1px solid var(--line-soft);
}
.cb-group:not(:first-child) { margin-top: 6px; }
.cb-count { font-weight: 500; }
.cb-opt {
    padding: 7px 10px; border-radius: var(--r-sm); cursor: pointer;
    text-align: left; font-size: .875rem;
}
.cb-opt.is-active { background: #f0f3fb; }
.cb-opt.is-selected { color: var(--cobalt); font-weight: 650; background: var(--cobalt-soft); }
.cb-empty { padding: 14px 10px; color: var(--muted); font-size: .875rem; text-align: center; }

/* بدون JavaScript: گزینه‌های پکیج LTR بمانند */
select.ltr-options option { direction: ltr; text-align: left; }

/* ===== Alerts ===== */
.flashes { display: grid; gap: 10px; margin-bottom: 24px; }
.alert {
    padding: 12px 16px; border-radius: var(--r-sm);
    border: 1px solid transparent; font-weight: 550;
}
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: #c4e6d6; }
.alert-error { background: var(--err-soft); color: var(--err); border-color: #f2cbc1; }
.alert-info { background: var(--cobalt-soft); color: var(--cobalt-deep); border-color: #cfd8f6; }
.alert details { margin-top: 6px; font-weight: 400; font-size: .8125rem; }
.alert summary { cursor: pointer; }
.alert pre { white-space: pre-wrap; margin: 6px 0 0; font-family: inherit; text-align: left; }
.panel-body > .alert { margin: 0; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
    font-size: .8125rem; font-weight: 600; color: var(--muted);
    text-align: right; padding: 10px 16px; white-space: nowrap;
    border-bottom: 1px solid var(--line);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #f7f9fc; }
.table .end { text-align: left; }
.no-match td { color: var(--muted); text-align: center; padding: 28px; }
.search { max-width: 380px; }

.badge {
    display: inline-block; font-size: .75rem; font-weight: 650;
    padding: 1px 10px; border-radius: 999px;
    background: var(--line-soft); color: var(--muted);
}
.badge-on { background: var(--ok-soft); color: var(--ok); }
.badge-off { background: var(--err-soft); color: var(--err); }

.empty {
    text-align: center; padding: 56px 24px;
    border: 1px dashed var(--line); border-radius: var(--r); background: var(--surface);
}
.empty p { margin-bottom: 16px; color: var(--muted); }

/* ===== User page ===== */
.back { display: inline-block; font-size: .875rem; margin-bottom: 16px; }
.back::before { content: "→ "; }

.profile { margin-bottom: 20px; }
.profile-id { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.profile-id h1 { font-size: 2rem; font-weight: 800; }
.profile-domain { color: var(--muted); font-size: 1rem; }

.facts {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    margin: 0 0 28px; padding: 0;
    border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.facts > div { padding: 14px 16px 14px 0; border-left: 1px solid var(--line-soft); }
.facts > div:last-child { border-left: 0; }
.facts > div + div { padding-right: 16px; }
.facts dt { font-size: .8125rem; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 650; overflow-wrap: anywhere; }

.domains {
    display: flex; gap: 6px; flex-wrap: wrap;
    padding: 14px 20px; border-bottom: 1px solid var(--line-soft);
}
.domains a {
    padding: 3px 12px; border-radius: 999px; font-size: .875rem;
    border: 1px solid var(--line); color: var(--ink);
}
.domains a:hover { text-decoration: none; border-color: var(--cobalt); }
.domains a.is-active { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }

.mail-list { list-style: none; margin: 0; padding: 0; }
.mail-list li {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 20px; border-bottom: 1px solid var(--line-soft);
}
.mail-list li > span { overflow-wrap: anywhere; }

.new-mail { background: #f8f9fc; border-radius: 0 0 var(--r) var(--r); border-top: 1px solid var(--line-soft); }
.new-mail h3 { margin-bottom: 14px; }

/* ===== Dialog ===== */
.dialog {
    width: min(480px, calc(100vw - 32px));
    border: 0; border-radius: var(--r); padding: 24px;
    color: var(--ink); background: var(--surface);
    box-shadow: 0 24px 60px rgba(23, 32, 54, .28);
}
.dialog::backdrop { background: rgba(23, 32, 54, .45); }
.dialog h2 { margin-bottom: 2px; }
.dialog-addr { color: var(--muted); margin-bottom: 18px; }
.dialog-actions { display: flex; gap: 10px; }

/* ===== Login ===== */
body.is-bare {
    background:
        linear-gradient(var(--cobalt) 0, var(--cobalt) 46vh, transparent 46vh) no-repeat,
        var(--bg);
}
.bare { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 10vh 20px 40px; }
.login { width: 100%; max-width: 400px; }
.login-head { color: #fff; text-align: center; margin-bottom: 28px; }
.login-head .brand-mark { margin-bottom: 12px; }
.login-head h1 { font-size: 1.75rem; font-weight: 800; }
.login-head p { color: rgba(255, 255, 255, .78); margin-top: 4px; }
.login-card {
    background: var(--surface); border-radius: var(--r); padding: 28px;
    box-shadow: 0 18px 50px rgba(23, 32, 54, .18);
}
.login-card .alert { margin-bottom: 18px; }

/* ===== Responsive ===== */
@media (max-width: 960px) {
    .split { grid-template-columns: 1fr; }
    .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .facts > div { border-left: 0; padding: 12px 0 !important; }
}
@media (max-width: 680px) {
    .topbar-inner {
        display: grid; grid-template-columns: 1fr auto;
        grid-template-areas: "brand who" "nav srv";
        gap: 8px 12px; padding: 10px 16px;
    }
    .brand { grid-area: brand; }
    .who { grid-area: who; }
    .nav { grid-area: nav; }
    .srv { grid-area: srv; }
    .srv-current { max-width: 130px; }
    .srv-menu { min-width: 240px; }
    .container { padding: 24px 16px 48px; }
    .grid-2 { grid-template-columns: 1fr; }
    .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hide-sm { display: none; }
    .table th, .table td { padding: 10px 12px; }
    .profile-id h1 { font-size: 1.625rem; }
    .panel-foot { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
