:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-input: #0f3460;
    --text-primary: #e0e0e0;
    --text-secondary: #888;
    --accent: #e94560;
    --accent-hover: #ff6b81;
    --green: #2ecc71;
    --red: #e74c3c;
    --yellow: #f39c12;
    --border: #2a2a4a;
    --radius: 8px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #1a1a2e 100%);
}

.auth-container {
    background: var(--bg-card);
    padding: 40px;
    border-radius: var(--radius);
    width: 100%;
    max-width: 400px;
    text-align: center;
    border: 1px solid var(--border);
}

.auth-container h1 {
    color: var(--accent);
    margin-bottom: 8px;
    font-size: 1.5rem;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.9rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
}

.auth-form label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.auth-form input {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.auth-form input:focus {
    border-color: var(--accent);
}

.auth-form input[maxlength="6"] {
    text-align: center;
    font-size: 1.8rem;
    letter-spacing: 8px;
    font-family: var(--mono);
}

.auth-form button {
    padding: 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.auth-form button:hover { background: var(--accent-hover); }

.back-link {
    display: inline-block;
    margin-top: 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
}

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

.error { color: var(--red); margin-bottom: 12px; font-size: 0.9rem; }
.info { color: var(--green); margin-bottom: 12px; font-size: 0.9rem; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 32px;
}

.logo {
    font-size: 1.1rem;
    color: var(--accent);
    font-weight: 700;
}

nav { display: flex; gap: 4px; }

nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: all 0.2s;
}

nav a:hover { color: var(--text-primary); background: var(--bg-card); }
nav a.active { color: var(--text-primary); background: var(--bg-card); }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-email { color: var(--text-secondary); font-size: 0.85rem; }

.btn-logout {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 6px 12px;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    transition: all 0.2s;
}

.btn-logout:hover { background: var(--accent); color: #fff; }

main { padding: 24px; max-width: 1400px; margin: 0 auto; }

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

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

.card h2 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat { display: flex; flex-direction: column; gap: 6px; }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); text-transform: uppercase; }
.stat-value { font-size: 0.9rem; font-family: var(--mono); }

.stat-bar {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.5s ease;
    width: 0%;
}

.stat-fill.ok { background: var(--green); }
.stat-fill.warn { background: var(--yellow); }
.stat-fill.danger { background: var(--red); }

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

.sites-table th, .sites-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.sites-table th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.sites-table a { color: var(--accent); text-decoration: none; }
.sites-table a:hover { text-decoration: underline; }

.badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
}

.badge-up { background: rgba(46,204,113,0.15); color: var(--green); }
.badge-down { background: rgba(231,76,60,0.15); color: var(--red); }

.btn-small {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
}

.btn-small:hover { color: var(--text-primary); }

.logs-section h2, .audit-section h2 { margin-bottom: 16px; }

.logs-filter {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.logs-filter select, .logs-filter button {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.logs-filter button {
    background: var(--accent);
    border-color: var(--accent);
    cursor: pointer;
    font-weight: 600;
}

.logs-filter button:hover { background: var(--accent-hover); }

.log-output {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 0.8rem;
    line-height: 1.5;
    max-height: 600px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

@media (max-width: 768px) {
    .topbar { flex-direction: column; height: auto; padding: 12px; gap: 8px; }
    .topbar-left { flex-direction: column; gap: 8px; }
    nav { flex-wrap: wrap; }
    main { padding: 12px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .sites-table { font-size: 0.8rem; }
    .sites-table th:nth-child(4), .sites-table td:nth-child(4),
    .sites-table th:nth-child(5), .sites-table td:nth-child(5) { display: none; }
}
