:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --navy: #0f172a;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --accent: #10b981;
    --accent-hover: #059669;
    --accent-soft: #ecfdf5;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --warning: #d97706;
    --warning-soft: #fffbeb;
    --info: #2563eb;
    --info-soft: #eff6ff;
    --shadow: 0 4px 20px rgba(15, 23, 42, 0.05);
    --radius: 12px;
}

*, *::before, *::after { box-sizing: border-box; }

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

a { color: inherit; text-decoration: none; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

.text-navy { color: var(--navy); }
.text-muted { color: var(--muted); }
.text-green { color: var(--accent-hover); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.link-accent { color: var(--accent-hover); font-weight: 500; }
.link-accent:hover { text-decoration: underline; }
.inline-form { display: inline-flex; align-items: center; gap: 8px; }
.truncate-url { display: block; max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 9px 16px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    background: transparent;
}
.btn-lg { padding: 11px 22px; font-size: 0.95rem; }
.btn-sm { padding: 7px 12px; font-size: 0.8125rem; }
.btn-xs { padding: 4px 10px; font-size: 0.75rem; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #ffffff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--navy); }
.btn-outline:hover { background: #f1f5f9; }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover { background: #f1f5f9; color: var(--navy); }
.btn-danger { background: var(--danger); color: #ffffff; }
.btn-danger:hover { background: #b91c1c; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Cards & Badges */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.card-header h2 { margin: 0; font-size: 1.05rem; color: var(--navy); }

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}
.status-up { background: var(--accent-soft); color: var(--accent-hover); }
.status-down, .status-error { background: var(--danger-soft); color: var(--danger); }
.status-timeout, .status-warning { background: var(--warning-soft); color: var(--warning); }
.status-paused, .status-unknown { background: #f1f5f9; color: var(--muted); }
.status-info { background: var(--info-soft); color: var(--info); }

/* Alerts */
.flash-stack { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.875rem;
    border: 1px solid transparent;
}
.alert-success { background: var(--accent-soft); border-color: #a7f3d0; color: #065f46; }
.alert-error { background: var(--danger-soft); border-color: #fecaca; color: #991b1b; }
.alert-warning { background: var(--warning-soft); border-color: #fde68a; color: #92400e; }
.alert-info { background: var(--info-soft); border-color: #bfdbfe; color: #1e40af; }
.alert-close { background: transparent; border: none; color: inherit; cursor: pointer; padding: 2px; display: flex; }

/* Public Layout */
.public-body { background: #ffffff; }
.public-nav { border-bottom: 1px solid var(--border); background: #ffffff; position: sticky; top: 0; z-index: 20; }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand-link { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--navy); font-size: 1rem; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 9px;
    background: var(--accent); color: #ffffff;
    display: inline-flex; align-items: center; justify-content: center;
}
.public-links { display: flex; align-items: center; gap: 20px; font-size: 0.9rem; font-weight: 500; }
.public-main { min-height: calc(100vh - 145px); }
.public-footer { border-top: 1px solid var(--border); padding: 24px 0; color: var(--muted); font-size: 0.85rem; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.footer-links { display: flex; gap: 18px; }

.hero-section { padding: 68px 0 54px; background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%); border-bottom: 1px solid var(--border); }
.hero-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 36px; align-items: center; }
.eyebrow { display: inline-block; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-hover); margin-bottom: 12px; }
.hero-title { font-size: 2.55rem; line-height: 1.14; color: var(--navy); margin: 0 0 16px; letter-spacing: -0.02em; }
.hero-subtitle { color: var(--muted); font-size: 1.05rem; margin: 0 0 26px; max-width: 560px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-card { background: #ffffff; border: 1px solid var(--border); border-radius: 14px; padding: 24px; box-shadow: var(--shadow); }
.hero-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.feature-checklist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; font-size: 0.9rem; color: var(--text); }
.feature-checklist li::before { content: "✓ "; color: var(--accent-hover); font-weight: 700; }

.section-padded { padding: 60px 0; }
.section-head { text-align: center; margin-bottom: 34px; }
.section-head h1, .section-head h2 { margin: 0 0 8px; color: var(--navy); }
.pricing-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.pricing-card { display: flex; flex-direction: column; }
.pricing-featured { border-color: var(--accent); box-shadow: 0 10px 30px rgba(16, 185, 129, 0.12); }
.pricing-name { font-size: 1.1rem; font-weight: 700; color: var(--navy); }
.pricing-price { margin: 10px 0 4px; }
.price-val { font-size: 1.9rem; font-weight: 800; color: var(--navy); }
.plan-specs { list-style: none; padding: 0; margin: 16px 0 22px; display: flex; flex-direction: column; gap: 8px; font-size: 0.85rem; flex: 1; }

/* Auth Pages */
.auth-section { padding: 56px 16px; display: flex; justify-content: center; }
.auth-card { width: 100%; max-width: 440px; padding: 28px; }
.auth-title { margin: 0 0 6px; font-size: 1.5rem; color: var(--navy); }
.auth-alt { text-align: center; margin: 18px 0 0; }
.resend-box { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }

/* App Shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 256px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 40;
    transition: transform 0.2s ease;
}
.sidebar-brand {
    height: 64px;
    padding: 0 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sidebar-close { display: none; background: none; border: none; color: var(--muted); cursor: pointer; }
.sidebar-nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; flex: 1; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted);
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { background: #f1f5f9; color: var(--navy); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }
.nav-icon { display: inline-flex; flex-shrink: 0; }
.sidebar-footer { padding: 14px 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.sidebar-plan-card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }

.app-main-wrap { flex: 1; margin-left: 256px; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-heading { margin: 0; font-size: 1.15rem; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px; cursor: pointer; color: var(--navy); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-chip { display: flex; align-items: center; gap: 9px; }
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--navy); color: #ffffff;
    font-weight: 700; font-size: 0.85rem;
    display: inline-flex; align-items: center; justify-content: center;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-size: 0.82rem; font-weight: 600; color: var(--navy); }
.user-role { font-size: 0.7rem; color: var(--muted); }
.app-content { padding: 24px; max-width: 1400px; width: 100%; }

/* Grids & KPIs */
.dashboard-toolbar, .page-actions-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi-card { padding: 18px; }
.kpi-label { font-size: 0.78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 1.65rem; font-weight: 800; color: var(--navy); margin: 6px 0 4px; }
.kpi-sub { font-size: 0.78rem; }

.charts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.chart-box { position: relative; height: 240px; width: 100%; }
.two-col-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.stack-cards { display: flex; flex-direction: column; gap: 18px; }

/* Tables */
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th {
    text-align: left; font-size: 0.74rem; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--muted);
    padding: 10px 12px; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td { padding: 11px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.actions-cell { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* Forms */
.form-card { max-width: 820px; }
.form-stack { display: flex; flex-direction: column; gap: 15px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.82rem; font-weight: 600; color: var(--navy); }
.form-group input, .form-group select, .form-group textarea, .inline-form select, .inline-form input[type="search"] {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--navy);
    background: #ffffff;
    font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.14);
}
.field-hint { font-size: 0.75rem; color: var(--muted); }
.form-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.form-row-between { display: flex; justify-content: space-between; align-items: center; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.inline-form-bar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }

.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.checkbox-item { display: inline-flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text); cursor: pointer; }
.sub-section { padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.sub-section h3 { margin: 0; font-size: 0.95rem; color: var(--navy); }
.test-actions-row { display: flex; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* Detail & Logs */
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.detail-title-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.detail-title-row h2 { margin: 0; color: var(--navy); }
.detail-actions, .scan-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.empty-state { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty-state h2 { color: var(--navy); margin-bottom: 6px; }
.diff-pre, .log-pre {
    background: #f8fafc; border: 1px solid var(--border); border-radius: 8px;
    padding: 12px; font-size: 0.78rem; overflow-x: auto; white-space: pre-wrap; margin: 6px 0 0;
}
.log-pre { max-height: 360px; background: #0f172a; color: #e2e8f0; }
.ai-box { background: var(--accent-soft); border: 1px solid #a7f3d0; border-radius: 10px; padding: 14px; }
.ai-box-head { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 0.85rem; }
.ai-details p { margin: 8px 0; font-size: 0.875rem; }
.score-pill { background: var(--bg); border: 1px solid var(--border); padding: 6px 12px; border-radius: 8px; font-size: 0.85rem; }
.mini-list { margin: 8px 0 0; padding-left: 18px; font-size: 0.83rem; display: flex; flex-direction: column; gap: 6px; }
.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.page-link { padding: 6px 11px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.82rem; }
.page-link.active { background: var(--accent); color: #ffffff; border-color: var(--accent); }

.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4); z-index: 35; }

@media (max-width: 1024px) {
    .hero-grid, .pricing-grid, .charts-grid, .two-col-grid, .form-grid-3, .form-grid-4 {
        grid-template-columns: 1fr;
    }
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: inline-flex; }
    .sidebar-backdrop.open { display: block; }
    .app-main-wrap { margin-left: 0; }
    .menu-toggle { display: inline-flex; }
}

@media (max-width: 640px) {
    .form-grid-2 { grid-template-columns: 1fr; }
    .user-meta { display: none; }
    .app-content { padding: 16px; }
    .hero-title { font-size: 1.95rem; }
}
