:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --text-color: #333;
    --light-gray: #f5f5f5;
    --border-color: #ddd;
    --error-color: #e74c3c;
    --sidebar-width: 280px;
    --pop-duration: .8s;
    --tilt: 8deg;
    --glow: 28px;
}

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

html {
    height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: #f9f9f9;
    overflow-x: hidden;
}

/* ================== LOGIN STYLES ================== */
#login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 15px;
}

.login-container {
    background-color: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
    animation: fadeIn 0.5s ease-in-out;
}

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

.login-header h1 {
    color: var(--primary-color);
    margin-bottom: 8px;
    font-size: 1.8rem;
}

.login-header p {
    color: #666;
    margin-bottom: 30px;
}

.login-form .input-group {
    position: relative;
    margin-bottom: 20px;
}

.login-form .input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
}

.login-form input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.login-form button {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
}

.login-form button:hover {
    background-color: var(--secondary-color);
}

.login-form button:active {
    transform: scale(0.98);
}

.login-status {
    margin-top: 15px;
    color: var(--error-color);
    font-size: 0.9rem;
    height: 1em;
}

.signout-btn {
    color: var(--accent-color) !important;
    font-weight: 600;
}
.signout-btn:hover {
    background-color: #fceae8 !important;
}


/* ================== MAIN APP STYLES (Unchanged) ================== */

#app-container {
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
}

.mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: var(--primary-color);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.menu-toggle, .close-menu {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
}

.header-time {
    font-size: 0.9rem;
}

.sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: var(--sidebar-width);
    height: 100%;
    background-color: white;
    z-index: 1000;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    will-change: transform;
}

.sidebar.active {
    left: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: var(--primary-color);
    color: white;
}

.sidebar ul {
    list-style: none;
    padding: 0;
}

.sidebar li {
    border-bottom: 1px solid var(--border-color);
}

.report-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 15px;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-color);
    transition: background-color 0.2s;
}

.report-btn:hover {
    background-color: var(--light-gray);
}

.report-btn.active {
    background-color: var(--secondary-color);
    color: white;
}

.report-btn i {
    width: 20px;
    text-align: center;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.overlay.active {
    opacity: 1;
    pointer-events: all;
}

.container {
    max-width: 1200px;
    margin: 60px auto 0;
    padding: 15px;
}

.report-section { display: none; }
.report-section.active { display: block; }

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}
.dashboard-header h2 {
    color: var(--primary-color);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
}
.dashboard-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}
.dashboard-controls select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
}
.refresh-btn {
    padding: 8px 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}
