/* ====================================================
   EVCC Custom CSS v3.5 - Tailwind + Custom Styles
   Font: Nunito (Google Fonts)
   Icons: Font Awesome 6 Pro (local fafont/)
   ==================================================== */

/* Google Fonts - Nunito */
@import url('https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,400&family=Noto+Sans+Thai:wght@300;400;500;600;700&display=swap');

/* Font Awesome 6 Pro - Local */
@import url('../fafont/css/all.min.css');

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Nunito', 'Noto Sans Thai', sans-serif;
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

/* ---- Color Variables ---- */
:root {
    --brand: #f97316;
    --brand-dark: #ea580c;
    --brand-light: #fff7ed;
    --brand-subtle: #ffedd5;
    --sidebar-bg: #18181b;
    --sidebar-width: 240px;
}

/* ==============================
   AUTH PAGES (login/register/otp)
   ============================== */

.auth-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1c1917 0%, #292524 50%, #1c1917 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    position: relative;
    overflow: hidden;
}

.auth-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 40%, rgba(249,115,22,0.12) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 60%, rgba(234,88,12,0.08) 0%, transparent 50%);
    pointer-events: none;
}

.auth-card {
    background: rgba(28, 25, 23, 0.95);
    border: 1px solid rgba(249,115,22,0.15);
    border-radius: 1.25rem;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5), 0 0 0 1px rgba(249,115,22,0.1);
    backdrop-filter: blur(20px);
}

.auth-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
}

.auth-logo img {
    height: 76px;
    width: auto;
    object-fit: contain;
    margin-bottom: 0.75rem;
    filter: drop-shadow(0 4px 12px rgba(249,115,22,0.3));
}

.auth-logo h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #f5f5f4;
    margin: 0 0 0.25rem;
}

.auth-logo p {
    font-size: 0.8rem;
    color: #a8a29e;
    margin: 0;
    font-weight: 400;
}

/* Auth form inputs */
.auth-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #d6d3d1;
    margin-bottom: 0.1rem;
    text-transform: uppercase;
}

.auth-input {
    width: 100%;
    background: rgba(41,37,36,0.8);
    border: 1.5px solid rgba(87,83,78,0.5);
    border-radius: 0.625rem;
    padding: 0.7rem 1rem;
    color: #f5f5f4;
    font-size: 0.875rem;
    font-family: 'Nunito', 'Noto Sans Thai', sans-serif;
    transition: all 0.2s ease;
    outline: none;
}

.auth-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(249,115,22,0.15);
    background: rgba(41,37,36,0.95);
}

.auth-input.is-valid {
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34,197,94,0.1);
}

.auth-input.is-invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239,68,68,0.1);
}

.auth-input::placeholder {
    color: #78716c;
}

.auth-input-wrapper {
    position: relative;
}

.auth-input-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: #78716c;
    font-size: 0.875rem;
    pointer-events: none;
}

.auth-input-wrapper .auth-input {
    padding-left: 2.5rem;
}

.auth-feedback {
    font-size: 0.75rem;
    margin-top: 0.3rem;
}

