@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg: #0b0d12;
    --bg-elev: #141720;
    --bg-elev-2: #1b1f2a;
    --bg-hover: #222736;
    --border: #232733;
    --border-soft: #1c2029;
    --text: #eceef3;
    --text-dim: #9aa0b4;
    --text-faint: #636a80;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-subtle: rgba(99,102,241,0.14);
    --green: #22c55e;
    --green-subtle: rgba(34,197,94,0.14);
    --red: #ef4444;
    --red-subtle: rgba(239,68,68,0.14);
    --amber: #f59e0b;
    --amber-subtle: rgba(245,158,11,0.14);
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-pill: 9999px;
    --shadow: 0 1px 2px rgba(0,0,0,0.25);
    --shadow-lg: 0 24px 60px rgba(0,0,0,0.55);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-hover); text-decoration: none; }
a:hover { color: var(--accent); }

/* ─── Shell / layout ─────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--bg-elev);
    border-right: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    padding: 22px 0;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 22px 22px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border-soft);
}
.sidebar-header .logo { font-size: 24px; line-height: 1; }
.sidebar-header .app-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }

.nav { display: flex; flex-direction: column; gap: 3px; padding: 0 14px; flex: 1; }
.nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    border-radius: var(--r-sm);
    color: var(--text-dim);
    font-weight: 500;
    font-size: 14.5px;
    transition: background .12s ease, color .12s ease;
}
.nav a .nav-ico { font-size: 17px; width: 20px; text-align: center; }
.nav a:hover { background: var(--bg-hover); color: var(--text); }
.nav a.active { background: var(--accent-subtle); color: var(--accent-hover); }

.sidebar-footer { padding: 16px 22px 0; margin-top: 14px; border-top: 1px solid var(--border-soft); }
.sidebar-footer .who { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }
.sidebar-footer .who strong { color: var(--text); font-weight: 600; }

.main { flex: 1; padding: 34px 40px; max-width: 1320px; width: 100%; margin: 0 auto; }

/* ─── Mobile top bar ─────────────────────────────────── */
.mobile-bar { display: none; }

@media (max-width: 860px) {
    .shell { flex-direction: column; }
    .sidebar {
        position: static; width: 100%; height: auto;
        flex-direction: column; padding: 0;
        border-right: none; border-bottom: 1px solid var(--border-soft);
    }
    .sidebar-header { padding: 16px 20px; margin-bottom: 0; border-bottom: 1px solid var(--border-soft); }
    .nav {
        flex-direction: row; overflow-x: auto; gap: 4px; padding: 10px 14px;
        -webkit-overflow-scrolling: touch;
    }
    .nav a { white-space: nowrap; padding: 9px 12px; }
    .nav a span.label { display: none; }
    .nav a .nav-ico { font-size: 19px; }
    .sidebar-footer {
        display: flex; align-items: center; justify-content: space-between;
        gap: 12px; margin-top: 0; padding: 12px 20px;
        border-top: 1px solid var(--border-soft);
    }
    .sidebar-footer .who { margin-bottom: 0; }
    .sidebar-footer form { margin: 0 !important; }
    .sidebar-footer .btn { width: auto !important; }
    .main { padding: 22px 18px; }
}

