@font-face { font-family: IRAN; src: url(/fonts/IRAN-Regular.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: IRAN; src: url(/fonts/IRAN-SemiBold.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: IRAN; src: url(/fonts/IRAN-Bold.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #f4f6f7; --card: #fff; --ink: #14272c; --muted: #6b7c80; --line: #e2e8ea;
  --brand: #004552; --brand2: #0b6b7c; --accent: #FA5322; --soft: #e6f0f2;
  --good: #14905a; --bad: #d23b2f; --warn: #b7791f;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,40,50,.05);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0d1719; --card: #152326; --ink: #e3eced; --muted: #8fa3a7; --line: #243538;
    --brand: #3fb3c4; --brand2: #6fd0de; --soft: #1b3236; --good: #3cc983; --bad: #ff6b5e; --warn: #e2b04a;
    --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.7 IRAN, Vazirmatn, Tahoma, sans-serif; }
a { color: var(--brand2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0; }
h3 { font-size: 15px; margin: 0 0 8px; }
code, .mono, pre { font-family: ui-monospace, Consolas, monospace; }
code { background: var(--soft); padding: 1px 6px; border-radius: 6px; font-size: 13px; }
pre { background: var(--soft); padding: 12px 14px; border-radius: 10px; overflow-x: auto; font-size: 13px; line-height: 1.6; text-align: left; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.good { color: var(--good); } .bad { color: var(--bad); }
.hidden { display: none !important; }

.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--brand); color: #fff; padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
@media (prefers-color-scheme: dark) { .side { background: #0a2a30; } }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 15px; }
.brand img { width: 34px; height: 34px; }
.brand:hover { text-decoration: none; }
.side nav { display: flex; flex-direction: column; gap: 4px; }
.side nav a { color: rgba(255,255,255,.82); padding: 8px 12px; border-radius: 9px; }
.side nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.side nav a.on { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.logout { margin-top: auto; display: flex; justify-content: space-between; align-items: center; }
.logout .muted { color: rgba(255,255,255,.6); }
.logout .link { color: #fff; }
.main { padding: 24px 28px 60px; min-width: 0; max-width: 1280px; }
.bare { max-width: 760px; margin: 0 auto; padding: 40px 16px; }

.head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.head h1 { display: flex; align-items: center; gap: 8px; }
.head .push, .head > .btn:last-child { margin-inline-start: auto; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid2 > .card { margin-bottom: 18px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; color: var(--ink); box-shadow: var(--shadow); }
a.stat:hover { text-decoration: none; border-color: var(--brand2); }
.stat b { font-size: 20px; font-weight: 700; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.good b { color: var(--good); }
.stat.warn b { color: var(--warn); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 9px; padding: 7px 14px; font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--brand2); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand2); }
@media (prefers-color-scheme: dark) { .btn.primary { color: #062126; } }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn.danger:hover { background: var(--bad); color: #fff; }
.btn.small { padding: 3px 10px; font-size: 13px; }
.btn.wide { width: 100%; justify-content: center; padding: 10px; }
.btn:disabled { opacity: .6; cursor: wait; }
button.link { background: none; border: 0; font: inherit; cursor: pointer; padding: 0; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; flex: 1; min-width: 0; }
input, select, textarea { font: inherit; font-size: 14px; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; width: 100%; }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--brand2) 40%, transparent); border-color: var(--brand2); }
input[dir=ltr] { text-align: left; }
input[dir=ltr]::placeholder { text-align: right; direction: rtl; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0; }
legend { padding: 0 6px; font-size: 14px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.grow { flex: 2; }
.check { flex-direction: row; align-items: center; gap: 8px; flex: none; }
.check input { width: auto; }
.checks { display: flex; flex-direction: column; gap: 8px; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; }
.flash.ok { background: color-mix(in srgb, var(--good) 10%, var(--card)); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.flash.err { background: color-mix(in srgb, var(--bad) 10%, var(--card)); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.flash.warn { background: color-mix(in srgb, var(--warn) 10%, var(--card)); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }

.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: right; font-weight: 600; color: var(--muted); font-size: 13px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.revoked td { opacity: .5; }
.tbl.small td { padding: 6px 10px; font-size: 13px; }
.card .tbl th:first-child, .card .tbl td:first-child { padding-inline-start: 4px; }
.card.flush .tbl th:first-child, .card.flush .tbl td:first-child { padding-inline-start: 18px; }
.name { white-space: nowrap; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; font-family: ui-monospace, Consolas, monospace; font-size: 14px; }
.usage { min-width: 150px; }

.meter { height: 6px; background: var(--soft); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.meter i { display: block; height: 100%; background: var(--brand2); border-radius: 4px; }
.meter i.hot { background: var(--accent); }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--muted); flex: none; }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 20%, transparent); }
.dot.off { background: var(--bad); }
.dot.wait { background: var(--warn); }

.pill { display: inline-block; padding: 1px 10px; border-radius: 20px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.s-active { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.s-disabled { background: var(--soft); color: var(--muted); }
.s-expired, .s-limited, .s-limit { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }

.tag { display: inline-block; font-size: 12px; padding: 0 8px; border-radius: 6px; margin: 1px 0 1px 4px; background: var(--soft); color: var(--brand2); font-family: ui-monospace, Consolas, monospace; white-space: nowrap; direction: ltr; }
.p-openvpn { background: #fdeee8; color: #c2410c; }
.p-vless, .p-phone { background: #e6f2f4; color: #00606f; }
.p-vmess { background: #eef0fb; color: #4048a8; }
.p-trojan { background: #f6ecf8; color: #8a2f9c; }
.p-shadowsocks { background: #eaf6ee; color: #1d7a45; }
@media (prefers-color-scheme: dark) {
  .p-openvpn { background: #3a2116; color: #ffa47f; } .p-vless, .p-phone { background: #12343a; color: #7fd8e6; }
  .p-vmess { background: #23264a; color: #a9b0ff; } .p-trojan { background: #35203a; color: #e2a6ef; } .p-shadowsocks { background: #173523; color: #8de0ae; }
}

.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; }
.bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.bar i { display: block; width: 100%; background: linear-gradient(to top, var(--brand), var(--brand2)); border-radius: 4px 4px 0 0; min-height: 0; }
.bar span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.bar:nth-child(even) span { visibility: hidden; }
.small-bars { height: 90px; gap: 3px; }

.srv-row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); color: var(--ink); }
.srv-row:last-child { border-bottom: 0; }
.srv-row .muted { margin-inline-start: auto; font-size: 13px; }
.srv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 18px; }
.srv-card { color: var(--ink); display: flex; flex-direction: column; gap: 8px; margin: 0; }
.srv-card:hover { text-decoration: none; border-color: var(--brand2); }
.srv-card h2 { display: flex; align-items: center; gap: 8px; }
.srv-nums { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); }
.srv-nums b { color: var(--ink); }

.quick-form { display: flex; flex-direction: column; gap: 12px; }
.quick-opts { display: flex; gap: 10px; flex-wrap: wrap; }
.quick-opts label { flex: 1; min-width: 120px; }
.quick-opts label.grow { flex: 3; min-width: 200px; }
.quick-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.proto { font-weight: 600; border-width: 1.5px; }
.btn.proto.p-openvpn { border-color: #f3b49b; } .btn.proto.p-vless { border-color: #9fd0d9; } .btn.proto.p-vmess { border-color: #b8bdf0; }
.btn.proto.p-trojan { border-color: #dbb3e4; } .btn.proto.p-shadowsocks { border-color: #a9dcbc; }
.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input { flex: 2; min-width: 180px; width: auto; }
.filters select { flex: 1; min-width: 140px; width: auto; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 20px; padding: 3px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--brand2); }

.actions form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.cfg { display: flex; gap: 18px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.cfg:last-child { border-bottom: 0; }
.qr { width: 150px; height: 150px; flex: none; background: #fff; border-radius: 10px; padding: 6px; border: 1px solid var(--line); }
.qr svg { width: 100%; height: 100%; display: block; }
.ovpn-icon { display: flex; align-items: center; justify-content: center; font: 700 24px ui-monospace, monospace; color: #c2410c; background: #fdeee8; }
.cfg-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.copy { display: flex; gap: 8px; width: 100%; }
.copy input { flex: 1; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; background: var(--soft); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 14px 0 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.danger-zone { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.acc-title { font-family: ui-monospace, Consolas, monospace; }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tab { border: 0; background: none; font: inherit; padding: 8px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.on { color: var(--brand2); border-bottom-color: var(--brand2); font-weight: 600; }

.login { max-width: 380px; margin: 6vh auto 0; }
.login-head { text-align: center; margin-bottom: 18px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.subpage { max-width: 640px; margin: 0 auto; }
.doc p { margin: 8px 0; }
.doc h2 { margin-bottom: 8px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 14px; gap: 10px; }
  .side nav { flex-direction: row; flex-wrap: wrap; order: 3; width: 100%; }
  .side nav a { padding: 5px 10px; font-size: 14px; }
  .logout { margin: 0 auto 0 0; gap: 10px; }
  .main { padding: 16px 16px 50px; }
  .grid2 { grid-template-columns: 1fr; gap: 0; }
  .cfg { flex-direction: column; align-items: stretch; }
  .qr { margin: 0 auto; width: 190px; height: 190px; }
}

/* v2: resellers, orders, plans, shop */
.badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-inline-start: 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; text-align: center; }
.credit { color: rgba(255,255,255,.85); font-size: 13px; background: rgba(255,255,255,.08); padding: 8px 12px; border-radius: 9px; }
.sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 14px 0; }
.sep::before, .sep::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.plan-btn { flex-direction: column; align-items: flex-start; gap: 0; padding: 8px 14px; }
.row-checks { flex-direction: row; flex-wrap: wrap; display: flex; gap: 8px 18px; }
.indent { padding-inline-start: 26px; }
.inline-form { display: flex; gap: 6px; align-items: center; }
.w-sm { width: 140px; padding: 4px 8px; }
.card-head.pad { padding: 14px 18px 0; }
.o-new { background: var(--soft); color: var(--muted); }
.o-paid { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.o-done { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.o-rejected { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.s-onhold { background: color-mix(in srgb, var(--brand2) 14%, transparent); color: var(--brand2); }
.toc { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.toc a { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 3px 12px; font-size: 13px; }
.bullets { padding-inline-start: 18px; margin: 0 0 12px; }
.bullets li { margin-bottom: 4px; }
textarea { font: inherit; font-size: 13px; }
.tabs a.tab { text-decoration: none; }
.shop .opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { flex: none; flex-direction: row; }
.opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.opt span { display: inline-block; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 16px; cursor: pointer; background: var(--card); }
.opt input:checked + span { border-color: var(--brand2); background: var(--soft); color: var(--brand2); font-weight: 600; }
.opt input:focus-visible + span { outline: 2px solid var(--brand2); }
.total { display: flex; justify-content: space-between; align-items: center; font-size: 18px; padding: 12px 14px; background: var(--soft); border-radius: 10px; }
.total b { color: var(--brand2); font-size: 22px; }
