:root {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border: #334155;
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* NAV */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 56px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}
.nav-icon { font-size: 1.4rem; }
.nav-links { display: flex; gap: 0.25rem; align-items: center; }
.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: all 0.15s;
}
.nav-links a:hover, .nav-links a.active {
    color: var(--text);
    background: var(--bg-hover);
}
.nav-logout { color: var(--danger) !important; }
.badge {
    background: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    margin-left: 0.25rem;
}

/* CONTAINER */
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

/* CARDS */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    overflow: hidden;
}
.card-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1rem; }

/* STATS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.stat-value { font-size: 2rem; font-weight: 700; }
.stat-label { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.25rem; }
.stat-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 0.75rem;
    overflow: hidden;
}
.stat-bar-fill { height: 100%; background: var(--success); border-radius: 2px; transition: width 0.3s; }
.stat-alert .stat-value { color: var(--danger); }
.stat-human .stat-value { color: var(--warning); }
.stat-vehicle .stat-value { color: var(--primary); }

/* DASHBOARD GRID */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}
@media (max-width: 768px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}

/* ZONE MAP */
.zone-map {
    position: relative;
    width: 100%;
    height: 300px;
    background: #0c1222;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    background-image:
        radial-gradient(circle, var(--border) 1px, transparent 1px);
    background-size: 30px 30px;
}
.sensor-dot {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: pointer;
    z-index: 2;
}
.sensor-dot.online {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulse 2s infinite;
}
.sensor-dot.offline {
    background: var(--text-muted);
    opacity: 0.5;
}
.sensor-label {
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    white-space: nowrap;
    color: var(--text-muted);
}
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 4px var(--success); }
    50% { box-shadow: 0 0 16px var(--success); }
}

/* ALERTS */
.alert-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    border-left: 3px solid var(--border);
}
.alert-item.severity-high { border-left-color: var(--danger); background: rgba(239,68,68,0.08); }
.alert-item.severity-medium { border-left-color: var(--warning); background: rgba(245,158,11,0.08); }
.alert-item.severity-low { border-left-color: var(--primary); background: rgba(59,130,246,0.08); }
.alert-item.resolved { opacity: 0.5; }
.alert-icon { font-size: 1.4rem; }
.alert-info { flex: 1; }
.alert-message { font-size: 0.9rem; }
.alert-time, .alert-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; }
.alert-meta { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.severity-badge {
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-weight: 600;
}
.severity-badge.severity-high { background: var(--danger); color: #fff; }
.severity-badge.severity-medium { background: var(--warning); color: #000; }
.severity-badge.severity-low { background: var(--primary); color: #fff; }

/* EVENTS FEED */
.events-feed { max-height: 400px; overflow-y: auto; }
.event-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}
.event-row:last-child { border-bottom: none; }
.event-type {
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: 500;
}
.type-human { background: rgba(245,158,11,0.2); color: var(--warning); }
.type-vehicle { background: rgba(59,130,246,0.2); color: var(--primary); }
.type-unknown { background: rgba(148,163,184,0.2); color: var(--text-muted); }

/* TABLE */
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}
.data-table th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; }
.data-table tr:hover td { background: var(--bg-hover); }

/* ZONE BADGE */
.zone-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.8rem;
    color: #fff;
}
.color-dot {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

/* STATUS DOT */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.25rem;
}
.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--text-muted); }

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.15s;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-full { width: 100%; }

/* FORMS */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
}
.form-group input[type="color"] { height: 38px; padding: 0.25rem; cursor: pointer; }

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}
.inline-form .form-group { margin-bottom: 0; }

.filters { margin-bottom: 1rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.filter-form { display: flex; gap: 0.5rem; }
.filter-form select {
    padding: 0.4rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.85rem;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* LOGIN */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
}
.login-header { text-align: center; margin-bottom: 1.5rem; }
.login-icon { font-size: 2.5rem; color: var(--primary); }
.login-header h1 { font-size: 1.3rem; margin-top: 0.5rem; }
.login-header p { font-size: 0.85rem; color: var(--text-muted); }

/* FLASH MESSAGES */
.flash-messages { margin-bottom: 1rem; }
.flash {
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}
.flash-error { background: rgba(239,68,68,0.15); border: 1px solid var(--danger); color: var(--danger); }
.flash-success { background: rgba(34,197,94,0.15); border: 1px solid var(--success); color: var(--success); }

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    font-size: 0.9rem;
}
