/* ═══════════════════════════════════════
   MY Data — Modern Dashboard
   ═══════════════════════════════════════ */

:root {
    --bg: #0c0f1a;
    --surface: #151926;
    --surface2: #1e2336;
    --surface3: #282e42;
    --text: #eef0f6;
    --text-muted: #8b92a8;
    --accent: #3b82f6;
    --accent-soft: rgba(59,130,246,0.12);
    --green: #10b981;
    --red: #ef4444;
    --yellow: #f59e0b;
    --purple: #a78bfa;
    --pink: #ec4899;
    --orange: #fb923c;
    --border: rgba(255,255,255,0.06);
    --border-strong: rgba(255,255,255,0.1);
    --radius: 14px;
    --radius-sm: 8px;
    --sidebar-w: 240px;
    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.15);
}

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

html { font-size: 15px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar__top { padding: 1.5rem 1.25rem 1rem; }

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}
.sidebar__logo {
    width: 32px; height: 32px;
    border-radius: 8px;
    object-fit: contain;
    flex-shrink: 0;
}
.sidebar__brand-text { font-weight: 700; font-size: 1.05rem; }

.sidebar__nav {
    list-style: none;
    padding: 0.75rem 0.75rem;
    flex: 1;
}
.sidebar__nav li + li { margin-top: 0.25rem; }

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.15s ease;
}
.sidebar__link:hover {
    background: var(--surface2);
    color: var(--text);
    text-decoration: none;
}
.sidebar__link--active {
    background: var(--accent-soft);
    color: var(--accent);
}
.sidebar__icon { flex-shrink: 0; }

.sidebar__footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}
.sidebar__footer-text {
    font-size: 0.72rem;
    color: var(--text-muted);
    opacity: 0.6;
}

/* ── Main content ── */
.app-content {
    flex: 1;
    overflow: auto;
    padding: 2rem 2.25rem;
    min-width: 0;
}

/* ── Module header ── */
.module__header { margin-bottom: 2rem; }
.module__header h1 {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.module__subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.3rem;
}

/* ── Card panel (generic container) ── */
.card-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}
.card-panel__header { margin-bottom: 1rem; }
.card-panel__header h2 {
    font-size: 1rem;
    font-weight: 600;
}
.card-panel__sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.section-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.section-grid--analysis {
    grid-template-columns: 1.2fr 1fr;
}

/* ── Spinner ── */
.prices-loading {
    display: flex; align-items: center; gap: 0.75rem;
    color: var(--text-muted); font-size: 0.9rem;
}
.spinner {
    width: 20px; height: 20px;
    border: 2.5px solid var(--surface3);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Prices module ── */
.prices-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.prices-section-label--sub { margin-top: 0.5rem; }
.prices-section-tag {
    display: inline-block;
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--purple);
    background: rgba(167,139,250,0.12);
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    letter-spacing: 0.04em;
}

.prices-cards {
    display: grid;
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}
.prices-cards--main {
    grid-template-columns: repeat(3, 1fr);
}
.prices-cards--sub {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.prices-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.2rem;
    display: flex; flex-direction: column; gap: 0.25rem;
    box-shadow: var(--shadow);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    position: relative;
    overflow: hidden;
}
.prices-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}
.prices-card__dot {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}
.prices-card__label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.2rem;
}
.prices-card__value { font-size: 1.5rem; font-weight: 700; }
.prices-card__prev {
    font-size: 0.72rem;
    color: var(--text-muted);
    opacity: 0.7;
}
.prices-card__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    width: fit-content;
    margin-top: 0.15rem;
}
.prices-card__badge--up { background: rgba(16,185,129,0.12); color: var(--green); }
.prices-card__badge--down { background: rgba(239,68,68,0.12); color: var(--red); }
.prices-card__badge--flat { background: rgba(139,146,168,0.1); color: var(--text-muted); }

.prices-card__meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.1rem;
}
.prices-card__saving {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--green);
    background: rgba(16,185,129,0.08);
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    margin-top: 0.25rem;
}

.prices-card--sub {
    border-left: 3px solid var(--purple);
}
.prices-card--sub .prices-card__dot { background: var(--purple) !important; }

