@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
    /* IntegraSell brand */
    --brand-violet: #7c6fff;
    --brand-lavender: #b0abff;
    --brand-deep: #1c1049;

    /* Primary */
    --primary: #7c6fff;
    --primary-dark: #6459e8;
    --primary-light: #ede9ff;
    --primary-mid: #a09aff;

    /* Semantic */
    --success: #10b981;
    --danger: #ef4444;

    /* Neutrals */
    --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: #ffffff;
    --bg-page: #f5f4ff;

    --radius: 10px;
    --shadow: 0 1px 4px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 20px rgba(124,111,255,0.1), 0 2px 6px rgba(0,0,0,0.06);
    --shadow-lg: 0 12px 40px rgba(124,111,255,0.18);
}

/* Dark mode */
[data-theme="dark"] {
    --gray-50: #12092e;
    --gray-100: #1c1149;
    --gray-200: #2b1f60;
    --gray-300: #3d2f7a;
    --gray-400: #7b6ecc;
    --gray-500: #9d90d4;
    --gray-600: #c4bcf0;
    --gray-700: #d9d5f8;
    --gray-800: #eceaff;
    --gray-900: #f5f3ff;
    --bg: #1c1149;
    --bg-page: #12092e;
    --primary: #a09aff;
    --primary-dark: #b0abff;
    --primary-light: #2b1f60;
    --shadow: 0 1px 4px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.4);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--gray-800);
    background: var(--bg-page);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* App layout */