/* ─── Page header ────────────────────────────────────── */
.page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; margin-bottom: 28px;
}
.page-head h1 { font-size: 26px; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
.page-head .sub { color: var(--text-dim); font-size: 14px; margin: 4px 0 0; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ─── Stat cards ─────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 30px; }
.stat {
    background: var(--bg-elev);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    padding: 22px 24px;
}
.stat .stat-top { display: flex; align-items: center; gap: 9px; color: var(--text-dim); font-size: 13px; font-weight: 500; }
.stat .stat-top .ico { font-size: 16px; }
.stat .stat-value { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; margin-top: 10px; line-height: 1; }
.stat .stat-value small { font-size: 16px; font-weight: 600; color: var(--text-dim); }

/* ─── Cards ──────────────────────────────────────────── */
.card {
    background: var(--bg-elev);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    padding: 24px;
    margin-bottom: 22px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.card-head h2 { font-size: 17px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.card-head .count { color: var(--text-faint); font-size: 13px; font-weight: 500; }
.card h2, .card h3 { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
@media (max-width: 1040px) { .grid-2 { grid-template-columns: 1fr; } }

/* ─── Tables ─────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { text-align: left; padding: 13px 14px; }
table.tbl th {
    color: var(--text-faint); font-weight: 600; text-transform: uppercase;
    font-size: 11px; letter-spacing: 0.05em; border-bottom: 1px solid var(--border);
}
table.tbl td { border-bottom: 1px solid var(--border-soft); }
table.tbl tbody tr:last-child td, table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr { transition: background .1s ease; }
table.tbl tbody tr:hover td { background: var(--bg-elev-2); }
table.tbl code, .mono { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }
.cell-dim { color: var(--text-dim); }
.cell-faint { color: var(--text-faint); font-size: 13px; }

/* ─── Status dots ────────────────────────────────────── */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot-online { background: var(--green); box-shadow: 0 0 0 3px var(--green-subtle); }
.dot-offline { background: var(--text-faint); }
.status-pill { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }
.status-pill.on { color: var(--green); }
.status-pill.off { color: var(--text-faint); }

/* ─── Badges ─────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 11px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; }
.badge-green { background: var(--green-subtle); color: var(--green); }
.badge-red { background: var(--red-subtle); color: var(--red); }
.badge-amber { background: var(--amber-subtle); color: var(--amber); }
.badge-accent { background: var(--accent-subtle); color: var(--accent-hover); }
.badge-gray { background: var(--bg-hover); color: var(--text-dim); }

/* ─── Buttons ────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--bg-elev-2); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--r-sm);
    padding: 9px 16px; font-size: 14px; font-weight: 500;
    cursor: pointer; font-family: inherit; transition: background .12s ease, border-color .12s ease;
    white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-danger { background: transparent; border-color: transparent; color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
.inline-form { display: inline; }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* ─── Forms ──────────────────────────────────────────── */
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 7px; font-weight: 500; }
.field .hint { font-size: 12.5px; color: var(--text-faint); margin: 6px 0 0; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
input[type="text"], input[type="password"], input[type="email"], input[type="url"],
input[type="date"], input[type="search"], select, textarea {
    width: 100%; background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--r-sm); color: var(--text);
    padding: 11px 13px; font-size: 14px; font-family: inherit;
    transition: border-color .12s ease, box-shadow .12s ease;
}
input::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle);
}
.check { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text); cursor: pointer; }
.check input { width: auto; }

/* ─── Toggle switch ──────────────────────────────────── */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--bg-hover); border-radius: var(--r-pill); transition: .2s; }
.switch .slider:before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(18px); }

