/* ========================================
   DESIGN SYSTEM — EstimatePro
   ======================================== */

:root {
    /* Colors — Dark Theme */
    --bg-primary: #0f1117;
    --bg-secondary: #161822;
    --bg-tertiary: #1c1f2e;
    --bg-card: #1a1d2e;
    --bg-elevated: #22253a;
    --bg-hover: #262a40;
    --bg-input: #1a1d2e;

    --border-color: #2a2d42;
    --border-hover: #3b3f5c;
    --border-focus: #6366f1;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --text-muted: #475569;

    /* Accent Colors */
    --accent-primary: #6366f1;
    --accent-primary-hover: #818cf8;
    --accent-primary-glow: rgba(99, 102, 241, 0.15);
    --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa);
    --accent-gradient-hover: linear-gradient(135deg, #818cf8, #a78bfa, #c4b5fd);

    /* Status Colors */
    --status-draft: #64748b;
    --status-draft-bg: rgba(100, 116, 139, 0.12);
    --status-sent: #3b82f6;
    --status-sent-bg: rgba(59, 130, 246, 0.12);
    --status-accepted: #10b981;
    --status-accepted-bg: rgba(16, 185, 129, 0.12);
    --status-declined: #ef4444;
    --status-declined-bg: rgba(239, 68, 68, 0.12);
    --status-expired: #f59e0b;
    --status-expired-bg: rgba(245, 158, 11, 0.12);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);

    /* Layout */
    --sidebar-width: 250px;
    --sidebar-collapsed: 72px;
    --header-height: 60px;
    --bottom-nav-height: 64px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   RESET & BASE
   ======================================== */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

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

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    background: none;
    outline: none;
}

input, textarea, select {
    font-family: inherit;
    font-size: 16px; /* Prevents iOS zoom on focus */
    outline: none;
}

/* ========================================
   SIDEBAR
   ======================================== */

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

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.brand-logo {
    height: 36px;
    width: auto;
    max-width: 180px;
    object-fit: contain;
}

.mobile-logo {
    height: 28px;
    width: auto;
    max-width: 140px;
    object-fit: contain;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-primary-glow);
    color: var(--accent-primary-hover);
}

.nav-item.active svg {
    stroke: var(--accent-primary-hover);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.sidebar-version {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

/* ========================================
   MOBILE HEADER
   ======================================== */

.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: 90;
    align-items: center;
    padding: 0 16px;
    padding-top: env(safe-area-inset-top);
    gap: 12px;
}

.menu-toggle {
    color: var(--text-secondary);
    padding: 10px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.menu-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

/* ========================================
   MAIN CONTENT
   ======================================== */

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin var(--transition-normal);
}

.page-container {
    padding: 32px;
    max-width: 1400px;
    margin: 0 auto;
    animation: fadeIn var(--transition-normal);
}

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

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========================================
   PAGE HEADER
   ======================================== */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

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

/* ========================================
   BUTTONS
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    transition: all var(--transition-fast);
    white-space: nowrap;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    background: var(--accent-gradient-hover);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.25);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
}

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

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

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

/* ========================================
   CARDS
   ======================================== */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all var(--transition-fast);
}

.card:hover {
    border-color: var(--border-hover);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ========================================
   STAT CARDS
   ======================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 22px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: all var(--transition-fast);
    animation: slideUp var(--transition-slow) both;
}

.stat-card:nth-child(1) { animation-delay: 0ms; }
.stat-card:nth-child(2) { animation-delay: 80ms; }
.stat-card:nth-child(3) { animation-delay: 160ms; }
.stat-card:nth-child(4) { animation-delay: 240ms; }

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

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