.app-layout {
    display: grid;
    grid-template-columns: auto 1fr;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: linear-gradient(180deg, #1c1049 0%, #261460 45%, #2e1972 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease;
    overflow: hidden;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 200;
    box-shadow: 2px 0 20px rgba(0,0,0,0.25);
}

[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #0d0724 0%, #1c1049 45%, #221460 100%);
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    height: 56px;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    white-space: nowrap;
    border-bottom: 1px solid rgba(176, 171, 255, 0.15);
    background: rgba(0,0,0,0.15);
}

.sidebar-header svg {
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.75rem 0.625rem;
}

.sidebar-footer {
    border-top: 1px solid rgba(176, 171, 255, 0.12);
    padding: 0.625rem 0.625rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    color: rgba(176, 171, 255, 0.75);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s, border-left-color 0.15s;
    white-space: nowrap;
    background: none;
    border: none;
    border-left: 3px solid transparent;
    cursor: pointer;
    width: 100%;
    font-family: inherit;
}

.sidebar-link:hover {
    background: rgba(176, 171, 255, 0.1);
    color: rgba(255,255,255,0.95);
}

.sidebar-link.active {
    background: rgba(176, 171, 255, 0.14);
    color: #fff;
    border-left-color: var(--brand-lavender);
    font-weight: 600;
}

/* Per-section icon colour when active */
.sidebar-nav .sidebar-link:nth-child(1).active .sidebar-icon { color: #c4b5fd; }
.sidebar-nav .sidebar-link:nth-child(2).active .sidebar-icon { color: #67e8f9; }
.sidebar-nav .sidebar-link:nth-child(3).active .sidebar-icon { color: #6ee7b7; }
.sidebar-nav .sidebar-link:nth-child(4).active .sidebar-icon { color: #fcd34d; }
.sidebar-nav .sidebar-link:nth-child(5).active .sidebar-icon { color: #fda4af; }

/* Subtle hover icon tint per section */
.sidebar-nav .sidebar-link:nth-child(1):hover .sidebar-icon { color: #c4b5fd; }
.sidebar-nav .sidebar-link:nth-child(2):hover .sidebar-icon { color: #67e8f9; }
.sidebar-nav .sidebar-link:nth-child(3):hover .sidebar-icon { color: #6ee7b7; }
.sidebar-nav .sidebar-link:nth-child(4):hover .sidebar-icon { color: #fcd34d; }
.sidebar-nav .sidebar-link:nth-child(5):hover .sidebar-icon { color: #fda4af; }

.sidebar-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-label {
    opacity: 1;
    width: auto;
    overflow: hidden;
    transition: opacity 0.2s ease, width 0.2s ease;
}

.sidebar.collapsed .sidebar-label {
    opacity: 0;
    width: 0;
}

/* Header bar */
.header {
    display: flex;
    align-items: center;
    height: 56px;
    padding: 0 1.25rem;
    background: var(--bg);
    border-bottom: 1px solid var(--gray-200);
    box-shadow: 0 1px 0 rgba(124,111,255,0.06);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-spacer {
    flex: 1;
}

.header-username {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.85rem;
    color: var(--gray-600);
    font-weight: 500;
    margin-right: 0.5rem;
}

.sidebar-toggle,
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--gray-600);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.sidebar-toggle:hover,
.theme-toggle:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

/* Main area */
.main-area {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

.main-content {
    flex: 1;
    background: var(--bg-page);
}

/* Mobile menu */
.mobile-menu {
    display: none;
    background: var(--bg);
    border-bottom: 1px solid var(--gray-200);
    padding: 0.5rem 0;
}

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

.mobile-menu-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    color: var(--gray-700);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s;
    background: none;
    border: none;
    cursor: pointer;
    width: 100%;
    font-family: inherit;
}

.mobile-menu-link:hover {
    background: var(--gray-100);
}

.mobile-menu-link.active {
    color: var(--primary);
    background: var(--primary-light);
    font-weight: 600;
}

/* Utility classes */
.desktop-only {
    display: inline-flex;
}

.mobile-only {
    display: none;
}

/* Layout */
.page {
    max-width: 820px;
    margin: 0 auto;
    padding: 2rem;
}

.page-title {
    font-size: 1.625rem;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 0.375rem;
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--gray-500);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

/* Card */
.card {
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: box-shadow 0.2s;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 14px;
    background: linear-gradient(180deg, var(--primary) 0%, var(--brand-lavender) 100%);
    border-radius: 2px;
    flex-shrink: 0;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(124,111,255,0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #5044d4 100%);
    box-shadow: 0 4px 12px rgba(124,111,255,0.45);
}

.btn-primary:disabled {
    background: var(--gray-300);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* Sync status */
.sync-status {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    display: none;
}

.sync-status.visible {
    display: block;
}

.sync-status.success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.sync-status.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.sync-status.loading {
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid #bfdbfe;
}

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

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

/* Search */
.search-container {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.15s;
    background: var(--bg);
    color: var(--gray-800);
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124,111,255,0.12);
}

.search-input::placeholder {
    color: var(--gray-400);
}

.search-hint {
    font-size: 0.8rem;
    color: var(--gray-400);
    margin-top: 0.375rem;
}

/* Dropdown */
.dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    max-height: 320px;
    overflow-y: auto;
    z-index: 50;
}

.dropdown-item {
    padding: 0.625rem 1rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.1s;
}

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

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

.dropdown-item-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.dropdown-item-code {
    font-size: 0.8rem;
    color: var(--gray-500);
    font-family: 'SF Mono', 'Consolas', monospace;
}

/* Customer detail */
.customer-detail {
    margin-top: 1.5rem;
    animation: fadeIn 0.2s ease;
}

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

.detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.detail-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.detail-name {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--gray-900);
}

.detail-code {
    font-size: 0.85rem;
    color: var(--gray-500);
    font-family: 'SF Mono', 'Consolas', monospace;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.detail-field {
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.detail-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: 0.25rem;
}

.detail-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.detail-value.positive {
    color: var(--success);
}

.detail-value.negative {
    color: var(--danger);
}

/* Offline banner */
.offline-banner {
    background: linear-gradient(90deg, #fef3c7, #fde68a);
    color: #78350f;
    text-align: center;
    padding: 0.5rem 1rem;
    font-size: 0.825rem;
    font-weight: 600;
    display: none;
    letter-spacing: 0.01em;
}

.offline-banner.visible {
    display: block;
}

/* No data message */
.no-data {
    text-align: center;
    padding: 2rem;
    color: var(--gray-400);
}

/* Stats row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    padding: 1.25rem 1.25rem 1rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--brand-lavender) 100%);
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 0.375rem;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Login page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1c1049 0%, #2e1972 40%, #3d1f85 70%, #1c1049 100%);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

/* Animated background orbs */
.login-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.35;
    animation: orbFloat 8s ease-in-out infinite;
}

.login-orb-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #b0abff 0%, #7c6fff 60%, transparent 100%);
    top: -100px;
    right: -80px;
    animation-delay: 0s;
    animation-duration: 10s;
}

.login-orb-2 {
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, #6ee7b7 0%, #059669 60%, transparent 100%);
    bottom: -60px;
    left: -80px;
    opacity: 0.2;
    animation-delay: -3s;
    animation-duration: 12s;
}

.login-orb-3 {
    width: 240px;
    height: 240px;
    background: radial-gradient(circle, #fda4af 0%, #e11d48 60%, transparent 100%);
    top: 40%;
    left: 5%;
    opacity: 0.18;
    animation-delay: -6s;
    animation-duration: 9s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%  { transform: translate(20px, -30px) scale(1.05); }
    66%  { transform: translate(-15px, 20px) scale(0.97); }
}

.login-panel {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 420px;
    gap: 2rem;
}

.login-brand {
    text-align: center;
}

.login-logo {
    height: 36px;
    width: auto;
    filter: brightness(0) invert(1);
    margin-bottom: 0.625rem;
}

.login-tagline {
    color: rgba(176, 171, 255, 0.75);
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.login-card {
    background: rgba(255,255,255,0.97);
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.35), 0 4px 16px rgba(0,0,0,0.2);
    padding: 2.5rem 2rem 2rem;
    width: 100%;
    backdrop-filter: blur(10px);
}

.login-card-header {
    margin-bottom: 1.75rem;
    text-align: center;
}

.login-title {
    font-size: 1.625rem;
    font-weight: 800;
    color: var(--gray-900);
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.login-subtitle {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-bottom: 0;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.375rem;
}

.form-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.95rem;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--bg);
    color: var(--gray-800);
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124,111,255,0.12);
}

.login-btn {
    width: 100%;
    justify-content: center;
    margin-top: 0.75rem;
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    letter-spacing: 0.01em;
    border-radius: 10px;
}

.login-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* Dashboard layout */
.page-wide {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.dashboard-card {
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

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

.dashboard-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    background: linear-gradient(90deg, var(--gray-50) 0%, rgba(237,233,255,0.5) 100%);
}

.dashboard-card-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-700);
}

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

.dashboard-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    padding: 2rem;
    color: var(--gray-400);
    font-size: 0.9rem;
}

.dashboard-spinner {
    border-color: rgba(26, 86, 219, 0.2);
    border-top-color: var(--primary);
}

.dashboard-error {
    padding: 1.5rem;
    text-align: center;
    color: var(--danger);
    font-size: 0.875rem;
    background: #fef2f2;
    border-radius: var(--radius);
}

/* Dashboard tables */
.dashboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.dashboard-table thead th {
    text-align: left;
    padding: 0.625rem 0.75rem;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    border-bottom: 2px solid var(--gray-200);
}

.dashboard-table tbody td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

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

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

/* Promotion cards */
.promo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.promo-card {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem;
    position: relative;
    transition: box-shadow 0.15s;
}

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

.promo-badge {
    display: inline-block;
    background: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    letter-spacing: 0.02em;
}

.promo-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.375rem;
}

.promo-desc {
    font-size: 0.825rem;
    color: var(--gray-500);
    line-height: 1.45;
    margin-bottom: 0.625rem;
}

.promo-dates {
    font-size: 0.75rem;
    color: var(--gray-400);
    font-weight: 500;
}

/* Prospect summary */
.prospect-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.prospect-stat {
    background: linear-gradient(135deg, var(--primary-light) 0%, rgba(176,171,255,0.2) 100%);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    border: 1px solid rgba(124,111,255,0.15);
}

.prospect-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
}

.prospect-stat-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 0.125rem;
}

.prospect-status {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

.prospect-status--new {
    background: #eff6ff;
    color: #1d4ed8;
}

.prospect-status--contacted {
    background: #fefce8;
    color: #a16207;
}

.prospect-status--qualified {
    background: #f0fdf4;
    color: #15803d;
}

.prospect-status--converted {
    background: #ecfdf5;
    color: #047857;
}

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

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

    .page-wide {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .app-layout {
        grid-template-columns: 1fr;
    }

    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: inline-flex !important;
    }

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

@media (max-width: 600px) {
    .page {
        padding: 1rem;
    }
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

/* Map page layout */
.map-page-container {
    display: flex;
    height: calc(100vh - 56px);
    overflow: hidden;
}

.map-main {
    flex: 1;
    position: relative;
    min-height: 0;
    height: 100%;
}

.map-view {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
}

/* Fix Leaflet container in dark mode */
[data-theme="dark"] .leaflet-container {
    background: #1f2937;
}

[data-theme="dark"] .leaflet-popup-content-wrapper,
[data-theme="dark"] .leaflet-popup-tip {
    background: var(--bg);
    color: var(--gray-800);
}

[data-theme="dark"] .leaflet-control-zoom a {
    background: var(--bg);
    color: var(--gray-800);
}

[data-theme="dark"] .leaflet-control-attribution {
    background: rgba(31, 41, 55, 0.8);
    color: var(--gray-400);
}

.map-sidebar {
    width: 360px;
    background: var(--bg);
    border-left: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.map-filter-section {
    padding: 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    background: var(--bg);
}

.map-filter-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 1rem;
}

.map-filter-group {
    margin-bottom: 1rem;
}

.map-filter-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

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

.map-results-count {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--gray-500);
    text-align: center;
}

/* Slider styling */
.slider-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.map-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: var(--gray-200);
    outline: none;
}

.map-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.map-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.map-slider:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.map-slider:disabled::-webkit-slider-thumb {
    cursor: not-allowed;
}

.slider-value {
    min-width: 50px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    text-align: right;
}

.btn-location {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: var(--primary-light);
    color: var(--primary);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.15s;
}

.btn-location:hover {
    background: var(--primary);
    color: #fff;
}

.location-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.location-status.success {
    background: #f0fdf4;
    color: #166534;
}

.location-status.error {
    background: #fef2f2;
    color: #991b1b;
}

/* Customer list in sidebar */
.map-customer-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.map-customer-card {
    background: var(--bg);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0.875rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.map-customer-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary);
}

.map-customer-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.125rem;
}

.map-customer-code {
    font-size: 0.75rem;
    color: var(--gray-500);
    font-family: 'SF Mono', 'Consolas', monospace;
    margin-bottom: 0.5rem;
}

.map-customer-contact {
    font-size: 0.8rem;
    margin-bottom: 0.125rem;
}

.map-customer-contact a {
    color: var(--primary);
    text-decoration: none;
}

.map-customer-contact a:hover {
    text-decoration: underline;
}

/* Map loading and error states */
.map-loading,
.map-error {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    height: 100%;
    padding: 2rem;
    font-size: 0.9rem;
}

.map-loading {
    color: var(--gray-400);
}

.map-error {
    color: var(--danger);
    background: #fef2f2;
}

/* Map popup styling */
.map-popup {
    min-width: 180px;
}

.map-popup-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
    padding-bottom: 0.375rem;
    border-bottom: 1px solid var(--gray-200);
}

.map-popup-field {
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.map-popup-field a {
    color: var(--primary);
    text-decoration: none;
}

.map-popup-field a:hover {
    text-decoration: underline;
}

.map-popup-date {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.5rem;
    padding-top: 0.375rem;
    border-top: 1px solid var(--gray-200);
}

/* Leaflet popup customization */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.leaflet-popup-content {
    margin: 12px 14px;
}

/* Responsive map layout */
@media (max-width: 900px) {
    .map-page-container {
        flex-direction: column-reverse;
    }

    .map-sidebar {
        width: 100%;
        height: 45%;
        border-left: none;
        border-top: 1px solid var(--gray-200);
    }

    .map-main {
        height: 55%;
    }
}

@media (max-width: 600px) {
    .map-sidebar {
        height: 50%;
    }

    .map-main {
        height: 50%;
    }

    .map-filter-section {
        padding: 1rem;
    }
}

/* ================================
   Call Plan Page Styles
   ================================ */

.callplan-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 56px);
    overflow: hidden;
}