/* ─── Alerts ─────────────────────────────────────────── */
.alert { border-radius: var(--r-sm); padding: 13px 16px; font-size: 14px; margin-bottom: 20px; }
.alert-ok { background: var(--green-subtle); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.alert-err { background: var(--red-subtle); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.alert-warn { background: var(--amber-subtle); color: var(--amber); border: 1px solid rgba(245,158,11,0.3); }

/* ─── Activity feed ──────────────────────────────────── */
.feed { display: flex; flex-direction: column; }
.feed-item {
    display: flex; align-items: center; gap: 13px;
    padding: 12px 2px; border-bottom: 1px solid var(--border-soft);
}
.feed-item:last-child { border-bottom: none; }
.feed-ico {
    width: 34px; height: 34px; flex-shrink: 0; border-radius: var(--r-sm);
    display: flex; align-items: center; justify-content: center; font-size: 15px;
    background: var(--bg-elev-2);
}
.feed-body { flex: 1; min-width: 0; }
.feed-title { font-size: 14px; font-weight: 500; }
.feed-title b { font-weight: 600; }
.feed-meta { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-time { font-size: 12.5px; color: var(--text-faint); flex-shrink: 0; white-space: nowrap; }
@keyframes flash { from { background: var(--accent-subtle); } to { background: transparent; } }
.feed-flash { animation: flash 1.4s ease; }

/* ─── Site cards ─────────────────────────────────────── */
.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.site-card {
    display: block; background: var(--bg-elev); border: 1px solid var(--border-soft);
    border-radius: var(--r-md); padding: 20px; color: var(--text);
    transition: border-color .12s ease, transform .12s ease;
}
.site-card:hover { border-color: var(--accent); color: var(--text); transform: translateY(-2px); }
.site-card .sc-top { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.site-card .sc-url { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-card .sc-stats { display: flex; gap: 22px; }
.site-card .sc-stat .n { font-size: 20px; font-weight: 700; }
.site-card .sc-stat .l { font-size: 12px; color: var(--text-faint); }

.empty { text-align: center; padding: 60px 20px; color: var(--text-faint); }
.empty .big { font-size: 40px; margin-bottom: 12px; }

/* ─── Filters ────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters .field { margin-bottom: 0; min-width: 150px; flex: 1; }

/* ─── Uptime strip ───────────────────────────────────── */
.uptime { display: flex; gap: 3px; height: 38px; align-items: flex-end; }
.uptime .bar { flex: 1; border-radius: 2px; min-height: 5px; }
.uptime .up { background: var(--green); }
.uptime .down { background: var(--red); }
.uptime .none { background: var(--bg-hover); }

/* ─── Pagination ─────────────────────────────────────── */
.pager { display: flex; gap: 8px; align-items: center; margin-top: 20px; }
.pager .info { color: var(--text-faint); font-size: 13px; margin-right: auto; }

/* ─── Login ──────────────────────────────────────────── */
.login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 40px; width: 100%; max-width: 400px; box-shadow: var(--shadow-lg); }
.login-logo { text-align: center; margin-bottom: 30px; }
.login-logo .logo { font-size: 42px; }
.login-logo h1 { font-size: 22px; margin: 10px 0 2px; font-weight: 700; }
.login-logo p { color: var(--text-dim); font-size: 13px; margin: 0; }

/* ─── Modal ──────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(5,7,12,.7); backdrop-filter: blur(6px); z-index: 999; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 28px; width: 100%; max-width: 440px; box-shadow: var(--shadow-lg); }
.modal h2 { margin: 0 0 20px; font-size: 19px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ─── Password strength ──────────────────────────────── */
.pw-meter { height: 5px; border-radius: 3px; background: var(--bg-hover); margin-top: 8px; overflow: hidden; }
.pw-meter-fill { height: 100%; width: 0%; background: var(--red); transition: width .2s ease, background .2s ease; }
.pw-meter-fill.scd-pw-weak { background: var(--red); }
.pw-meter-fill.scd-pw-medium { background: var(--amber); }
.pw-meter-fill.scd-pw-strong { background: var(--green); }

/* back link */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: 14px; margin-bottom: 18px; }
.back-link:hover { color: var(--text); }

.stat-mini-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px,1fr)); gap: 12px; }
.stat-mini { background: var(--bg-elev-2); border-radius: var(--r-sm); padding: 14px 16px; }
.stat-mini .n { font-size: 22px; font-weight: 700; }
.stat-mini .l { font-size: 12px; color: var(--text-faint); margin-top: 2px; text-transform: capitalize; }

/* ─── Login screen ───────────────────────────────────── */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 36px 32px;
    box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo { font-size: 40px; line-height: 1; }
.login-logo h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 12px 0 4px; }
.login-logo p { color: var(--text-dim); font-size: 14px; margin: 0; }