.auth-feedback.valid { color: #4ade80; }
.auth-feedback.invalid { color: #f87171; }
.auth-feedback.info { color: #94a3b8; }

/* Auth button */
.auth-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: white;
    border: none;
    border-radius: 0.625rem;
    padding: 0.8rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 700;
    font-family: 'Nunito', 'Noto Sans Thai', sans-serif;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(249,115,22,0.3);
}

.auth-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(249,115,22,0.4);
    background: linear-gradient(135deg, #fb923c 0%, var(--brand) 100%);
}

.auth-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(249,115,22,0.3);
}

.auth-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Auth divider & links */
.auth-link-row {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.82rem;
    color: #78716c;
}

.auth-link-row a {
    color: var(--brand);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.auth-link-row a:hover { color: #fb923c; }

/* Alert messages */
.auth-alert {
    border-radius: 0.625rem;
    padding: 0.75rem 1rem;
    font-size: 0.825rem;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.auth-alert.success {
    background: rgba(34,197,94,0.1);
    border: 1px solid rgba(34,197,94,0.3);
    color: #86efac;
}

.auth-alert.error {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.3);
    color: #fca5a5;
}

.auth-alert.warning {
    background: rgba(234,179,8,0.1);
    border: 1px solid rgba(234,179,8,0.3);
    color: #fde047;
}

/* Auth footer */
.auth-footer {
    text-align: center;
    margin-top: 2rem;
    font-size: 0.72rem;
    color: #57534e;
}

/* ==============================
   COLOR SELECTION (for register)
   ============================== */
.color-selection-area {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    padding: 0.5rem 0;
}

.color-btn-sm {
    position: relative;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 2px solid rgba(87,83,78,0.5);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
}

.color-btn-sm::after {
    content: '\2713';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    opacity: 0;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    transition: opacity 0.2s;
}

.color-btn-sm.selected {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(249,115,22,0.3);
    transform: scale(1.15);
}

.color-btn-sm.selected::after { opacity: 1; }

.color-btn-sm:hover { transform: scale(1.1); }
.color-btn-sm.selected:hover { transform: scale(1.15); }

/* ==============================
   OTP INPUT
   ============================== */
.otp-inputs {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.otp-digit {
    width: 52px;
    height: 60px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    background: rgba(41,37,36,0.8);
    border: 2px solid rgba(87,83,78,0.5);
    border-radius: 0.75rem;
    color: #f5f5f4;
    font-family: 'Nunito', monospace;
    transition: all 0.2s;
    outline: none;
}

.otp-digit:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(249,115,22,0.2);
    background: rgba(41,37,36,0.95);
}

.otp-digit.filled {
    border-color: rgba(249,115,22,0.6);
    color: var(--brand);
}

/* OTP Timer */
.otp-timer {
    font-size: 0.85rem;
    font-weight: 600;
}

.otp-timer.active { color: #4ade80; }
.otp-timer.warning { color: #facc15; }
.otp-timer.expired { color: #f87171; }

/* ==============================
   MAIN APP - LAYOUT
   ============================== */

.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: #f9fafb;
}

/* Navbar */
.app-navbar {
    height: 56px;
    min-height: 56px;
    background: linear-gradient(90deg, var(--brand) 0%, var(--brand-dark) 100%);
    display: flex;
    align-items: center;
    padding: 0 0.8rem;
    box-shadow: 0 2px 8px rgba(249,115,22,0.25);
    flex-shrink: 0;
    z-index: 100;
    position: relative;
}

.app-navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    text-decoration: none;
    flex: 1;
}

.app-navbar-brand img {
    height: 40px;
    width: auto;
    object-fit: contain;
    filter: brightness(1.1);
}

.app-navbar-brand span {
    font-size: 1rem;
    font-weight: 700;
    color: white;
}

.app-navbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-menu-toggle {
    display: none;
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 0.5rem;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    font-size: 1rem;
    transition: background 0.2s;
}

.navbar-menu-toggle:hover { background: rgba(255,255,255,0.25); }

@media (max-width: 991px) {
    .navbar-menu-toggle { display: flex; }
    .app-navbar-brand span { font-size: 0.9rem; }
    .navbar-actions-hide-mobile { display: none !important; }
}

/* Sidebar sections visible only on mobile (inside hamburger menu) */
.sidebar-mobile-only { display: none; }
@media (max-width: 991px) {
    .sidebar-mobile-only { display: block; }
}

/* Body = sidebar + main */
.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ---- SIDEBAR / VERTICAL TABS ---- */
.app-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: #1c1917;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease;
    z-index: 50;
    border-right: 1px solid rgba(249,115,22,0.1);
}

.sidebar-top {
    padding: 1rem 0.75rem;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* User panel at top of sidebar */
.sidebar-user {
    background: rgba(249,115,22,0.08);
    border: 1px solid rgba(249,115,22,0.15);
    border-radius: 0.75rem;
    padding: 0.4rem 0.4rem;
    margin-bottom: 1rem;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: white;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: #f5f5f4;
    cursor: pointer;
    transition: color 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-name:hover { color: var(--brand); }

.sidebar-user-email {
    font-size: 0.68rem;
    color: #78716c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tab Navigation */
.sidebar-nav-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #57534e;
    padding: 0 0.625rem;
    margin-bottom: 0.375rem;
}

.sidebar-tab {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.875rem;
    border-radius: 0.625rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.83rem;
    font-weight: 500;
    color: #a8a29e;
    text-decoration: none;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    margin-bottom: 0.125rem;
    font-family: 'Nunito', 'Noto Sans Thai', sans-serif;
}

.sidebar-tab i, .sidebar-tab .fa-icon {
    width: 18px;
    text-align: center;
    font-size: 0.875rem;
    flex-shrink: 0;
    transition: color 0.2s;
}

.sidebar-tab:hover {
    background: rgba(249,115,22,0.08);
    color: #f5f5f4;
}

.sidebar-tab:hover i { color: var(--brand); }

.sidebar-tab.active {
    background: rgba(249,115,22,0.15);
    color: var(--brand);
    font-weight: 600;
}

.sidebar-tab.active i { color: var(--brand); }

.sidebar-tab.tab-danger {
    color: #f87171;
}

.sidebar-tab.tab-danger:hover {
    background: rgba(239,68,68,0.1);
    color: #fca5a5;
}

.sidebar-tab.tab-admin {
    color: #facc15;
    background: rgba(234,179,8,0.08);
    border: 1px solid rgba(234,179,8,0.15);
}

.sidebar-tab.tab-admin:hover {
    background: rgba(234,179,8,0.15);
    color: #fde047;
}

.sidebar-tab.tab-home {
    color: #38bdf8;
    background: rgba(56,189,248,0.08);
    border: 1px solid rgba(56,189,248,0.15);
}

.sidebar-tab.tab-home:hover {
    background: rgba(56,189,248,0.15);
    color: #7dd3fc;
}

/* Change password — neutral slate style */
.sidebar-tab.tab-pwd {
    color: #a8a29e;
    background: rgba(120,113,108,0.08);
    border: 1px solid rgba(120,113,108,0.2);
}

.sidebar-tab.tab-pwd:hover {
    background: rgba(120,113,108,0.16);
    color: #d6d3d1;
}

.sidebar-tab.tab-pwd i { color: #a8a29e; }
.sidebar-tab.tab-pwd:hover i { color: #d6d3d1; }

/* ── Bottom nav row (Home + Admin) ─────────────────────── */
.sidebar-bottom-nav {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.625rem;
}

.sidebar-bottom-nav-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.5rem;
    border-radius: 0.625rem;
    font-family: 'Nunito','Noto Sans Thai',sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s;
}

.sidebar-bottom-nav-btn.btn-home {
    background: rgba(56,189,248,0.08);
    border: 1px solid rgba(56,189,248,0.2);
    color: #38bdf8;
}

.sidebar-bottom-nav-btn.btn-home:hover {
    background: rgba(56,189,248,0.18);
    color: #7dd3fc;
}

.sidebar-bottom-nav-btn.btn-admin {
    background: rgba(234,179,8,0.08);
    border: 1px solid rgba(234,179,8,0.2);
    color: #facc15;
}

.sidebar-bottom-nav-btn.btn-admin:hover {
    background: rgba(234,179,8,0.16);
    color: #fde047;
}

/* On mobile (≤991px): hide text label inside bottom-nav buttons */
@media (max-width: 991px) {
    .sidebar-bottom-nav-label { display: none; }
}

/* Sidebar divider */
.sidebar-divider {
    height: 1px;
    background: rgba(87,83,78,0.3);
    margin: 0.75rem 0;
}

/* Sidebar bottom */
.sidebar-bottom {
    padding: 0.75rem;
}

.sidebar-version {
    font-size: 0.65rem;
    color: #57534e;
    text-align: center;
    margin-bottom: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(87,83,78,0.2);
}

.sidebar-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem;
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.2);
    border-radius: 0.5rem;
    color: #f87171;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-logout-btn:hover {
    background: rgba(239,68,68,0.2);
    color: #fca5a5;
}

/* ---- MOBILE SIDEBAR ---- */
@media (max-width: 991px) {
    .app-sidebar {
        position: fixed;
        top: 56px;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        z-index: 200;
    }
    
    .app-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,0.5);
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 150;
        backdrop-filter: blur(2px);
    }
    
    .sidebar-overlay.visible { display: block; }
}

/* ---- MAIN CONTENT ---- */
.app-main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.25rem;
    background: #f9fafb;
}

.tab-panel {
    display: none;
    animation: fadeSlide 0.25s ease;
}

.tab-panel.active { display: block; }

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

/* ==============================
   CARDS (main area)
   ============================== */
.ev-card {
    background: #fff;
    border-radius: 0.875rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
    border: 1px solid #f3f4f6;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.ev-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.ev-card-header {
    padding: 0.6rem 0.6rem 0.4rem 0.6rem;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #fafafa;
}

.ev-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.ev-card-icon.orange { background: #fff7ed; color: var(--brand); }
.ev-card-icon.blue { background: #eff6ff; color: #3b82f6; }
.ev-card-icon.green { background: #f0fdf4; color: #22c55e; }
.ev-card-icon.purple { background: #faf5ff; color: #a855f7; }
.ev-card-icon.yellow { background: #fefce8; color: #eab308; }
.ev-card-icon.red { background: #fef2f2; color: #ef4444; }

.ev-card-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: #1f2937;
}

.ev-card-body { padding: 1.25rem; }

/* Stat cards */
.stat-card {
    background: #fff;
    border-radius: 0.875rem;
    padding: 1.25rem 1rem;
    border: 1px solid #f3f4f6;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.stat-card.orange::before { background: linear-gradient(90deg, var(--brand), var(--brand-dark)); }
.stat-card.blue::before { background: linear-gradient(90deg, #3b82f6, #2563eb); }
.stat-card.green::before { background: linear-gradient(90deg, #22c55e, #16a34a); }
.stat-card.yellow::before { background: linear-gradient(90deg, #eab308, #ca8a04); }

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

.stat-card-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: #111827;
    line-height: 1;
    margin-bottom: 0.25rem;
}

@media (max-width: 576px) {
    .stat-card-value {
        font-size: 1.5rem;
    }
}

.stat-card-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #9ca3af;
}

/* ==============================
   Color Selection (index page)
   ============================== */
.color-btn {
    position: relative;
    border-radius: 5px !important;
    border: 2px solid rgba(156,163,175,0.3) !important;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 22px !important;
    height: 22px !important;
}

.color-btn::after {
    content: '\2713';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    opacity: 0;
    text-shadow: 0 0 3px rgba(0,0,0,0.8);
    transition: opacity 0.2s;
}

.color-btn.selected::after { opacity: 1; }

.color-btn.selected {
    border-color: var(--brand) !important;
    box-shadow: 0 0 0 3px rgba(249,115,22,0.25);
    transform: scale(1.15);
}

.color-btn:hover { transform: translateY(-1px) scale(1.05); }

/* ==============================
   CHANGE PASSWORD MODAL (centered)
   ============================== */
.cp-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 999;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.cp-modal-overlay.open { display: flex; }

.cp-modal {
    background: #fff;
    border-radius: 1rem;
    width: 100%;
    max-width: 420px;
    margin: 1rem;
    box-shadow: 0 25px 60px rgba(0,0,0,0.3);
    animation: modalIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
    overflow: hidden;
}

@keyframes modalIn {
    from { transform: scale(0.85) translateY(20px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.cp-modal-header {
    background: linear-gradient(135deg, #1f2937, #111827);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cp-modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cp-modal-close {
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 0.375rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgba(255,255,255,0.8);
    font-size: 0.875rem;
    transition: all 0.2s;
}

.cp-modal-close:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

.cp-modal-body { padding: 1.5rem; }

.cp-modal-footer {
    padding: 1rem 1.5rem;
    background: #f9fafb;
    border-top: 1px solid #f3f4f6;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Form fields (main app) */
.app-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
}

.app-input {
    width: 100%;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.55rem 0.875rem;
    color: #1f2937;
    font-size: 0.875rem;
    font-family: 'Nunito', 'Noto Sans Thai', sans-serif;
    transition: all 0.2s;
    outline: none;
}

.app-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(249,115,22,0.1);
}

/* Buttons (main app) */
.btn-brand {
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: white;
    border: none;
    border-radius: 0.5rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: 'Nunito', 'Noto Sans Thai', sans-serif;
    box-shadow: 0 2px 8px rgba(249,115,22,0.25);
}

.btn-brand:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(249,115,22,0.35);
}

.btn-outline-brand {
    background: transparent;
    color: var(--brand);
    border: 1.5px solid var(--brand);
    border-radius: 0.5rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: 'Nunito', 'Noto Sans Thai', sans-serif;
}

.btn-outline-brand:hover {
    background: var(--brand);
    color: white;
}

.btn-secondary-app {
    background: #f3f4f6;
    color: #4b5563;
    border: none;
    border-radius: 0.5rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Nunito', 'Noto Sans Thai', sans-serif;
}

.btn-secondary-app:hover { background: #e5e7eb; }

/* ==============================
   TABLE Styles
   ============================== */
.ev-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.ev-table th {
    padding: 0.75rem 0.875rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: white;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    white-space: nowrap;
}

.ev-table th:first-child { border-radius: 0.5rem 0 0 0; }
.ev-table th:last-child { border-radius: 0 0.5rem 0 0; }

.ev-table td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
    color: #374151;
}

.ev-table tr:last-child td { border-bottom: none; }

.ev-table tr:hover td {
    background: rgba(249,115,22,0.03);
}

/* Sortable headers */
.ev-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.ev-table th.sortable:hover {
    background: linear-gradient(135deg, #fb923c, var(--brand));
}

/* ==============================
   Toast Notifications
   ============================== */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 360px;
}

.toast-item {
    background: #1c1917;
    border-radius: 0.75rem;
    padding: 0.875rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.05);
    animation: toastIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
    font-size: 0.825rem;
    color: #d6d3d1;
}

.toast-item.success .toast-icon { color: #4ade80; }
.toast-item.error .toast-icon { color: #f87171; }
.toast-item.info .toast-icon { color: #60a5fa; }
.toast-item.warning .toast-icon { color: #facc15; }

.toast-icon { font-size: 1rem; flex-shrink: 0; margin-top: 0.1rem; }
.toast-title { font-weight: 700; font-size: 0.825rem; color: #f5f5f4; margin-bottom: 0.15rem; }
.toast-message { font-size: 0.78rem; color: #a8a29e; }

@keyframes toastIn {
    from { transform: translateX(100%) scale(0.8); opacity: 0; }
    to { transform: translateX(0) scale(1); opacity: 1; }
}

/* ==============================
   Scrollbar
   ============================== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(120,113,108,0.4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(120,113,108,0.7); }

/* ==============================
   Utilities
   ============================== */
.text-brand { color: var(--brand); }
.bg-brand { background: var(--brand); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Spinner */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==============================
   Legacy Bootstrap compatibility 
   (for index.ejs calculator section)
   ============================== */
.form-control {
    display: block;
    width: 100%;
    padding: 0.55rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.5;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 0.5rem;
    color: #1f2937;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: 'Nunito', 'Noto Sans Thai', sans-serif;
}

.form-control:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(249,115,22,0.1);
}

.form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 0.1rem;
}

.form-text {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 0.25rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25em 0.6em;
    font-size: 0.72em;
    font-weight: 700;
    border-radius: 9999px;
}

.badge-orange {
    background: rgba(249,115,22,0.15);
    color: var(--brand);
}

/* Car image styles */
#carImage {
    transition: all 0.5s ease-in-out;
    border-radius: 0.875rem;
}

.car-image-hidden {
    opacity: 0 !important;
    transform: scale(0.95);
}

.car-image-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 220px;
}

.spinner-border {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    border: 3px solid rgba(249,115,22,0.2);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
}

/* ---- Custom Searchable Dropdown ---- */
.ev-dropdown { position: relative; width: 100%; }

.ev-dropdown-btn {
    width: 100%; display: flex; align-items: center; justify-content: space-between;
    padding: 0.5rem 0.75rem; border: 1.5px solid #d1d5db; border-radius: 0.5rem;
    background: #fff; cursor: pointer; font-size: 0.85rem; color: #374151;
    font-family: inherit; transition: border-color 0.2s;
    text-align: left; gap: 0.5rem;
}
.ev-dropdown-btn:focus { outline: none; border-color: var(--brand); }
.ev-dropdown-btn .ev-dd-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-dropdown-btn .ev-dd-chevron { flex-shrink: 0; transition: transform 0.2s; color: #9ca3af; font-size: 0.75rem; }
.ev-dropdown-btn.open .ev-dd-chevron { transform: rotate(180deg); }
.ev-dropdown-btn.open { border-color: var(--brand); }

.ev-dropdown-menu {
    position: fixed; z-index: 99999; min-width: 200px;
    background: #fff; border: 1.5px solid #e5e7eb; border-radius: 0.5rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    overflow: hidden;
}
.ev-dropdown-menu .ev-dd-search {
    padding: 0.5rem; border-bottom: 1px solid #f3f4f6;
}
.ev-dropdown-menu .ev-dd-search input {
    width: 100%; padding: 0.375rem 0.625rem; border: 1.5px solid #e5e7eb;
    border-radius: 0.375rem; font-size: 0.8rem; font-family: inherit; outline: none;
    background: #f9fafb;
}
.ev-dropdown-menu .ev-dd-search input:focus { border-color: var(--brand); background: #fff; }
.ev-dropdown-menu .ev-dd-list {
    max-height: 200px; overflow-y: auto;
}
.ev-dropdown-menu .ev-dd-item {
    padding: 0.45rem 0.75rem; font-size: 0.83rem; color: #374151; cursor: pointer;
    transition: background 0.12s;
}
.ev-dropdown-menu .ev-dd-item:hover, .ev-dropdown-menu .ev-dd-item.selected {
    background: #fff7ed; color: var(--brand);
}
.ev-dropdown-menu .ev-dd-empty {
    padding: 0.6rem 0.75rem; font-size: 0.8rem; color: #9ca3af; text-align: center;
}

/* Dark-theme variant (register page) */
.ev-dropdown.dark .ev-dropdown-btn {
    background: rgba(28,25,23,0.8); border-color: rgba(87,83,78,0.6);
    color: #d6d3d1;
}
.ev-dropdown.dark .ev-dropdown-btn.open, .ev-dropdown.dark .ev-dropdown-btn:focus {
    border-color: var(--brand);
}
.ev-dropdown.dark .ev-dropdown-menu {
    background: #1c1917; border-color: rgba(87,83,78,0.6);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.ev-dropdown.dark .ev-dd-search { border-bottom-color: rgba(87,83,78,0.4); }
.ev-dropdown.dark .ev-dd-search input {
    background: rgba(87,83,78,0.3); border-color: rgba(87,83,78,0.5); color: #d6d3d1;
}
.ev-dropdown.dark .ev-dd-search input:focus { border-color: var(--brand); background: rgba(87,83,78,0.4); }
.ev-dropdown.dark .ev-dd-item { color: #d6d3d1; }
.ev-dropdown.dark .ev-dd-item:hover, .ev-dropdown.dark .ev-dd-item.selected {
    background: rgba(249,115,22,0.15); color: #fdba74;
}
.ev-dropdown.dark .ev-dd-empty { color: #78716c; }

/* ---- Charging Calculator grid ---- */
.calc-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
@media (max-width: 479px) {
    .calc-grid-2 { grid-template-columns: 1fr; }
}

/* ---- Preset Modal responsive ---- */
@media (max-width: 639px) {
    .preset-modal-box {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }
    #presetModal {
        align-items: flex-end !important;
    }
}