.callplan-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: var(--bg);
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.callplan-date-picker {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.callplan-date-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
}

.callplan-date-input {
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: var(--bg);
    color: var(--gray-800);
    cursor: pointer;
}

.callplan-date-input:focus {
    outline: none;
    border-color: var(--primary);
}

.callplan-week-info {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-600);
    flex: 1;
}

.callplan-save-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.callplan-saved-msg {
    font-size: 0.875rem;
    color: var(--success, #16a34a);
    font-weight: 500;
}

.callplan-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.callplan-main {
    flex: 1;
    overflow: auto;
    background: var(--bg-page);
}

.callplan-grid {
    display: flex;
    min-width: max-content;
}

.callplan-time-column {
    width: 60px;
    flex-shrink: 0;
    background: var(--bg);
    border-right: 1px solid var(--gray-200);
    position: sticky;
    left: 0;
    z-index: 10;
}

.callplan-day-column {
    flex: 1;
    min-width: 160px;
    border-right: 1px solid var(--gray-200);
}

.callplan-day-column:last-child {
    border-right: none;
}

.callplan-header-cell {
    height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border-bottom: 2px solid var(--gray-200);
    cursor: pointer;
    transition: background 0.15s;
}

.callplan-header-cell:hover {
    background: var(--gray-50);
}

.callplan-header-cell.selected {
    background: var(--primary-light);
    border-bottom-color: var(--primary);
}

.callplan-header-cell.today {
    position: relative;
}

.callplan-header-cell.today::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
}