.stat-icon.blue { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.stat-icon.green { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.stat-icon.purple { background: rgba(139, 92, 246, 0.12); color: #8b5cf6; }
.stat-icon.amber { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ========================================
   FORMS
   ======================================== */

.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

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

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

.form-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
}

.form-section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-section-title svg {
    width: 18px;
    height: 18px;
    color: var(--accent-primary);
}

/* ========================================
   TABLE
   ======================================== */

.table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    position: relative;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.table tbody td {
    padding: 14px 16px;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

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

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

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

/* ========================================
   STATUS BADGES
   ======================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.3px;
}

.badge-draft { background: var(--status-draft-bg); color: var(--status-draft); }
.badge-sent { background: var(--status-sent-bg); color: var(--status-sent); }
.badge-accepted { background: var(--status-accepted-bg); color: var(--status-accepted); }
.badge-declined { background: var(--status-declined-bg); color: var(--status-declined); }
.badge-expired { background: var(--status-expired-bg); color: var(--status-expired); }

/* ========================================
   ITEMS TABLE (Estimate Form)
   ======================================== */

.items-table {
    width: 100%;
    border-collapse: collapse;
}

.items-table thead th {
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.items-table tbody td {
    padding: 8px 6px;
    vertical-align: top;
}

.items-table .form-input,
.items-table .form-textarea,
.items-table .form-select {
    padding: 8px 10px;
    font-size: 13px;
}

.items-table .item-amount {
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
    padding-top: 12px;
    white-space: nowrap;
}

.items-table .remove-item-btn {
    color: var(--text-muted);
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    margin-top: 4px;
}

.items-table .remove-item-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.add-item-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    color: var(--accent-primary);
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    margin-top: 12px;
    border: 1px dashed var(--border-color);
    width: 100%;
    justify-content: center;
}

.add-item-btn:hover {
    background: var(--accent-primary-glow);
    border-color: var(--accent-primary);
}

/* ========================================
   TOTALS SECTION
   ======================================== */

.totals-section {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}

.totals-table {
    width: 300px;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 14px;
}

.totals-row.subtotal {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 4px;
}

.totals-row.total {
    font-size: 18px;
    font-weight: 700;
    border-top: 2px solid var(--border-color);
    padding-top: 12px;
    margin-top: 4px;
}

.totals-row.amount-due {
    background: var(--accent-gradient);
    color: white;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 16px;
    margin-top: 8px;
}

.totals-label {
    color: var(--text-secondary);
}

.totals-value {
    font-weight: 600;
    color: var(--text-primary);
}

.totals-row.amount-due .totals-label,
.totals-row.amount-due .totals-value {
    color: white;
}

/* ========================================
   SEARCH & FILTERS
   ======================================== */

.filters-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

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

.search-box svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 18px;
    height: 18px;
}

.search-box .form-input {
    padding-left: 40px;
}

.filter-select {
    min-width: 150px;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

.toast-container {
    position: fixed;
    bottom: calc(24px + env(safe-area-inset-bottom));
    right: 16px;
    left: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    color: white;
    min-width: 280px;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    animation: toastIn 300ms ease-out;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success {
    background: linear-gradient(135deg, #059669, #10b981);
}

.toast.error {
    background: linear-gradient(135deg, #dc2626, #ef4444);
}

.toast.info {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
}

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

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

/* ========================================
   EMPTY STATE
   ======================================== */

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

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    margin-bottom: 16px;
    opacity: 0.5;
}

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

.empty-state p {
    font-size: 14px;
    max-width: 360px;
    margin: 0 auto 20px;
}

/* ========================================
   CLIENT CARDS
   ======================================== */

.clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.client-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition-fast);
    animation: slideUp var(--transition-slow) both;
}

.client-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.client-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.client-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}

.client-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.client-info {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.client-info svg {
    width: 14px;
    height: 14px;
    vertical-align: middle;
    margin-right: 4px;
    color: var(--text-muted);
}

/* ========================================
   MODAL
   ======================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 200ms;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 300ms;
}

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

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    color: var(--text-secondary);
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

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

.modal-body {
    padding: 24px;
}

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

/* ========================================
   SETTINGS PAGE
   ======================================== */

.logo-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.logo-upload-area:hover {
    border-color: var(--accent-primary);
    background: var(--accent-primary-glow);
}

.logo-upload-area img {
    max-height: 80px;
    max-width: 200px;
    object-fit: contain;
    margin-bottom: 8px;
}

.logo-upload-area .upload-text {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ========================================
   CHECKBOX
   ======================================== */

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-wrapper input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

/* ========================================
   SHARE LINK
   ======================================== */

.share-link-box {
    display: flex;
    gap: 8px;
    align-items: center;
}

.share-link-box .form-input {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ========================================
   LOADING
   ======================================== */

.loading-skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-elevated) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========================================
   RESPONSIVE
   ======================================== */

@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: flex;
    }

    .main-content {
        margin-left: 0;
        padding-top: var(--header-height);
        padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 8px);
    }

    .page-container {
        padding: 16px;
        padding-bottom: 24px;
    }

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

    .page-actions {
        width: 100%;
        flex-wrap: wrap;
    }

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

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

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

    .form-section {
        padding: 16px;
    }

    .totals-section {
        justify-content: stretch;
    }

    .totals-table {
        width: 100%;
    }

    .filters-bar {
        flex-direction: column;
    }

    .search-box {
        width: 100%;
    }

    .toast-container {
        bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 12px);
    }

    .modal {
        margin: 8px;
        max-height: calc(100vh - 16px);
        border-radius: var(--radius-lg);
    }

    .table thead th {
        padding: 10px 10px;
        font-size: 11px;
    }

    .table tbody td {
        padding: 12px 10px;
        font-size: 13px;
    }
}

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

    .clients-grid {
        grid-template-columns: 1fr;
    }

    .page-title {
        font-size: 22px;
    }
}