/* ── Prices controls ── */
.prices-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.prices-tabs {
    display: flex;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.prices-tab {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.55rem 1.15rem;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}
.prices-tab:hover { color: var(--text); background: var(--surface2); }
.prices-tab--active {
    color: var(--accent);
    background: var(--accent-soft);
    font-weight: 600;
}
.prices-tab + .prices-tab { border-left: 1px solid var(--border); }

.prices-filters { display: flex; gap: 0.5rem; }
.prices-select {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.82rem;
    padding: 0.5rem 0.85rem;
    cursor: pointer;
    appearance: auto;
    outline: none;
    transition: border-color 0.15s;
}
.prices-select:focus { border-color: var(--accent); }
.prices-select:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Larger chart wrap ── */
.chart-wrap--lg { height: 380px; }
.chart-wrap--md { height: 300px; }

/* ── Table dot ── */
.td-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
    vertical-align: middle;
}

/* Table group header row (subsidy section divider) */
.table-group-row td {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--purple);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding-top: 1rem;
    border-bottom: 1px solid rgba(167,139,250,0.15);
    background: transparent;
}
.tr-sub td:first-child { padding-left: 1.5rem; }

/* Subdued table columns */
.th-sub { color: var(--text-muted); opacity: 0.7; font-style: italic; }
.td-sub { color: var(--text-muted); opacity: 0.75; }

/* ── Prices chart panel ── */
.prices-chart-panel { margin-bottom: 1.5rem; }

/* ── Table pagination ── */
.prices-table-nav {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}
.prices-page-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.12s ease;
}
.prices-page-btn:hover:not(:disabled) {
    background: var(--surface3);
    color: var(--text);
}
.prices-page-btn--active {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
    font-weight: 600;
}
.prices-page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ── Tables ── */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-sm);
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.data-table th, .data-table td {
    padding: 0.7rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface2); }

.pct-up { color: var(--green); font-weight: 600; }
.pct-down { color: var(--red); font-weight: 600; }
.pct-flat { color: var(--text-muted); }

/* ── Chart ── */
.chart-wrap { position: relative; height: 260px; }

/* ══════════════════════════════════
   Transport module
   ══════════════════════════════════ */
.transport-wrap {
    display: flex;
    gap: 1rem;
    height: calc(100vh - 140px);
    min-height: 480px;
}
.transport-map {
    flex: 1;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    min-width: 0;
}
.leaflet-container { font-family: var(--font); }

/* Animated vehicle icon */
.vehicle-icon {
    background: none !important;
    border: none !important;
}
.vehicle-icon__img {
    display: block;
    transition: transform 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
    transform-origin: center center;
}

/* Legend vehicle icon + colour dot */
.legend-icon-img {
    flex-shrink: 0;
    border-radius: 3px;
}
.legend-color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 4px currentColor;
}

/* ── Legend panel ── */
.legend-panel {
    width: 250px;
    min-width: 250px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: var(--shadow);
}
.legend-panel__header {
    padding: 1rem 1.15rem 0.75rem;
    border-bottom: 1px solid var(--border);
}
.legend-panel__header h3 {
    font-size: 0.95rem;
    font-weight: 700;
}
.legend-panel__group {
    padding: 0.85rem 1.15rem 0.5rem;
}
.legend-panel__group h4 {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}
.legend-panel__sep {
    height: 1px;
    background: var(--border);
    margin: 0 1.15rem;
}

/* ── Legend rows ── */
.legend-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    transition: opacity 0.15s;
}
.legend-row--hidden { opacity: 0.4; }
.legend-row--radio {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.3rem 0;
    font-size: 0.82rem;
}
.legend-row--radio input[type="radio"] {
    accent-color: var(--accent);
    margin: 0;
}
.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}
.legend-label {
    flex: 1;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.legend-badge {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}
.legend-eye {
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.12s, color 0.12s;
    flex-shrink: 0;
}
.legend-eye:hover { background: var(--surface3); }
.legend-eye--on { color: var(--green); }
.legend-eye--off { color: var(--text-muted); opacity: 0.45; }

/* ══════════════════════════════════
   AI Analysis Chat
   ══════════════════════════════════ */
.analysis-panel {
    display: flex;
    flex-direction: column;
    max-height: 620px;
}
.analysis-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.analysis-header__icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    flex-shrink: 0;
}
.analysis-disclaimer {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    background: rgba(245,158,11,0.08);
    border: 1px solid rgba(245,158,11,0.15);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.85rem;
    font-size: 0.7rem;
    color: var(--yellow);
    line-height: 1.45;
}
.analysis-disclaimer svg { flex-shrink: 0; margin-top: 1px; }

