:root {
  color-scheme: light;
  --bg: #f3f5f6;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --ink: #182127;
  --ink-soft: #39454d;
  --muted: #6d7880;
  --line: #dfe5e7;
  --line-strong: #cbd4d8;
  --nav: #172127;
  --nav-soft: #223039;
  --teal: #087f6b;
  --teal-soft: #e8f4f1;
  --blue: #356faf;
  --blue-soft: #eaf1f8;
  --coral: #c6534d;
  --coral-soft: #f9ecea;
  --amber: #ad6a12;
  --amber-soft: #fff4df;
  --shadow: 0 8px 22px rgba(23, 33, 39, 0.06);
  --sidebar-width: 242px;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); overflow-x: hidden; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
svg { width: 19px; height: 19px; stroke-width: 1.8; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px 18px 88px; background: var(--bg); position: relative; }
.auth-brand { position: fixed; top: 28px; right: 32px; display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 750; font-size: 18px; }
.brand-mark { width: 38px; height: 38px; display: inline-grid; place-items: center; color: white; background: var(--teal); border-radius: 7px; flex: 0 0 auto; }
.brand-mark svg { width: 22px; height: 22px; }
.auth-panel { width: min(100%, 410px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 34px; box-shadow: var(--shadow); }
.auth-heading { margin-bottom: 28px; }
.auth-heading .eyebrow { margin: 0 0 7px; color: var(--teal); font-size: 13px; font-weight: 800; }
.auth-heading h1 { margin: 0; font-size: 28px; line-height: 1.3; }
.auth-heading p:not(.eyebrow) { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.auth-status { display: flex; justify-content: center; align-items: center; gap: 7px; margin-top: 20px; color: var(--muted); font-size: 12px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #22a06b; box-shadow: 0 0 0 3px rgba(34,160,107,.12); }

.field { display: grid; gap: 8px; min-width: 0; }
.field > span:first-child, fieldset legend { color: var(--ink-soft); font-size: 13px; font-weight: 700; }
.input-wrap, .select-wrap, .search-box { position: relative; min-height: 44px; display: flex; align-items: center; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 6px; transition: border-color .18s, box-shadow .18s; }
.input-wrap:focus-within, .select-wrap:focus-within, .search-box:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,127,107,.11); }
.input-wrap > svg, .select-wrap > svg, .search-box > svg { position: absolute; right: 13px; width: 17px; color: var(--muted); pointer-events: none; }
.input-wrap input, .input-wrap textarea, .select-wrap select, .search-box input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; padding: 10px 40px 10px 12px; }
.input-wrap input::placeholder, .input-wrap textarea::placeholder, .search-box input::placeholder { color: #9aa4aa; }
.input-wrap em { position: absolute; left: 10px; color: var(--muted); font-size: 10px; font-style: normal; }
.input-icon { position: absolute; left: 5px; width: 34px; height: 34px; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; }
.textarea-wrap { align-items: flex-start; }
.textarea-wrap > svg { top: 13px; }
.input-wrap textarea { resize: vertical; min-height: 82px; }
.field-select select { appearance: none; }
.field-select::after, .select-wrap::after { content: ""; position: absolute; left: 14px; width: 7px; height: 7px; border-left: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); pointer-events: none; }
.select-wrap select { appearance: none; padding-left: 34px; }
.form-error { min-height: 20px; margin: 8px 0; color: var(--coral); font-size: 13px; }

