:root {
    --ip-primary: #7c3aed;
    --ip-primary-dark: #6d28d9;
    --ip-primary-light: #a78bfa;
    --ip-accent: #f59e0b;
    --ip-bg: #faf5ff;
    --ip-card-bg: #ffffff;
    --ip-text: #1e293b;
    --ip-text-muted: #64748b;
    --ip-border: #e9d5ff;
    --ip-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --ip-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --ip-radius: 12px;
    --ip-radius-sm: 8px;
    --ip-transition: all 0.2s ease;
}

* {
    box-sizing: border-box;
}

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

#map {
    height: 400px;
    border-radius: var(--ip-radius-sm);
    margin-bottom: 1rem;
}

/* ====== NAVIGATION ====== */
.app-nav {
    background: var(--ip-card-bg);
    border-bottom: 1px solid var(--ip-border);
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--ip-shadow);
}

.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--ip-text);
    font-weight: 700;
    font-size: 1.25rem;
}

.nav-brand img {
    width: 36px;
    height: auto;
    flex-shrink: 0;
}

.nav-brand span {
    color: var(--ip-primary);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-links a {
    text-decoration: none;
    color: var(--ip-text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-radius: var(--ip-radius-sm);
    transition: var(--ip-transition);
}

.nav-links a:hover {
    color: var(--ip-primary);
    background: rgba(124, 58, 237, 0.08);
}

.nav-links a.active {
    color: var(--ip-primary);
    background: rgba(124, 58, 237, 0.12);
}

/* ====== MAIN LAYOUT ====== */
.app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 0.25rem 0;
    color: var(--ip-text);
}

.page-header p {
    color: var(--ip-text-muted);
    margin: 0;
    font-size: 0.95rem;
}

/* ====== CARDS ====== */
.card {
    background: var(--ip-card-bg);
    border-radius: var(--ip-radius);
    border: 1px solid var(--ip-border);
    box-shadow: var(--ip-shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: var(--ip-transition);
}

.card:hover {
    box-shadow: var(--ip-shadow-lg);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--ip-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--ip-text);
    line-height: 1;
}

.card-subtitle {
    font-size: 0.85rem;
    color: var(--ip-text-muted);
    margin-top: 0.5rem;
}

/* ====== STATS GRID ====== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--ip-card-bg);
    border-radius: var(--ip-radius);
    border: 1px solid var(--ip-border);
    box-shadow: var(--ip-shadow);
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--ip-primary), var(--ip-primary-light));
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(124, 58, 237, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.stat-icon svg {
    width: 20px;
    height: 20px;
    color: var(--ip-primary);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    color: var(--ip-text);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--ip-text-muted);
    margin-top: 0.25rem;
}

/* ====== DATE PICKER ====== */
.date-control {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.date-control label {
    font-weight: 600;
    color: var(--ip-text);
    font-size: 0.95rem;
}

.date-control input[type="date"] {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--ip-border);
    border-radius: var(--ip-radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--ip-text);
    background: var(--ip-card-bg);
    cursor: pointer;
    transition: var(--ip-transition);
}

.date-control input[type="date"]:focus {
    outline: none;
    border-color: var(--ip-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--ip-radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    text-decoration: none;
    cursor: pointer;
    transition: var(--ip-transition);
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--ip-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--ip-primary-dark);
}

.btn-outline {
    background: transparent;
    color: var(--ip-primary);
    border: 1px solid var(--ip-primary);
}

.btn-outline:hover {
    background: rgba(124, 58, 237, 0.08);
}

/* ====== TABLES ====== */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
}

.data-table thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ip-text-muted);
    border-bottom: 2px solid var(--ip-border);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 1rem;
    border-bottom: 1px solid var(--ip-border);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: var(--ip-transition);
    cursor: pointer;
}

.data-table tbody tr:hover {
    background: rgba(124, 58, 237, 0.04);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table code {
    background: rgba(124, 58, 237, 0.08);
    color: var(--ip-primary-dark);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: 'SF Mono', monospace;
}

/* ====== BADGES ====== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-primary {
    background: rgba(124, 58, 237, 0.1);
    color: var(--ip-primary-dark);
}

.badge-accent {
    background: rgba(245, 158, 11, 0.1);
    color: #b45309;
}

/* ====== EMPTY STATE ====== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--ip-text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* ====== LOGIN ====== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--ip-bg) 0%, #f3e8ff 100%);
    padding: 1rem;
}

.login-card {
    background: var(--ip-card-bg);
    border-radius: var(--ip-radius);
    box-shadow: var(--ip-shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.login-logo {
    margin-bottom: 1.5rem;
}

.login-logo-img {
    width: 64px;
    height: auto;
}

.login-card h2 {
    margin: 0 0 0.25rem 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.login-card p {
    color: var(--ip-text-muted);
    margin: 0 0 1.5rem 0;
    font-size: 0.9rem;
}

.login-form label {
    display: block;
    text-align: left;
    font-weight: 500;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    color: var(--ip-text);
}

.login-form input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--ip-border);
    border-radius: var(--ip-radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    transition: var(--ip-transition);
}

.login-form input:focus {
    outline: none;
    border-color: var(--ip-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.login-form button {
    width: 100%;
    padding: 0.75rem;
    background: var(--ip-primary);
    color: white;
    border: none;
    border-radius: var(--ip-radius-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--ip-transition);
}

.login-form button:hover {
    background: var(--ip-primary-dark);
}

.login-error {
    background: #fef2f2;
    color: #991b1b;
    padding: 0.75rem;
    border-radius: var(--ip-radius-sm);
    margin-bottom: 1rem;
    font-size: 0.85rem;
    border: 1px solid #fecaca;
}

/* ====== FOOTER ====== */
.app-footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--ip-text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--ip-border);
    margin-top: 2rem;
}

/* ====== RESPONSIVE ====== */
@media (max-width: 640px) {
    .app-main {
        padding: 1rem;
    }

    .nav-inner {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .nav-links {
        gap: 0.1rem;
    }

    .nav-links a {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .data-table {
        font-size: 0.8rem;
    }

    .data-table thead th,
    .data-table tbody td {
        padding: 0.75rem 0.5rem;
    }

    .page-header h1 {
        font-size: 1.4rem;
    }
}
