:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-2: #f0f3f7;
    --border: #d9e0e8;
    --text: #17212b;
    --muted: #687786;
    --primary: #2867c7;
    --primary-dark: #1e4f9d;
    --success: #177245;
    --warning: #9b6100;
    --danger: #c53645;
    --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.link { color: var(--primary); font-size: 14px; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.note { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-top: 18px; }

/* ---------- Alerts ---------- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    font-size: 14px;
}
.alert-error   { background: #fff0f1; border: 1px solid #e7aab0; color: #8f2430; }
.alert-success { background: #edf8f1; border: 1px solid #a8d5b8; color: #155c38; }
.alert-warn    { background: #fff8e8; border: 1px solid #e8c77b; color: #765000; }
.setup-url { margin-top: 10px; padding: 10px; border-radius: 6px; background: #17202e; font-size: 12px; word-break: break-all; }

/* ---------- Login ---------- */
body.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-wrap { width: 100%; max-width: 420px; }
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 34px 30px;
    box-shadow: 0 8px 24px rgba(30, 45, 60, .08);
}
.login-logo { text-align: center; margin-bottom: 24px; }
.logo-mark, .logo-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 48px; height: 48px; border-radius: 12px;
    background: var(--primary);
    color: #fff; font-weight: 700; font-size: 22px; margin-bottom: 10px;
}
.login-logo h1 { font-size: 20px; font-weight: 600; }
.login-logo p { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---------- Forms ---------- */
.panel-form label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.panel-form input, .f-control {
    width: 100%; padding: 11px 13px; margin-top: 6px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); font-size: 14px;
}
.panel-form input:focus, .f-control:focus { outline: none; border-color: var(--primary); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 11px 18px; border: none; border-radius: 8px;
    font-size: 14px; font-weight: 600; cursor: pointer; color: #fff;
    background: var(--surface-2);
    transition: filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger  { background: var(--danger); }
.btn-delete  { background: transparent; border: 1px solid rgba(240,85,107,.65); color: #ff9eaa; }
.btn-quiet { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-success { background: var(--success); color: #06281a; }
.btn-warn    { background: var(--warning); color: #3a2a0a; }
.btn-block   { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

/* ---------- Topbar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner {
    max-width: 1100px; margin: 0 auto; padding: 14px 20px;
    display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo-badge { width: 34px; height: 34px; font-size: 16px; margin: 0; }
.brand-name { font-weight: 700; font-size: 16px; }
.topbar nav { display: flex; gap: 8px; }
.nav-link {
    padding: 8px 14px; border-radius: 8px; color: var(--muted); font-size: 14px;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: rgba(91,140,255,.14); color: var(--primary); font-weight: 600; }
.nav-danger:hover { background: rgba(240,85,107,.12); color: var(--danger); }

/* ---------- Container ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 28px 20px 60px; }
.section-head {
    display: flex; align-items: center; justify-content: space-between;
    margin: 8px 0 18px;
}
.section-head h2 { font-size: 20px; font-weight: 600; }
.page-intro { display: flex; align-items: flex-end; justify-content: space-between; margin: 12px 0 28px; }
.page-intro h1 { font-size: 30px; line-height: 1.15; font-weight: 600; }
.page-intro p { color: var(--muted); margin-top: 10px; }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 30px; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px 20px; text-align: left;
}
.stat-value { font-size: 32px; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat-active .stat-value   { color: var(--success); }
.stat-disabled .stat-value { color: var(--warning); }
.stat-banned .stat-value   { color: var(--danger); }
.stat-expired .stat-value  { color: var(--warning); }
.stat-offline .stat-value  { color: var(--muted); }

/* ---------- Cards ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px; margin-bottom: 22px;
}
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.card p { color: var(--muted); font-size: 13px; }
.card-title { margin-bottom: 14px; }
.card-heading, .table-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.count-badge { border: 1px solid var(--border); color: var(--muted); padding: 6px 9px; border-radius: 99px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.onboarding-card { border-color: var(--border); }
.form-help { margin-top: 12px; font-size: 12px; }
.connection-panel { background: #f0f6ff; border: 1px solid #bfd3ee; border-radius: var(--radius); padding: 22px; margin-bottom: 22px; }
.connection-panel h2 { font-size: 22px; margin-bottom: 5px; }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.profile-grid label { color: var(--muted); font-size: 11px; font-weight: 700; }
.profile-grid input { display: block; width: 100%; margin-top: 6px; padding: 10px; color: var(--text); background: #fff; border: 1px solid var(--border); border-radius: 6px; font: 12px ui-monospace, monospace; }
.config-snippet { margin-top: 14px; padding: 14px; overflow-x: auto; color: #26384a; background: #fff; border: 1px solid var(--border); border-radius: 6px; font: 12px/1.6 ui-monospace, monospace; }
.connection-panel > .btn { margin-top: 10px; }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.profile-warning { color: #765000; margin-top: 10px; }

/* ---------- Tables ---------- */
.table-card { padding: 0; overflow-x: auto; }
.table-card .card-title { padding: 16px 18px 0; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 10px; }
.data-table th, .data-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.data-table tbody tr { transition: background .15s; }
.data-table tbody tr:hover { background: rgba(255,255,255,.025); }
.data-table tbody tr:focus-within { background: rgba(91,140,255,.08); }
.data-table tr:last-child td { border-bottom: none; }
.empty { text-align: center; color: var(--muted); padding: 30px !important; }

/* ---------- Status pills ---------- */
.status-pill {
    display: inline-block; padding: 3px 10px; border-radius: 20px;
    font-size: 12px; font-weight: 600;
}
.status-active   { background: rgba(52,199,123,.15); color: var(--success); }
.status-disabled { background: rgba(240,164,76,.15);  color: var(--warning); }
.status-banned   { background: rgba(240,85,107,.15);  color: var(--danger); }
.status-expired  { background: rgba(240,164,76,.22);  color: var(--warning); }
.status-offline  { background: rgba(139,146,163,.15); color: var(--muted); }
.web-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.web-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.web-active { color: var(--success); }
.web-down { color: var(--danger); }
.web-unknown { color: var(--muted); }
.web-code { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }

/* ---------- Badge ---------- */
.badge {
    display: inline-block; min-width: 22px; text-align: center;
    background: var(--warning); color: #3a2a0a; border-radius: 10px;
    font-size: 12px; font-weight: 700; padding: 2px 7px;
}

/* ---------- Inline forms / actions ---------- */
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form .f-control { width: auto; flex: 1; min-width: 150px; }
.inline-form.actions { display: flex; gap: 6px; }
.actions { flex-wrap: nowrap; }
.actions-cell { white-space: nowrap; min-width: 290px; }
.inline-form.actions .btn-sm { margin: 0; }
.small-select { padding: 6px 8px; font-size: 13px; width: auto; min-width: 90px; }
.license-form { margin-bottom: 6px; }

@media (max-width: 720px) {
    .topbar-inner { flex-direction: column; gap: 10px; }
    .actions-cell { white-space: normal; }
    .actions { flex-wrap: wrap; }
    .card { padding: 14px; }
    .data-table th, .data-table td { padding: 10px 12px; }
    .page-intro { align-items: flex-start; gap: 18px; }
    .profile-grid { grid-template-columns: 1fr; }
}
