:root {
    --sidebar-width: 256px;
    --sidebar-bg: #0d1b2e;
    --sidebar-border: rgba(255, 255, 255, 0.07);
    --sidebar-text: rgba(255, 255, 255, 0.68);
    --sidebar-text-hover: #ffffff;
    --sidebar-hover: rgba(255, 255, 255, 0.07);
    --sidebar-active: rgba(59, 130, 246, 0.22);
    --sidebar-active-text: #93c5fd;
    --app-bg: #f0f4f8;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --card-radius: 0.9rem;
    --text-primary: #0f172a;
    --text-muted: #64748b;
    --accent: #f59e0b;
    --primary: #2563eb;
    --success: #16a34a;
    --danger: #dc2626;
    --app-shadow: 0 1px 3px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
}

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

html, body { height: 100%; margin: 0; }

body {
    background: var(--app-bg);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

a { text-decoration: none; }

/* Sidebar */
.app-sidebar {
    background: var(--sidebar-bg);
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

@media (min-width: 992px) {
    #appSidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        height: 100vh !important;
        width: var(--sidebar-width) !important;
        transform: none !important;
        visibility: visible !important;
        z-index: 1030;
        overflow-y: auto;
        border-right: 1px solid var(--sidebar-border);
    }
    .app-main { margin-left: var(--sidebar-width); }
    .app-mobilebar { display: none !important; }
}

@media (max-width: 991.98px) {
    .app-main { margin-left: 0; }
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.25rem 1.1rem 1rem;
    color: #ffffff;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    border-bottom: 1px solid var(--sidebar-border);
    text-decoration: none;
}

.sidebar-brand:hover { color: #ffffff; }

.sidebar-brand-icon {
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 0.55rem;
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.3);
    padding: 1rem 1.1rem 0.3rem;
}

.sidebar-nav { padding: 0.5rem 0.6rem; flex: 1; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.75rem;
    color: var(--sidebar-text);
    border-radius: 0.6rem;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.12s ease, color 0.12s ease;
    margin-bottom: 0.1rem;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-hover);
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-active-text);
    font-weight: 600;
}

.sidebar-link i { font-size: 1.05rem; flex-shrink: 0; }

.sidebar-checkin-wrap { padding: 0.75rem 0.6rem; }

.sidebar-checkin {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.65rem 1rem;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 0.65rem;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease;
}

.sidebar-checkin:hover { background: #d97706; color: #000; }

.sidebar-footer {
    padding: 0.85rem 0.6rem;
    border-top: 1px solid var(--sidebar-border);
}

.sidebar-user-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: none;
    background: transparent;
    border-radius: 0.6rem;
    cursor: pointer;
    transition: background 0.12s ease;
    text-align: left;
}

.sidebar-user-btn:hover { background: var(--sidebar-hover); }

.sidebar-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.sidebar-avatar-placeholder {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #334155, #475569);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-username {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.82rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-handle {
    color: rgba(255, 255, 255, 0.38);
    font-size: 0.72rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Mobile bar */
.app-mobilebar {
    position: sticky;
    top: 0;
    z-index: 900;
    background: var(--sidebar-bg);
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--sidebar-border);
}

.mobile-brand {
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.02em;
    font-size: 1.05rem;
}

/* Main content */
.app-main { min-height: 100vh; }

.app-content {
    padding: 1.5rem 1.25rem;
    max-width: 1180px;
    margin: 0 auto;
}

@media (min-width: 992px) {
    .app-content { padding: 1.75rem 2rem; }
}

/* Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--app-shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--card-border);
    padding: 0.9rem 1.1rem;
    font-weight: 600;
}

.card-body { padding: 1.1rem; }

.card-footer {
    background: transparent;
    border-top: 1px solid var(--card-border);
    padding: 0.75rem 1.1rem;
}

/* Page layout helpers */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.page-header h1, .page-header h2 {
    margin: 0;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.925rem;
    margin: 0;
}

/* Stat cards */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    padding: 1rem 1.1rem;
    box-shadow: var(--app-shadow);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    font-weight: 700;
}

.stat-value {
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    margin-top: 0.2rem;
}

/* Feed */
.feed-wrap { max-width: 620px; }

.feed-post {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--app-shadow);
    margin-bottom: 0.85rem;
    overflow: hidden;
}

.feed-post-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.9rem 1rem 0.6rem;
}

