/* =============================================
   ปันทองเซอร์วิส - Modern White Theme
   Apple / Google / HubSpot Inspired
   ============================================= */

/* --- CSS Variables --- */
:root {
    --primary: #6366F1;
    --primary-light: #EEF2FF;
    --primary-dark: #4338CA;
    --success: #10B981;
    --success-light: #ECFDF5;
    --warning: #F59E0B;
    --warning-light: #FFFBEB;
    --danger: #EF4444;
    --danger-light: #FEF2F2;
    --info: #06B6D4;
    --info-light: #ECFEFF;

    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;

    --bg: #F8FAFC;
    --surface: #FFFFFF;
    --text: #0F172A;
    --text-secondary: #64748B;
    --border: #E2E8F0;

    --sidebar-width: 260px;
    --header-height: 56px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.1);

    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
}

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

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--gray-50);
    color: var(--text);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-400);
    padding: 16px 14px 6px;
}

.nav-section-label:first-child {
    padding-top: 0;
}

.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 12px 14px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, #6366F1, #8B5CF6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.btn-logout {
    color: var(--gray-400);
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.btn-logout:hover {
    color: var(--danger);
    background: var(--danger-light);
}

/* --- Mobile Header --- */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    align-items: center;
    gap: 12px;
    z-index: 90;
}

.menu-toggle {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 4px;
}

.mobile-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 99;
    backdrop-filter: blur(2px);
}

/* --- Mobile Bottom Nav --- */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 80;
    padding: 6px 0 env(safe-area-inset-bottom, 6px);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 0;
    color: var(--gray-400);
    font-size: 0.65rem;
    font-weight: 500;
    transition: color var(--transition);
}

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

/* --- Main Content --- */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 32px;
    min-height: 100vh;
}

/* --- Page Header --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.page-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.page-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* --- Cards --- */
.card {
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--gray-50);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* --- Stat Cards (Dashboard) --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    padding: 20px 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-info h3 {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.stat-value.text-success { color: var(--success); }
.stat-value.text-danger { color: var(--danger); }
.stat-value.text-warning { color: var(--warning); }

.stat-change {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    line-height: 1.4;
    white-space: nowrap;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
    color: white;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-outline {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
    color: var(--text);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}

.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--text);
}

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

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.form-label .required {
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    transition: all var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-control::placeholder {
    color: var(--gray-400);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-hint {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* --- Tables --- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table th {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.table tbody tr {
    transition: background var(--transition);
}

.table tbody tr:hover {
    background: var(--gray-50);
}

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

.table .text-right {
    text-align: right;
}

.table .text-center {
    text-align: center;
}

.table .actions {
    display: flex;
    gap: 4px;
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    letter-spacing: 0.02em;
}

.badge-success {
    background: var(--success-light);
    color: #065F46;
}

.badge-warning {
    background: var(--warning-light);
    color: #92400E;
}

.badge-danger {
    background: var(--danger-light);
    color: #B91C1C;
}

.badge-info {
    background: var(--info-light);
    color: #0E7490;
}

.badge-secondary {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* --- Alerts --- */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    animation: slideDown 0.3s ease;
}

.alert-success {
    background: var(--success-light);
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.alert-danger {
    background: var(--danger-light);
    color: #B91C1C;
    border: 1px solid #FECACA;
}

.alert-warning {
    background: var(--warning-light);
    color: #92400E;
    border: 1px solid #FDE68A;
}

.alert-info {
    background: var(--info-light);
    color: #0E7490;
    border: 1px solid #A5F3FC;
}

.alert-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
    padding: 0 4px;
}

.alert-close:hover {
    opacity: 1;
}

/* --- Toasts --- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    min-width: 280px;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    font-size: 0.88rem;
    animation: slideInRight 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }

/* --- Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    animation: scaleIn 0.2s ease;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--gray-400);
    padding: 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* --- Search & Filters --- */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.search-input input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--surface);
    transition: all var(--transition);
    outline: none;
}

.search-input input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.search-input svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--gray-400);
}

/* --- Pagination --- */
.pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
    padding: 0 4px;
}

.table-info {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition);
    cursor: pointer;
    user-select: none;
}

a.page-btn:hover {
    background: var(--gray-100);
    color: var(--text);
}

.page-btn.active {
    background: var(--primary);
    color: white;
    pointer-events: none;
}

.page-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* --- Sortable Table Headers --- */
th.sortable a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

th.sortable a:hover {
    color: var(--primary);
}

th.sorted {
    color: var(--primary);
}

th.sorted a {
    color: var(--primary);
}

/* --- Autocomplete Dropdown --- */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 50;
    max-height: 220px;
    overflow-y: auto;
}

.autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--gray-100);
    transition: background var(--transition);
}

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

.autocomplete-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

