:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d24;
    --bg-card: #21252d;
    --bg-hover: #2a2f3a;
    --border: #2e3440;
    --border-hover: #3b4252;
    --text: #eceff4;
    --text-muted: #8b92a0;
    --text-dim: #5c6370;
    --accent: #5e81ac;
    --accent-hover: #81a1c1;
    --success: #a3be8c;
    --success-bg: rgba(163, 190, 140, 0.12);
    --danger: #bf616a;
    --danger-bg: rgba(191, 97, 106, 0.12);
    --warning: #ebcb8b;
    --warning-bg: rgba(235, 203, 139, 0.12);
    --info: #88c0d0;
    --info-bg: rgba(136, 192, 208, 0.12);
    --font-sans: 'DM Sans', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius: 8px;
    --radius-lg: 12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.app { max-width: 1100px; margin: 0 auto; padding: 24px; }

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.logo { display: flex; align-items: center; gap: 12px; }

.logo-icon {
    font-size: 28px;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent), var(--info));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-text h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.logo-subtitle { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

.header-right { display: flex; align-items: center; gap: 12px; }

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--success);
}

.pulse {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(163, 190, 140, 0.4); }
    50% { opacity: 0.8; box-shadow: 0 0 0 6px rgba(163, 190, 140, 0); }
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-icon {
    padding: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.btn-icon:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-hover); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #d08770; }
.btn-small { padding: 6px 10px; font-size: 12px; }

.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: border-color 0.15s;
}

.stat-card:hover { border-color: var(--border-hover); }

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.stat-icon.blue { background: var(--info-bg); }
.stat-icon.green { background: var(--success-bg); }
.stat-icon.red { background: var(--danger-bg); }
.stat-icon.orange { background: var(--warning-bg); }

.stat-content { display: flex; flex-direction: column; }
.stat-value { font-family: var(--font-mono); font-size: 26px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.add-form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
}

.add-form .form-row { display: flex; gap: 12px; align-items: flex-end; }
.input-group { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.input-group .optional { color: var(--text-dim); font-weight: 400; }

.input-group input {
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 13px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(94, 129, 172, 0.15);
}

.input-group input::placeholder { color: var(--text-dim); }

.sites-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 { font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

.sites-count {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 4px 10px;
    border-radius: 20px;
}

.sites-list { min-height: 200px; }

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    gap: 12px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state p { font-size: 14px; }

.site-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
    gap: 12px;
}

.site-item:last-child { border-bottom: none; }
.site-item:hover { background: var(--bg-hover); }

.site-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.site-status.up { background: var(--success); box-shadow: 0 0 6px rgba(163, 190, 140, 0.5); }
.site-status.down { background: var(--danger); box-shadow: 0 0 6px rgba(191, 97, 106, 0.5); animation: blink-status 1s infinite; }
.site-status.warning { background: var(--warning); box-shadow: 0 0 6px rgba(235, 203, 139, 0.5); }
.site-status.unknown { background: var(--text-dim); }
.site-status.maintenance { background: var(--info); box-shadow: 0 0 6px rgba(136, 192, 208, 0.5); }

@keyframes blink-status { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.site-info { display: flex; align-items: center; flex: 1; min-width: 0; gap: 16px; }

.site-domain {
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 200px;
}

.site-domain a { color: inherit; text-decoration: none; white-space: nowrap; }
.site-domain a:hover { color: var(--accent); }

.site-badge {
    font-size: 9px;
    padding: 2px 5px;
    border-radius: 3px;
    font-weight: 600;
    text-transform: uppercase;
}

.site-badge.up { background: var(--success-bg); color: var(--success); }
.site-badge.down { background: var(--danger-bg); color: var(--danger); }
.site-badge.warning { background: var(--warning-bg); color: var(--warning); }
.site-badge.maintenance { background: var(--info-bg); color: var(--info); }

.site-meta { display: flex; gap: 12px; font-size: 11px; color: var(--text-muted); }
.site-meta span { display: flex; align-items: center; gap: 3px; white-space: nowrap; }

.site-actions { display: flex; gap: 6px; }
.site-actions .btn { opacity: 0.3; transition: opacity 0.15s; padding: 5px 8px; }
.site-item:hover .site-actions .btn { opacity: 1; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 90%;
    max-width: 400px;
    text-align: center;
}

.modal-icon { font-size: 40px; margin-bottom: 16px; }
.modal h3 { font-size: 18px; margin-bottom: 8px; }
.modal p { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: center; }

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1001;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    font-size: 13px;
    animation: slideIn 0.3s ease;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

.toast.hiding { animation: slideOut 0.3s ease forwards; }

.footer { text-align: center; padding: 20px; margin-top: 24px; color: var(--text-dim); font-size: 12px; }
.footer p { margin: 4px 0; }

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 380px;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.login-form input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(94, 129, 172, 0.15);
}

.btn-block {
    width: 100%;
    padding: 14px;
    font-size: 14px;
}

.login-error {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 20px;
    text-align: center;
}

@media (max-width: 800px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .add-form .form-row { flex-wrap: wrap; }
    .input-group { min-width: calc(50% - 6px); }
    .add-form .btn-primary { width: 100%; }
}

@media (max-width: 500px) {
    .app { padding: 16px; }
    .header { flex-direction: column; gap: 16px; text-align: center; }
    .stats-row { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px; }
    .input-group { min-width: 100%; }
    .site-item { flex-wrap: wrap; gap: 10px; }
    .site-actions { width: 100%; margin-left: 26px; }
    .site-actions .btn { opacity: 1; }
}