/* ========================================
   SCROLLBAR
   ======================================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* ========================================
   DROPDOWN MENU
   ======================================== */

.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 6px;
    min-width: 180px;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    display: none;
    animation: fadeIn 150ms;
}

.dropdown-menu.open {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    cursor: pointer;
    width: 100%;
    text-align: left;
}

.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.dropdown-item.danger {
    color: #ef4444;
}

.dropdown-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

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

/* ========================================
   BOTTOM NAVIGATION (Mobile)
   ======================================== */

.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    z-index: 100;
    align-items: center;
    justify-content: space-around;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 0;
    flex: 1;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    transition: color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

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

.bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: var(--accent-gradient);
    border-radius: 0 0 3px 3px;
}

.bottom-nav-item svg {
    width: 22px;
    height: 22px;
}

.bottom-nav-item span {
    letter-spacing: 0.2px;
}

/* FAB Button in Bottom Nav */
.bottom-nav-fab {
    flex: none;
    width: 52px;
    position: relative;
    padding: 0;
}

.fab-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin-top: -18px;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
    transition: all var(--transition-fast);
}

.fab-circle:active {
    transform: scale(0.92);
}

.fab-circle svg {
    width: 24px;
    height: 24px;
}

/* ========================================
   PWA INSTALL BANNER
   ======================================== */

.pwa-install-banner {
    display: none;
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 12px);
    left: 12px;
    right: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    z-index: 150;
    box-shadow: var(--shadow-lg);
    animation: slideUp 400ms ease-out;
    flex-direction: column;
    gap: 12px;
}

.pwa-install-banner.visible {
    display: flex;
}

.pwa-install-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pwa-install-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.pwa-install-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.pwa-install-text strong {
    font-size: 15px;
    color: var(--text-primary);
}

.pwa-install-text span {
    font-size: 12px;
    color: var(--text-secondary);
}

.pwa-install-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.pwa-install-dismiss {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.pwa-install-dismiss:hover {
    background: var(--bg-hover);
}

.pwa-install-btn {
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 600;
    color: white;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-glow);
    transition: all var(--transition-fast);
}

.pwa-install-btn:hover {
    background: var(--accent-gradient-hover);
}

/* Desktop: no bottom-nav install banner position */
@media (min-width: 769px) {
    .pwa-install-banner {
        bottom: 24px;
        left: auto;
        right: 24px;
        max-width: 360px;
    }
}

/* ========================================
   TOUCH OPTIMIZATIONS
   ======================================== */

@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        padding: 12px 20px;
    }

    .btn-sm {
        min-height: 38px;
        padding: 8px 14px;
    }

    .btn-icon {
        min-height: 44px;
        min-width: 44px;
        padding: 10px;
    }

    .nav-item {
        padding: 14px 16px;
    }

    .form-input,
    .form-select,
    .form-textarea {
        padding: 12px 14px;
        font-size: 16px;
    }

    .dropdown-item {
        padding: 12px 14px;
        font-size: 14px;
    }

    .checkbox-wrapper input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }
}

/* ========================================
   STANDALONE PWA (installed)
   ======================================== */

@media (display-mode: standalone) {
    .pwa-install-banner {
        display: none !important;
    }
}
