/* ============================================
   RESET & BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #0a0c10;
    color: #e5e7eb;
    font-family: system-ui, -apple-system, sans-serif;
    padding: 20px;
}
/* ============================================
   THEME VARIABLES
============================================ */
:root {
    --bg-primary: #0a0c10;
    --bg-secondary: #111316;
    --bg-card: #111316;
    --bg-hover: rgba(255,255,255,0.03);
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --border-color: #262b33;
    --shadow: none;
    --badge-active-bg: rgba(34, 197, 94, 0.15);
    --badge-active-color: #86efac;
    --badge-closed-bg: rgba(239, 68, 68, 0.15);
    --badge-closed-color: #fca5a5;
    --map-bg: #0a0c10;
    --modal-overlay: rgba(0, 0, 0, 0.85);
}

body.light-mode {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: rgba(0,0,0,0.03);
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #d1d5db;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --badge-active-bg: rgba(34, 197, 94, 0.15);
    --badge-active-color: #166534;
    --badge-closed-bg: rgba(239, 68, 68, 0.15);
    --badge-closed-color: #991b1b;
    --map-bg: #e5e7eb;
    --modal-overlay: rgba(0, 0, 0, 0.6);
}

/* ============================================
   APPLY THEME VARIABLES
============================================ */
body {
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
}

/* ============================================
   THEME TOGGLE BUTTON
============================================ */
.theme-toggle {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    transition: all 0.3s ease !important;
}
.theme-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.2);
}

/* ============================================
   HEADER
   ============================================ */
.header {
    margin-bottom: 24px;
}
.header h1 {
    font-size: 28px;
    margin-bottom: 6px;
}
.header p {
    color: #9ca3af;
    font-size: 14px;
}

/* ============================================
   RSS TICKER
   ============================================ */
.ticker {
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
    background: #0d0f13;
    border-radius: 999px;
    padding: 8px 0;
    margin-top: 12px;
    border: 1px solid #262b33;
}

.ticker-track {
    display: inline-block;
    animation: scroll-left 60s linear infinite;
    padding-left: 10%;
}

.ticker-track a {
    color: #9ca3af;
    text-decoration: none;
    margin-right: 32px;
    font-size: 12px;
    transition: color 0.2s;
}

.ticker-track a:hover {
    color: #22c55e;
}

.ticker-source {
    color: #22c55e;
    font-weight: 600;
    margin-right: 6px;
    font-size: 11px;
}

.ticker-loading,
.ticker-error {
    color: #9ca3af;
    font-size: 12px;
    padding-left: 20px;
}

@keyframes scroll-left {
    0% {
        transform: translateX(0%);
    }
    100% {
        transform: translateX(-50%);
    }
}

.ticker:hover .ticker-track {
    animation-play-state: paused;
}

.rss-dot {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-right: 6px;
    vertical-align: middle;
}

.rss-dot span {
    width: 4px;
    height: 4px;
    background-color: #22c55e;
    border-radius: 50%;
    display: inline-block;
    animation: dotBlink 1.2s infinite ease-in-out;
}

.rss-dot span:nth-child(1) {
    animation-delay: -0.3s;
}
.rss-dot span:nth-child(2) {
    animation-delay: -0.15s;
}
.rss-dot span:nth-child(3) {
    animation-delay: 0s;
}

@keyframes dotBlink {
    0%,
    60%,
    100% {
        transform: scale(0.5);
        opacity: 0.3;
    }
    30% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   KPI CARDS
   ============================================ */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: #111316;
    border: 1px solid #262b33;
    border-radius: 18px;
    padding: 12px;
}
.card small {
    color: #9ca3af;
    display: block;
    margin-bottom: 6px;
    font-size: 11px;
    letter-spacing: 0.5px;
}
.card h2 {
    font-size: 24px;
}

.card-dot {
    width: 10px;
    height: 10px;
    background-color: #22c55e;
    border-radius: 50%;
    display: inline-block;
    animation: pulseDot 1.2s ease-in-out infinite;
    box-shadow: 0 0 2px #22c55e;
}

@keyframes pulseDot {
    0%,
    100% {
        opacity: 0.4;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
        box-shadow: 0 0 4px #22c55e;
    }
}

/* ============================================
   CHARTS
   ============================================ */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.chart-card {
    background: #111316;
    border: 1px solid #262b33;
    border-radius: 18px;
    padding: 18px;
}

