:root {
    --bg: #0a0f14;
    --bg-secondary: #0e1520;
    --panel: #121c26;
    --panel-hover: #162230;
    --text: #e7edf5;
    --text-secondary: #c5d0dc;
    --muted: #9aa7b6;
    --accent: #7bbad9;
    --accent-strong: #b7e6ff;
    --accent-active: #58d29a;
    --border: #1c2a38;
    --border-light: #243444;
    --success: #58d29a;
    --error: #ff8f8f;
    --warning: #ffc857;
    --shadow: rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --font-heading: 'Fraunces', Georgia, serif;
    --font-body: 'Figtree', -apple-system, BlinkMacSystemFont, sans-serif;
    --topbar-height: 64px;
    --bottombar-height: 64px;
}

html[data-theme="light"] {
    --bg: #f5f7fa;
    --bg-secondary: #edf0f5;
    --panel: #ffffff;
    --panel-hover: #f8f9fb;
    --text: #1a2332;
    --text-secondary: #3d4f63;
    --muted: #6b7d92;
    --accent: #2b7cb8;
    --accent-strong: #1a5c8a;
    --accent-active: #1a8a5c;
    --border: #dde3eb;
    --border-light: #e8ecf2;
    --success: #1a8a5c;
    --error: #d63031;
    --warning: #e67e22;
    --shadow: rgba(0, 0, 0, 0.08);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    padding-bottom: calc(var(--bottombar-height) + 16px);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-strong);
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 400;
    line-height: 1.3;
}

.hidden {
    display: none !important;
}

/* Topbar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--topbar-height);
    padding: 0 24px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-logo {
    width: 32px;
    height: 32px;
}

.topbar-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

.topbar-tagline {
    font-size: 0.75rem;
    color: var(--muted);
    display: block;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-email {
    font-size: 0.85rem;
    color: var(--muted);
}

.topbar-logout {
    font-size: 0.85rem;
    color: var(--accent);
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.topbar-logout:hover {
    background: var(--panel-hover);
    border-color: var(--accent);
}

/* Bottom Navigation */
.bottombar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    height: var(--bottombar-height);
    background: var(--panel);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(12px);
    max-width: 480px;
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 4px 24px var(--shadow);
    margin: 0 16px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--muted);
    font-size: 0.7rem;
    transition: color 0.2s;
    text-decoration: none;
}

.nav-item svg {
    width: 20px;
    height: 20px;
}

.nav-item:hover,
.nav-item.active {
    color: var(--accent);
}

.nav-item.active {
    color: var(--accent-active);
}

@media (min-width: 768px) {
    .bottombar {
        bottom: 16px;
    }
}

/* Content */
.content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* Dashboard Grid */
.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.dashboard-section {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .dashboard-section {
        animation: none;
    }
}

/* Overview Cards */
.overview-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 768px) {
    .overview-cards {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

.overview-card {
    background: linear-gradient(135deg, var(--panel), var(--panel-hover));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.overview-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px var(--shadow);
    transform: translateY(-2px);
}

.overview-card h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 12px;
}

/* Panels */
.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.panel h2 {
    font-size: 1.5rem;
    margin-bottom: 16px;
    color: var(--text);
}

/* Auth Pages */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--topbar-height));
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 32px;
    box-shadow: 0 8px 32px var(--shadow);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
}

.auth-header h2 {
    font-size: 1.5rem;
    color: var(--text);
}

.auth-error {
    background: rgba(255, 143, 143, 0.1);
    border: 1px solid var(--error);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 20px;
    color: var(--error);
    font-size: 0.9rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.9rem;
    color: var(--muted);
}

/* Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.95rem;
    font-family: var(--font-body);
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(123, 186, 217, 0.15);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-family: var(--font-body);
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    background: var(--panel-hover);
    border-color: var(--accent);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #0a0f14;
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Weather */
.weather-current {
    text-align: center;
    padding: 16px 0;
}

.weather-temp {
    font-size: 3rem;
    font-family: var(--font-heading);
    font-weight: 300;
    color: var(--accent);
}

.weather-condition {
    font-size: 1rem;
    color: var(--muted);
    margin-top: 4px;
}

.weather-forecast {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.weather-item {
    flex: 1;
    min-width: 80px;
    text-align: center;
    padding: 8px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.weather-time {
    font-size: 0.75rem;
    color: var(--muted);
    display: block;
}

.weather-temp-sm {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text);
    display: block;
}

.weather-cond-sm {
    font-size: 0.7rem;
    color: var(--muted);
    display: block;
}

/* News */
.news-actions {
    margin-bottom: 16px;
}

.news-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.news-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.news-item:last-child {
    border-bottom: none;
}

.news-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text);
    line-height: 1.4;
}

.news-title:hover {
    color: var(--accent);
}

.news-meta {
    display: flex;
    gap: 12px;
    margin-top: 6px;
}

.news-source,
.news-category {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.news-category {
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 4px;
}

.news-summary {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 6px;
    line-height: 1.5;
}

/* Postal */
.postal-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.postal-item {
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.postal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.postal-tracking {
    font-weight: 500;
    font-size: 0.95rem;
}

.postal-status {
    font-size: 0.8rem;
    padding: 2px 10px;
    border-radius: 12px;
    background: var(--border);
    color: var(--muted);
}

.postal-status.status-delivered {
    background: rgba(88, 210, 154, 0.15);
    color: var(--success);
}

.postal-status.status-in-transit {
    background: rgba(123, 186, 217, 0.15);
    color: var(--accent);
}

.postal-meta {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--muted);
}

.postal-today {
    color: #58d29a;
}

/* Events */
.events-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.event-item {
    display: flex;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.event-item:last-child {
    border-bottom: none;
}

.event-date {
    flex-shrink: 0;
    width: 60px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 500;
    padding-top: 2px;
}

.event-body {
    flex: 1;
}

.event-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text);
}

.event-title:hover {
    color: var(--accent);
}

.event-location {
    font-size: 0.8rem;
    color: var(--muted);
    display: block;
    margin-top: 4px;
}

.event-summary {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 6px;
    line-height: 1.5;
}

/* Settings */
.settings-form {
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-message {
    background: rgba(88, 210, 154, 0.1);
    border: 1px solid var(--success);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
    color: var(--success);
    font-size: 0.9rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 24px;
    color: var(--muted);
    font-size: 0.9rem;
}

/* Connection Banner */
.connection-banner {
    position: fixed;
    top: calc(var(--topbar-height) + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    background: var(--error);
    color: #fff;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    box-shadow: 0 4px 16px var(--shadow);
    transition: opacity 0.3s;
}

.connection-banner.connected {
    background: var(--success);
}

/* HTMX Loading */
.htmx-request .btn {
    opacity: 0.6;
    pointer-events: none;
}

/* Responsive */
@media (min-width: 1120px) {
    .content {
        padding: 32px 24px;
    }

    .overview-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}
