:root {
    --bg:      #f1f5f9;
    --surface: #ffffff;
    --border:  #e2e8f0;
    --text:    #0f172a;
    --muted:   #94a3b8;
    --primary: #6366f1;
    --primary-h:#4f46e5;
    --success: #10b981;
    --danger:  #ef4444;
    --danger-h:#dc2626;
    --warning: #f59e0b;
    --radius:  12px;
    --shadow:  0 2px 8px rgba(0,0,0,.07), 0 0 0 1px rgba(0,0,0,.04);
    --shadow-lg:0 8px 32px rgba(0,0,0,.12);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Inter, 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
button, input, select { font: inherit; }
code { font-family: 'Cascadia Code','Fira Code',monospace; font-size: 12px; background: #f1f5f9; padding: 2px 6px; border-radius: 4px; }

/* ── Topnav ──────────────────────────────────────────────── */
.topnav { position: sticky; top: 0; z-index: 100; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 20px; padding: 0 24px; height: 56px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.nav-brand { font-weight: 800; font-size: 15px; color: var(--primary); white-space: nowrap; }
.nav-tabs  { display: flex; gap: 2px; flex: 1; }
.tab-btn   { background: none; border: none; padding: 6px 14px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; transition: all .15s; }
.tab-btn:hover  { background: #f1f5f9; color: var(--text); }
.tab-btn.active { background: #eef2ff; color: var(--primary); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ── Layout ──────────────────────────────────────────────── */
.wrap { max-width: 1280px; margin: 0 auto; padding: 24px 20px 48px; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Stats bar ───────────────────────────────────────────── */
.stats-bar { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow); }
.stat-card b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; font-weight: 700; }
.stat-card span { font-size: 28px; font-weight: 800; }

/* ── Section header ──────────────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.section-header h2 { font-size: 17px; font-weight: 800; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: none; border-radius: 8px; padding: 8px 14px; font-weight: 600; font-size: 13px; cursor: pointer; transition: all .15s; white-space: nowrap; color: #fff; background: var(--primary); }
.btn:hover:not(:disabled) { background: var(--primary-h); }
.btn.ghost  { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover:not(:disabled) { background: #f8fafc; }
.btn.danger { background: var(--danger); }
.btn.danger:hover:not(:disabled) { background: var(--danger-h); }
.btn.sm     { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-icon { background: none; border: none; width: 30px; height: 30px; border-radius: 6px; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; color: var(--muted); transition: all .15s; }
.btn-icon:hover { background: var(--bg); color: var(--text); }

/* ── Bot cards grid ──────────────────────────────────────── */
.bot-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(280px,1fr)); gap: 16px; }
.bot-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: visible; transition: box-shadow .2s, transform .1s; display: flex; flex-direction: column; cursor: pointer; }
.bot-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.card-header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--muted); transition: all .3s; }
.status-dot.up      { background: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.status-dot.down    { background: var(--danger); }
.status-dot.loading { background: var(--warning); animation: blink 1.2s infinite; }
.status-dot.disabled{ background: var(--muted); }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }
.card-info { flex: 1; min-width: 0; }
.card-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-url  { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-menu { position: relative; }
.dropdown { position: absolute; right: 0; top: 36px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); z-index: 200; min-width: 140px; padding: 4px; display: none; }
.dropdown.open { display: block; }
.dd-item { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text); text-align: left; transition: background .1s; }
.dd-item:hover { background: var(--bg); }
.dd-item.danger { color: var(--danger); }
.card-body { padding: 12px 16px; flex: 1; }
.card-badge-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.card-badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.card-badge.up   { background: #d1fae5; color: #065f46; }
.card-badge.down { background: #fee2e2; color: #991b1b; }
.card-badge.loading { background: #fef3c7; color: #92400e; }
.card-badge.disabled{ background: #f1f5f9; color: var(--muted); }
.card-meta { font-size: 12px; color: var(--muted); }
.card-bars { margin-top: 10px; display: flex; flex-direction: column; gap: 5px; }
.bar-row { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.bar-label { width: 32px; flex-shrink: 0; }
.bar-track { flex: 1; height: 4px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.bar-fill  { height: 4px; border-radius: 99px; background: var(--primary); transition: width .4s; }
.bar-fill.warn   { background: var(--warning); }
.bar-fill.danger { background: var(--danger); }
.bar-val { width: 36px; text-align: right; }
.card-ts { font-size: 11px; color: var(--muted); margin-top: 8px; }
.card-footer { display: flex; gap: 6px; padding: 10px 16px; border-top: 1px solid var(--border); background: #fafafa; border-radius: 0 0 var(--radius) var(--radius); }
.card-footer .btn { flex: 1; }

/* ── Form inputs ─────────────────────────────────────────── */
.form-grid { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.input { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-size: 14px; background: var(--surface); color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }

/* ── Panel (users / numbers) ─────────────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.panel-head h3 { font-size: 15px; font-weight: 700; }
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filter-row .input { max-width: 220px; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { border-radius: 8px; border: 1px solid var(--border); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { background: #f8fafc; padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--border); }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 13px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }
.td-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.user-numbers-row td { background: #fafafa; }
.numbers-inline { padding: 6px 0; }
.numbers-inline table { font-size: 12px; }

/* ── Badges ──────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.ok   { background: #d1fae5; color: #065f46; }
.badge.err  { background: #fee2e2; color: #991b1b; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.info { background: #e0e7ff; color: #3730a3; }
.badge.neutral { background: #f1f5f9; color: var(--muted); }

/* ── Modals ──────────────────────────────────────────────── */
dialog { border: none; border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 0; width: min(500px,95vw); max-height: 90vh; overflow: hidden; background: var(--surface); margin: auto; }
dialog::backdrop { background: rgba(15,23,42,.5); }
dialog.wide { width: min(760px,95vw); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dialog-header h3 { font-size: 15px; font-weight: 700; }
.dialog-body { padding: 20px; overflow-y: auto; max-height: calc(90vh - 120px); }
.dialog-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: #fafafa; }

/* ── Result inside modal ─────────────────────────────────── */
.result-block { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.result-block-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: #f8fafc; border-bottom: 1px solid var(--border); }
.result-block-title { font-weight: 700; font-size: 13px; }
.result-block-body { padding: 14px; }
.info-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; }
.info-grid.cols-4 { grid-template-columns: repeat(4,1fr); }
.info-item { background: #f8fafc; border-radius: 6px; padding: 8px 10px; }
.info-item b { display: block; font-size: 10px; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; letter-spacing: .04em; font-weight: 700; }
.info-item span { font-size: 13px; font-weight: 600; }
.section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; margin: 14px 0 8px; }
pre { background: #0f172a; color: #e2e8f0; border-radius: 8px; padding: 12px; font-size: 12px; overflow: auto; max-height: 220px; line-height: 1.6; }
.json-toggle-btn { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; color: var(--muted); margin-top: 10px; display: block; }

/* ── Toast ───────────────────────────────────────────────── */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: #0f172a; color: #f8fafc; padding: 11px 16px; border-radius: 10px; font-size: 13px; font-weight: 600; pointer-events: all; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(12px); transition: opacity .2s,transform .2s; max-width: 320px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok  { background: #065f46; }
.toast.err { background: #991b1b; }

/* ── Login ───────────────────────────────────────────────── */
.login-shell { min-height: 100vh; display: grid; place-items: center; background: var(--bg); }
.login-card  { width: min(420px,95vw); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow-lg); }
.login-card h1 { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.login-card p  { color: var(--muted); margin-bottom: 24px; }
.login-row { display: flex; gap: 10px; margin-top: 14px; }
.notice { padding: 10px 14px; border-radius: 8px; font-size: 13px; background: #fef3c7; color: #92400e; margin-bottom: 16px; }
.notice.err { background: #fee2e2; color: #991b1b; }
.js-hidden { display: none !important; }
.empty-state { text-align: center; padding: 40px 24px; color: var(--muted); }

/* ── VPS: terminal ───────────────────────────────────────── */
.term-output {
    background: #0b1120; color: #d1fae5; font-family: 'Cascadia Code','Fira Code',monospace;
    font-size: 13px; line-height: 1.5; padding: 14px; height: 420px; overflow-y: auto;
    white-space: pre-wrap; word-break: break-all; border-bottom: 1px solid var(--border);
}
#vps-term-input { font-family: 'Cascadia Code','Fira Code',monospace; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .topnav { padding: 0 14px; gap: 10px; }
    .wrap   { padding: 16px 14px 40px; }
    .stats-bar { grid-template-columns: repeat(2,1fr); }
    .info-grid.cols-4 { grid-template-columns: repeat(2,1fr); }
    .section-header { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
    .stats-bar { grid-template-columns: repeat(2,1fr); }
    .nav-tabs .tab-btn { padding: 6px 8px; }
}
