/* ═══════════════════════════════════════════════════════════
   PLAINWEAVE DESIGN TOKENS
   These variables provide consistent spacing, radii, shadows,
   and transitions across all CRM pages.
   ═══════════════════════════════════════════════════════════ */

:root {
    /* Fallback theme defaults — matches void bg + plainweave accent */
    --bg-body: #0D0C10;
    --bg-panel: #18171E;
    --bg-surface: #242330;
    --text-main: #F0ECE4;
    --text-faint: #A09C94;
    --accent: #1C71D8;
    --accent-text: #FFFFFF;

    /* Brand pop colors — always present, not theme-dependent */
    --pw-coral: #F25757;
    --pw-coral-soft: #E8716F;
    --pw-coral-glow: rgba(242, 87, 87, 0.12);
    --pw-teal: #1B7A6A;
    --pw-teal-soft: #25947F;
    --pw-teal-glow: rgba(27, 122, 106, 0.12);
    --pw-peri: #5B73D6;
    --pw-peri-soft: #7B8FE0;
    --pw-peri-glow: rgba(91, 115, 214, 0.12);

    /* Functional colors mapped to brand */
    --pw-success: #4EC58A;
    --pw-warning: #F59E0B;
    --pw-danger: #D94040;
    --pw-info: var(--pw-peri);
    --pw-money: var(--pw-teal-soft);

    --pw-space-xs: 4px;
    --pw-space-sm: 8px;
    --pw-space-md: 16px;
    --pw-space-lg: 24px;
    --pw-space-xl: 32px;
    --pw-radius: 6px;
    --pw-transition: 0.2s ease;
    --pw-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.12);
    --pw-shadow-md: 0 2px 8px rgba(0, 0, 0, 0.18);
    --pw-shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.24);
}

/* Prevent black flash — immediate background before JS loads */
html { background-color: var(--bg-body, #0D0C10); }

/* ============================================
   CRM Template - Shared Styles
   ============================================ */

/* ========================================
   CSS RESET
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
html { overflow-x: hidden; }

/* ========================================
   BASE STYLES
   ======================================== */
body {
    font-family: var(--font-main);
    background-color: var(--bg-body, #0D0C10);
    color: var(--text-main, #E8E0DC);
    height: 100vh;
    overflow: hidden;
    padding: 10px 16px 0;
    line-height: 1.6;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'kern' 1, 'liga' 1;
}
.container, .container.pw-layout {
    height: calc(100vh - 20px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.pw-grid, .content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    max-width: 100%;
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
}

/* ========================================
   PASSWORD SCREEN
   ======================================== */
#passwordScreen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--bg-body) 0%, var(--bg-panel) 100%);
    z-index: 10000;
}

.password-container {
    background: var(--bg-panel);
    padding: 50px;
    border-radius: 6px;
    box-shadow: 0 6px 24px var(--accent-glow);
    text-align: center;
    max-width: 400px;
    width: 100%;
    border: 1px solid var(--accent);
}

.password-container h1 {
    font-family: var(--font-heading);
    color: var(--accent);
    font-size: 2em;
    margin-bottom: 12px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.password-container p {
    color: var(--text-faint);
    margin-bottom: 30px;
    font-size: 1.1em;
}

.password-input {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 1.1em;
    font-family: var(--font-main);
    margin-bottom: 10px;
    transition: border-color 0.2s;
    background: var(--bg-body);
    color: var(--text-main);
}

.password-input:focus {
    outline: none;
    border-color: var(--accent);
}

.password-btn {
    width: 100%;
    padding: 15px;
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    border-radius: 6px;
    font-size: 1.2em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-main);
    box-shadow: 0 4px 15px var(--accent-glow);
}

.password-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.password-error {
    color: #ff6b6b;
    margin-top: 15px;
    font-weight: 600;
    display: none;
}

#mainContent {
    display: none;
}

/* ========================================
   CONTAINER
   ======================================== */
.container {
    max-width: none;
    width: 100%;
    margin: 0;
    background: var(--bg-panel);
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    border: none;
}

/* ========================================
   HEADER
   ======================================== */
.header {
    background: var(--bg-panel);
    color: var(--text-main);
    padding: 25px 30px;
    text-align: center;
    border-bottom: 1px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    position: relative;
}

.header h1 {
    font-size: 1.8em;
    margin: 0;
    color: var(--accent);
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    transition: color 0.2s;
}

.header h1:hover {
    color: var(--text-faint);
}

/* Header Logo */
.header-logo-container {
    position: relative;
    width: 80px;
    height: 80px;
    cursor: pointer;
}

.header-logo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--accent);
    box-shadow: 0 4px 12px var(--accent-glow);
    display: none;
}

.header-logo-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--bg-panel) 70%, var(--bg-surface));
    border: 1px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: 0.7em;
    text-align: center;
    padding: 10px;
    box-shadow: 0 4px 12px var(--accent-glow);
    transition: all 0.2s ease;
}