.feed-avatar {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.feed-avatar-placeholder {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #334155, #475569);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.feed-avatar-self {
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
}

.feed-actor { flex: 1; min-width: 0; }

.feed-display-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.feed-handle {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.feed-timestamp {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.feed-post-body { padding: 0 1rem 0.75rem; }

/* Route card (check-in) */
.route-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.7rem;
    padding: 0.85rem 1rem;
    margin-bottom: 0.6rem;
}

.transport-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-bottom: 0.65rem;
}

/* Transport category colors */
.transport-high-speed    { background: #fef2f2; color: #dc2626; }
.transport-long-distance { background: #eff6ff; color: #1d4ed8; }
.transport-night         { background: #faf5ff; color: #7c3aed; }
.transport-regional      { background: #f0fdf4; color: #15803d; }
.transport-suburban      { background: #ecfeff; color: #0891b2; }
.transport-metro         { background: #fff7ed; color: #c2410c; }
.transport-tram          { background: #fffbeb; color: #b45309; }
.transport-bus           { background: #f5f3ff; color: #6d28d9; }
.transport-ferry         { background: #eff6ff; color: #0369a1; }
.transport-flight        { background: #f8fafc; color: #475569; }
.transport-unknown       { background: #eff6ff; color: #1d4ed8; }

.route-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.5rem;
}

.route-station { min-width: 0; }

.route-station-name {
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.route-station-time {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.route-station-time.delayed { color: var(--danger); }

.route-connector {
    color: #94a3b8;
    font-size: 1.1rem;
    text-align: center;
}

.route-station-dest { text-align: right; }

/* Post content */
.post-content {
    font-size: 0.92rem;
    line-height: 1.55;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}

/* Feed actions */
.feed-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem 0.75rem;
    border-top: 1px solid #f1f5f9;
}

.feed-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.12s ease, color 0.12s ease;
}

.feed-action-btn:hover { background: #f1f5f9; color: var(--text-primary); }

.feed-action-btn.active-like { color: #e11d48; }
.feed-action-btn.active-boost { color: #16a34a; }

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.18rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
}

.status-active   { background: #dcfce7; color: #15803d; }
.status-completed { background: #f1f5f9; color: #475569; }
.status-cancelled { background: #fef2f2; color: #dc2626; }

/* Empty state */
.empty-state {
    padding: 2.5rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
    border: 1.5px dashed var(--card-border);
    border-radius: var(--card-radius);
    background: rgba(255, 255, 255, 0.6);
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.4;
}

/* Buttons */
.btn {
    border-radius: 0.65rem;
    font-weight: 600;
    box-shadow: none !important;
}

.btn-sm { border-radius: 0.5rem; }
.btn-primary { background: linear-gradient(135deg, #2563eb, #1d4ed8); border-color: transparent; }
.btn-success { background: linear-gradient(135deg, #16a34a, #15803d); border-color: transparent; }
.btn-warning { background: var(--accent); border-color: transparent; color: #000; }
.btn-warning:hover { background: #d97706; color: #000; }

.input-group { flex-wrap: nowrap; }
.input-group > .btn { border-radius: 0; }
.input-group > .btn:first-child { border-top-left-radius: 0.65rem; border-bottom-left-radius: 0.65rem; }
.input-group > .btn:last-child { border-top-right-radius: 0.65rem; border-bottom-right-radius: 0.65rem; }

/* Forms */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select, textarea {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--card-border);
    border-radius: 0.65rem;
    background: #fff;
    color: var(--text-primary);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    font-size: 0.9rem;
}

input[type="file"] {
    width: 100%;
    padding: 0.35rem;
    border: 1px solid var(--card-border);
    border-radius: 0.65rem;
    background: #fff;
}

input:focus, select:focus, textarea:focus {
    border-color: rgba(37, 99, 235, 0.5);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea { min-height: 6rem; }

form label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    font-size: 0.88rem;
}

form p { margin-bottom: 0.9rem; }

/* Tables */
.table { --bs-table-bg: transparent; }
.table > :not(caption) > * > * {
    padding: 0.85rem 0.65rem;
    border-bottom-color: var(--card-border);
}
.table thead th {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}

/* Alerts */
.alert { border-radius: 0.8rem; border: 1px solid transparent; }

/* Auth pages */
.auth-shell {
    min-height: calc(100vh - 8rem);
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 28rem;
    padding: 2rem;
}

/* List groups */
.list-group-item { border-color: var(--card-border); }

/* People cards */
.person-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 0;
}

.person-avatar {
    width: 2.8rem;
    height: 2.8rem;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.person-avatar-placeholder {
    width: 2.8rem;
    height: 2.8rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #334155, #475569);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.9rem;
    font-weight: 700;
    flex-shrink: 0;
}

.person-info { flex: 1; min-width: 0; }

.person-display-name {
    font-weight: 700;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.person-handle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Active journey widget */
.active-journey-card {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
    border: none;
    color: white;
}

.active-journey-card .card-header {
    border-bottom-color: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.active-journey-route {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0.35rem 0;
}

.section-stack > * + * { margin-top: 1rem; }

.muted { color: var(--text-muted); }

/* Settings layout */
.settings-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 900px) {
    .settings-layout { grid-template-columns: 1fr; }
}

/* Misc */
.badge { border-radius: 999px; padding: 0.35rem 0.65rem; font-weight: 600; }