/* --- Toggle Group (Radio Buttons) --- */
.toggle-group {
    display: inline-flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.toggle-btn {
    padding: 8px 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    border-right: 1px solid var(--border);
    user-select: none;
}

.toggle-btn:last-child {
    border-right: none;
}

.toggle-btn input[type="radio"] {
    display: none;
}

.toggle-btn:hover {
    background: var(--gray-50);
}

.toggle-btn.active {
    background: var(--primary);
    color: white;
}

/* --- Utility Classes --- */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-secondary) !important; }
.text-bold { font-weight: 600; }
.text-money { font-family: 'Inter', monospace; font-weight: 600; letter-spacing: -0.02em; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }

/* --- Login Page --- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #EEF2FF 0%, #F8FAFC 50%, #ECFEFF 100%);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 48px 40px;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
}

.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* --- Dashboard Sections --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.dashboard-grid .full-width {
    grid-column: 1 / -1;
}

/* --- Renewal Alerts --- */
.renewal-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.renewal-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.renewal-item:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.renewal-item.urgent {
    border-color: var(--danger);
    background: var(--danger-light);
}

.renewal-item.warning {
    border-color: var(--warning);
    background: var(--warning-light);
}

.renewal-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.renewal-info .customer {
    font-weight: 600;
    font-size: 0.9rem;
}

.renewal-info .details {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* --- Invoice Items List --- */
.invoice-items-table {
    width: 100%;
    border-collapse: collapse;
}

.invoice-items-table th,
.invoice-items-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.invoice-items-table th {
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--gray-50);
}

.add-item-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* --- Summary Row --- */
.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.9rem;
}

.summary-row.total {
    font-size: 1.1rem;
    font-weight: 700;
    border-top: 2px solid var(--text);
    padding-top: 12px;
    margin-top: 8px;
}

/* --- Tabs --- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}

.tab-btn {
    padding: 12px 20px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* --- Print Styles --- */
@media print {
    body { background: white; }
    .sidebar, .mobile-header, .bottom-nav, .no-print, .toast-container { display: none !important; }
    .main-content { margin: 0; padding: 0; }
}

/* --- Print: A5 Bill --- */
.print-bill {
    width: 148mm;
    margin: 0 auto;
    padding: 5mm;
    font-size: 11px;
    font-family: 'Inter', 'Noto Sans Thai', sans-serif;
    color: #000;
    background: white;
    box-sizing: border-box;
}

.print-bill .bill-header {
    text-align: center;
    margin-bottom: 12px;
    border-bottom: 2px solid #000;
    padding-bottom: 10px;
}

.print-bill .shop-name {
    font-size: 16px;
    font-weight: 700;
}

.print-bill .bill-title {
    font-size: 14px;
    font-weight: 600;
    margin: 6px 0;
}

.print-bill .bill-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 11px;
}

.print-bill .bill-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 20px;
    margin-bottom: 12px;
}

.print-bill .items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
}

.print-bill .items-table th,
.print-bill .items-table td {
    border: 1px solid #000;
    padding: 4px 8px;
    font-size: 11px;
}

.print-bill .items-table th {
    background: #f0f0f0;
    font-weight: 600;
}

.print-bill .bill-summary {
    text-align: right;
    margin-bottom: 20px;
}

.print-bill .bill-summary .total-line {
    font-size: 14px;
    font-weight: 700;
}

.print-bill .bill-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    font-size: 10px;
}

.print-bill .signature-line {
    width: 120px;
    border-top: 1px solid #000;
    text-align: center;
    padding-top: 4px;
}

/* A4 folded = same as A5 rotated */
.print-a4-folded .print-bill {
    width: 210mm;
    min-height: 148mm;
}

@media print {
    .print-bill {
        width: 100%;
        padding: 0;
        page-break-after: always;
    }
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .mobile-header {
        display: flex;
    }

    .bottom-nav {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
    }

    .main-content {
        margin-left: 0;
        padding: 72px 16px 80px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .table th,
    .table td {
        padding: 10px 12px;
        font-size: 0.82rem;
    }

    .login-card {
        padding: 32px 24px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .page-actions {
        width: 100%;
    }

    .page-actions .btn {
        flex: 1;
        justify-content: center;
    }
}

/* --- Renewal Items (Dashboard) --- */
.renewal-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

a.renewal-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

a.renewal-item:hover {
    background: var(--gray-50);
    border-left-color: var(--primary);
    transform: translateX(4px);
}

a.renewal-item.urgent:hover {
    border-left-color: var(--danger);
}

a.renewal-item.warning:hover {
    border-left-color: var(--warning);
}

/* --- Payment Timeline --- */
.payment-timeline {
    padding: 24px;
}

.timeline-row {
    display: flex;
    gap: 16px;
    position: relative;
}

.timeline-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    width: 32px;
}

.marker-dot {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    z-index: 1;
}

.marker-success {
    background: var(--success);
    color: white;
}

.marker-danger {
    background: var(--danger);
    color: white;
}

.marker-pending {
    background: var(--gray-200);
    color: var(--gray-600);
}

.marker-warning {
    background: var(--warning);
    color: white;
}

.marker-line {
    width: 2px;
    flex: 1;
    background: var(--gray-200);
    min-height: 20px;
}

.timeline-paid .marker-line { background: var(--success); opacity: 0.3; }

.timeline-content {
    flex: 1;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--gray-100);
    margin-bottom: 0;
}

