/* ============================================================
   ServicePro — Main Stylesheet
   Design System with CSS Variables + Dark Mode support
   ============================================================ */

/* ── Google Font loaded in layout ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ── */
:root {
    --primary:      #4361ee;
    --primary-dark: #3a56d4;
    --primary-light:rgba(67, 97, 238, 0.12);
    --secondary:    #3f37c9;
    --success:      #10b981;
    --success-light:rgba(16, 185, 129, 0.12);
    --warning:      #f59e0b;
    --warning-light:rgba(245, 158, 11, 0.12);
    --danger:       #ef4444;
    --danger-light: rgba(239, 68, 68, 0.12);
    --info:         #06b6d4;
    --info-light:   rgba(6, 182, 212, 0.12);

    --dark:         #0f172a;
    --dark-2:       #1e293b;
    --dark-3:       #334155;
    --surface:      #ffffff;
    --surface-2:    #f8fafc;
    --surface-3:    #f1f5f9;
    --border:       #e2e8f0;
    --border-dark:  #cbd5e1;

    --text:         #0f172a;
    --text-muted:   #64748b;
    --text-light:   #94a3b8;

    --sidebar-bg:   #0f172a;
    --sidebar-w:    260px;
    --topbar-h:     64px;

    --radius:       10px;
    --radius-lg:    16px;
    --radius-sm:    6px;

    --shadow-sm:    0 1px 3px rgba(0,0,0,0.08);
    --shadow:       0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg:    0 12px 40px rgba(0,0,0,0.12);

    --transition:   0.2s ease;
    --font:         'Inter', -apple-system, sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--surface-2);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button { font-family: var(--font); cursor: pointer; }

/* ── Utilities ── */
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 24px; }
.py-4 { padding: 24px 0; }

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: width var(--transition);
    position: relative;
    z-index: 100;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.brand-icon {
    width: 38px; height: 38px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 1rem;
    flex-shrink: 0;
}
.brand-name { color: white; font-weight: 700; font-size: 1rem; line-height: 1.2; }
.brand-version { color: rgba(255,255,255,0.35); font-size: 0.7rem; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    margin: 8px 10px;
    background: rgba(255,255,255,0.05);
    border-radius: var(--radius-sm);
}
.user-avatar {
    width: 34px; height: 34px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 700; font-size: 0.85rem;
    flex-shrink: 0;
}
.user-name { color: white; font-size: 0.85rem; font-weight: 600; line-height: 1.2; }
.user-role { color: rgba(255,255,255,0.4); font-size: 0.72rem; text-transform: capitalize; }

.sidebar-nav {
    flex: 1;
    padding: 8px 10px;
    overflow-y: auto;
    scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.6);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    position: relative;
    margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-item.active { background: var(--primary); color: white; }
.nav-icon { width: 18px; text-align: center; font-size: 0.95rem; }
.nav-active-dot {
    position: absolute; right: 12px;
    width: 6px; height: 6px;
    background: white; border-radius: 50%;
    opacity: 0.7;
}