.callplan-time-header {
    cursor: default;
}

.callplan-time-header:hover {
    background: var(--bg);
}

.callplan-header-day {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.callplan-header-date {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-800);
}

.callplan-time-cell {
    height: 80px;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 0.25rem 0.5rem;
    border-bottom: 1px solid var(--gray-100);
    background: var(--bg);
}

.callplan-time-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--gray-400);
}

.callplan-hour-cell {
    height: 80px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
}

.callplan-slot {
    flex: 1;
    padding: 2px;
    border-bottom: 1px dashed var(--gray-100);
    min-height: 38px;
    transition: background 0.15s;
}

.callplan-slot-half {
    border-bottom: none;
}

.callplan-slot.drag-over {
    background: var(--primary-light);
}

.callplan-appointment {
    background: var(--primary);
    color: #fff;
    border-radius: 4px;
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
    cursor: grab;
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    transition: transform 0.1s, box-shadow 0.1s;
}

.callplan-appointment:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.callplan-appointment:active {
    cursor: grabbing;
}

.callplan-apt-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 16px;
}

.callplan-apt-time {
    font-size: 0.65rem;
    opacity: 0.85;
}

.callplan-apt-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    border: none;
    background: rgba(255,255,255,0.2);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}

.callplan-appointment:hover .callplan-apt-remove {
    opacity: 1;
}

.callplan-apt-remove:hover {
    background: rgba(255,255,255,0.4);
}

/* Call Plan Sidebar */
.callplan-sidebar {
    width: 360px;
    background: var(--bg);
    border-left: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.callplan-filter-section {
    padding: 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    background: var(--bg);
    flex-shrink: 0;
}

.callplan-filter-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 1rem;
}

.callplan-filter-group {
    margin-bottom: 0.875rem;
}

.callplan-filter-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.375rem;
}

.callplan-filter-btn {
    width: 100%;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.callplan-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--gray-700);
    cursor: pointer;
}

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

.callplan-results-count {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--gray-500);
    text-align: center;
}

/* AI Button */
.btn-ai {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-ai:hover {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
}

.btn-ai:disabled {
    background: var(--gray-300);
}

.btn-ai svg {
    flex-shrink: 0;
}

/* Customer List */
.callplan-customer-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.callplan-customer-card {
    background: var(--bg);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s, transform 0.1s;
}

.callplan-customer-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary);
    transform: translateX(-2px);
}