.header-logo-container:hover .header-logo-placeholder {
    background: var(--bg-surface);
    transform: scale(1.05);
}

.header-logo-upload {
    display: none;
}

.logo-edit-overlay {
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: var(--accent);
    color: var(--accent-text);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    cursor: pointer;
    border: 1px solid var(--bg-panel);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    transition: all 0.2s ease;
    opacity: 0;
}

.header-logo-container:hover .logo-edit-overlay {
    opacity: 1;
}

.logo-edit-overlay:hover {
    background: var(--accent-hover);
    transform: scale(1.1);
}

/* ========================================
   SYNC INDICATOR
   ======================================== */
.sync-indicator {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-faint);
    z-index: 10;
    transition: all 0.2s ease;
    box-shadow: 0 0 8px var(--accent-glow, rgba(100,100,100,0.3));
}

.sync-indicator.syncing {
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow, rgba(100,100,100,0.4));
    animation: pulse 1.5s infinite;
}

.sync-indicator.synced {
    background: var(--pw-success);
    box-shadow: 0 0 12px rgba(78, 197, 138, 0.4);
    animation: pw-breathe 4s ease-in-out infinite;
}
@keyframes pw-breathe {
    0%, 100% { box-shadow: 0 0 6px rgba(78, 197, 138, 0.3); }
    50%      { box-shadow: 0 0 12px rgba(78, 197, 138, 0.5); }
}

.sync-indicator.error {
    background: var(--pw-coral);
    box-shadow: 0 0 12px var(--pw-coral-glow);
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

/* ========================================
   NAVIGATION (old dropdown — hidden, replaced by nav.js sidebar/tabs)
   ======================================== */
/* Legacy nav elements are removed by nav.js on init.
   These rules serve as fallback if nav.js hasn't loaded yet. */
.nav-container,
#nav-placeholder { display: none; }

/* ========================================
   CONTENT AREA
   ======================================== */
.content {
    padding: 16px 20px;
    min-height: 0;
}

.section-title {
    font-size: 1.6em;
    color: var(--text-main);
    margin-bottom: 0;
    margin-top: 0;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--accent);
    font-weight: 700;
    align-self: start;
    flex-shrink: 0;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.2s ease;
    font-weight: 600;
    font-family: var(--font-main);
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-text);
    box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: var(--accent-faint, rgba(100,100,100,0.2));
    color: var(--accent);
}

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

.btn-success:hover {
    background: var(--accent-hover);
}

.btn-danger {
    background: var(--pw-danger);
    color: #fff;
}

.btn-danger:hover {
    background: #C53030;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85em;
}

/* ========================================
   CARDS
   ======================================== */