.sidebar-footer {
    padding: 8px 10px 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.nav-logout { color: rgba(239,68,68,0.7); }
.nav-logout:hover { background: rgba(239,68,68,0.15); color: #ef4444; }

/* ============================================================
   MAIN AREA
   ============================================================ */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* TOPBAR */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
    position: relative;
    z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.sidebar-toggle {
    background: none; border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: none;
}
.sidebar-toggle:hover { background: var(--surface-3); color: var(--text); }

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

.topbar-btn {
    background: none; border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    width: 38px; height: 38px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    position: relative;
    transition: var(--transition);
}
.topbar-btn:hover { background: var(--surface-3); color: var(--text); }
.notif-badge {
    position: absolute; top: 2px; right: 2px;
    background: var(--danger); color: white;
    border-radius: 10px; padding: 1px 5px;
    font-size: 0.65rem; font-weight: 700;
    border: 2px solid white;
}

.notif-wrapper { position: relative; }
.notif-dropdown {
    display: none;
    position: absolute; top: calc(100% + 8px); right: 0;
    background: var(--surface); width: 320px;
    border-radius: var(--radius); border: 1px solid var(--border);
    box-shadow: var(--shadow-lg); z-index: 200;
    overflow: hidden;
}
.notif-dropdown.show { display: block; animation: fadeDown 0.15s ease; }
.notif-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
.notif-count { font-size: 0.8rem; color: var(--primary); }
.notif-item {
    display: flex; gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: rgba(67,97,238,0.04); }
.notif-dot {
    width: 8px; height: 8px;
    background: var(--primary);
    border-radius: 50%;
    margin-top: 4px; flex-shrink: 0;
}
.notif-item:not(.unread) .notif-dot { background: var(--border-dark); }
.notif-content strong { display: block; font-size: 0.85rem; margin-bottom: 2px; }
.notif-content p { font-size: 0.8rem; color: var(--text-muted); }
.notif-content time { font-size: 0.72rem; color: var(--text-light); }

.topbar-user {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.85rem; font-weight: 500;
    color: var(--text);
}
.topbar-avatar {
    width: 34px; height: 34px;
    background: var(--primary);
    border-radius: 50%;
    color: white; font-weight: 700; font-size: 0.85rem;
    display: flex; align-items: center; justify-content: center;
}

/* PAGE CONTENT */
.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

/* FLASH MESSAGES */
.flash-message {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 20px;
    font-size: 0.9rem; font-weight: 500;
    animation: slideDown 0.3s ease;
    position: relative;
}
.flash-success { background: var(--success-light); color: var(--success); border-left: 3px solid var(--success); }
.flash-error   { background: var(--danger-light);  color: var(--danger);  border-left: 3px solid var(--danger); }
.flash-close {
    position: absolute; right: 14px;
    background: none; border: none;
    font-size: 1.2rem; color: inherit; opacity: 0.6; cursor: pointer;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.page-subtitle { color: var(--text-muted); font-size: 0.875rem; margin-top: 4px; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-card__body {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 20px 20px 16px;
}
.stat-card__label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.stat-card__value { font-size: 1.7rem; font-weight: 800; line-height: 1; color: var(--text); }
.stat-card__badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 8px; border-radius: 20px;
    font-size: 0.72rem; font-weight: 600;
    margin-top: 8px;
}
.badge-up   { background: var(--success-light); color: var(--success); }
.badge-warn { background: var(--warning-light); color: var(--warning); }
.badge-info { background: var(--info-light);    color: var(--info); }

.stat-card__icon {
    width: 48px; height: 48px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-card__bar {
    height: 3px;
    background: var(--border);
    position: relative;
    margin: 0 20px 16px;
    border-radius: 2px;
}
.stat-card__bar::after {
    content: '';
    position: absolute; top: 0; left: 0;
    height: 100%; width: var(--fill, 50%);
    border-radius: 2px;
    background: currentColor;
    transition: width 1s ease;
}

/* Per-card colors */
.stat-card--income .stat-card__icon { background: var(--success-light); color: var(--success); }
.stat-card--income .stat-card__bar  { color: var(--success); }
.stat-card--done   .stat-card__icon { background: var(--primary-light); color: var(--primary); }
.stat-card--done   .stat-card__bar  { color: var(--primary); }
.stat-card--pending .stat-card__icon { background: var(--warning-light); color: var(--warning); }
.stat-card--pending .stat-card__bar  { color: var(--warning); }
.stat-card--quotes  .stat-card__icon { background: var(--info-light); color: var(--info); }
.stat-card--quotes  .stat-card__bar  { color: var(--info); }
.stat-card--customers .stat-card__icon { background: rgba(99,102,241,0.12); color: #6366f1; }
.stat-card--customers .stat-card__bar  { color: #6366f1; }

/* ============================================================
   PANEL
   ============================================================ */
.panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    overflow: hidden;
}
.panel-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.panel-title {
    font-size: 0.95rem; font-weight: 600;
    display: flex; align-items: center; gap: 8px;
}
.panel > *:not(.panel-header):not(.table-responsive):not(.data-table) {
    padding-left: 20px; padding-right: 20px;
}
.panel > .panel-header ~ * { }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem; font-weight: 600;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}
.btn:active { transform: scale(0.98); }

.btn-primary   { background: var(--primary); border-color: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline   { background: transparent; border-color: var(--border-dark); color: var(--text); }
.btn-outline:hover { background: var(--surface-3); border-color: var(--border-dark); }
.btn-ghost     { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger    { background: var(--danger); border-color: var(--danger); color: white; }
.btn-warning   { background: var(--warning); border-color: var(--warning); color: white; }
.btn-success   { background: var(--success); border-color: var(--success); color: white; }

.btn-sm   { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg   { padding: 13px 28px; font-size: 1rem; }
.btn-block { width: 100%; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.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 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem; font-family: var(--font);
    color: var(--text); background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    -webkit-appearance: none;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-control--sm { padding: 7px 10px; font-size: 0.8rem; }
.form-control--amount { padding-left: 32px; font-size: 1rem; font-weight: 600; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 5px; display: block; }

.amount-input-wrapper { position: relative; }
.currency-symbol {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-weight: 600; font-size: 0.9rem;
    pointer-events: none;
}

.input-addon { display: flex; gap: 8px; }
.input-addon .form-control { flex: 1; }
.addon-btn {
    display: flex; align-items: center; justify-content: center;
    padding: 0 14px;
    background: var(--surface); border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-muted);
    transition: var(--transition); flex-shrink: 0;
}
.addon-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

.form-actions { display: flex; gap: 10px; padding: 20px; border-top: 1px solid var(--border); }
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

/* Radio Cards */
.radio-group { display: flex; gap: 10px; }
.radio-card {
    flex: 1; display: flex; align-items: center; gap: 10px;
    padding: 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}
.radio-card input { display: none; }
.radio-card:has(input:checked) { border-color: var(--primary); background: var(--primary-light); }
.radio-card__icon { font-size: 1.1rem; color: var(--text-muted); }
.radio-card:has(input:checked) .radio-card__icon { color: var(--primary); }
.radio-card__label { font-size: 0.85rem; font-weight: 500; }

/* Billing Summary */
.billing-summary {
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
}
.billing-row {
    display: flex; justify-content: space-between;
    padding: 6px 0;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
}
.billing-row:last-child { border-bottom: none; }
.billing-row--total {
    font-weight: 700; font-size: 1rem; color: var(--primary);
    padding-top: 10px; margin-top: 4px;
}

/* QR PIN Section */
.qr-pin-section {
    background: linear-gradient(135deg, rgba(67,97,238,0.06), rgba(63,55,201,0.04));
    border: 1px dashed var(--primary);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 16px;
}
.qr-pin-header {
    display: flex; align-items: center; gap: 8px;
    font-weight: 600; font-size: 0.875rem;
    color: var(--primary); margin-bottom: 12px;
}

/* Password field */
.password-wrapper { position: relative; }
.password-toggle {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    background: none; border: none;
    color: var(--text-muted); cursor: pointer;
    padding: 4px;
    transition: color var(--transition);
}
.password-toggle:hover { color: var(--text); }

/* Toggle switch */
.toggle-wrapper { display: flex; align-items: center; gap: 10px; }
.toggle { position: relative; display: inline-block; width: 42px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0;
    background: var(--border-dark); border-radius: 24px;
    transition: var(--transition); cursor: pointer;
}
.toggle-slider::before {
    content: '';
    position: absolute; left: 3px; bottom: 3px;
    width: 18px; height: 18px;
    background: white; border-radius: 50%;
    transition: var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ============================================================
   TABLES
   ============================================================ */
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    padding: 11px 16px;
    text-align: left;
    font-size: 0.75rem; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 13px 16px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }

.link { color: var(--primary); font-weight: 600; }
.link:hover { text-decoration: underline; }

/* Action buttons in tables */
.actions-cell { display: flex; gap: 6px; align-items: center; }
.action-btn {
    width: 32px; height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 0.8rem;
    cursor: pointer; transition: var(--transition);
    text-decoration: none;
}
.action-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.action-btn--danger:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }

/* Status badges */
.status-badge {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: 20px;
    font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.status-pending   { background: var(--warning-light); color: var(--warning); }
.status-paid      { background: var(--success-light); color: var(--success); }
.status-cancelled { background: var(--danger-light);  color: var(--danger); }
.status-approved  { background: var(--success-light); color: var(--success); }
.status-rejected  { background: var(--danger-light);  color: var(--danger); }

/* Type badges */
.type-badge { padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.type-registered { background: var(--primary-light); color: var(--primary); }
.type-guest { background: var(--surface-3); color: var(--text-muted); }

/* Role badges */
.role-badge { padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.role-admin { background: rgba(99,102,241,0.15); color: #6366f1; }
.role-manager { background: var(--primary-light); color: var(--primary); }
.role-technician { background: var(--info-light); color: var(--info); }

/* Inline status select */
.status-select {
    padding: 4px 8px; font-size: 0.78rem;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text);
    cursor: pointer; outline: none;
}
.status-select:focus { border-color: var(--primary); }

/* Customer avatar cell */
.customer-cell { display: flex; align-items: center; gap: 10px; }
.customer-avatar {
    width: 32px; height: 32px;
    background: var(--primary); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 700; font-size: 0.8rem;
    flex-shrink: 0;
}

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 6px; padding: 16px; }
.page-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 500;
    border: 1px solid var(--border); color: var(--text);
    transition: var(--transition); cursor: pointer;
}
.page-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar { margin-bottom: 16px; }
.filter-form {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: var(--surface); padding: 12px 16px;
    border-radius: var(--radius); border: 1px solid var(--border);
}
.filter-search {
    position: relative; flex: 1; min-width: 200px;
}
.filter-search i {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: 0.85rem;
}
.filter-search input {
    width: 100%; padding: 8px 12px 8px 32px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.875rem; outline: none; background: var(--surface);
}
.filter-search input:focus { border-color: var(--primary); }

/* ============================================================
   INVOICE / QUOTE VIEW
   ============================================================ */
.invoice-layout { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.invoice-sidebar { display: flex; flex-direction: column; gap: 16px; }

.invoice-doc { padding: 0; }
.invoice-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 28px 30px 20px;
    border-bottom: 2px solid var(--primary);
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.invoice-brand { display: flex; align-items: center; gap: 14px; }
.invoice-logo {
    width: 50px; height: 50px; background: rgba(255,255,255,0.2);
    border-radius: var(--radius); display: flex; align-items: center;
    justify-content: center; font-size: 1.4rem;
}
.invoice-company { font-size: 1.3rem; font-weight: 700; }
.invoice-tagline { font-size: 0.8rem; opacity: 0.8; }
.invoice-title { font-size: 2rem; font-weight: 800; opacity: 0.9; }
.invoice-meta-table td, .invoice-meta-table th { padding: 3px 0 3px 12px; font-size: 0.82rem; opacity: 0.9; }

.invoice-parties {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 20px; padding: 20px 30px;
    border-bottom: 1px solid var(--border);
}
.invoice-from h4, .invoice-to h4 {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--text-muted); margin-bottom: 8px;
}
.invoice-from p, .invoice-to p { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 2px; }

.invoice-items { padding: 0; }
.invoice-table { width: 100%; border-collapse: collapse; }
.invoice-table th {
    padding: 12px 16px;
    background: var(--surface-2); font-size: 0.78rem;
    font-weight: 600; color: var(--text-muted); text-transform: uppercase;
    border-bottom: 1px solid var(--border);
}
.invoice-table td { padding: 14px 16px; font-size: 0.875rem; border-bottom: 1px solid var(--border); }
.invoice-total-row td { background: var(--surface-2); font-size: 0.95rem; }
.invoice-grand-total { font-size: 1.1rem; color: var(--primary); }
.invoice-notes {
    padding: 16px 30px;
    border-top: 1px solid var(--border);
}
.invoice-notes h4 { font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; }
.invoice-footer-text { padding: 14px 30px; text-align: center; color: var(--text-muted); font-size: 0.8rem; }

/* QR Panel */
.qr-panel { text-align: center; padding: 20px; }
.qr-image-wrapper {
    position: relative; display: inline-block;
    border: 2px solid var(--border); border-radius: var(--radius);
    overflow: hidden; margin: 12px 0;
}
.qr-image { display: block; max-width: 180px; }
.qr-overlay {
    position: absolute; inset: 0;
    background: rgba(15,23,42,0.7);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: white; gap: 6px;
    font-size: 0.8rem; backdrop-filter: blur(2px);
}
.qr-overlay i { font-size: 1.5rem; opacity: 0.9; }
.qr-hint { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 10px; }
.qr-regen-section { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); text-align: left; }
.quick-status-btns { display: flex; flex-direction: column; gap: 8px; padding: 16px; }

/* Quote view */
.quote-detail-header { display: flex; justify-content: space-between; align-items: center; padding: 20px; border-bottom: 1px solid var(--border); }
.client-avatar {
    width: 48px; height: 48px; background: var(--primary);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 700; font-size: 1.2rem;
}
.quote-client-info { display: flex; align-items: center; gap: 14px; }
.quote-description { padding: 20px; border-bottom: 1px solid var(--border); }
.quote-description h4 { font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.quote-amount { display: flex; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); font-weight: 500; }
.quote-photo { padding: 20px; border-bottom: 1px solid var(--border); }
.quote-photo h4 { font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; }
.quote-ref-photo { max-width: 100%; border-radius: var(--radius); cursor: zoom-in; transition: opacity 0.2s; }
.quote-ref-photo:hover { opacity: 0.9; }
.quote-meta { padding: 14px 20px; font-size: 0.82rem; display: flex; align-items: center; gap: 8px; }

/* Lightbox */
.lightbox {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.85); z-index: 1000;
    align-items: center; justify-content: center; cursor: zoom-out;
}
.lightbox img { max-width: 90%; max-height: 90vh; border-radius: var(--radius); }

/* Upload zone */
.upload-zone {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 30px; border: 2px dashed var(--border);
    border-radius: var(--radius); cursor: pointer;
    transition: var(--transition); min-height: 140px;
    background: var(--surface-2);
}
.upload-zone:hover, .upload-zone.dragging { border-color: var(--primary); background: var(--primary-light); }
.upload-icon { font-size: 2rem; color: var(--text-muted); margin-bottom: 8px; }
.upload-zone:hover .upload-icon, .upload-zone.dragging .upload-icon { color: var(--primary); }
.upload-text { font-weight: 500; font-size: 0.875rem; color: var(--text); }
.upload-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }
.photo-preview-img { width: 100%; border-radius: var(--radius); max-height: 200px; object-fit: cover; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: var(--dark);
    position: relative; overflow: hidden;
}
.login-bg { position: absolute; inset: 0; pointer-events: none; }
.login-orb {
    position: absolute; border-radius: 50%;
    filter: blur(80px); opacity: 0.25;
}
.login-orb-1 { width: 400px; height: 400px; background: var(--primary); top: -100px; right: -100px; }
.login-orb-2 { width: 300px; height: 300px; background: #7c3aed; bottom: -80px; left: -80px; }
.login-orb-3 { width: 200px; height: 200px; background: var(--info); top: 50%; left: 50%; transform: translate(-50%,-50%); }

.login-container {
    width: 100%; max-width: 420px; padding: 20px;
    position: relative; z-index: 1;
}
.login-card {
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.4);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-logo {
    width: 60px; height: 60px; margin: 0 auto 14px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; color: white;
    box-shadow: 0 8px 20px rgba(67,97,238,0.4);
}
.login-title { font-size: 1.5rem; font-weight: 700; color: white; }
.login-subtitle { color: rgba(255,255,255,0.5); font-size: 0.875rem; margin-top: 4px; }

/* Override form controls for dark login page */
.login-card .form-label { color: rgba(255,255,255,0.7); }
.login-card .form-control {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.15);
    color: white;
}
.login-card .form-control::placeholder { color: rgba(255,255,255,0.3); }
.login-card .form-control:focus {
    border-color: var(--primary);
    background: rgba(255,255,255,0.1);
    box-shadow: 0 0 0 3px rgba(67,97,238,0.3);
}
.btn-login { width: 100%; padding: 12px; font-size: 0.95rem; }

.login-footer { text-align: center; margin-top: 20px; font-size: 0.78rem; color: rgba(255,255,255,0.3); }
.login-footer code {
    background: rgba(255,255,255,0.08); padding: 2px 6px;
    border-radius: 3px; font-size: 0.75rem; color: rgba(255,255,255,0.5);
}

.alert {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; border-radius: var(--radius-sm);
    font-size: 0.85rem; margin-bottom: 16px;
}
.alert-danger { background: var(--danger-light); color: #ef4444; border: 1px solid rgba(239,68,68,0.2); }
.login-card .alert-danger { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.3); color: #fca5a5; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-100%); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
    .sidebar, .topbar, .flash-message, .no-print,
    .page-header .page-actions, .filter-bar { display: none !important; }
    .main-area, .app-layout { display: block !important; overflow: visible !important; }
    .page-content { padding: 0 !important; overflow: visible !important; }
    .invoice-doc { box-shadow: none !important; border: none !important; }
    .invoice-header { background: #4361ee !important; -webkit-print-color-adjust: exact; }
    body { background: white !important; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .form-grid { grid-template-columns: 1fr; }
    .invoice-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }
    .sidebar { position: fixed; width: 260px; left: -260px; height: 100%; z-index: 200; transition: left 0.25s ease; }
    .sidebar.open { left: 0; }
    .sidebar-toggle { display: flex !important; }
    .main-area { width: 100%; }
    .page-content { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .topbar-date { display: none; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: 24px 20px; }
    .invoice-parties { grid-template-columns: 1fr; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
