:root {
    --bg: #0a0d12;
    --surface: #12161f;
    --card: #161b27;
    --card-hover: #1c2233;
    --line: #1f2737;
    --line-light: #2a3348;
    --text: #e8ebf0;
    --text-secondary: #a3adc0;
    --muted: #6b7a94;
    --accent: #5b9aff;
    --accent-dim: rgba(91, 154, 255, 0.12);
    --green: #34d399;
    --green-dim: rgba(52, 211, 153, 0.12);
    --red: #f87171;
    --red-dim: rgba(248, 113, 113, 0.1);
    --yellow: #fbbf24;
    --yellow-dim: rgba(251, 191, 36, 0.1);
    --purple: #a78bfa;
    --purple-dim: rgba(167, 139, 250, 0.12);
    --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
}

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

body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.6 var(--sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ─── Auth Pages ─── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(ellipse at 50% 0%, rgba(91,154,255,0.04) 0%, transparent 60%);
}

.auth-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow), 0 8px 32px rgba(0,0,0,0.3);
}

.auth-card-wide {
    max-width: 500px;
    text-align: center;
}

.auth-card h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.auth-sub {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 28px;
}

.field {
    margin-bottom: 18px;
}

.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.field input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: var(--sans);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s;
    font-family: var(--sans);
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: var(--accent);
    color: #fff;
    width: 100%;
    margin-top: 8px;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 18px;
    font-weight: 500;
}

.alert-error {
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.alert-warning {
    background: var(--yellow-dim);
    color: var(--yellow);
    border: 1px solid rgba(251, 191, 36, 0.2);
    margin-top: 24px;
}

.qr-container {
    margin: 24px auto;
    background: #fff;
    padding: 20px;
    border-radius: 16px;
    display: inline-block;
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}

.qr-container svg { display: block; width: 200px; height: 200px; }

.secret-display { margin-top: 20px; }
.secret-display p { font-size: 13px; color: var(--muted); margin-bottom: 8px; }

.secret-code {
    font-family: var(--mono);
    font-size: 18px;
    letter-spacing: 0.15em;
    color: var(--accent);
    font-weight: 600;
}

/* ─── Dashboard Layout ─── */
.dashboard {
    max-width: 1360px;
    margin: 0 auto;
    padding: 28px 32px;
}

.dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.dash-header h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.dash-header .meta {
    font-size: 12px;
    font-family: var(--mono);
    color: var(--muted);
    display: flex;
    gap: 20px;
    align-items: center;
}

.dash-header .meta span { display: flex; align-items: center; gap: 4px; }

.logout-btn {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    transition: all 0.2s;
    font-family: var(--sans);
}

.logout-btn:hover { color: var(--text); border-color: var(--text-secondary); background: var(--surface); }

/* ─── Health Banner ─── */
.health-banner {
    padding: 14px 20px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--line);
    background: var(--card);
    display: flex;
    align-items: center;
    gap: 10px;
}

.health-banner.ok { border-color: rgba(52, 211, 153, 0.3); background: rgba(52, 211, 153, 0.04); }
.health-banner.down { border-color: rgba(248, 113, 113, 0.4); background: var(--red-dim); }

.health-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.health-dot.green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.health-dot.red { background: var(--red); box-shadow: 0 0 6px var(--red); animation: pulse 2s infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ─── System Metrics ─── */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.metric-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    transition: border-color 0.2s;
}

.metric-card:hover { border-color: var(--line-light); }

.metric-card .label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 8px;
}

.metric-card .value {
    font-size: 26px;
    font-weight: 700;
    font-family: var(--mono);
    letter-spacing: -0.02em;
}

.metric-card .sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
    font-family: var(--mono);
}

.gauge-bar {
    height: 4px;
    background: var(--line);
    border-radius: 2px;
    margin-top: 12px;
    overflow: hidden;
}

.gauge-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.4s ease;
}

.gauge-fill.low { background: var(--green); }
.gauge-fill.mid { background: var(--yellow); }
.gauge-fill.high { background: var(--red); }

/* ─── Section Headers ─── */
.section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin: 32px 0 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

/* ─── Sites Grid ─── */
.sites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.site-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.site-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    transition: all 0.2s;
    height: 100%;
}

.site-card:hover {
    border-color: var(--accent);
    background: var(--card-hover);
    box-shadow: 0 0 0 1px var(--accent-dim), 0 4px 16px rgba(0,0,0,0.2);
}