.card {
    background: color-mix(in srgb, var(--bg-panel) 70%, var(--bg-surface));
    border: 1px solid var(--bg-surface);
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.item-card {
    background: color-mix(in srgb, var(--bg-panel) 70%, var(--bg-surface));
    padding: 14px 16px;
    border-radius: 6px;
    border: 1px solid var(--bg-surface);
    transition: all 0.2s ease;
    margin-bottom: 8px;
}

.stat-card {
    background: var(--bg-surface);
    color: var(--text-main);
    padding: 14px 16px;
    border-radius: 6px;
    border: 1px solid var(--accent-faint, rgba(100,100,100,0.15));
    border-left: 3px solid var(--accent);
}

.stat-card h3 {
    font-size: 1.6em;
    margin-bottom: 2px;
    font-weight: 700;
    color: var(--text-main);
}

.stat-card p {
    opacity: 0.7;
    font-size: 0.82em;
    color: var(--text-faint);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.stat-value {
    font-size: 2em;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 5px;
}

.stat-label {
    color: var(--text-faint);
    font-size: 0.95em;
}

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

.form-group label {
    display: block;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--bg-surface);
    border-radius: 6px;
    font-size: 1em;
    font-family: var(--font-main);
    background: var(--bg-body);
    color: var(--text-main);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}

input:focus, select:focus, textarea:focus {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

/* ========================================
   MODALS
   ======================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    padding: 5vh 20px;
    overflow: hidden;
}

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

body.modal-open,
body:has(.modal.active) {
    overflow: hidden !important;
    height: 100vh !important;
}

.modal-content {
    background: var(--bg-panel);
    border-radius: 6px;
    padding: 30px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid var(--bg-surface);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 15px;
    flex-shrink: 0;
}

.modal-header h2 {
    color: var(--accent);
    font-size: 1.8em;
}

/* Ensure close buttons have aria-label="Close" in HTML for accessibility */
.close-btn {
    font-size: 2em;
    cursor: pointer;
    color: var(--text-faint);
    background: none;
    border: none;
    padding: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: var(--bg-surface);
    color: var(--accent);
}

/* ========================================
   TABLES
   ======================================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.data-table th {
    background: color-mix(in srgb, var(--bg-panel) 70%, var(--bg-surface));
    color: var(--accent);
    padding: 12px;
    text-align: left;
    border-bottom: 2px solid var(--bg-surface);
    font-weight: 600;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid var(--bg-surface);
    color: var(--text-main);
}

.data-table tr:hover {
    background: color-mix(in srgb, var(--bg-panel) 70%, var(--bg-surface));
}

.empty-state {
    text-align: center;
    padding: 20px 16px;
    color: var(--text-faint);
    font-style: italic;
    font-size: 0.92em;
}

/* ========================================
   REPORT SECTIONS
   ======================================== */
.report-section {
    background: var(--bg-body);
    border: 2px solid var(--bg-surface);
    border-radius: 6px;
    padding: 25px;
    margin-bottom: 25px;
}

.report-section h2 {
    color: var(--accent);
    margin-bottom: 20px;
    font-size: 1.5em;
    border-bottom: 2px solid var(--bg-surface);
    padding-bottom: 10px;
}

/* ========================================
   CONTROLS
   ======================================== */
.controls {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    align-items: center;
}

.controls select,
.controls button,
.controls input {
    padding: 10px 20px;
    font-size: 1em;
    border-radius: 6px;
    border: 2px solid var(--bg-surface);
    font-family: var(--font-main);
}

.controls select,
.controls input {
    background: var(--bg-body);
    color: var(--text-main);
}

.controls button {
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.controls button:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.export-btn {
    background: var(--bg-surface);
    color: var(--text-main);
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 1em;
    font-weight: 600;
    transition: all 0.2s ease;
}

.export-btn:hover {
    background: var(--accent-faint, rgba(100,100,100,0.2));
    color: var(--accent);
}

/* ========================================
   SELECTION MODE
   ======================================== */
.selection-mode-bar {
    background: var(--bg-surface);
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    display: none;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.selection-mode-bar.active {
    display: flex;
}

/* ========================================
   SCROLLBAR STYLES
   ======================================== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

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

::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--text-faint) 40%, transparent);
    border-radius: 6px;
}

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

/* ========================================
   MOBILE RESPONSIVE STYLES
   ======================================== */
@media (max-width: 768px) {
    body {
        padding: 10px;
        font-size: 16px;
        height: auto;
        overflow: auto;
    }
    .container, .container.pw-layout {
        height: auto;
        overflow: visible;
    }
    .pw-grid, .content {
        overflow: visible;
    }

    .container {
        padding: 10px !important;
        width: 100% !important;
    }

    .content {
        padding: 15px 20px;
    }

    .header {
        flex-direction: column;
        gap: 10px;
        padding: 15px 10px !important;
    }

    .header h1 {
        font-size: 1.8em !important;
    }

    .password-container {
        padding: 30px 20px;
    }

    /* Old nav classes removed — nav.js handles responsive nav */

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

    .stat-card {
        padding: 15px;
    }

    .stat-card h3 {
        font-size: 1.8em;
    }

    .card {
        padding: 12px;
        margin-bottom: 15px;
    }

    .item-card {
        padding: 12px;
    }

    .section-title {
        font-size: 1.5em;
        margin-bottom: 12px;
    }

    .modal-content {
        padding: 20px;
        max-height: 85vh;
        margin: 20px 10px !important;
        max-width: 100% !important;
    }

    .modal-header {
        margin-bottom: 15px;
        padding-bottom: 10px;
    }

    .modal-header h2 {
        font-size: 1.4em;
    }

    .btn {
        padding: 10px 18px;
        font-size: 0.9em;
    }

    .btn-sm {
        padding: 6px 10px;
        font-size: 0.8em;
    }

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

    .form-group label {
        margin-bottom: 5px;
        font-size: 0.9em;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 8px 10px;
        font-size: 0.95em;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .controls button,
    .controls select {
        width: 100%;
    }

    .selection-mode-bar {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        padding: 12px;
        font-size: 0.9em;
    }

    .selection-mode-bar .btn {
        width: 100%;
        margin-top: 8px;
        font-size: 0.95em;
        padding: 12px;
        min-height: 44px;
    }

    /* Tables */
    .data-table {
        font-size: 0.85em;
    }

    .data-table th,
    .data-table td {
        padding: 8px 4px;
    }

    /* Forms */
    .form-row {
        flex-direction: column;
    }

    input, select, textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
        min-height: 44px;
    }

    /* Ensure tappable elements meet 44px touch target */
    button, .btn, .nav-btn, a.btn, [role="button"] {
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5em !important;
    }

    .section-title {
        font-size: 1.3em !important;
    }

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

    /* Force auto-fit grids with minmax(200px) to single column */
    [style*="grid-template-columns"][style*="minmax"] {
        grid-template-columns: 1fr !important;
    }

    .modal-content {
        margin: 10px 5px !important;
        padding: 15px 10px !important;
    }

    .data-table {
        font-size: 0.75em;
    }

    .data-table th,
    .data-table td {
        padding: 6px 3px;
    }
}

/* ═══════════════════════════════════════════════════════════
   PW LAYOUT SYSTEM — Floating Glass Panel Grid
   Add these classes to existing HTML. Existing rules untouched.
   ═══════════════════════════════════════════════════════════ */

/* ── Scene: solid background + watermark ── */

body.pw-scene::before {
    content: 'Plainweave Software';
    position: fixed;
    bottom: 30px;
    right: 30px;
    font-family: var(--font-main, 'Outfit', sans-serif);
    font-size: 1.1em;
    color: var(--glass-border);
    pointer-events: none;
    z-index: 0;
    opacity: 0.5;
    letter-spacing: 0.02em;
}

/* ── Layout container: transparent, wider ── */
.container.pw-layout {
    max-width: none;
    width: 100%;
    background: transparent;
    box-shadow: none;
    border: none;
    overflow: visible;
}

/* ── Grid wrapper (replaces .content padding) ── */
.pw-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
    min-height: 0;
}

/* ── Floating glass panel ── */
.pw-panel {
    background: var(--glass);
    border: 1px solid color-mix(in srgb, var(--accent) 15%, transparent);
    border-radius: 6px;
    padding: 18px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.08);
    position: relative;
    margin-bottom: 0;
}

/* Solid variant — higher opacity */
.pw-panel--solid {
    background: var(--glass-solid);
}

/* ── Multi-column grids ── */
.pw-cols-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.pw-cols-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.pw-cols-60-40 {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 20px;
}

.pw-cols-40-60 {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: 20px;
}

/* ── Stats row: 4 cols on desktop, 2x2 on mobile ── */
.pw-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* ── Full-width span for items inside pw-cols-* parents ── */
.pw-full {
    grid-column: 1 / -1;
}

/* ── Header as glass panel ── */
.header.pw-panel {
    background: var(--glass);
    border-bottom: none;
    border-radius: 6px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.12), inset 0 1px 0 var(--glass-highlight);
}

/* ── Override rules for existing classes used as panels ── */
.report-section.pw-panel {
    background: var(--glass);
    border: none;
    border-radius: 6px;
    margin-bottom: 0;
}

.section.pw-panel {
    background: var(--glass);
    border: none;
    border-radius: 6px;
}

.card.pw-panel {
    background: var(--glass);
    border: none;
    border-radius: 6px;
    margin-bottom: 0;
}

.financial-summary.pw-panel {
    background: var(--glass);
    border: none;
    border-radius: 6px;
}

.chart-container.pw-panel {
    background: var(--glass);
    border: none;
    border-radius: 6px;
}

.forms-card.pw-panel {
    background: var(--glass);
    border: none;
    border-radius: 6px;
}

.schedule-section.pw-panel {
    background: var(--glass);
    border: none;
    border-radius: 6px;
}

/* ── Stats inside panels ── */
.pw-stats-row .stat-card {
    background: var(--glass-solid);
    border: none;
    border-radius: 6px;
}

/* ── Responsive: Tablet ── */
@media (max-width: 1024px) {
    .container.pw-layout {
        max-width: 100%;
    }

    .pw-cols-2,
    .pw-cols-3,
    .pw-cols-60-40,
    .pw-cols-40-60 {
        grid-template-columns: 1fr;
    }

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

/* ── Responsive: Mobile ── */
@media (max-width: 768px) {
    body.pw-scene::before {
        display: none;
    }

    .pw-grid {
        padding: 14px 12px;
        gap: 14px;
    }

    .pw-panel {
        border-radius: 6px;
        padding: 18px;
    }

    .header.pw-panel {
        border-radius: 6px;
    }

    .report-section.pw-panel,
    .section.pw-panel,
    .card.pw-panel,
    .financial-summary.pw-panel,
    .chart-container.pw-panel,
    .forms-card.pw-panel,
    .schedule-section.pw-panel {
        border-radius: 6px;
    }

    .pw-stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

/* ── Responsive: Small mobile ── */
@media (max-width: 480px) {
    .pw-panel {
        border-radius: 6px;
        padding: 14px;
    }

    .header.pw-panel {
        border-radius: 6px;
    }

    .report-section.pw-panel,
    .section.pw-panel,
    .card.pw-panel,
    .financial-summary.pw-panel,
    .chart-container.pw-panel,
    .forms-card.pw-panel,
    .schedule-section.pw-panel {
        border-radius: 6px;
    }

    .pw-grid {
        padding: 10px 8px;
        gap: 12px;
    }

    .pw-stats-row {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
}

/* ═══════════════════════════════════════════════════════════
   PRINT STYLES
   Clean output for invoice printing — hides app chrome,
   forces white background and black text.
   ═══════════════════════════════════════════════════════════ */
@media print {
    #pw-titlebar,
    .header,
    .nav-container,
    #nav-placeholder,
    .controls,
    .btn,
    button,
    .sync-indicator,
    .selection-mode-bar,
    .modal,
    #passwordScreen,
    body.pw-scene::before {
        display: none !important;
    }

    body {
        background: #fff !important;
        color: #000 !important;
        padding: 0 !important;
        padding-top: 0 !important;
        font-size: 12pt;
    }

    .container {
        box-shadow: none !important;
        border: none !important;
        background: #fff !important;
        max-width: 100% !important;
    }

    .content {
        padding: 0 !important;
    }

    .card, .item-card, .pw-panel, .report-section {
        background: #fff !important;
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        color: #000 !important;
    }

    a { color: #000 !important; text-decoration: none !important; }
}

/* ════════════════════════════════════════════════════════════════
   LIGHT MODE OVERRIDES — visual structure & depth for light themes
   ════════════════════════════════════════════════════════════════ */

/* Light mode text contrast — ensure headings and data are always readable */
/* Fade-in removed — was causing perceived lag on page transitions */

/* ========================================
   TABULAR NUMS
   ======================================== */
.stat-card h3, .stat-value, [style*="font-data"] {
    font-variant-numeric: tabular-nums;
}

.pw-light .section-title { color: var(--text-main); }
.pw-light .stat-card h3 { color: var(--text-main); }
.pw-light .stat-card p { color: var(--text-faint); }
.pw-light .report-section h2 { color: var(--text-main); }
.pw-light .data-table th { color: var(--text-main); }
.pw-light h2, .pw-light h3 { color: var(--text-main); }

/* Panels: visible card elevation with subtle shadow and crisp border */
.pw-light .pw-panel {
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
    border: 1px solid rgba(0,0,0,0.08);
}

.pw-light .pw-panel:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.08), 0 6px 20px rgba(0,0,0,0.05);
}

.pw-light .header.pw-panel {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06), 0 6px 24px rgba(0,0,0,0.04);
}

/* Cards inside panels — inset look with surface background */
.pw-light .card {
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.07);
}

.pw-light .card.pw-panel {
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
}

/* Stat cards: subtle inset styling for light mode */
.pw-light .stat-card {
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* Stat cards inside pw-stats-row panels */
.pw-light .pw-stats-row .stat-card {
    background: var(--bg-surface);
    border: 1px solid rgba(0,0,0,0.06);
}

/* Inner stat boxes (used in BI panels) — light surface bg */
.pw-light [data-dash-section] [style*="background: var(--bg-body"] {
    border: 1px solid rgba(0,0,0,0.05);
}

/* Calendar cells — visible grid lines */
.pw-light .calendar-cell {
    border-color: rgba(0,0,0,0.08);
}

/* Buttons: clearer outlines in light mode */
.pw-light .btn-secondary,
.pw-light .btn.btn-secondary {
    border-color: rgba(0,0,0,0.15);
}

/* Weather emoji: ensure contrast with text-shadow */
.pw-light #weatherIcon {
    filter: drop-shadow(0 0 1px rgba(0,0,0,0.2));
}

/* Quick action links: crisp borders */
.pw-light [data-dash-section="quickLinks"] .pw-panel {
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* Modal overlays: lighter backdrop */
.pw-light .modal {
    background: rgba(0,0,0,0.3);
}

/* Nav sidebar: subtle right border */
.pw-light .nav-sidebar,
.pw-light .sidebar {
    border-right: 1px solid rgba(0,0,0,0.06);
}

/* Divider lines — stronger in light mode */
.pw-light [style*="border-bottom: 1px solid"] {
    border-color: rgba(0,0,0,0.08) !important;
}

/* Section labels inside panels — darken slightly for readability */
.pw-light .pw-panel [style*="color: var(--text-faint)"] {
    opacity: 0.85;
}

/* ════════════════════════════════════════════════════════════════
   DARK MODE OVERRIDES — depth, hierarchy, and polish
   ════════════════════════════════════════════════════════════════ */

/* Panels: subtle edge glow and lifted shadow */
.pw-dark .pw-panel {
    box-shadow: 0 1px 1px rgba(0,0,0,0.25),
                0 4px 14px rgba(0,0,0,0.20),
                inset 0 1px 0 rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
}

.pw-dark .pw-panel:hover {
    border-color: rgba(255,255,255,0.10);
    box-shadow: 0 2px 4px rgba(0,0,0,0.18),
                0 8px 24px rgba(0,0,0,0.22),
                inset 0 1px 0 rgba(255,255,255,0.05);
}

/* Header panel: stronger lift */
.pw-dark .header.pw-panel {
    box-shadow: 0 2px 6px rgba(0,0,0,0.18),
                0 8px 32px rgba(0,0,0,0.20),
                inset 0 1px 0 rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.06);
}

/* Cards: visible separation from panel background */
.pw-dark .card {
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.05);
}