.timeline-row:last-child .timeline-content {
    border-bottom: none;
    padding-bottom: 0;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.timeline-title {
    font-size: 0.9rem;
    color: var(--text);
}

.timeline-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.timeline-amount-area {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.timeline-amount {
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Inter', monospace;
    letter-spacing: -0.02em;
}

.timeline-meta {
    display: flex;
    gap: 12px;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.slip-link {
    color: var(--primary);
    font-weight: 500;
}

.slip-link:hover {
    text-decoration: underline;
}

/* Payment Log Sub-items */
.payment-log-list {
    margin-top: 8px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
}

.payment-log-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 0.8rem;
}

.payment-log-item + .payment-log-item {
    border-top: 1px dotted var(--gray-200);
}

.log-info {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    color: var(--text-secondary);
}

.log-date {
    font-weight: 500;
    color: var(--text);
}

.log-method {
    background: var(--gray-100);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
}

.log-note {
    font-style: italic;
    opacity: 0.8;
}

.log-amount {
    font-weight: 700;
    font-family: 'Inter', monospace;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .timeline-header {
        flex-direction: column;
    }
    .timeline-amount-area {
        flex-direction: row;
        align-items: center;
    }
}

/* --- Slip Lightbox Modal --- */
.slip-lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 300;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.slip-lightbox-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.25s ease;
}

.slip-lightbox-container {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
    width: 92%;
    max-width: 520px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.slip-lightbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--gray-50);
}

.slip-lightbox-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.slip-lightbox-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.slip-lightbox-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.slip-lightbox-btn:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.slip-lightbox-close:hover {
    background: var(--danger-light);
    color: var(--danger);
}

.slip-lightbox-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    min-height: 200px;
    background: var(--gray-50);
}

.slip-lightbox-img {
    max-width: 100%;
    max-height: 72vh;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    object-fit: contain;
    display: none;
    cursor: default;
}

.slip-lightbox-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 0.88rem;
}

.slip-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

@media (max-width: 480px) {
    .slip-lightbox-container {
        width: 96%;
        max-height: 85vh;
    }
    .slip-lightbox-body {
        padding: 12px;
    }
    .slip-lightbox-img {
        max-height: 60vh;
    }
}

/* ============================================= */
/* Reports Page — Chart & Rankings               */
/* ============================================= */

/* --- Daily Revenue Chart --- */
.report-chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 200px;
    padding: 0 4px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}

.chart-col {
    flex: 1;
    min-width: 20px;
    max-width: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    cursor: pointer;
    position: relative;
}

.chart-col:hover .chart-bar {
    filter: brightness(1.15);
    transform: scaleY(1.02);
    transform-origin: bottom;
}

.chart-col.weekend {
    opacity: 0.7;
}

.chart-bars {
    flex: 1;
    width: 100%;
    display: flex;
    gap: 2px;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 2px;
}

.chart-bar {
    width: 100%;
    max-width: 18px;
    min-height: 2px;
    border-radius: 3px 3px 0 0;
    transition: all 0.3s ease;
    animation: chartGrow 0.6s ease-out forwards;
    transform-origin: bottom;
}

