:root {
  --bg: #090d14;
  --surface: #111722;
  --surface-2: #171f2d;
  --surface-3: #202a3a;
  --line: #273245;
  --text: #edf3ff;
  --muted: #8491a6;
  --primary: #48a7ff;
  --primary-2: #6d5dfc;
  --green: #39d98a;
  --yellow: #f6c76e;
  --red: #ff6874;
  --shadow: 0 18px 48px rgba(0, 0, 0, .24);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(circle at 78% -10%, rgba(72,167,255,.09), transparent 28%), var(--bg); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 28px; padding: 24px 18px; border-right: 1px solid var(--line); background: rgba(12, 17, 26, .94); backdrop-filter: blur(18px); z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brand-mark { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: white; font-weight: 800; letter-spacing: -.04em; box-shadow: 0 10px 24px rgba(72, 167, 255, .23); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .01em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.sidebar nav { display: grid; gap: 6px; }
.nav-link { position: relative; padding: 11px 13px; border-radius: 10px; color: #aeb9ca; font-size: 14px; transition: .18s ease; }
.nav-link:hover { color: white; background: var(--surface-2); }
.nav-link.active { color: white; background: linear-gradient(90deg, rgba(72,167,255,.19), rgba(109,93,252,.08)); }
.nav-link.active::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 4px; background: var(--primary); box-shadow: 0 0 15px var(--primary); }
.sidebar-footer { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 14px 10px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.sidebar-footer form { margin-left: auto; }
.link-button { padding: 0; border: 0; color: var(--primary); background: transparent; }

.main { min-width: 0; padding: 30px 34px 56px; }
.topbar { display: flex; align-items: center; gap: 16px; margin-bottom: 26px; }
.topbar h1 { margin: 0; font-size: clamp(22px, 3vw, 30px); letter-spacing: -.025em; }
.topbar p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.topbar-meta { margin-left: auto; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid rgba(57,217,138,.2); border-radius: 999px; color: #a9eecb; background: rgba(57,217,138,.06); font-size: 12px; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(57,217,138,.08); }
.menu-button { display: none; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; color: white; background: var(--surface); }

.panel { margin-bottom: 20px; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(145deg, rgba(23,31,45,.88), rgba(15,21,31,.94)); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel h2 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.narrow { max-width: 520px; margin: 6vh auto 0; }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.three-column { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.forms-row > .panel { min-width: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { position: relative; overflow: hidden; min-height: 134px; padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: linear-gradient(145deg, var(--surface-2), var(--surface)); box-shadow: var(--shadow); }
.stat-card::after { content: ""; position: absolute; right: -20px; bottom: -42px; width: 110px; height: 110px; border-radius: 50%; background: rgba(72,167,255,.06); }
.stat-card span, .stat-card strong, .stat-card small { display: block; position: relative; z-index: 1; }
.stat-card span { color: var(--muted); font-size: 12px; }
.stat-card strong { margin: 14px 0 5px; font-size: 32px; letter-spacing: -.04em; }
.stat-card small { color: #9ba9bd; font-size: 11px; }
.stat-card.accent { border-color: rgba(72,167,255,.35); }
.stat-card.success { border-color: rgba(57,217,138,.27); }

.role-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.role-row:first-of-type { border-top: 0; }
.role-row div:nth-child(2) span, .role-row div:nth-child(2) strong { display: block; }
.role-row div:nth-child(2) strong { margin-top: 3px; font-size: 14px; }
.role-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; font-size: 13px; font-weight: 800; }
.role-icon.listener { color: #83c4ff; background: rgba(72,167,255,.1); }
.role-icon.sender { color: #a69bff; background: rgba(109,93,252,.13); }
.status-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.status-summary > div { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; color: #b9c3d3; font-size: 12px; }
.status-summary strong { color: white; }

.compact-list, .mini-list { display: grid; }
.compact-item, .mini-list > div { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.compact-item:first-child, .mini-list > div:first-child { border-top: 0; }
.compact-item strong, .mini-list strong { display: block; font-size: 13px; }
.compact-item p, .mini-list small { display: block; margin: 4px 0 0; color: var(--muted); font-size: 11px; }

.stack-form { display: grid; gap: 13px; }
.grid-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; gap: 13px; }
.grid-form .span-2 { grid-column: span 2; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { min-width: 0; flex: 1; }
.top-gap { margin-top: 10px; }
label { display: grid; gap: 7px; color: #aeb9ca; font-size: 11px; }
input, select, textarea { width: 100%; border: 1px solid #303d52; border-radius: 9px; outline: none; color: var(--text); background: #0d131d; transition: border-color .18s, box-shadow .18s; }
input, select { min-height: 39px; padding: 8px 10px; }
textarea { padding: 10px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: rgba(72,167,255,.74); box-shadow: 0 0 0 3px rgba(72,167,255,.09); }
select { color-scheme: dark; }
.check-row { display: flex; flex-wrap: wrap; gap: 14px; }
.check-row label { display: flex; align-items: center; gap: 7px; }
.check-row input { width: auto; min-height: 0; }
.file-drop { min-height: 112px; place-items: center; padding: 18px; border: 1px dashed #3b4b63; border-radius: 10px; background: rgba(7,11,17,.4); text-align: center; }
.file-drop input { padding: 5px; border: 0; background: transparent; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 8px 13px; border: 1px solid #34425a; border-radius: 9px; color: white; background: var(--surface-3); font-size: 12px; font-weight: 600; white-space: nowrap; transition: .16s ease; }
.button:hover { border-color: #4a5d78; transform: translateY(-1px); }
.button.primary { border-color: transparent; background: linear-gradient(135deg, #288fe8, #6252e8); box-shadow: 0 8px 20px rgba(49,119,232,.17); }
.button.ghost { color: #bdc8d8; background: rgba(255,255,255,.025); }
.button.danger { border-color: rgba(255,104,116,.25); color: #ff9ca4; background: rgba(255,104,116,.08); }
.button.small { min-height: 30px; padding: 5px 9px; font-size: 11px; }
.button.wide { width: 100%; }
.icon-button { display: inline-grid; place-items: center; width: 27px; height: 27px; padding: 0; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: transparent; }
.text-link { color: var(--primary); font-size: 12px; }

.badge { display: inline-flex; align-items: center; width: fit-content; padding: 4px 8px; border: 1px solid #334159; border-radius: 999px; color: #aeb9ca; background: rgba(255,255,255,.025); font-size: 10px; text-transform: uppercase; letter-spacing: .035em; }
.badge.active, .status-online, .status-sent { border-color: rgba(57,217,138,.24); color: #83e8b5; background: rgba(57,217,138,.08); }
.status-cooldown, .status-pending, .status-queued, .level-warning { border-color: rgba(246,199,110,.24); color: #f8d897; background: rgba(246,199,110,.08); }
.status-error, .status-auth_invalid, .status-banned, .status-frozen, .status-mutual_only, .status-blocked, .status-failed, .level-error { border-color: rgba(255,104,116,.25); color: #ff9ca4; background: rgba(255,104,116,.08); }
.status-unchecked, .status-disabled, .status-ignored, .status-cancelled { color: #929eb0; background: rgba(132,145,166,.08); }
.role-listener { color: #83c4ff; background: rgba(72,167,255,.09); }
.role-sender { color: #a69bff; background: rgba(109,93,252,.12); }
.level-info { color: #8ccaff; background: rgba(72,167,255,.08); }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #677387; }
.status-dot.online, .status-dot.status-online { background: var(--green); box-shadow: 0 0 9px rgba(57,217,138,.55); }
.status-dot.warn, .status-dot.status-cooldown { background: var(--yellow); }
.status-dot.status-error, .status-dot.status-auth_invalid, .status-dot.status-frozen, .status-dot.status-mutual_only { background: var(--red); }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 10px 12px; border-bottom: 1px solid var(--line); color: #6f7d91; font-size: 10px; font-weight: 600; text-align: left; text-transform: uppercase; letter-spacing: .06em; }
td { padding: 13px 12px; border-bottom: 1px solid rgba(39,50,69,.68); vertical-align: middle; color: #c2ccda; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255,255,255,.012); }
td strong, td small { display: block; }
td small { margin-top: 4px; max-width: 260px; color: var(--muted); font-size: 10px; }
.actions { min-width: 150px; }
.actions form { display: inline-flex; margin: 2px 3px 2px 0; vertical-align: middle; }
.account-actions { min-width: 310px; max-width: 380px; }
.account-table { min-width: 1180px; }
.select-column { width: 38px; padding-right: 4px; text-align: center; }
.row-select { width: 16px; min-height: 16px; margin: 0; accent-color: var(--primary); }
.panel-head-tools, .batch-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 7px; }
.mini-edit { display: flex; align-items: center; gap: 5px; }
.mini-edit input { min-width: 110px; min-height: 30px; padding: 4px 7px; }
code { padding: 3px 6px; border-radius: 5px; color: #a9d7ff; background: #0c121c; font-family: "SFMono-Regular", Consolas, monospace; font-size: 11px; }
.nowrap { white-space: nowrap; }
.log-detail { min-width: 280px; max-width: 680px; white-space: pre-wrap; word-break: break-word; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface); font-size: 11px; }
.chip.active { border-color: rgba(72,167,255,.4); color: white; background: rgba(72,167,255,.12); }
.lead-list { display: grid; gap: 12px; }
.lead-card { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: rgba(7,11,17,.35); }
.lead-meta, .lead-foot, .lead-actions { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.lead-meta strong, .lead-meta span { display: block; }
.lead-meta span, .lead-foot { margin-top: 3px; color: var(--muted); font-size: 10px; }
.lead-card blockquote { margin: 13px 0; padding: 11px 13px; border-left: 2px solid var(--primary); border-radius: 0 8px 8px 0; color: #d5deea; background: rgba(72,167,255,.045); font-size: 13px; line-height: 1.55; white-space: pre-wrap; }
.lead-actions { margin-top: 12px; }
.queue-form { display: grid; grid-template-columns: minmax(220px, 1fr) 180px auto; align-items: end; gap: 7px; flex: 1; }
.danger-text { color: #ff9ca4; }

.alert { margin-bottom: 18px; padding: 12px 14px; border: 1px solid rgba(72,167,255,.24); border-radius: 10px; color: #b9dcff; background: rgba(72,167,255,.08); font-size: 12px; line-height: 1.5; }
.alert.success { border-color: rgba(57,217,138,.22); color: #9cebc4; background: rgba(57,217,138,.07); }
.alert.warning { border-color: rgba(246,199,110,.22); color: #f8d897; background: rgba(246,199,110,.07); }
.alert.error { border-color: rgba(255,104,116,.23); color: #ffadb4; background: rgba(255,104,116,.08); }
.muted { color: var(--muted); }
.empty { padding: 28px 12px; color: #637086; font-size: 12px; text-align: center; }

.login-body { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 8%, rgba(72,167,255,.15), transparent 32%), var(--bg); }
.login-card { width: min(100%, 390px); padding: 34px; border: 1px solid var(--line); border-radius: 20px; background: rgba(17,23,34,.92); box-shadow: 0 28px 80px rgba(0,0,0,.4); }
.login-brand { display: flex; justify-content: center; }
.login-card .brand-mark { width: 52px; height: 52px; border-radius: 16px; }
.login-card h1 { margin: 10px 0 5px; font-size: 26px; text-align: center; }
.login-card > .muted { margin: 0 0 24px; text-align: center; font-size: 12px; }
.eyebrow { margin: 16px 0 0; color: var(--primary); font-size: 9px; text-align: center; letter-spacing: .18em; }

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .three-column { grid-template-columns: 1fr; }
  .grid-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -270px; width: 250px; transition: left .2s ease; }
  .sidebar.open { left: 0; box-shadow: 20px 0 50px rgba(0,0,0,.5); }
  .main { padding: 22px 16px 44px; }
  .menu-button { display: inline-block; }
  .topbar-meta { display: none; }
  .two-column, .stat-grid { grid-template-columns: 1fr; }
  .grid-form { grid-template-columns: 1fr; }
  .grid-form .span-2 { grid-column: auto; }
  .queue-form { grid-template-columns: 1fr; }
  .lead-actions { flex-direction: column; }
}