.site-card .domain {
    font-family: var(--mono);
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.site-card .badges {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
}

.badge {
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-ssl { background: var(--green-dim); color: var(--green); }
.badge-php { background: var(--purple-dim); color: var(--purple); }
.badge-static { background: var(--yellow-dim); color: var(--yellow); }

.site-kpis {
    display: flex;
    gap: 28px;
    margin-bottom: 16px;
}

.site-kpi .num {
    font-size: 22px;
    font-weight: 700;
    font-family: var(--mono);
    letter-spacing: -0.02em;
}

.site-kpi .lbl {
    font-size: 11px;
    color: var(--muted);
    font-weight: 500;
}

.sparkline {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 44px;
    margin-bottom: 8px;
}

.spark-bar {
    flex: 1;
    background: var(--accent);
    border-radius: 2px 2px 0 0;
    min-height: 2px;
    transition: opacity 0.15s;
    opacity: 0.6;
}

.spark-bar:hover { opacity: 1; }

.spark-axis {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--muted);
    font-family: var(--mono);
    opacity: 0.7;
}

.site-details { margin-top: 14px; }

.site-details .detail-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin: 12px 0 6px;
}

.site-details table {
    width: 100%;
    border-collapse: collapse;
}

.site-details td {
    padding: 3px 0;
    font-size: 12px;
    color: var(--text-secondary);
}

.site-details td:last-child {
    text-align: right;
    font-family: var(--mono);
    color: var(--text);
    font-weight: 500;
}

/* ─── Databases ─── */
.db-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.db-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    transition: border-color 0.2s;
}

.db-card:hover { border-color: var(--line-light); }

.db-card .db-name {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text);
}

.db-card .db-size {
    font-size: 22px;
    font-weight: 700;
    font-family: var(--mono);
    letter-spacing: -0.02em;
}

.db-card .db-conns {
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
}

.db-summary {
    display: flex;
    gap: 32px;
    margin-bottom: 16px;
    padding: 14px 20px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 13px;
}

.db-summary .item { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); }
.db-summary .item .val { font-family: var(--mono); font-weight: 700; color: var(--text); }

/* ─── Site Detail Page ─── */
.back-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 6px;
    transition: color 0.2s;
}

.back-link:hover { color: var(--accent); }

.detail-chart-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.sparkline-large { height: 100px; }

.detail-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 28px;
}

.detail-panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
}

.detail-panel .section-title { margin-top: 0; border: none; padding-bottom: 8px; }

.detail-table {
    width: 100%;
    border-collapse: collapse;
}

.detail-table td {
    padding: 6px 0;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--line);
}

.detail-table tr:last-child td { border-bottom: none; }
.detail-table td.num { text-align: right; font-family: var(--mono); color: var(--text); font-weight: 600; }

.empty-state {
    color: var(--muted);
    font-size: 13px;
    padding: 16px 0;
    font-style: italic;
}

/* ─── Log Table ─── */
.log-filters { margin-bottom: 16px; }

.filter-input {
    width: 100%;
    max-width: 420px;
    padding: 10px 16px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: var(--sans);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.filter-input::placeholder { color: var(--muted); }

.log-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    max-height: 70vh;
    overflow-y: auto;
}

.log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.log-table th {
    background: var(--surface);
    padding: 12px 16px;
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 1px solid var(--line);
}

.log-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    color: var(--text-secondary);
    font-size: 12px;
}

.log-table tbody tr:hover td { background: var(--surface); }
.log-table tbody tr:last-child td { border-bottom: none; }

.log-table .mono { font-family: var(--mono); font-size: 11px; }
.log-table .nowrap { white-space: nowrap; }

.log-table .path-cell {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--mono);
    font-size: 11px;
}

.log-table .ua-cell {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: 11px;
}

.method-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    font-family: var(--mono);
    letter-spacing: 0.02em;
}

.method-get { background: var(--green-dim); color: var(--green); }
.method-post { background: var(--accent-dim); color: var(--accent); }
.method-put, .method-patch { background: var(--yellow-dim); color: var(--yellow); }
.method-delete { background: var(--red-dim); color: var(--red); }
.method-head { background: var(--purple-dim); color: var(--purple); }

.status-code {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-family: var(--mono);
    font-weight: 700;
}

.status-2xx { background: var(--green-dim); color: var(--green); }
.status-3xx { background: var(--accent-dim); color: var(--accent); }
.status-4xx { background: var(--yellow-dim); color: var(--yellow); }
.status-5xx { background: var(--red-dim); color: var(--red); }

tr.status-4xx td { opacity: 0.75; }
tr.status-5xx td { background: rgba(248, 113, 113, 0.03); }

/* ─── Footer ─── */
.dash-footer {
    text-align: center;
    padding: 24px 0;
    font-size: 11px;
    color: var(--muted);
    font-family: var(--mono);
    border-top: 1px solid var(--line);
    margin-top: 20px;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .dashboard { padding: 16px; }
    .dash-header { flex-direction: column; align-items: flex-start; }
    .metrics-row { grid-template-columns: 1fr 1fr; }
    .sites-grid { grid-template-columns: 1fr; }
    .db-grid { grid-template-columns: 1fr; }
    .detail-panels { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .metrics-row { grid-template-columns: 1fr; }
    .auth-card { padding: 32px 24px; }
}