.callplan-customer-card.requires-visit {
    border-left: 3px solid var(--danger);
}

.callplan-customer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.callplan-customer-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-800);
}

.callplan-visit-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    background: #fef2f2;
    color: #991b1b;
    border-radius: 4px;
    white-space: nowrap;
}

.callplan-customer-code {
    font-size: 0.7rem;
    color: var(--gray-500);
    font-family: 'SF Mono', 'Consolas', monospace;
    margin-bottom: 0.375rem;
}

.callplan-customer-address {
    font-size: 0.75rem;
    color: var(--gray-600);
    margin-bottom: 0.375rem;
    line-height: 1.4;
}

.callplan-customer-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.callplan-last-visit {
    font-size: 0.7rem;
    color: var(--gray-500);
}

.callplan-no-results {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--gray-400);
    font-size: 0.875rem;
}

/* Responsive Call Plan */
@media (max-width: 1024px) {
    .callplan-sidebar {
        width: 300px;
    }

    .callplan-day-column {
        min-width: 140px;
    }
}

@media (max-width: 768px) {
    .callplan-body {
        flex-direction: column-reverse;
    }

    .callplan-sidebar {
        width: 100%;
        height: 40%;
        border-left: none;
        border-top: 1px solid var(--gray-200);
    }

    .callplan-main {
        height: 60%;
    }

    .callplan-topbar {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
    }

    .callplan-day-column {
        min-width: 120px;
    }
}

/* ================================
   Modal Styles
   ================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    animation: fadeIn 0.15s ease;
}

.modal-panel {
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.2s ease;
}

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

.modal-sm { width: 100%; max-width: 400px; }
.modal-md { width: 100%; max-width: 600px; }
.modal-lg { width: 100%; max-width: 800px; }
.modal-full { width: 100%; max-width: 95vw; height: 90vh; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--gray-500);
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
}

/* ================================
   Tab Component
   ================================ */

.tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 1rem;
    gap: 0;
}

.tab-btn {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-500);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    font-family: inherit;
}

.tab-btn:hover {
    color: var(--gray-700);
    background: var(--gray-50);
    border-radius: var(--radius) var(--radius) 0 0;
}

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

.tab-panel {
    display: none;
}

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

/* ================================
   Sales Order Page Styles
   ================================ */

.so-page {
    max-width: 820px;
    margin: 0 auto;
    padding: 2rem;
}

.so-page.embedded {
    padding: 1.5rem 0 0;
}

.so-step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

.so-step {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-400);
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    transition: color 0.15s, background 0.15s;
}

.so-step.active {
    color: var(--primary);
    background: var(--primary-light);
}

.so-step.completed {
    color: var(--success);
}

.so-step-number {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--gray-200);
    color: var(--gray-500);
}

.so-step.active .so-step-number {
    background: var(--primary);
    color: #fff;
}

.so-step.completed .so-step-number {
    background: var(--success);
    color: #fff;
}

.so-step-divider {
    width: 24px;
    height: 2px;
    background: var(--gray-200);
}

/* Customer card in sales order */
.so-customer-card {
    background: var(--bg);
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.2s ease;
}

.so-customer-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--gray-900);
}

.so-customer-info {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--gray-600);
}

/* Line items */
.so-line-item {
    background: var(--bg);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0.875rem;
    margin-bottom: 0.5rem;
    transition: border-color 0.15s;
}

.so-line-item.price-error {
    border-color: var(--danger);
    background: #fef2f2;
}

.so-line-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.so-line-product {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-800);
}

.so-line-code {
    font-size: 0.75rem;
    color: var(--gray-500);
    font-family: 'SF Mono', 'Consolas', monospace;
}

.so-line-fields {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.so-line-field {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.so-line-field label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.so-line-field input {
    width: 80px;
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    background: var(--bg);
    color: var(--gray-800);
}

.so-line-field input:focus {
    outline: none;
    border-color: var(--primary);
}

.so-line-field input.error {
    border-color: var(--danger);
}

.so-line-total {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-left: auto;
}

.so-line-actions {
    display: flex;
    gap: 0.375rem;
    margin-top: 0.5rem;
}

.so-line-btn {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    background: var(--gray-100);
    color: var(--gray-600);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.15s;
    font-family: inherit;
}

.so-line-btn:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.so-line-btn.danger {
    color: var(--danger);
}

.so-line-btn.danger:hover {
    background: #fef2f2;
}

/* Order summary */
.so-summary {
    background: var(--bg);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 1rem;
}

.so-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.375rem 0;
    font-size: 0.9rem;
    color: var(--gray-700);
}

.so-summary-row.total {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-900);
    border-top: 2px solid var(--gray-200);
    padding-top: 0.75rem;
    margin-top: 0.375rem;
}

/* Signature pad styles */
.signature-pad {
    text-align: center;
}

.signature-canvas {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    cursor: crosshair;
    max-width: 100%;
    height: auto;
}

.signature-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 0.75rem;
}

.signature-preview {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0.5rem;
    text-align: center;
}