.refresh-btn:hover {
    background-color: var(--secondary-color);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.dashboard-card {
    border-radius: 12px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    transform-style: preserve-3d;
    transition: transform .25s ease, box-shadow .25s ease;
    background: radial-gradient(120% 120% at 10% 0%, #ffffff 0%, #f7f9fc 45%, #eef3fb 100%);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.05);
}
.dashboard-card::before {
    content:"";
    position:absolute; inset: -1px;
    border-radius: 14px;
    background: conic-gradient(from 180deg, #7cc6ff, #bdb2ff, #ffd6a5, #9bf6ff, #7cc6ff);
    z-index: -1;
    filter: blur(6px);
    opacity:.6;
    animation: borderSpin 6s linear infinite;
}
@keyframes borderSpin { to { transform: rotate(360deg); } }

.dashboard-card::after {
    content:"";
    position:absolute; inset:0;
    border-radius:12px;
    background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,.35) 50%, transparent 70%);
    transform: translateX(-120%);
    opacity:0; pointer-events:none;
}
.dashboard-card:hover::after {
    opacity:1; animation: sheenPass 1.2s ease;
}
@keyframes sheenPass { to { transform: translateX(120%); } }

.dashboard-card:hover {
    transform: perspective(900px) rotateX(calc(var(--my, 0) * var(--tilt))) rotateY(calc(var(--mx, 0) * var(--tilt))) translateY(-6px) scale(1.01);
    box-shadow: 0 var(--glow) var(--glow) -16px rgba(0,0,0,.25);
}

[data-animate] {
    opacity:0; transform: translateY(28px) scale(.98);
}
[data-animate].in-view {
    animation: popIn var(--pop-duration) cubic-bezier(.22,.9,.24,1) forwards;
}
@keyframes popIn {
    0% { opacity:0; transform: translateY(28px) scale(.98); filter: blur(2px); }
    100% { opacity:1; transform: translateY(0) scale(1); filter: blur(0); }
}

.card-content { display: flex; align-items: center; gap: 15px; position: relative; z-index: 2; }
.card-icon {
    width: 50px; height: 50px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; color: white; transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.total-vehicles .card-icon { background: linear-gradient(135deg, #3498db, #2980b9); }
.yearly-spending .card-icon { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.current-year .card-icon { background: linear-gradient(135deg, #9b59b6, #8e44ad); }
.highest-spender .card-icon { background: linear-gradient(135deg, #e67e22, #d35400); }

.dashboard-card:hover .card-icon { transform: rotate(15deg) scale(1.1); box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15); }
.card-text h3 { font-size: 0.9rem; color: #666; margin-bottom: 5px; font-weight: 500; }
.card-text p { font-size: 1.5rem; font-weight: 700; color: var(--primary-color); margin: 0; }

.metric-pulse { animation: metricPulse .6s ease; }
@keyframes metricPulse {
    0% { transform: scale(.98); opacity:.85; }
    50% { transform: scale(1.02); opacity:1; }
    100% { transform: scale(1); }
}

.highest-spender .road-stripe {
    position:absolute; left:-20%; right:-20%; bottom:14px; height:2px;
    background: repeating-linear-gradient(90deg, rgba(0,0,0,.08), rgba(0,0,0,.08) 12px, transparent 12px, transparent 24px);
    animation: roadMove 2.2s linear infinite; z-index:0;
}
@keyframes roadMove { to { transform: translateX(20%); } }

.highest-spender .exhaust {
    position:absolute; bottom:12px; left: calc(50% - 80px);
    width: 6px; height: 6px; border-radius:50%;
    background: radial-gradient(circle at 40% 40%, #bbb, #999);
    filter: blur(1px); opacity:.0;
    animation: puff 1.4s ease-in-out infinite; z-index:1;
}
@keyframes puff {
    0% { transform: translateX(0) translateY(0) scale(.6); opacity:.0; }
    30% { opacity:.5; }
    100% { transform: translateX(-40px) translateY(-8px) scale(1.8); opacity:0; }
}
.highest-spender .top-spender-car { position:absolute; bottom:6px; left:-80px; z-index:2; opacity:.97; }
.highest-spender .top-spender-car i { font-size:30px; animation: drive 6s linear infinite, carbounce 1.2s ease-in-out infinite; }
@keyframes drive { 0%{transform: translateX(0)} 50%{transform: translateX(calc(100% + 140px))} 100%{transform: translateX(0)} }
@keyframes carbounce { 0%,100%{transform: translateY(0)} 50%{transform: translateY(-3px)} }

.highest-spender .fireworks { position:absolute; inset:0; pointer-events:none; z-index:1; }
.highest-spender .fireworks .burst {
    position:absolute; width:6px; height:6px; border-radius:50%;
    background: currentColor; opacity:0; transform: translate(-50%, -50%) scale(0);
    top: 50%; left: 50%; color:#ff6b6b;
}
.highest-spender.fire .fireworks .burst { animation: explode 950ms ease-out forwards; }
.highest-spender .fireworks .b2{ color:#ffd93d; } .highest-spender .fireworks .b3{ color:#51cf66; }
.highest-spender .fireworks .b4{ color:#74c0fc; } .highest-spender .fireworks .b5{ color:#b197fc; } .highest-spender .fireworks .b6{ color:#ffa94d; }
.highest-spender.fire .fireworks .b1{ animation-delay:0ms; }   .highest-spender.fire .fireworks .b2{ animation-delay:60ms; }
.highest-spender.fire .fireworks .b3{ animation-delay:120ms; } .highest-spender.fire .fireworks .b4{ animation-delay:180ms; }
.highest-spender.fire .fireworks .b5{ animation-delay:240ms; } .highest-spender.fire .fireworks .b6{ animation-delay:300ms; }
@keyframes explode {
    0% { opacity:0; transform: translate(-50%, -50%) scale(0) }
    20% { opacity:1; }
    100% { opacity:0; transform: translate(-50%, -250%) scale(10) }
}

.dashboard-chart, .dashboard-table {
    background: white; border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 20px;
}
.dashboard-chart { grid-column: span 1; }
.dashboard-table { grid-column: span 2; }

.chart-header, .table-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.chart-header h3, .table-header h3 { font-size: 1.1rem; color: var(--primary-color); display: flex; align-items: center; gap: 8px; }
.chart-action-btn { padding: 6px 10px; background-color: var(--light-gray); border: none; border-radius: 4px; cursor: pointer; }

.chart-container {
    position: relative;
    height: 250px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.chart-wrapper {
    position: relative;
    height: 100%;
    min-width: 550px;
}

.table-search { display: flex; align-items: center; gap: 5px; }
.table-search input { padding: 8px 12px; border: 1px solid var(--border-color); border-radius: 4px; min-width: 200px; }
.table-search button { padding: 8px 10px; background-color: var(--light-gray); border: none; border-radius: 4px; cursor: pointer; }
.table-container {
    overflow-x: auto;
    max-height: 400px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    position: relative;
}

.chart-container::after,
.table-container::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to right, rgba(255, 255, 255, 0), white 70%);
    pointer-events: none;
    z-index: 2;
}

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    vertical-align: middle;
}
th { background-color: var(--primary-color); color: white; position: sticky; top: 0; z-index: 1; }
tbody tr:hover { background-color: #f9f9f9; }
.financial { text-align: right; font-family: 'Courier New', monospace; font-weight: 500; }
.total-row { font-weight: 700; background-color: #f0f7ff; }
.total-row td { border-top: 2px solid var(--primary-color); }
.action-btn { padding: 5px 8px; background-color: var(--secondary-color); color: white; border: none; border-radius: 4px; cursor: pointer; transition: background-color 0.2s; }
.action-btn:hover { background-color: var(--primary-color); }

.filters, .filter-controls { display: flex; gap: 10px; margin-bottom: 15px; flex-wrap: wrap; }
.search-box { display: flex; gap: 10px; flex-grow: 1; }
.search-box input, .filter-controls input, .filter-controls select { flex: 1; padding: 12px; border: 1px solid var(--border-color); border-radius: 8px; font-size: 1rem; }
.search-box button, .filter-controls button { padding: 12px 15px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 5px; transition: background-color 0.2s; }
.search-box button { background-color: var(--secondary-color); color: white; }
.filter-controls button:not(.print-btn) { background-color: #f0f0f0; }

.print-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.95rem;
    background-color: var(--primary-color);
    color: white;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 2px 5px rgba(44, 62, 80, 0.15);
}
.print-btn:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.2);
}

.loading-indicator { text-align: center; padding: 30px; }
.spinner { border: 4px solid rgba(0, 0, 0, 0.1); border-top: 4px solid var(--primary-color); border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin: 0 auto 15px; }
@keyframes spin { 100% { transform: rotate(360deg); } }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 15px; }
.summary-item { background-color: #f8f9fa; border-radius: 4px; padding: 10px; display: flex; justify-content: space-between; align-items: center; }

.full-report-controls { margin-bottom: 20px; text-align: right; }
.full-report-table th.blue-header { background-color: #3498db; color: white; }
.full-report-table th.red-header { background-color: #e74c3c; color: white; }

footer { margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--border-color); text-align: center; color: #777; font-size: 0.8rem; }

.auth-card { background:#fff; border:1px solid #ddd; border-radius:10px; padding:12px; margin-bottom:12px; }
.auth-status { font-weight:600; margin-bottom: 8px; }
.auth-actions { display:flex; gap:8px; flex-wrap:wrap; }
.auth-actions input { padding:8px; border:1px solid #ddd; border-radius:6px; }
input:disabled { opacity: 0.8; cursor: not-allowed; background: #f1f3f5; }

.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0;
    height: 64px; background: #ffffff;
    border-top: 1px solid var(--border-color);
    display: flex; justify-content: space-around;
    z-index: 1000; box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
    padding-bottom: env(safe-area-inset-bottom);
    backface-visibility: hidden; transform: translateZ(0); will-change: transform;
}
.bottom-nav .nav-item {
    background: transparent; border: none;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 6px; font-size: 0.75rem; color: #666;
    flex: 1 1 25%; height: 100%; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.bottom-nav .nav-item i { font-size: 1.1rem; }
.bottom-nav .nav-item.active { color: var(--secondary-color); }

@media (min-width: 768px) {
    .mobile-header, .bottom-nav { display: none; }
    #app-container { padding-bottom: 0; }
    .sidebar { position: static; width: auto; height: auto; background: none; box-shadow: none; }
    .sidebar-header { display: none; }
    .sidebar ul { display: flex; gap: 10px; margin-bottom: 20px; }
    .sidebar li { border-bottom: none; }
    .report-btn { padding: 12px 20px; border-radius: 8px; background-color: #e0e0e0; }
    .report-btn.active { background-color: var(--primary-color); color: white; }
    .overlay { display: none; }
    .container { margin-top: 20px; padding: 20px; }
    .dashboard-grid { grid-template-columns: repeat(4, 1fr); }
    .dashboard-chart { grid-column: span 2; }
    .chart-container::after, .table-container::after {
        display: none;
    }
}
@media (max-width: 767px) {
    .dashboard-grid { grid-template-columns: 1fr 1fr; }
    .dashboard-chart, .dashboard-table { grid-column: span 2; }
}
@media (max-width: 480px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .dashboard-chart, .dashboard-table { grid-column: span 1; }
    .search-box, .filter-controls { flex-direction: column; }
    .search-box input, .search-box button, .filter-controls select, .filter-controls input, .filter-controls button { width: 100%; }
}

@media (max-width: 1199.98px) {
    .container { margin-top: 80px !important; }
    #dashboard, #singleReport, #fullReport, #adminSection { content-visibility: auto; contain-intrinsic-size: 1200px; }
    .dashboard-card, .dashboard-chart, .dashboard-table { animation: none !important; opacity: 1 !important; transform: none !important; }
}
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}