.chart-bar.bar-revenue {
    background: linear-gradient(180deg, #34D399, #10B981);
}

.chart-bar.bar-expense {
    background: linear-gradient(180deg, #F87171, #EF4444);
    opacity: 0.6;
}

.chart-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-align: center;
    padding-top: 4px;
    line-height: 1;
    white-space: nowrap;
}

@keyframes chartGrow {
    from { transform: scaleY(0); opacity: 0; }
    to { transform: scaleY(1); opacity: 1; }
}

/* --- Tooltip on hover --- */
.chart-col::before {
    content: attr(title);
    position: absolute;
    bottom: 105%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-900);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.chart-col:hover::before {
    opacity: 1;
}

/* --- Ranking List --- */
.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ranking-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.ranking-rank {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ranking-content {
    flex: 1;
    min-width: 0;
}

.ranking-name {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.ranking-value {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
}

.ranking-bar-bg {
    width: 100%;
    height: 6px;
    background: var(--gray-100);
    border-radius: 3px;
    overflow: hidden;
}

.ranking-bar {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    animation: rankingGrow 0.8s ease-out;
}

@keyframes rankingGrow {
    from { width: 0 !important; }
}

/* Responsive */
@media (max-width: 768px) {
    .report-chart {
        height: 150px;
        gap: 2px;
    }
    .chart-col {
        min-width: 14px;
    }
    .chart-bar {
        max-width: 12px;
    }
    .chart-label {
        font-size: 0.55rem;
    }
    .chart-col::before {
        display: none;
    }
}

@media (max-width: 480px) {
    .report-chart {
        height: 120px;
    }
}

.mt-2 { margin-top: 16px; }

/* =============================================
   New Feature Styles (v2)
   ============================================= */

/* --- Vehicle Selection Highlight --- */
.vehicle-selected {
    background: var(--primary-light) !important;
    border-left: 3px solid var(--primary);
    transition: background var(--transition);
}

.vehicle-selected td:first-child {
    padding-left: 13px;
}

/* --- Drag & Drop (SortableJS) --- */
.drag-handle {
    cursor: grab;
    user-select: none;
    font-size: 1.1rem;
    color: var(--gray-400);
    transition: color var(--transition);
}

.drag-handle:hover {
    color: var(--text);
}

.drag-handle:active {
    cursor: grabbing;
}

.sortable-ghost {
    background: var(--primary-light) !important;
    opacity: 0.6;
    border: 2px dashed var(--primary);
    border-radius: var(--radius-sm);
}

.sortable-drag {
    background: var(--surface) !important;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-sm);
    opacity: 0.95;
}

/* --- Slip Upload --- */
.slip-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--gray-50);
}

.slip-upload-area:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.slip-upload-area .upload-icon {
    font-size: 2rem;
    margin-bottom: 8px;
    color: var(--gray-400);
}

.slip-upload-area .upload-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* --- Selected Vehicle Card (prominent) --- */
.selected-vehicle-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    margin-bottom: 14px;
    background: linear-gradient(135deg, #d1fae5 0%, #ecfdf5 100%);
    border: 2px solid #10b981;
    border-radius: var(--radius-lg);
    animation: vehicleSlideIn 0.3s ease;
}

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

.selected-vehicle-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.selected-vehicle-icon {
    font-size: 1.6rem;
}

.selected-vehicle-text {
    font-size: 1.05rem;
    font-weight: 700;
    color: #065f46;
}

/* Vehicle table row highlight */
.vehicle-selected {
    background: #d1fae5 !important;
}

.vehicle-selected td {
    font-weight: 600;
}
/* --- Cash Drawer Summary --- */
.cash-drawer-summary {
    max-width: 520px;
}

.drawer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
}

.drawer-label {
    font-size: 0.9rem;
    color: var(--text);
}

.drawer-value {
    font-size: 1rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.drawer-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.drawer-total {
    padding: 12px 0;
}

.drawer-total .drawer-label {
    font-weight: 700;
    font-size: 0.95rem;
}

.drawer-total .drawer-value {
    font-size: 1.2rem;
    font-weight: 700;
}

.drawer-alert {
    background: var(--danger-light);
    margin: 0 -24px;
    padding: 12px 24px !important;
    border-radius: var(--radius-sm);
}

.drawer-ok {
    background: var(--success-light);
    margin: 0 -24px;
    padding: 12px 24px !important;
    border-radius: var(--radius-sm);
}

/* --- Close Drawer CTA (Big Prominent Button) --- */
.close-drawer-cta {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: #fff;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.35);
    animation: cta-pulse 2s ease-in-out infinite;
}

.close-drawer-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(220, 53, 69, 0.45);
}

.close-drawer-cta:active {
    transform: translateY(0);
}

.close-drawer-cta.open-cta {
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.35);
    animation: cta-pulse-green 2s ease-in-out infinite;
}

.close-drawer-cta.open-cta:hover {
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.45);
}

@keyframes cta-pulse-green {
    0%, 100% { box-shadow: 0 4px 12px rgba(40, 167, 69, 0.35); }
    50% { box-shadow: 0 4px 20px rgba(40, 167, 69, 0.55); }
}

@keyframes cta-pulse {
    0%, 100% { box-shadow: 0 4px 12px rgba(220, 53, 69, 0.35); }
    50% { box-shadow: 0 4px 20px rgba(220, 53, 69, 0.55); }
}

.cta-icon {
    font-size: 2.2rem;
    line-height: 1;
    flex-shrink: 0;
}

.cta-text {
    flex: 1;
}

.cta-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.cta-subtitle {
    font-size: 0.85rem;
    opacity: 0.85;
}

.cta-expected {
    text-align: right;
    flex-shrink: 0;
}

.cta-expected-label {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-bottom: 2px;
}

.cta-expected-value {
    font-size: 1.4rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