.analysis-chat {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    margin-bottom: 0.75rem;
}

/* Welcome state */
.analysis-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.5rem 0.5rem;
    gap: 0.75rem;
}
.analysis-welcome__icon { opacity: 0.3; }
.analysis-welcome p {
    color: var(--text-muted);
    font-size: 0.85rem;
}
.analysis-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    margin-top: 0.25rem;
}
.analysis-suggestion {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.72rem;
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    transition: all 0.15s ease;
}
.analysis-suggestion:hover {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}

/* Messages */
.analysis-messages {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.25rem 0;
}
.analysis-msg {
    display: flex;
    gap: 0.55rem;
    align-items: flex-start;
}
.analysis-msg--user {
    justify-content: flex-end;
}
.analysis-msg--user .analysis-msg__body {
    background: var(--accent);
    color: #fff;
    border-radius: 14px 14px 4px 14px;
    max-width: 85%;
    padding: 0.6rem 0.85rem;
    font-size: 0.82rem;
    line-height: 1.5;
}
.analysis-msg--ai .analysis-msg__body {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 14px 14px 14px 4px;
    max-width: 95%;
    padding: 0.75rem 0.9rem;
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--text);
}
.analysis-msg__avatar {
    width: 28px; height: 28px;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    flex-shrink: 0;
    margin-top: 2px;
}

/* AI response formatting */
.analysis-msg--ai .ai-h3 {
    font-size: 0.88rem;
    font-weight: 700;
    margin: 0.6rem 0 0.3rem;
    color: var(--text);
}
.analysis-msg--ai .ai-h4 {
    font-size: 0.82rem;
    font-weight: 600;
    margin: 0.5rem 0 0.2rem;
    color: var(--accent);
}
.analysis-msg--ai .ai-list {
    margin: 0.3rem 0;
    padding-left: 1.1rem;
}
.analysis-msg--ai .ai-list li {
    margin-bottom: 0.2rem;
}
.analysis-msg--ai strong {
    color: var(--text);
    font-weight: 600;
}
.analysis-msg--ai p {
    margin: 0.3rem 0;
}
.analysis-msg--ai p:first-child { margin-top: 0; }
.analysis-msg--ai p:last-child { margin-bottom: 0; }

/* Typing indicator */
.analysis-typing {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}
.analysis-typing span {
    width: 6px; height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingDot 1.2s infinite;
}
.analysis-typing span:nth-child(2) { animation-delay: 0.2s; }
.analysis-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* Input area */
.analysis-input-wrap {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}
.analysis-input {
    flex: 1;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.82rem;
    padding: 0.6rem 0.85rem;
    outline: none;
    transition: border-color 0.15s;
}
.analysis-input:focus { border-color: var(--accent); }
.analysis-input::placeholder { color: var(--text-muted); opacity: 0.6; }
.analysis-input:disabled { opacity: 0.5; }
.analysis-send {
    width: 36px; height: 36px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
}
.analysis-send:hover { background: #2563eb; }
.analysis-send:active { transform: scale(0.95); }
.analysis-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ══════════════════════════════════
   Responsive
   ══════════════════════════════════ */
@media (max-width: 1024px) {
    .section-grid { grid-template-columns: 1fr; }
    .section-grid--analysis { grid-template-columns: 1fr; }
    .analysis-panel { max-height: 500px; }
}
@media (max-width: 768px) {
    html { font-size: 14px; }
    body { flex-direction: column; }
    .sidebar {
        width: 100%; min-width: 0; height: auto;
        flex-direction: row; align-items: center;
        padding: 0.5rem 1rem; position: static;
    }
    .sidebar__top { padding: 0; }
    .sidebar__nav { display: flex; gap: 0.25rem; padding: 0 0.5rem; flex: unset; }
    .sidebar__footer { display: none; }
    .app-content { padding: 1.25rem; }
    .transport-wrap { flex-direction: column; height: auto; }
    .transport-map { height: 380px; }
    .legend-panel { width: 100%; min-width: 0; max-height: 200px; }
    .prices-cards--main { grid-template-columns: 1fr 1fr; }
    .prices-cards--sub { grid-template-columns: 1fr; }
    .prices-controls { flex-direction: column; align-items: stretch; }
    .prices-filters { flex-wrap: wrap; }
    .chart-wrap--lg { height: 280px; }
    .analysis-panel { max-height: 450px; }
}