.signature-preview img {
    max-width: 200px;
    max-height: 80px;
}

/* Camera styles */
.camera-capture {
    text-align: center;
}

.camera-preview {
    margin-bottom: 0.75rem;
}

.camera-video {
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius);
    background: #000;
}

.camera-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.camera-error {
    padding: 1.5rem;
    text-align: center;
    color: var(--gray-600);
}

.camera-error p {
    margin-bottom: 0.75rem;
}

.camera-upload-label {
    cursor: pointer;
}

.camera-loading {
    padding: 2rem;
    color: var(--gray-400);
}

/* Photo thumbnails */
.so-photos {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.so-photo-thumb {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.so-photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.so-photo-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Order status badges */
.so-status-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.so-status-badge.submitted {
    background: #eff6ff;
    color: #1d4ed8;
}

.so-status-badge.pending {
    background: #fefce8;
    color: #a16207;
}

.so-status-badge.synced {
    background: #f0fdf4;
    color: #15803d;
}

.so-status-badge.failed {
    background: #fef2f2;
    color: #991b1b;
}

/* Stock indicator colors */
.stock-high {
    color: var(--success);
    font-weight: 600;
}

.stock-medium {
    color: #d97706;
    font-weight: 600;
}

.stock-low {
    color: var(--danger);
    font-weight: 600;
}

/* Mini table for stock info */
.so-stock-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.so-stock-table th {
    text-align: left;
    padding: 0.5rem 0.625rem;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    border-bottom: 2px solid var(--gray-200);
}

.so-stock-table td {
    padding: 0.5rem 0.625rem;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

/* Button outline variant */
.btn-outline {
    background: transparent;
    color: var(--gray-600);
    border: 1.5px solid var(--gray-300);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-outline:hover {
    background: var(--gray-100);
    color: var(--gray-800);
    border-color: var(--gray-400);
}

/* ================================
   Draft Orders list (home page)
   ================================ */

.draft-list {
    display: flex;
    flex-direction: column;
}

.draft-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--gray-100);
}

.draft-row:last-child {
    border-bottom: none;
}

.draft-row-body {
    flex: 1;
    min-width: 0;
}

.draft-row-customer {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.draft-row-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    font-size: 0.78rem;
    color: var(--gray-500);
}

.draft-row-sep {
    color: var(--gray-300);
}

.draft-row-total {
    font-weight: 600;
    color: var(--gray-700);
}

.draft-row-delete {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    color: var(--gray-400);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.draft-row-delete:hover {
    background: #fee2e2;
    color: var(--danger);
    border-color: var(--danger);
}

.draft-row-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.draft-row-load {
    height: 30px;
    padding: 0 0.6rem;
    font-size: 0.78rem;
    font-weight: 600;
    background: none;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    color: var(--primary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.draft-row-load:hover {
    background: var(--primary);
    color: #fff;
}

/* Pending sync badge on nav */
.nav-badge {
    background: var(--danger);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    margin-left: 0.25rem;
}

/* Price error message */
.so-price-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 0.25rem;
}

/* Confirmation page */
.so-confirm {
    text-align: center;
    padding: 2rem 0;
}

.so-confirm-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #f0fdf4;
    color: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.so-confirm-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.so-confirm-order-id {
    font-size: 1rem;
    color: var(--primary);
    font-family: 'SF Mono', 'Consolas', monospace;
    font-weight: 600;
    margin-bottom: 1rem;
}

.so-confirm-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1.5rem;
}

/* Checkbox styled */
.so-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--gray-700);
    cursor: pointer;
    margin: 0.75rem 0;
}

.so-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* Review section */
.so-review-section {
    margin-bottom: 1.25rem;
}

.so-review-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: 0.5rem;
    padding-bottom: 0.375rem;
    border-bottom: 1px solid var(--gray-200);
}

/* History bar chart container */
.so-history-chart {
    height: 200px;
    margin-bottom: 1rem;
}