.pw-dark .card.pw-panel {
    box-shadow: 0 1px 3px rgba(0,0,0,0.25),
                0 4px 14px rgba(0,0,0,0.18),
                inset 0 1px 0 rgba(255,255,255,0.04);
}

/* Stat cards */
.pw-dark .stat-card {
    box-shadow: 0 1px 4px rgba(0,0,0,0.20);
    border: 1px solid rgba(255,255,255,0.04);
}

.pw-dark .pw-stats-row .stat-card {
    border: 1px solid rgba(255,255,255,0.05);
}

/* Quick links row — card-like depth */
.pw-dark [data-dash-section="quickLinks"] > a {
    border: 1px solid rgba(255,255,255,0.05);
}

.pw-dark [data-dash-section="quickLinks"] > a:hover {
    border-color: rgba(255,255,255,0.10);
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

/* Buttons: clearer in dark mode */
.pw-dark .btn-secondary,
.pw-dark .btn.btn-secondary {
    border-color: rgba(255,255,255,0.12);
}

.pw-dark .btn-secondary:hover,
.pw-dark .btn.btn-secondary:hover {
    border-color: rgba(255,255,255,0.20);
    background: rgba(255,255,255,0.06);
}

/* Nav sidebar: soft edge */
.pw-dark .nav-sidebar,
.pw-dark .sidebar {
    border-right: 1px solid rgba(255,255,255,0.04);
}