.chart-header {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #9ca3af;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
}

.chart-header i {
    color: #22c55e;
    font-size: 16px;
}

.chart-header .badge-info {
    margin-left: auto;
    font-size: 11px;
    font-weight: 400;
    color: #6b7280;
}

.chart-wrapper {
    position: relative;
    height: 200px;
}

/* ============================================
   MAP
   ============================================ */
.map-container {
    background: #111316;
    border: 1px solid #262b33;
    border-radius: 18px;
    padding: 18px;
    margin-bottom: 24px;
}

.map-header {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #9ca3af;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
}

.map-header i {
    color: #22c55e;
    font-size: 14px;
}

.map-count {
    margin-left: auto;
    color: #86efac;
    font-size: 12px;
    background: rgba(34, 197, 94, 0.15);
    padding: 2px 12px;
    border-radius: 999px;
    animation: pulseDot 1.5s ease-in-out infinite;
}

.leaflet-container {
    background: #0a0c10 !important;
    border-radius: 12px;
	background: var(--map-bg) !important;
}
}

.leaflet-popup-content-wrapper {
    background: #1a1d23 !important;
    color: #e5e7eb !important;
    border-radius: 8px !important;
	background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

.leaflet-popup-tip {
    background: #1a1d23 !important;
	background: var(--bg-secondary) !important;
}

.leaflet-control-zoom a {
    background: #1a1d23 !important;
    color: #e5e7eb !important;
    border-color: #262b33 !important;
	background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* ============================================
   TABLE
   ============================================ */
.table-wrap {
    background: #111316;
    border: 1px solid #262b33;
    border-radius: 18px;
    overflow: hidden;
    min-height: 400px;
}

.table-header {
    padding: 16px;
    border-bottom: 1px solid #262b33;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    background: #0f1117;
    color: #9ca3af;
    font-size: 12px;
    letter-spacing: 0.5px;
    padding: 12px 14px;
	background: var(--bg-primary);
    color: var(--text-secondary);
}

tr {
    border-bottom: 1px solid #1c2128;
    cursor: pointer;
    transition: background 0.2s;
	border-bottom: 1px solid var(--border-color);
}
tr:hover {
    background: rgba(255, 255, 255, 0.03);
	background: var(--bg-hover);
}

td {
    padding: 12px 14px;
    font-size: 13px;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.badge-active {
    background: rgba(34, 197, 94, 0.15);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.35);
	background: var(--badge-active-bg);
    color: var(--badge-active-color);
    border: 1px solid rgba(34, 197, 94, 0.35);
}

.badge-closed {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.35);
	background: var(--badge-closed-bg);
    color: var(--badge-closed-color);
    border: 1px solid rgba(239, 68, 68, 0.35);
}

.footer {
    margin-top: 16px;
    color: #6b7280;
    font-size: 12px;
    text-align: center;
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
	background: var(--modal-overlay) !important;
}

.modal-overlay.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-content {
    background: #111316;
    border: 1px solid #262b33;
    border-radius: 24px;
    padding: 28px;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
	background: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
}
.ticker {
    background: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #262b33;
	border-bottom-color: var(--border-color) !important;
}

.modal-header h3 {
    font-size: 20px;
    color: #e5e7eb;
}

.modal-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    margin-top: 4px;
}

.modal-status.active {
    background: rgba(34, 197, 94, 0.15);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.35);
}

.modal-status.closed {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.35);
}

.modal-close {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 28px;
    cursor: pointer;
    transition: 0.2s;
    line-height: 1;
    padding: 0 8px;
}

.modal-close:hover {
    color: #e5e7eb;
    transform: rotate(90deg);
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.modal-item label {
    display: block;
    color: #9ca3af;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
	color: var(--text-secondary) !important;
}

.modal-item p {
    color: #e5e7eb;
    font-size: 14px;
    word-break: break-word;
	color: var(--text-primary) !important;
}

#modalMap {
    height: 200px;
    margin-top: 12px;
    border-radius: 8px;
    background: #0a0c10;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 600px) {
    .modal-grid {
        grid-template-columns: 1fr;
    }
    .modal-content {
        padding: 20px;
    }
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .header h1 {
        font-size: 22px;
    }
    td,
    th {
        font-size: 12px;
        padding: 8px 10px;
    }
    .grid {
        grid-template-columns: 1fr 1fr;
    }
}