.so-history-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.so-history-stat {
    text-align: center;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.so-history-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.so-history-stat-label {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* Responsive sales order */
@media (max-width: 600px) {
    .so-page {
        padding: 1rem;
    }
    .so-page.embedded {
        padding: 0.75rem 0 0;
    }

    .so-step-indicator {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .so-step {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }

    .so-step-divider {
        width: 12px;
    }

    .so-line-fields {
        flex-direction: column;
        align-items: flex-start;
    }

    .so-customer-info {
        flex-direction: column;
        gap: 0.25rem;
    }

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

    .so-confirm-actions {
        flex-direction: column;
    }
}

/* ============================================================
   Account / Customer Page
   ============================================================ */

.account-page {
    padding: 2rem;
}

@media (max-width: 900px) {
    .account-page {
        padding: 1.5rem;
    }
}

@media (max-width: 600px) {
    .account-page {
        padding: 1rem;
    }
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-primary { background: var(--primary-light); color: var(--primary); }

[data-theme="dark"] .badge-success { background: #14532d; color: #4ade80; }
[data-theme="dark"] .badge-danger  { background: #450a0a; color: #f87171; }
[data-theme="dark"] .badge-warning { background: #422006; color: #fcd34d; }

/* Account header */
.account-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem 1.25rem;
}

.account-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.account-info {
    flex: 1;
    min-width: 0;
}

.account-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-code {
    font-size: 0.8rem;
    color: var(--gray-500);
    font-family: 'SF Mono', 'Consolas', monospace;
}

.account-balance-block {
    text-align: right;
    flex-shrink: 0;
}

.account-balance-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
}

.account-balance {
    font-size: 1.3rem;
    font-weight: 700;
}

.account-balance.positive { color: var(--success); }
.account-balance.negative { color: var(--danger); }

/* Tab navigation */
.tab-nav {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0;
    border-bottom: 2px solid var(--gray-200);
    padding-bottom: 0;
}

.tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    border-radius: 0;
}

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

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

.tab-content {
    padding: 1.5rem;
    margin-top: 1rem;
}

/* Filter bar */
.filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-bar-dates {
    display: flex;
    gap: 0.75rem;
    flex: 1;
    flex-wrap: wrap;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 140px;
}

.filter-field-search {
    flex: 1;
    min-width: 180px;
}

.filter-apply-btn {
    align-self: flex-end;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

/* History table */
.history-table {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}

.history-table-head {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr 0.6fr 1fr;
    gap: 0;
    background: var(--gray-50);
    padding: 0.625rem 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    border-bottom: 1px solid var(--gray-200);
}

.history-table-row {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr 0.6fr 1fr;
    gap: 0;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    transition: background 0.1s;
    align-items: center;
}

.history-table-row:last-child { border-bottom: none; }

.history-table-row:hover { background: var(--primary-light); }

.history-id {
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 600;
}

.history-po {
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 0.8rem;
}

.history-total {
    font-weight: 600;
}

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

/* Address cards */
.addresses-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-subtitle {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.address-card {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: var(--bg);
    transition: border-color 0.15s;
}

.address-card-default {
    border-color: var(--primary);
    background: var(--primary-light);
}

.address-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.address-label {
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
}

.address-card-actions {
    display: flex;
    gap: 0.25rem;
}

.btn-icon {
    background: none;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0.3rem;
    cursor: pointer;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s, color 0.1s;
}

.btn-icon:hover { background: var(--gray-100); color: var(--gray-900); }

.btn-icon-danger:hover { background: #fee2e2; color: var(--danger); border-color: var(--danger); }

.address-body {
    font-size: 0.875rem;
    color: var(--gray-600);
    line-height: 1.6;
}

/* Address form */
.address-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.85rem;
}

/* Transaction detail modal */
.tx-detail {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tx-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.tx-detail-meta {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.tx-meta-row {
    display: flex;
    gap: 0.75rem;
    font-size: 0.875rem;
    align-items: baseline;
}

.tx-meta-label {
    font-weight: 600;
    color: var(--gray-500);
    min-width: 80px;
    font-size: 0.8rem;
}

.tx-meta-value {
    color: var(--gray-800);
}

.tx-detail-total {
    text-align: right;
    flex-shrink: 0;
}

.tx-total-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
}

.tx-total-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

/* Transaction line items */
.tx-lines {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}

.tx-lines-header {
    display: grid;
    grid-template-columns: 44px 1fr 60px 60px 90px 90px;
    padding: 0.5rem 0.75rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    gap: 0.5rem;
    align-items: center;
}

.tx-line-row {
    display: grid;
    grid-template-columns: 44px 1fr 60px 60px 90px 90px;
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.875rem;
    gap: 0.5rem;
    align-items: center;
}

.tx-line-row:last-child { border-bottom: none; }

.tx-col-img { display: flex; align-items: center; }
.tx-col-qty, .tx-col-uom, .tx-col-price, .tx-col-total { text-align: right; }

.tx-product-img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--gray-200);
    background: var(--gray-100);
}

.tx-product-name {
    font-weight: 500;
    font-size: 0.875rem;
}

.tx-product-code {
    font-size: 0.75rem;
    color: var(--gray-500);
    font-family: 'SF Mono', 'Consolas', monospace;
}

.tx-col-total { font-weight: 600; }

.tx-line-total-row {
    display: flex;
    justify-content: space-between;
    padding: 0.625rem 0.75rem;
    background: var(--gray-50);
    font-weight: 700;
    font-size: 0.9rem;
    border-top: 2px solid var(--gray-200);
}

/* Email dialog */
.email-dialog {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem;
}

.email-dialog-inner {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.email-dialog-inner .form-input {
    flex: 1;
    min-width: 200px;
}

.email-success {
    color: var(--success);
    font-weight: 500;
    font-size: 0.9rem;
}

.email-error {
    color: var(--danger);
    font-weight: 500;
    font-size: 0.9rem;
}

/* Transaction action buttons */
.tx-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    flex-wrap: wrap;
    padding-top: 0.5rem;
    border-top: 1px solid var(--gray-200);
}

/* Responsive */
@media (max-width: 640px) {
    .account-header {
        flex-wrap: wrap;
    }

    .account-balance-block {
        width: 100%;
        text-align: left;
        padding-top: 0.5rem;
        border-top: 1px solid var(--gray-200);
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

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

    .history-table-head,
    .history-table-row {
        grid-template-columns: 1fr 0.8fr 1fr;
        font-size: 0.8rem;
    }

    .history-table-head span:nth-child(3),
    .history-table-row span:nth-child(3),
    .history-table-head span:nth-child(4),
    .history-table-row span:nth-child(4) {
        display: none;
    }

    .tx-lines-header,
    .tx-line-row {
        grid-template-columns: 36px 1fr 50px 70px 70px;
        font-size: 0.8rem;
    }

    .tx-col-uom { display: none; }

    .tx-lines-header span:nth-child(4),
    .tx-line-row span:nth-child(4) { display: none; }

    .tx-actions {
        flex-direction: column;
    }

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

/* ============================================================
   Sidebar logo
   ============================================================ */
.sidebar-logo-full {
    height: 22px;
    width: auto;
    display: block;
    flex-shrink: 0;
}

.sidebar-logo-icon {
    height: 34px;
    width: 34px;
    display: none;
    flex-shrink: 0;
    border-radius: 6px;
}

.sidebar.collapsed .sidebar-logo-full { display: none; }
.sidebar.collapsed .sidebar-logo-icon { display: block; }

/* ============================================================
   Header customer selector
   ============================================================ */
.header-customer {
    position: relative;
    margin-right: 0.75rem;
}

.customer-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    border: 1px solid var(--gray-300);
    background: var(--gray-50);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--gray-600);
    max-width: 300px;
    white-space: nowrap;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    font-family: inherit;
}

.customer-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.customer-pill.has-customer {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

[data-theme="dark"] .customer-pill {
    background: rgba(176,171,255,0.08);
    border-color: rgba(176,171,255,0.25);
    color: rgba(176,171,255,0.75);
}

[data-theme="dark"] .customer-pill:hover {
    border-color: var(--brand-lavender);
    color: var(--brand-lavender);
    background: rgba(176,171,255,0.15);
}

[data-theme="dark"] .customer-pill.has-customer {
    background: rgba(176,171,255,0.15);
    border-color: var(--brand-lavender);
    color: var(--brand-lavender);
}

.customer-pill-name {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.customer-pill-code {
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 0.72rem;
    opacity: 0.65;
    flex-shrink: 0;
}

.customer-picker-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    background: var(--bg);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
    padding: 0.5rem;
    z-index: 500;
}

[data-theme="dark"] .customer-picker-dropdown {
    border-color: var(--gray-700);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

@media (max-width: 600px) {
    .customer-pill-code { display: none; }
    .customer-pill-name { max-width: 120px; }
    .customer-picker-dropdown { width: calc(100vw - 2rem); right: -0.5rem; }
}

/* ============================================================
   Customer page — new-order tab
   ============================================================ */
.no-customer-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3.5rem 2rem;
    text-align: center;
    color: var(--gray-500);
    font-size: 1rem;
    gap: 0.5rem;
}

.new-order-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 2.5rem 2rem;
}

.new-order-customer-card {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.new-order-hint {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin: 0;
}

.new-order-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-lg {
    padding: 0.7rem 1.75rem;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
}

/* ============================================================
   Customer page — account info tab
   ============================================================ */
.account-info-tab {
    padding: 0.25rem 0;
}

.account-info-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.account-info-details {
    flex: 1;
    min-width: 0;
}

.account-avatar.lg {
    width: 64px;
    height: 64px;
    font-size: 1.3rem;
}

@media (max-width: 640px) {
    .account-info-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .account-balance-block {
        width: 100%;
    }
}

/* ---- Notes Tab ---- */
.notes-tab {}

.notes-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.note-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: var(--surface);
    transition: border-color 0.15s;
}

.note-card:last-child { margin-bottom: 0; }

.note-card-task {
    border-left: 3px solid var(--warning, #f59e0b);
}

.note-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.note-card-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.note-card-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.note-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.note-meta-item {
    color: var(--text-muted);
}

.note-meta-date {
    margin-left: auto;
}

.note-body {
    font-size: 0.875rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
    margin-top: 0.25rem;
    /* Quill ql-editor resets */
    padding-left: 0;
    min-height: unset;
}

/* ---- Note Form ---- */
.note-form {}

.note-form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ---- Rich Text Editor ---- */
.rich-text-editor-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.rich-text-editor-inner {
    min-height: 160px;
}

/* Override Quill snow theme to fit our design */
.rich-text-editor-wrap .ql-toolbar {
    border: none;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt, var(--gray-50));
}

.rich-text-editor-wrap .ql-container {
    border: none;
    font-family: inherit;
    font-size: 0.9rem;
}

.rich-text-editor-wrap .ql-editor {
    min-height: 140px;
    color: var(--text-primary);
}

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

[data-theme="dark"] .badge-neutral {
    background: var(--gray-700);
    color: var(--gray-300);
}

@media (max-width: 640px) {
    .note-form-row-2 {
        grid-template-columns: 1fr;
    }
    .note-meta-date {
        margin-left: 0;
    }
}