.button { min-height: 40px; border: 1px solid transparent; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 15px; font-weight: 750; white-space: nowrap; transition: background .18s, border-color .18s, transform .18s; }
.button:active { transform: translateY(1px); }
.button.primary { background: var(--teal); color: white; }
.button.primary:hover { background: #066f5e; }
.button.secondary { color: var(--ink-soft); background: var(--surface); border-color: var(--line-strong); }
.button.secondary:hover { background: var(--surface-soft); }
.button.danger { color: white; background: var(--coral); }
.button.wide { width: 100%; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink-soft); display: inline-grid; place-items: center; flex: 0 0 auto; }
.icon-button:hover { background: var(--surface-soft); border-color: var(--line-strong); }
.icon-button.inverted { border-color: rgba(255,255,255,.12); background: rgba(255,255,255,.05); color: #dfe7e9; }
.text-button { border: 0; background: transparent; color: var(--teal); font-weight: 750; display: inline-flex; align-items: center; gap: 6px; padding: 5px; }
.text-button svg { width: 16px; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; z-index: 40; inset: 0 0 0 auto; width: var(--sidebar-width); background: var(--nav); color: white; display: flex; flex-direction: column; padding: 22px 15px 16px; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 24px; }
.sidebar-brand > span:last-child { display: flex; align-items: baseline; gap: 4px; }
.sidebar-brand strong { font-size: 19px; }
.sidebar-brand small { font-size: 13px; color: #aab9bf; }
.main-nav { display: grid; gap: 4px; }
.nav-item { min-height: 44px; width: 100%; border: 0; border-radius: 6px; background: transparent; color: #b9c6ca; display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 10px; padding: 9px 11px; text-align: right; font-weight: 650; text-decoration: none; }
.nav-item:hover { background: rgba(255,255,255,.05); color: white; }
.nav-item.active { background: var(--nav-soft); color: white; box-shadow: inset -3px 0 var(--teal); }
.nav-item b { min-width: 25px; min-height: 20px; padding: 2px 7px; border-radius: 10px; background: rgba(255,255,255,.08); font-size: 11px; text-align: center; }
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.server-mini { min-width: 0; display: flex; align-items: center; gap: 9px; }
.server-mini-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 6px; background: rgba(255,255,255,.07); color: #a9d9cf; }
.server-mini > span:last-child { min-width: 0; display: grid; gap: 3px; }
.server-mini strong { max-width: 112px; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.server-mini small { color: #93a5ab; font-size: 10px; }
.server-mini .status-dot { width: 6px; height: 6px; box-shadow: none; }
.sidebar-scrim { display: none; }

.main-content { min-height: 100vh; margin-right: var(--sidebar-width); }
.topbar { height: 74px; padding: 0 clamp(18px, 3vw, 38px); display: flex; align-items: center; justify-content: space-between; gap: 18px; background: rgba(243,245,246,.94); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 25; backdrop-filter: blur(10px); }
.topbar-title { min-width: 0; display: flex; align-items: center; gap: 10px; }
.topbar-title > span { min-width: 0; display: grid; gap: 2px; }
.topbar-title small { color: var(--muted); font-size: 11px; font-weight: 650; }
.topbar-title strong { font-size: 19px; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.last-update { color: var(--muted); font-size: 11px; }
.page-stack { width: min(100%, 1540px); margin-inline: auto; padding: 26px clamp(18px, 3vw, 38px) 48px; }
.view { display: none; }
.view.active { display: block; animation: viewIn .2s ease-out; }
@keyframes viewIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card { min-width: 0; min-height: 148px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 17px 18px; box-shadow: 0 3px 10px rgba(23,33,39,.03); }
.metric-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; }
.metric-icon { width: 34px; height: 34px; border-radius: 6px; display: grid; place-items: center; }
.metric-network-in .metric-icon { color: var(--teal); background: var(--teal-soft); }
.metric-network-out .metric-icon { color: var(--blue); background: var(--blue-soft); }
.metric-cpu .metric-icon { color: var(--amber); background: var(--amber-soft); }
.metric-memory .metric-icon { color: var(--coral); background: var(--coral-soft); }
.metric-card p { margin: 12px 0 4px; color: var(--muted); font-size: 12px; font-weight: 650; }
.metric-card strong { display: block; font-size: 28px; line-height: 1.2; white-space: nowrap; }
.metric-card strong small { color: var(--muted); font-size: 12px; font-weight: 650; }
.metric-sub, .metric-trend, .live-label { color: var(--muted); font-size: 10px; }
.metric-sub { display: block; margin-top: 4px; direction: ltr; text-align: right; }
.live-label { display: flex; align-items: center; gap: 5px; color: var(--teal); font-weight: 750; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px rgba(8,127,107,.1); }
.meter { height: 5px; margin-top: 12px; background: #edf0f1; border-radius: 3px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; border-radius: inherit; transition: width .4s; }
.metric-cpu .meter span { background: var(--amber); }
.metric-memory .meter span { background: var(--coral); }

.surface { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 3px 12px rgba(23,33,39,.035); }
.network-surface { padding: 19px 20px 15px; margin-bottom: 22px; }
.section-heading { min-width: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-heading.compact { align-items: center; }
.section-heading h2 { margin: 0; font-size: 16px; line-height: 1.4; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.chart-legend { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 11px; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 2px; }
.legend-dot.download { background: var(--teal); }
.legend-dot.upload { background: var(--blue); }
.chart-wrap { position: relative; width: 100%; height: 230px; }
.chart-wrap canvas { display: block; width: 100%; height: 100%; }
.chart-axis { position: absolute; top: 2px; left: 4px; color: var(--muted); font-size: 10px; direction: ltr; }

.overview-split { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .55fr); gap: 20px; margin-bottom: 22px; }
.services-section { min-width: 0; }
.service-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.service-card { min-width: 0; min-height: 176px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: 0 3px 10px rgba(23,33,39,.03); position: relative; overflow: hidden; }
.service-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--provider-color); }
.service-card.remnawave { --provider-color: var(--teal); }
.service-card.xboard { --provider-color: var(--blue); }
.service-card.marzban { --provider-color: var(--coral); }
.service-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.provider-identity { display: flex; align-items: center; gap: 9px; min-width: 0; }
.provider-logo { width: 34px; height: 34px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 6px; color: white; background: var(--teal); font-size: 15px; font-weight: 850; }
.provider-logo.xboard, .provider-option.xboard .provider-logo { background: var(--blue); }
.provider-logo.marzban, .provider-option.marzban .provider-logo { background: var(--coral); }
.provider-identity span:last-child { min-width: 0; display: grid; }
.provider-identity strong { font-size: 13px; }
.provider-identity small { color: var(--muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.health-pill, .health-badge { display: inline-flex; align-items: center; gap: 6px; min-height: 25px; border-radius: 14px; padding: 3px 8px; font-size: 10px; font-weight: 750; color: var(--teal); background: var(--teal-soft); }
.health-pill.down { color: var(--coral); background: var(--coral-soft); }
.service-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 23px; }
.service-stats div { display: grid; gap: 3px; }
.service-stats span { color: var(--muted); font-size: 10px; }
.service-stats strong { font-size: 21px; }
.service-footer { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 10px; }
.service-skeleton { height: 176px; border: 1px solid var(--line); border-radius: var(--radius); background: #edf1f2; animation: shimmer 1.2s infinite alternate; }
@keyframes shimmer { to { background: #f7f9f9; } }

.account-summary { padding: 18px; }
.summary-total { font-size: 22px; font-weight: 800; }
.donut-area { min-height: 176px; display: grid; grid-template-columns: 138px 1fr; align-items: center; gap: 12px; }
.donut { width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--teal) var(--active-angle, 280deg), #e8edef 0); position: relative; }
.donut::after { content: ""; position: absolute; inset: 16px; border-radius: 50%; background: var(--surface); }
.donut span { position: relative; z-index: 1; display: grid; place-items: center; }
.donut strong { font-size: 24px; }
.donut small { color: var(--muted); font-size: 10px; }
.summary-list { margin: 0; display: grid; gap: 14px; }
.summary-list div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.summary-list dt { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.summary-list dd { margin: 0; font-weight: 800; }
.status-swatch { width: 8px; height: 8px; border-radius: 2px; }
.status-swatch.active { background: var(--teal); }
.status-swatch.warning { background: var(--amber); }
.status-swatch.muted { background: #9ba6ab; }

.table-surface { overflow: hidden; }
.table-surface > .section-heading { padding: 17px 19px 0; }
.table-scroll { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { height: 42px; padding: 10px 14px; color: var(--muted); background: var(--surface-soft); border-block: 1px solid var(--line); text-align: right; font-weight: 750; white-space: nowrap; }
td { height: 56px; padding: 10px 14px; border-bottom: 1px solid #edf0f1; color: var(--ink-soft); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfc; }
.empty-cell { height: 130px; text-align: center; color: var(--muted); }
.account-cell { display: flex; align-items: center; gap: 9px; min-width: 160px; }
.account-avatar { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 6px; color: var(--ink-soft); background: #edf1f2; font-size: 11px; font-weight: 850; }
.account-cell span { min-width: 0; display: grid; gap: 2px; }
.account-cell strong { max-width: 190px; overflow: hidden; text-overflow: ellipsis; color: var(--ink); font-size: 12px; }
.account-cell small { max-width: 190px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 9px; }
.provider-badge { display: inline-flex; align-items: center; gap: 6px; min-height: 25px; padding: 3px 8px; border-radius: 5px; font-size: 10px; font-weight: 750; }
.provider-badge.remnawave { color: var(--teal); background: var(--teal-soft); }
.provider-badge.xboard { color: var(--blue); background: var(--blue-soft); }
.provider-badge.marzban { color: var(--coral); background: var(--coral-soft); }
.status-badge { display: inline-flex; align-items: center; gap: 6px; min-height: 25px; padding: 3px 8px; border-radius: 12px; font-size: 10px; font-weight: 750; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-badge.active { color: var(--teal); background: var(--teal-soft); }
.status-badge.disabled { color: #6d7880; background: #eef1f2; }
.status-badge.expired, .status-badge.limited { color: var(--coral); background: var(--coral-soft); }
.status-badge.on_hold { color: var(--amber); background: var(--amber-soft); }
.online-indicator { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.online-indicator::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #afb7bb; }
.online-indicator.yes { color: var(--teal); }
.online-indicator.yes::before { background: var(--teal); box-shadow: 0 0 0 3px rgba(8,127,107,.1); }
.usage-cell { min-width: 130px; }
.usage-cell > span { display: flex; justify-content: space-between; gap: 8px; font-size: 10px; }
.usage-cell > span small { color: var(--muted); }
.usage-bar { width: 100%; height: 4px; margin-top: 6px; border: 0; border-radius: 2px; background: #edf0f1; overflow: hidden; appearance: none; }
.usage-bar::-webkit-progress-bar { background: #edf0f1; }
.usage-bar::-webkit-progress-value { background: var(--blue); }
.usage-bar::-moz-progress-bar { background: var(--blue); }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.row-actions .icon-button { width: 32px; height: 32px; }
.row-actions .icon-button svg { width: 15px; height: 15px; }
.row-actions .danger-action { color: var(--coral); }

.accounts-toolbar { padding: 13px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.segmented { min-height: 38px; display: inline-flex; align-items: center; padding: 3px; border-radius: 6px; background: #edf1f2; }
.segmented button { min-height: 32px; border: 0; border-radius: 4px; padding: 5px 12px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 750; white-space: nowrap; }
.segmented button.active { color: var(--ink); background: var(--surface); box-shadow: 0 1px 4px rgba(23,33,39,.1); }
.toolbar-fields { display: flex; align-items: center; gap: 8px; }
.search-box { width: 250px; min-height: 38px; }
.select-wrap { min-height: 38px; }
.select-wrap select { border: 0; outline: 0; background: transparent; }
.table-meta { height: 42px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; }
.table-meta #accountsError { color: var(--coral); }
.accounts-table-surface { min-height: 520px; }
.pagination { min-height: 58px; padding: 10px 14px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 11px; }

.create-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.create-form { padding: 22px; }
.form-step { width: 36px; height: 28px; border-radius: 5px; display: grid; place-items: center; background: var(--surface-soft); color: var(--muted); font-size: 11px; font-weight: 800; }
.provider-picker { border: 0; margin: 0 0 22px; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.provider-picker legend { margin-bottom: 9px; }
.provider-option { min-width: 0; min-height: 72px; padding: 11px; border: 1px solid var(--line-strong); border-radius: 6px; display: grid; grid-template-columns: 34px 1fr 20px; align-items: center; gap: 9px; cursor: pointer; }
.provider-option:hover { border-color: #aebbc0; }
.provider-option.selected { border-color: var(--provider-color); box-shadow: 0 0 0 2px color-mix(in srgb, var(--provider-color) 12%, transparent); }
.provider-option.remnawave { --provider-color: var(--teal); }
.provider-option.xboard { --provider-color: var(--blue); }
.provider-option.marzban { --provider-color: var(--coral); }
.provider-option input { position: absolute; opacity: 0; }
.provider-option > span:nth-child(3) { min-width: 0; display: grid; gap: 2px; }
.provider-option strong { font-size: 12px; }
.provider-option small { color: var(--muted); font-size: 9px; }
.provider-option > svg { display: none; color: var(--provider-color); }
.provider-option.selected > svg { display: block; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.create-summary { position: sticky; top: 98px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--nav); color: white; padding: 20px; }
.summary-header { display: flex; align-items: center; gap: 10px; padding-bottom: 18px; border-bottom: 1px solid rgba(255,255,255,.1); }
.summary-header > span:last-child { display: grid; gap: 2px; }
.summary-header small { color: #9fb0b6; font-size: 10px; }
.summary-header strong { font-size: 14px; }
.create-summary dl { margin: 19px 0; display: grid; gap: 13px; }
.create-summary dl div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.create-summary dt { color: #9fb0b6; font-size: 11px; }
.create-summary dd { margin: 0; font-size: 12px; font-weight: 750; }
.summary-note { display: flex; align-items: flex-start; gap: 8px; padding: 11px; border-radius: 6px; background: rgba(255,255,255,.06); color: #b9c6ca; font-size: 10px; line-height: 1.7; }
.summary-note svg { color: #7fd0bf; flex: 0 0 auto; }

.audit-surface { padding: 20px; min-height: 640px; }
.audit-list { display: grid; }
.audit-item { min-height: 70px; display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 12px; border-top: 1px solid var(--line); padding: 12px 0; }
.audit-item:first-child { border-top: 0; }
.audit-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 6px; background: var(--surface-soft); color: var(--teal); }
.audit-icon.failed { color: var(--coral); background: var(--coral-soft); }
.audit-main { min-width: 0; display: grid; gap: 3px; }
.audit-main strong { font-size: 12px; }
.audit-main span { color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.audit-time { color: var(--muted); font-size: 10px; direction: ltr; }
.empty-state { min-height: 300px; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--muted); }
.empty-state svg { width: 30px; height: 30px; }
.empty-state p { margin: 0; font-size: 12px; }

.system-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, .7fr); gap: 20px; }
.system-details, .provider-health { padding: 20px; }
.details-list { margin: 0; display: grid; grid-template-columns: 1fr 1fr; }
.details-list div { min-height: 62px; padding: 13px 0; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.details-list div:nth-child(odd) { padding-left: 20px; }
.details-list div:nth-child(even) { padding-right: 20px; border-right: 1px solid var(--line); }
.details-list dt { color: var(--muted); font-size: 11px; }
.details-list dd { margin: 0; font-size: 12px; font-weight: 750; direction: ltr; }
.health-list { display: grid; }
.health-row { min-height: 66px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px; }
.health-row:first-child { border-top: 0; }
.health-row > span:first-child { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 6px; background: var(--surface-soft); }
.health-row > span:nth-child(2) { min-width: 0; display: grid; gap: 2px; }
.health-row strong { font-size: 12px; }
.health-row small { color: var(--muted); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.infra-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.infra-metrics article { min-width: 0; min-height: 94px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); display: flex; align-items: center; gap: 13px; box-shadow: 0 3px 10px rgba(23,33,39,.03); }
.infra-metrics article:nth-child(1) .metric-icon { color: var(--blue); background: var(--blue-soft); }
.infra-metrics article:nth-child(2) .metric-icon { color: var(--amber); background: var(--amber-soft); }
.infra-metrics article:nth-child(3) .metric-icon { color: var(--coral); background: var(--coral-soft); }
.infra-metrics article:nth-child(4) .metric-icon { color: var(--teal); background: var(--teal-soft); }
.infra-metrics article > span:last-child { min-width: 0; display: grid; gap: 3px; }
.infra-metrics small { color: var(--muted); font-size: 10px; }
.infra-metrics strong { font-size: 24px; }
.infra-toolbar { min-height: 66px; margin-bottom: 16px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.infra-toolbar .segmented button { display: inline-flex; align-items: center; gap: 6px; }
.infra-toolbar .segmented svg { width: 15px; height: 15px; }
.infra-toolbar-actions { display: flex; align-items: center; gap: 7px; }
.infra-panel { display: none; }
.infra-panel.active { display: block; animation: viewIn .18s ease-out; }
.infrastructure-table > .section-heading { padding: 18px 19px 0; }
.backup-security { min-height: 28px; padding: 5px 9px; display: inline-flex; align-items: center; gap: 6px; color: var(--teal); background: var(--teal-soft); border-radius: 5px; font-size: 10px; font-weight: 750; }
.backup-security svg { width: 14px; height: 14px; }
.endpoint-cell { min-width: 170px; display: grid; gap: 3px; direction: ltr; text-align: right; }
.endpoint-cell strong { color: var(--ink); font: 700 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.endpoint-cell small { max-width: 220px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.host-name { min-width: 150px; display: grid; gap: 3px; }
.host-name strong { color: var(--ink); }
.host-name small { max-width: 190px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.protocol-stack { min-width: 130px; display: grid; gap: 4px; }
.protocol-stack small { color: var(--muted); }
.protocol-pill { width: fit-content; min-height: 23px; padding: 3px 7px; border-radius: 4px; color: var(--blue); background: var(--blue-soft); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.transport-pair { display: inline-flex; align-items: center; gap: 5px; }
.transport-pair span { min-height: 23px; padding: 3px 7px; border-radius: 4px; color: var(--ink-soft); background: var(--surface-soft); border: 1px solid var(--line); font-size: 9px; text-transform: uppercase; }
.sni-stack { max-width: 210px; display: grid; gap: 3px; direction: ltr; text-align: right; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; }
.sni-stack span { overflow: hidden; text-overflow: ellipsis; }
.sni-stack small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.profiles-toolbar { min-height: 62px; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.profiles-toolbar h2 { margin: 0; font-size: 16px; }
.profiles-toolbar p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.profile-card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; box-shadow: 0 3px 10px rgba(23,33,39,.03); }
.profile-card-header { min-height: 68px; padding: 13px 15px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.profile-title { min-width: 0; display: flex; align-items: center; gap: 10px; }
.profile-title > span:first-child { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 6px; color: var(--blue); background: var(--blue-soft); }
.profile-title > span:last-child { min-width: 0; display: grid; gap: 2px; }
.profile-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.profile-title small { color: var(--muted); font-size: 9px; }
.profile-card-actions { display: flex; gap: 4px; }
.profile-card-actions .icon-button { width: 32px; height: 32px; }
.inbound-list { display: grid; }
.inbound-row { min-height: 54px; padding: 10px 15px; display: grid; grid-template-columns: minmax(120px, 1fr) auto auto; align-items: center; gap: 10px; border-top: 1px solid #edf0f1; }
.inbound-row:first-child { border-top: 0; }
.inbound-row > span:first-child { min-width: 0; display: grid; gap: 2px; }
.inbound-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 10px ui-monospace, SFMono-Regular, Menlo, monospace; }
.inbound-row small { color: var(--muted); font-size: 9px; }
.inbound-port { direction: ltr; color: var(--ink-soft); font: 700 10px ui-monospace, SFMono-Regular, Menlo, monospace; }
.profile-empty { min-height: 76px; display: grid; place-items: center; color: var(--muted); font-size: 11px; }

.dialog { width: min(92vw, 620px); max-height: 90vh; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: var(--surface); box-shadow: 0 22px 60px rgba(15,25,30,.25); }
.dialog::backdrop { background: rgba(17,27,32,.58); backdrop-filter: blur(3px); }
.dialog form, .dialog > div { display: contents; }
.dialog header { min-height: 76px; padding: 15px 18px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 11px; }
.dialog header > span:first-child { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 6px; color: var(--teal); background: var(--teal-soft); }
.dialog header .danger-icon { color: var(--coral) !important; background: var(--coral-soft) !important; }
.dialog header h2 { margin: 0; font-size: 15px; }
.dialog header p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.dialog-body { padding: 20px; overflow-y: auto; }
.dialog footer { min-height: 66px; padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.link-output { width: 100%; min-height: 140px; padding: 12px; border: 1px solid var(--line-strong); border-radius: 6px; resize: none; direction: ltr; text-align: left; font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.secret-notice { display: flex; align-items: flex-start; gap: 7px; color: var(--amber); background: var(--amber-soft); border-radius: 6px; padding: 10px; font-size: 10px; line-height: 1.7; }
.confirm-dialog { width: min(92vw, 440px); }
.confirm-dialog header { border-bottom: 0; }
.wide-dialog { width: min(96vw, 980px); }
.profile-dialog { width: min(96vw, 900px); }
.wide-dialog > form, .profile-dialog > form { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; width: 100%; height: min(90vh, 820px); }
.wide-dialog .dialog-body, .profile-dialog .dialog-body { min-height: 0; overflow-y: auto; }
.infra-form-body { padding: 0; }
.form-section { padding: 20px; border-bottom: 1px solid var(--line); }
.form-section-title { margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.form-section-title > span { width: 32px; height: 25px; display: grid; place-items: center; border-radius: 4px; color: var(--teal); background: var(--teal-soft); font-size: 10px; font-weight: 850; }
.form-section-title > div { display: grid; gap: 2px; }
.form-section-title strong { font-size: 12px; }
.form-section-title small { color: var(--muted); font-size: 9px; }
.advanced-section { border: 0; }
.advanced-section summary { min-height: 54px; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; color: var(--ink-soft); background: var(--surface-soft); list-style: none; }
.advanced-section summary::-webkit-details-marker { display: none; }
.advanced-section summary > span { display: flex; align-items: center; gap: 8px; }
.advanced-section summary svg { width: 16px; height: 16px; }
.advanced-section[open] summary > svg { transform: rotate(180deg); }
.advanced-content { padding: 20px; border-top: 1px solid var(--line); }
.check-list { min-height: 86px; max-height: 140px; padding: 8px; display: grid; align-content: start; gap: 5px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); overflow-y: auto; }
.check-list label { min-height: 30px; padding: 4px 6px; display: flex; align-items: center; gap: 8px; border-radius: 4px; color: var(--ink-soft); font-size: 10px; }
.check-list label:hover { background: var(--surface-soft); }
.check-list input, .toggle-grid input { accent-color: var(--teal); }
.check-list .empty-option { color: var(--muted); align-self: center; justify-self: center; }
.horizontal-check-list { min-height: 48px; grid-template-columns: repeat(6, minmax(0, 1fr)); overflow: visible; }
.toggle-grid { margin-top: 16px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.toggle-grid > label { min-height: 55px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; display: flex; align-items: flex-start; gap: 8px; background: var(--surface-soft); }
.toggle-grid > label span { min-width: 0; display: grid; gap: 2px; }
.toggle-grid b { font-size: 10px; }
.toggle-grid small { color: var(--muted); font-size: 8px; line-height: 1.45; }
.json-grid { margin-top: 16px; }
.code-wrap textarea, .config-editor { font: 11px/1.7 ui-monospace, SFMono-Regular, Menlo, Monaco, monospace; }
.save-safety { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; }
.save-safety svg { width: 14px; height: 14px; color: var(--teal); }
.profile-editor-body { padding: 18px; }
.profile-editor-toolbar { margin-bottom: 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; }
.editor-actions { display: flex; gap: 7px; }
.config-editor { width: 100%; min-height: 430px; padding: 14px; resize: vertical; border: 1px solid var(--line-strong); border-radius: 6px; outline: 0; color: #dce7eb; background: #172127; text-align: left; tab-size: 2; }
.config-editor:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,127,107,.12); }
.editor-hint { margin-top: 12px; padding: 10px; display: flex; align-items: flex-start; gap: 8px; border-radius: 6px; color: var(--amber); background: var(--amber-soft); font-size: 10px; line-height: 1.65; }
.editor-hint svg { flex: 0 0 auto; width: 16px; height: 16px; }
.toast-region { position: fixed; z-index: 100; left: 20px; bottom: 20px; display: grid; gap: 8px; pointer-events: none; }
.toast { width: min(360px, calc(100vw - 40px)); min-height: 50px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); box-shadow: var(--shadow); display: grid; grid-template-columns: 22px 1fr; align-items: center; gap: 8px; font-size: 12px; animation: toastIn .2s ease-out; }
.toast.success svg { color: var(--teal); }
.toast.error svg { color: var(--coral); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

.mobile-only, .mobile-nav { display: none; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-split { grid-template-columns: 1fr; }
  .account-summary { min-height: 230px; }
  .donut-area { grid-template-columns: 160px 1fr; }
  .create-layout { grid-template-columns: 1fr 270px; }
  .accounts-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-fields { justify-content: flex-end; }
}

@media (max-width: 860px) {
  :root { --sidebar-width: 250px; }
  .sidebar { transform: translateX(105%); transition: transform .22s ease-out; box-shadow: -16px 0 40px rgba(0,0,0,.2); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim { position: fixed; z-index: 35; inset: 0; background: rgba(17,27,32,.45); }
  .sidebar-scrim.open { display: block; }
  .main-content { margin-right: 0; padding-bottom: 68px; }
  .mobile-only { display: inline-grid; }
  .mobile-nav { position: fixed; z-index: 30; inset: auto 0 0; min-height: 64px; padding: 6px max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(6, 1fr); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(12px); }
  .mobile-nav button { min-width: 0; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; align-content: center; gap: 3px; font-size: 9px; }
  .mobile-nav button.active { color: var(--teal); }
  .mobile-nav .mobile-create { width: 54px; height: 54px; align-self: center; justify-self: center; margin-top: -22px; border-radius: 50%; background: var(--teal); color: white; box-shadow: 0 6px 16px rgba(8,127,107,.25); }
  .mobile-nav .mobile-create span { display: none; }
  .desktop-create, .last-update { display: none; }
  .service-list { grid-template-columns: 1fr; }
  .service-card { min-height: 150px; }
  .create-layout { grid-template-columns: 1fr; }
  .create-summary { position: static; }
  .system-grid { grid-template-columns: 1fr; }
  .infra-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-grid { grid-template-columns: 1fr; }
  .toggle-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .auth-brand { top: 20px; right: 20px; }
  .auth-panel { padding: 25px 20px; }
  .topbar { height: 66px; padding: 0 14px; }
  .topbar-title strong { font-size: 16px; }
  .page-stack { padding: 18px 12px 30px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric-card { min-height: 132px; padding: 13px; }
  .metric-card strong { font-size: 22px; }
  .metric-icon { width: 30px; height: 30px; }
  .network-surface { padding: 15px 12px 10px; }
  .chart-wrap { height: 190px; }
  .section-heading { margin-bottom: 14px; }
  .chart-legend { gap: 8px; }
  .donut-area { grid-template-columns: 126px 1fr; }
  .donut { width: 118px; height: 118px; }
  .accounts-toolbar { padding: 9px; overflow: hidden; }
  .segmented { width: 100%; overflow-x: auto; justify-content: flex-start; }
  .segmented button { flex: 0 0 auto; }
  .toolbar-fields { display: grid; grid-template-columns: 1fr 1fr auto; }
  .search-box { width: auto; grid-column: 1 / -1; }
  .accounts-table-surface { min-height: 0; }
  .accounts-table-surface .table-scroll { overflow: visible; }
  .accounts-table { min-width: 0; display: block; }
  .accounts-table thead { display: none; }
  .accounts-table tbody { display: grid; }
  .accounts-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 9px 7px; padding: 12px; border-top: 1px solid var(--line); }
  .accounts-table tbody tr:first-child { border-top: 0; }
  .accounts-table tbody td { min-width: 0; padding: 0; border: 0; background: transparent; }
  .accounts-table tbody td:nth-child(1) { grid-column: 1; }
  .accounts-table tbody td:nth-child(2) { grid-column: 2; }
  .accounts-table tbody td:nth-child(3) { grid-column: 3; }
  .accounts-table tbody td:nth-child(4) { display: none; }
  .accounts-table tbody td:nth-child(5) { grid-column: 1 / 3; }
  .accounts-table tbody td:nth-child(6) { display: none; }
  .accounts-table tbody td:nth-child(7) { grid-column: 3; color: var(--muted); font-size: 9px; text-align: left; direction: rtl; }
  .accounts-table tbody td:nth-child(7)::before { content: "الانتهاء"; display: block; margin-bottom: 2px; }
  .accounts-table tbody td:nth-child(8) { grid-column: 1 / -1; padding-top: 7px; border-top: 1px solid var(--line); }
  .accounts-table .account-cell { min-width: 0; }
  .accounts-table .account-cell strong, .accounts-table .account-cell small { max-width: 145px; }
  .accounts-table .usage-cell { min-width: 0; }
  .accounts-table .row-actions { justify-content: flex-start; }
  .accounts-table .row-actions .icon-button { flex: 1 1 0; max-width: 48px; }
  .provider-picker { grid-template-columns: 1fr; }
  .provider-option { min-height: 60px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .create-form { padding: 16px 13px; }
  .details-list { grid-template-columns: 1fr; }
  .details-list div:nth-child(odd), .details-list div:nth-child(even) { padding: 12px 0; border-right: 0; }
  .dialog .form-grid { grid-template-columns: 1fr; }
  .dialog-body { padding: 15px; }
  .infra-toolbar { align-items: stretch; flex-direction: column; }
  .infra-toolbar .segmented { width: 100%; overflow-x: auto; }
  .infra-toolbar-actions { display: grid; grid-template-columns: 40px 1fr 1fr; }
  .infra-toolbar-actions .button { min-width: 0; padding-inline: 8px; }
  .infra-metrics { gap: 8px; }
  .infra-metrics article { min-height: 78px; padding: 11px; }
  .infra-metrics strong { font-size: 20px; }
  .profiles-toolbar { align-items: flex-start; }
  .profiles-toolbar p { max-width: 220px; }
  .profile-editor-toolbar { grid-template-columns: 1fr; }
  .editor-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .config-editor { min-height: 360px; font-size: 10px; }
  .form-section, .advanced-content { padding: 15px; }
  .toggle-grid { grid-template-columns: 1fr; }
  .horizontal-check-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .save-safety { display: none; }
  .dialog footer { padding-inline: 12px; }
  .mobile-nav button { font-size: 8px; }
  .toast-region { left: 10px; bottom: 76px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
