/* ═══════════════════════════════════════════
   DUKE CONTRACTORS ERP — STYLES
   Corporate: Orange, White, Black
   Apple-inspired minimalist design
   ═══════════════════════════════════════════ */

:root {
    --primary: #E87A2E;
    --primary-dark: #C96820;
    --primary-light: #F5A623;
    --bg: #FAFAFA;
    --bg-card: #FFFFFF;
    --bg-sidebar: #1A1A1A;
    --text: #1A1A1A;
    --text-secondary: #6B7280;
    --text-light: #9CA3AF;
    --border: #E5E7EB;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --transition: all 0.2s ease;
    --sidebar-width: 260px;
    --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
}

[data-theme="dark"] {
    --bg: #111111;
    --bg-card: #1E1E1E;
    --bg-sidebar: #0A0A0A;
    --text: #F3F4F6;
    --text-secondary: #9CA3AF;
    --text-light: #6B7280;
    --border: #2D2D2D;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.4);
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ─── LOGIN ─── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1A1A1A 0%, #2D2D2D 100%);
}

.login-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 48px;
    width: 420px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-card .logo {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.login-card .subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}

/* ─── LAYOUT ─── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.3px;
}

.sidebar-brand small {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-nav { padding: 12px 8px; flex: 1; }

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.3);
    padding: 12px 12px 6px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

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

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

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

.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px; color: #fff;
}

.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.4); }

/* ─── MAIN CONTENT ─── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    max-width: calc(100vw - var(--sidebar-width));
    overflow-x: hidden;
}

.top-bar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.top-bar-actions { display: flex; gap: 12px; align-items: center; }

.page-content { padding: 28px 32px; }

/* ─── CARDS ─── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.card-body { padding: 24px; }
.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.stat-value.money::before { content: '$'; }

.stat-card.accent {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.stat-card.accent .stat-label { color: rgba(255,255,255,0.8); }

/* ─── TABLES ─── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

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

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:hover { background: rgba(232, 122, 46, 0.03); }
tbody tr:last-child td { border-bottom: none; }

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

/* Standalone field label (used outside .form-group, e.g. modal grids). */
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

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

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="tel"],
input[type="url"], select, textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg-card);
    transition: var(--transition);
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(232, 122, 46, 0.1);
}

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

.calendar-datetime-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 12px;
}

.calendar-datetime-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.calendar-datetime-card {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(140px, 0.9fr);
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #fbf7f2 100%);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
}

.calendar-datetime-part {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.calendar-datetime-part-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.calendar-datetime-card input[type="date"],
.calendar-datetime-card select {
    min-height: 44px;
    border-radius: 12px;
    border-color: #e7d8ca;
    background: rgba(255, 255, 255, 0.96);
    font-weight: 600;
}

.calendar-datetime-card input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.7;
}

.calendar-datetime-card input[type="date"]:focus,
.calendar-datetime-card select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(232, 122, 46, 0.12);
}

/* ─── BUTTONS ─── */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

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

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

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

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

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 15px; }

.btn-group { display: flex; gap: 8px; }

/* ─── BADGES ─── */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-orange { background: rgba(232,122,46,0.12); color: var(--primary); }
.badge-green { background: rgba(16,185,129,0.12); color: var(--success); }
.badge-red { background: rgba(239,68,68,0.12); color: var(--danger); }
.badge-blue { background: rgba(59,130,246,0.12); color: var(--info); }
.badge-yellow { background: rgba(245,158,11,0.12); color: var(--warning); }
.badge-gray { background: rgba(107,114,128,0.12); color: var(--text-secondary); }

/* ─── KANBAN BOARD ─── */
.kanban-board {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 16px;
    min-height: 400px;
}

.kanban-column {
    min-width: 260px;
    max-width: 300px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.kanban-column-header {
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kanban-column-header .count {
    background: var(--primary);
    color: #fff;
    width: 22px; height: 22px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px;
}

.kanban-cards { padding: 8px; min-height: 50px; }

.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
}

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

.kanban-card .name { font-weight: 600; margin-bottom: 4px; }
.kanban-card .address { color: var(--text-secondary); font-size: 12px; }
.kanban-card .meta { color: var(--text-light); font-size: 11px; margin-top: 6px; }

/* ─── MODAL ─── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border-radius: 16px;
    width: 90%;
    max-width: 640px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-lg { max-width: 900px; }
.wide { max-width: 960px; }
/* Full-bleed modal for PDF preview — leaves a small breathing margin around the
   edges of the viewport so the user can still see the chrome and click outside
   to dismiss, but otherwise lets the document fill the screen. */
.modal-pdf {
    max-width: 95vw;
    width: 95vw;
    max-height: 95vh;
    height: 95vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-pdf .modal-body {
    flex: 1;
    overflow: hidden;
    padding: 12px 16px 16px;
    display: flex;
    flex-direction: column;
}

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

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    color: var(--text-secondary);
}

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

/* ─── SEARCH BAR ─── */
.search-bar {
    position: relative;
}

.search-bar input {
    padding-left: 36px;
    width: 280px;
}

.search-bar svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-light);
}

/* ─── FILTER BAR ─── */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar select {
    width: auto;
    min-width: 160px;
}

/* ─── BUNDLED LISTS ─── */
.bundle-toolbar {
    margin-bottom: 18px;
    padding: 18px 20px;
}

.bundle-toolbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.bundle-toolbar-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.bundle-view-switch {
    display: inline-flex;
    align-items: center;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    gap: 4px;
}

.bundle-view-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    min-height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: var(--transition);
}

.bundle-view-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 6px 14px rgba(232,122,46,0.22);
}

.bundle-view-btn:hover:not(.active) {
    color: var(--text);
    background: rgba(0,0,0,0.04);
}

.bundle-toolbar-summary {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: right;
    color: var(--text-secondary);
    font-size: 12px;
}

.bundle-toolbar-summary strong {
    color: var(--text);
    font-size: 14px;
}

.bundle-inline-control,
.bundle-inline-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-card);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.bundle-inline-control select {
    min-width: 150px;
    border: none;
    background: transparent;
    color: var(--text);
    font-weight: 600;
    outline: none;
}

.bundle-inline-control input {
    min-width: 220px;
    border: none;
    background: transparent;
    color: var(--text);
    font-weight: 600;
    outline: none;
}

.bundle-search-control {
    min-width: 300px;
}

.bundle-inline-check input {
    accent-color: var(--primary);
}

.bundle-scope-note {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.bundle-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.bundle-group {
    overflow: hidden;
}

.bundle-summary {
    width: 100%;
    border: none;
    background: transparent;
    padding: 20px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    cursor: pointer;
    text-align: left;
    transition: background 0.18s ease;
}

.bundle-summary:hover {
    background: rgba(232,122,46,0.04);
}

.bundle-summary.is-open {
    border-bottom: 1px solid var(--border);
}

.bundle-summary-main {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.bundle-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.bundle-customer-name {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.bundle-count {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 11px;
    border-radius: 999px;
    background: rgba(107,114,128,0.12);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
}

.bundle-count.is-alert {
    background: rgba(232,122,46,0.14);
    color: var(--primary-dark);
}

.bundle-address {
    color: var(--text-secondary);
    font-size: 14px;
}

.bundle-meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.bundle-meta-pill,
.bundle-more-status {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
}

.bundle-chevron {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg);
    position: relative;
    flex-shrink: 0;
    transition: transform 0.18s ease, background 0.18s ease;
}

.bundle-chevron::before,
.bundle-chevron::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 999px;
    transform-origin: center;
}

.bundle-chevron::before {
    transform: translate(-68%, -50%) rotate(45deg);
}

.bundle-chevron::after {
    transform: translate(-22%, -50%) rotate(-45deg);
}

.bundle-summary.is-open .bundle-chevron {
    transform: rotate(180deg);
    background: rgba(232,122,46,0.08);
}

.bundle-items {
    padding: 18px 20px 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    background: linear-gradient(180deg, rgba(232,122,46,0.03), transparent 36%);
}

.bundle-item-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-card);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.bundle-item-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
    border-color: rgba(232,122,46,0.35);
}

.bundle-item-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.bundle-item-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.bundle-item-subtitle {
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.5;
}

.bundle-item-price {
    color: var(--primary-dark);
    font-size: 18px;
    font-weight: 800;
    white-space: nowrap;
}

.bundle-item-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.bundle-item-grid strong {
    display: block;
    margin-top: 4px;
    color: var(--text);
    font-size: 13px;
}

.bundle-item-label {
    display: block;
    color: var(--text-light);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.bundle-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.estimate-bundle-items {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 14px;
}

.estimate-bundle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 18px;
    align-items: stretch;
    grid-auto-rows: 1fr;
}

.estimate-bundle-group {
    min-height: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.estimate-bundle-summary {
    min-height: 180px;
    padding: 16px 18px;
    align-items: flex-start;
    flex: 1 1 auto;
}

.estimate-bundle-summary .bundle-summary-main {
    gap: 10px;
}

.estimate-bundle-summary .bundle-customer-name {
    font-size: 16px;
    line-height: 1.2;
}

.estimate-bundle-summary .bundle-address {
    font-size: 13px;
    line-height: 1.4;
}

.estimate-jobtype-pill {
    max-width: 100%;
}

.estimate-bundle-items .bundle-item-card {
    flex: 1 1 100%;
    width: 100%;
    max-width: none;
    min-height: 100%;
    padding: 14px;
}

.estimate-bundle-group .bundle-items {
    padding: 0 16px 16px;
    background: none;
    grid-template-columns: 1fr;
    gap: 12px;
}

.estimate-price-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.estimate-option-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(232,122,46,0.08);
    color: var(--primary-dark);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.estimate-price-summary {
    display: grid;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid rgba(232,122,46,0.14);
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(232,122,46,0.06), rgba(232,122,46,0.02));
}

.estimate-price-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.estimate-price-label {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
}

.estimate-price-value {
    color: var(--primary-dark);
    font-size: 14px;
    font-weight: 800;
}

.estimate-bundle-items .bundle-item-actions {
    margin-top: auto;
}

.bundle-empty-state {
    background: var(--bg-card);
    border: 1px dashed var(--border);
}

/* ─── PIPELINE ─── */
.pipeline-bar {
    display: flex;
    gap: 2px;
    margin-bottom: 24px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.pipeline-segment {
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    min-width: 30px;
    cursor: pointer;
    transition: var(--transition);
}

.pipeline-segment:hover { opacity: 0.85; }

/* ─── ALERTS ─── */
.alert-banner {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
}

.alert-warning {
    background: rgba(245,158,11,0.1);
    border: 1px solid rgba(245,158,11,0.2);
    color: #92400E;
}

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

.alert-success {
    background: rgba(16,185,129,0.1);
    border: 1px solid rgba(16,185,129,0.2);
    color: #065F46;
}

/* ─── TABS ─── */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.tab {
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
}

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

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

/* ─── CHECKLIST ─── */
.checklist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

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

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

.checklist-item.completed .task-text {
    text-decoration: line-through;
    color: var(--text-light);
}

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

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideIn 0.3s ease;
    min-width: 280px;
}

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

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ─── MISC ─── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.clickable { cursor: pointer; }

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

.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { font-size: 16px; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 13px; }

/* ─── MOBILE HAMBURGER ─── */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--text);
    flex-shrink: 0;
}
.hamburger-btn svg { width: 24px; height: 24px; }
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s;
}
.sidebar-overlay.active {
    display: block;
    opacity: 1;
}
.sidebar-close-btn {
    display: none;
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    z-index: 101;
}

/* ─── NOTES ─── */
.notes-page {
    display: grid;
    gap: 16px;
}

.notes-toolbar-card {
    padding: 18px 20px;
}

.notes-toolbar-top,
.notes-toolbar-bottom,
.notes-filter-row,
.notes-draft-controls,
.notes-composer-header,
.notes-composer-footer,
.note-editor-toolbar,
.note-editor-footer,
.notes-label-manager-row,
.notes-label-manager-create {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.notes-toolbar-card,
.notes-composer,
.note-card,
.note-editor {
    overflow: visible;
}

.notes-search-wrap {
    position: relative;
    flex: 1;
    min-width: 260px;
}

.notes-search-wrap input {
    width: 100%;
    padding: 12px 16px 12px 42px;
    border-radius: 999px;
    background: var(--bg);
}

.notes-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
    display: inline-flex;
}

.notes-search-icon svg,
.notes-empty-icon svg,
.note-icon-btn svg,
.note-pill-btn svg,
.note-label-suggestion svg,
.notes-toolbar-card .btn svg,
.note-upload-btn svg,
.note-panel-badge svg,
.note-link-search-icon svg,
.note-client-chip button svg,
.note-card-linked-icon svg {
    width: 16px;
    height: 16px;
}

.notes-view-tabs {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    border-radius: 999px;
    background: var(--bg);
    border: 1px solid var(--border);
}

.notes-view-tab {
    border: none;
    background: transparent;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.notes-view-tab strong {
    background: rgba(0,0,0,0.06);
    color: inherit;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 11px;
}

.notes-view-tab.active {
    background: var(--primary);
    color: #fff;
}

.notes-view-tab.active strong {
    background: rgba(255,255,255,0.18);
}

.notes-toolbar-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
}

.notes-manage-labels-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid rgba(15,23,42,0.08);
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    color: #1f2937;
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(15,23,42,0.06);
}

.notes-manage-labels-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(232,122,46,0.18);
    box-shadow: 0 14px 30px rgba(232,122,46,0.08);
}

.notes-manage-labels-icon {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(232,122,46,0.12);
    color: var(--primary);
    flex: 0 0 auto;
}

.notes-manage-labels-icon svg {
    width: 16px;
    height: 16px;
}

.notes-inline-field {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
}

.notes-inline-field select {
    width: auto;
    min-width: 140px;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--bg);
}

.note-filter-toggle,
.note-pill-btn,
.note-icon-btn,
.note-label-filter-chip,
.note-label-suggestion {
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.note-filter-toggle,
.note-pill-btn,
.note-label-filter-chip,
.note-label-suggestion {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 700;
}

.note-filter-toggle.active,
.note-pill-btn.active,
.note-label-filter-chip.active,
.note-label-suggestion:hover {
    background: rgba(232,122,46,0.1);
    border-color: rgba(232,122,46,0.25);
    color: var(--primary);
}

.note-icon-btn {
    width: 34px;
    height: 34px;
    justify-content: center;
    border-radius: 10px;
    padding: 0;
}

.note-icon-btn:hover,
.note-icon-btn.active {
    background: rgba(232,122,46,0.1);
    border-color: rgba(232,122,46,0.2);
    color: var(--primary);
}

.note-icon-btn.danger:hover {
    background: rgba(239,68,68,0.1);
    border-color: rgba(239,68,68,0.2);
    color: var(--danger);
}

.notes-label-filter-strip,
.note-color-palette,
.note-label-suggestions,
.note-selected-labels,
.note-card-labels,
.note-card-actions,
.note-link-header strong,
.note-attachments-header strong,
.note-card-linked-lead {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.notes-label-filter-strip {
    margin-top: 12px;
}

.notes-muted {
    color: var(--text-secondary);
    font-size: 12px;
}

.notes-composer {
    border-radius: 16px;
}

.notes-composer-collapsed {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: text;
    min-height: 60px;
}

.notes-composer-collapsed:hover {
    box-shadow: var(--shadow-lg);
}

.notes-composer-collapsed-input {
    color: var(--text-secondary);
    font-size: 15px;
}

.notes-composer-collapsed-actions {
    display: inline-flex;
    gap: 8px;
}

.notes-composer-expanded {
    padding: 18px;
}

.notes-composer-header input,
.note-editor-title {
    border: none;
    background: transparent;
    padding: 0;
    font-size: 18px;
    font-weight: 700;
    box-shadow: none !important;
}

.notes-composer-body textarea,
.note-editor-textarea {
    min-height: 110px;
    border: none;
    background: transparent;
    padding: 0;
    resize: vertical;
    box-shadow: none !important;
}

.notes-draft-meta {
    display: grid;
    gap: 12px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(0,0,0,0.06);
}

.note-link-panel,
.note-attachments-panel {
    display: grid;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(0,0,0,0.02), rgba(0,0,0,0.035));
    border: 1px solid rgba(0,0,0,0.04);
}

.note-link-header,
.note-attachments-header,
.note-linked-lead-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.note-link-header p,
.note-linked-lead-card div,
.note-attachment-card figcaption {
    font-size: 12px;
    color: var(--text-secondary);
}

.note-panel-badge {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(232,122,46,0.12);
    color: var(--primary);
    flex: 0 0 auto;
}

.note-link-search {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.note-link-search-icon {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    display: inline-flex;
}

.note-link-search input {
    border: none;
    background: transparent;
    padding: 0;
    box-shadow: none !important;
}

.note-client-chip-row,
.note-lead-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.note-client-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid rgba(232,122,46,0.16);
    box-shadow: 0 6px 18px rgba(15,23,42,0.04);
}

.note-client-chip-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
}

.note-client-chip button {
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 999px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.06);
    color: var(--text-secondary);
    cursor: pointer;
}

.note-lead-suggestion {
    display: grid;
    gap: 3px;
    min-width: 180px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
}

.note-lead-suggestion:hover {
    border-color: rgba(232,122,46,0.25);
    box-shadow: 0 10px 24px rgba(232,122,46,0.08);
}

.note-lead-suggestion strong {
    font-size: 12px;
    color: var(--text-primary);
}

.note-lead-suggestion span {
    font-size: 11px;
    color: var(--text-secondary);
}

.note-linked-lead-card {
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid rgba(232,122,46,0.16);
}

.note-linked-lead-card span {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(232,122,46,0.1);
    color: var(--primary);
    font-size: 11px;
    font-weight: 700;
}

.note-link-type-field {
    justify-content: space-between;
}

.note-link-type-field select {
    flex: 1;
    min-width: 0;
}

.note-label-input-wrap {
    display: grid;
    gap: 10px;
    flex: 1;
}

.note-label-input {
    padding: 9px 12px;
    border-radius: 999px;
    background: var(--bg);
}

.note-selected-labels .note-label-chip,
.note-card-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(0,0,0,0.06);
    color: inherit;
    font-size: 11px;
    font-weight: 700;
}

.note-selected-labels .note-label-chip button {
    border: none;
    background: transparent;
    width: 14px;
    height: 14px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: inherit;
}

.note-color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.note-color-swatch.active {
    transform: scale(1.08);
    box-shadow: 0 0 0 2px rgba(232,122,46,0.16);
}

.note-checklist-editor {
    display: grid;
    gap: 10px;
}

.note-checklist-editor-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
}

.note-checklist-editor-row input[type="text"] {
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--bg);
}

.note-checklist-editor-actions {
    display: inline-flex;
    gap: 6px;
}

.note-checklist-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    width: fit-content;
    padding: 9px 14px;
    margin-top: 4px;
    border: 1px dashed rgba(232,122,46,0.3);
    border-radius: 999px;
    background: rgba(232,122,46,0.06);
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.note-checklist-add-btn:hover {
    background: rgba(232,122,46,0.12);
    border-color: rgba(232,122,46,0.45);
    transform: translateY(-1px);
}

.note-checklist-add-icon {
    width: 20px;
    height: 20px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    box-shadow: 0 6px 14px rgba(232,122,46,0.12);
    flex: 0 0 auto;
}

.note-checklist-add-icon svg {
    width: 12px;
    height: 12px;
}

.notes-section {
    display: grid;
    gap: 12px;
}

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

.notes-section-header h3 {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.notes-section-header p {
    font-size: 12px;
    color: var(--text-secondary);
}

.notes-section-header span {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
}

.notes-masonry {
    column-count: 4;
    column-gap: 16px;
}

.note-card {
    position: relative;
    display: inline-block;
    width: 100%;
    margin: 0 0 16px;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    cursor: pointer;
    break-inside: avoid;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.note-card:hover,
.note-card:focus-visible {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
    outline: none;
}

.note-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.note-card-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.note-card-pin,
.note-card-meta,
.note-card-timestamp,
.note-card-more {
    font-size: 11px;
    font-weight: 700;
    opacity: 0.82;
}

.note-card-pin svg {
    width: 14px;
    height: 14px;
}

.note-card-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.4;
}

.note-card-body {
    font-size: 13px;
    line-height: 1.6;
    white-space: normal;
    margin-bottom: 10px;
}

.note-card-linked-lead {
    margin-bottom: 10px;
    font-size: 12px;
    font-weight: 700;
    opacity: 0.92;
}

.note-card-linked-icon {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: rgba(232,122,46,0.12);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.note-card-linked-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(0,0,0,0.06);
    color: inherit;
    font-size: 11px;
    font-weight: 700;
}

.note-card-linked-chip.more {
    background: rgba(232,122,46,0.12);
    color: var(--primary);
}

.note-card-attachments,
.note-attachments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 10px;
}

.note-card-attachments {
    margin-bottom: 10px;
}

.note-card-attachments img,
.note-attachment-card img {
    width: 100%;
    height: 96px;
    object-fit: cover;
    border-radius: 12px;
    display: block;
    border: 1px solid rgba(0,0,0,0.06);
}

.note-card-attachment-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 96px;
    border-radius: 12px;
    background: rgba(0,0,0,0.06);
    font-size: 12px;
    font-weight: 800;
}

.note-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(15,23,42,0.04);
}

.note-upload-btn input {
    display: none;
}

.note-dropzone {
    border: 1.5px dashed rgba(232,122,46,0.22);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,247,240,0.9));
    padding: 18px;
    cursor: pointer;
    transition: var(--transition);
}

.note-dropzone:hover,
.note-dropzone.drag-active {
    border-color: rgba(232,122,46,0.44);
    background: linear-gradient(180deg, rgba(255,249,244,1), rgba(255,242,231,1));
    box-shadow: 0 14px 28px rgba(232,122,46,0.08);
}

.note-dropzone-inner {
    display: flex;
    align-items: center;
    gap: 14px;
}

.note-dropzone-badge {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(232,122,46,0.12);
    color: var(--primary);
    flex: 0 0 auto;
}

.note-dropzone-badge svg {
    width: 18px;
    height: 18px;
}

.note-dropzone strong {
    display: block;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 3px;
}

.note-dropzone p {
    margin: 0;
    font-size: 12px;
    color: var(--text-secondary);
}

.note-attachment-card {
    position: relative;
    margin: 0;
}

.note-attachment-card.pending::after {
    content: "Pending";
    position: absolute;
    left: 8px;
    bottom: 8px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(26,26,26,0.72);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
}

.note-attachment-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 999px;
    background: rgba(26,26,26,0.72);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.note-attachment-remove svg {
    width: 14px;
    height: 14px;
}

.note-card-checklist {
    display: grid;
    gap: 8px;
    margin-bottom: 10px;
}

.note-card-checklist-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px;
    align-items: flex-start;
    font-size: 13px;
    cursor: pointer;
}

.note-card-checklist-item input {
    margin-top: 2px;
}

.note-card-checklist-item span.completed {
    text-decoration: line-through;
    opacity: 0.6;
}

.note-card-actions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0,0,0,0.08);
}

.note-card-color-menu {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.notes-empty-state {
    padding: 40px 24px;
}

.notes-empty-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: rgba(232,122,46,0.1);
    color: var(--primary);
}

.note-editor {
    display: grid;
    gap: 18px;
}

.note-editor-toolbar-actions {
    display: inline-flex;
    gap: 8px;
}

.note-editor-main {
    display: grid;
    gap: 14px;
}

.notes-label-manager {
    display: grid;
    gap: 16px;
}

.notes-label-manager-list {
    display: grid;
    gap: 10px;
}

.notes-label-manager-row {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
}

/* ═══════════════════════════════════════════
   RESPONSIVE — MOBILE-FIRST OVERHAUL
   Desktop stays UNTOUCHED. Only kicks in ≤768px.
   ═══════════════════════════════════════════ */

/* ── TABLET (≤1024px) ── */
@media (max-width: 1024px) {
    .stats-grid[style*="repeat(6"] { grid-template-columns: repeat(3, 1fr) !important; }
    .stats-grid[style*="repeat(4"] { grid-template-columns: repeat(2, 1fr) !important; }
    .notes-masonry { column-count: 3; }
}

/* ══════════════════════════════════════════════
   MOBILE (≤768px) — Main responsive breakpoint
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* ── NAVIGATION — Hamburger + slide-out ── */
    .hamburger-btn { display: flex; align-items: center; }
    .sidebar-close-btn { display: flex; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 280px;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content {
        margin-left: 0;
        max-width: 100vw !important;
    }

    /* ── TOP BAR ── */
    .top-bar {
        padding: 10px 12px;
        gap: 8px;
    }
    .top-bar .page-title { font-size: 15px; }
    .top-bar-actions { gap: 6px !important; }
    .top-bar-actions .btn {
        font-size: 11px;
        padding: 6px 10px;
    }

    /* ── PAGE CONTENT ── */
    .page-content { padding: 10px 8px !important; }

    /* ── STAT CARDS — Always 2-col grid ── */
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }
    .stat-card {
        padding: 12px !important;
    }
    .stat-card .stat-value { font-size: 20px !important; }
    .stat-card .stat-label { font-size: 10px !important; }

    /* ── GRIDS — Force single column ── */
    .grid-2 { grid-template-columns: 1fr !important; }
    .form-grid { grid-template-columns: 1fr !important; }

    /* ── CARDS ── */
    .card { border-radius: 10px; }
    .card-header { padding: 14px 12px; }
    .card-header h3 { font-size: 14px; }
    .card-body { padding: 12px; }
    .card-footer { padding: 12px; }

    /* ── TABLES — Horizontally scrollable ── */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    table { min-width: 600px; }
    thead th { padding: 10px 12px; font-size: 11px; }
    tbody td { padding: 10px 12px; font-size: 12px; }

    /* ── FORMS — Full-width, touch-friendly ── */
    input[type="text"], input[type="email"], input[type="password"],
    input[type="number"], input[type="date"], input[type="tel"],
    input[type="url"], select, textarea {
        font-size: 16px !important; /* Prevents iOS zoom on focus */
        padding: 12px 14px !important;
        min-height: 44px; /* Apple touch target minimum */
    }
    .form-group { margin-bottom: 14px; }
    .form-group label { font-size: 12px; }

    /* ── BUTTONS — Touch-friendly sizing ── */
    .btn {
        min-height: 44px;
        padding: 10px 16px;
        font-size: 13px;
    }
    .btn-sm {
        min-height: 36px;
        padding: 6px 12px;
        font-size: 12px;
    }
    .btn-lg {
        min-height: 50px;
        padding: 14px 24px;
        font-size: 15px;
    }
    .btn-group { flex-wrap: wrap; }

    /* ── MODALS — Near-full-screen on mobile ── */
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
    .modal {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 95vh !important;
        border-radius: 16px 16px 0 0 !important;
        margin: 0 !important;
    }
    .modal-lg, .wide {
        max-width: 100% !important;
    }
    .modal-header {
        padding: 14px 16px;
        position: sticky;
        top: 0;
        background: var(--bg-card);
        z-index: 2;
    }
    .modal-header h2 { font-size: 15px; }
    .modal-body { padding: 14px 16px; }
    .modal-footer {
        padding: 12px 16px;
        flex-wrap: wrap;
        position: sticky;
        bottom: 0;
        background: var(--bg-card);
        z-index: 2;
    }
    .modal-footer .btn { flex: 1; min-width: 0; justify-content: center; }
    .modal-close {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }

    /* ── KANBAN — Vertical stacking ── */
    .kanban-board { flex-direction: column !important; }
    .kanban-column {
        max-width: 100% !important;
        min-width: 100% !important;
    }

    /* ── PIPELINE BAR ── */
    .pipeline-bar { flex-wrap: wrap; }
    .pipeline-segment {
        font-size: 9px;
        min-width: 24px;
        height: 28px;
    }

    /* ── LOGIN ── */
    .login-card {
        width: 94vw;
        padding: 28px 20px;
        border-radius: 16px;
    }
    .login-card .logo { font-size: 22px; }
    .login-card .subtitle { font-size: 13px; }

    /* ── TABS — Horizontal scroll on mobile ── */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 0;
        scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab {
        white-space: nowrap;
        padding: 10px 14px;
        font-size: 12px;
        flex-shrink: 0;
    }

    /* ── BADGES ── */
    .badge { font-size: 10px; padding: 3px 8px; }

    /* ── FILTER BAR ── */
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-bar select {
        width: 100%;
        min-width: 0;
    }
    .search-bar input { width: 100% !important; }

    /* ── TOAST — Mobile friendly position ── */
    .toast-container {
        top: auto;
        bottom: 12px;
        left: 12px;
        right: 12px;
    }
    .toast {
        min-width: 0;
        width: 100%;
        font-size: 12px;
        padding: 12px 14px;
    }

    /* ── ALERTS ── */
    .alert-banner { font-size: 12px; padding: 10px 12px; }

    /* ── CHECKLISTS ── */
    .checklist-item { padding: 8px 0; gap: 8px; }

    /* ── BUNDLES (Lead/Proposal/Estimate lists) ── */
    .bundle-toolbar,
    .bundle-summary,
    .bundle-items { padding-left: 10px; padding-right: 10px; }
    .bundle-toolbar { padding: 12px 10px; }
    .bundle-toolbar-row { flex-direction: column; align-items: stretch; gap: 10px; }
    .bundle-toolbar-controls { flex-direction: column; align-items: stretch; }
    .bundle-toolbar-summary {
        text-align: left;
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }
    .bundle-view-switch { width: 100%; justify-content: center; }
    .bundle-inline-control,
    .bundle-inline-check { width: 100%; justify-content: space-between; }
    .bundle-inline-control select,
    .bundle-inline-control input { min-width: 0; flex: 1; }
    .bundle-items { grid-template-columns: 1fr !important; }
    .bundle-item-grid { grid-template-columns: 1fr !important; }
    .estimate-bundle-grid { grid-template-columns: 1fr !important; }
    .bundle-customer-name { font-size: 15px; }
    .bundle-address { font-size: 12px; }
    .bundle-item-card { padding: 12px; }
    .bundle-item-title { font-size: 14px; }
    .bundle-item-price { font-size: 16px; }
    .bundle-item-actions { flex-wrap: wrap; }
    .bundle-item-head { flex-direction: column; align-items: flex-start !important; gap: 6px; }
    .bundle-summary { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px 10px; }
    .bundle-summary-main { width: 100%; }
    .estimate-bundle-items .bundle-item-card { flex: 1 1 100%; width: 100%; max-width: none; }
    .estimate-price-side { align-items: flex-start; }
    .bundle-chevron {
        position: absolute;
        right: 10px;
        top: 14px;
    }
    .bundle-summary { position: relative; }

    /* ── NOTES ── */
    .notes-toolbar-top,
    .notes-toolbar-bottom,
    .notes-filter-row,
    .notes-draft-controls,
    .notes-composer-header,
    .notes-composer-footer,
    .note-editor-toolbar,
    .note-editor-footer,
    .notes-label-manager-row,
    .notes-label-manager-create { flex-direction: column; align-items: stretch; }
    .notes-search-wrap { min-width: 0; }
    .notes-view-tabs { width: 100%; justify-content: space-between; }
    .notes-view-tab { flex: 1; justify-content: center; }
    .notes-inline-field { width: 100%; justify-content: space-between; }
    .notes-inline-field select { flex: 1; min-width: 0; }
    .notes-masonry { column-count: 2; }
    .note-link-header,
    .note-attachments-header,
    .note-linked-lead-card { flex-direction: column; align-items: stretch; }
    .notes-toolbar-card { padding: 12px 10px; }

    /* ── CALENDAR ── */
    .calendar-datetime-grid,
    .calendar-datetime-card { grid-template-columns: 1fr !important; }

    /* ── INLINE STYLE OVERRIDES ──
       Many elements use inline style="display:grid;grid-template-columns:..."
       These need !important to override at mobile widths.
    */

    /* Force all inline 2/3/4-col grids to single column */
    [style*="grid-template-columns: 1fr 1fr 1fr 1fr"],
    [style*="grid-template-columns:1fr 1fr 1fr 1fr"],
    [style*="grid-template-columns: repeat(4"],
    [style*="grid-template-columns:repeat(4"],
    [style*="grid-template-columns: repeat(3"],
    [style*="grid-template-columns:repeat(3"] {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Force inline 2-col grids with complex column defs to stack */
    [style*="grid-template-columns: 1.2fr 1fr"],
    [style*="grid-template-columns:1.2fr 1fr"],
    [style*="grid-template-columns: 1fr 1fr;"],
    [style*="grid-template-columns:1fr 1fr;"] {
        grid-template-columns: 1fr !important;
    }

    /* Force all inline flex rows with wrapping to wrap */
    [style*="display:flex"][style*="justify-content:space-between"] {
        flex-wrap: wrap !important;
    }

    /* Override common inline widths */
    [style*="width:280px"],
    [style*="width: 280px"],
    [style*="width:300px"],
    [style*="width: 300px"],
    [style*="min-width:300px"],
    [style*="min-width: 300px"] {
        width: 100% !important;
        min-width: 0 !important;
    }

    /* ── ESTIMATE BUILDER ── */
    .estimate-builder .form-grid {
        grid-template-columns: 1fr !important;
    }

    /* ── PROPOSAL MODAL SPECIFICS ── */
    /* The two-col layout in proposals */
    [style*="grid-template-columns: 1.2fr 1fr"],
    [style*="grid-template-columns:1.2fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Signature grids inside proposals/signing pages */
    [style*="grid-template-columns: 1fr 1fr;"][style*="gap: 40px"],
    [style*="grid-template-columns:1fr 1fr;"][style*="gap:40px"] {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    /* ── CUSTOMER PROFILE ── */
    /* Profile tabs in customer detail */
    [style*="display:flex"][style*="gap:0"][style*="border-bottom"] {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Profile header blocks that use inline flex */
    [style*="display:grid"][style*="gap:16px"][style*="grid-template-columns: 1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* ── SETTINGS PAGE ── */
    /* Settings sometimes uses inline 2-col grids */
    [style*="display:grid"][style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* ── INLINE FONT SIZE FIXES ── */
    [style*="font-size:48px"],
    [style*="font-size: 48px"] {
        font-size: 32px !important;
    }
    [style*="font-size:40px"],
    [style*="font-size: 40px"] {
        font-size: 28px !important;
    }
    [style*="font-size:28px"],
    [style*="font-size: 28px"] {
        font-size: 22px !important;
    }
    [style*="font-size:42px"],
    [style*="font-size: 42px"] {
        font-size: 30px !important;
    }

    /* ── MISC UTILITIES ── */
    .empty-state { padding: 32px 16px; }
    .empty-state h3 { font-size: 15px; }

    /* Force max-width on deeply nested elements */
    .page-content > * {
        max-width: 100%;
        overflow-x: hidden;
    }
    .page-content table {
        overflow-x: visible; /* Tables should scroll within their wrapper */
    }
}

/* ═══════════════════════════════════
   PHONE (≤480px) — Extra small screens
   ═══════════════════════════════════ */
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr !important; }
    .stat-card .stat-value { font-size: 18px !important; }

    .top-bar-actions .btn { font-size: 10px; padding: 5px 8px; min-height: 36px; }

    .notes-masonry { column-count: 1; }
    .notes-composer-expanded { padding: 12px; }
    .note-card { padding: 10px; }
    .note-card-attachments,
    .note-attachments-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    /* Force ALL multi-col grids to single col */
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Proposal/signing page signature grids */
    .page .two-col,
    [style*="grid-template-columns: 1fr 1fr;"][style*="gap:40px"],
    [style*="grid-template-columns: 1fr 1fr;"][style*="gap: 40px"] {
        grid-template-columns: 1fr !important;
    }

    /* Smaller modal header */
    .modal-header h2 { font-size: 14px; }

    /* Bundle items even more compact */
    .bundle-customer-name { font-size: 14px; }
    .bundle-summary { padding: 10px 8px; }
    .estimate-bundle-summary { min-height: 0; }

    /* Calendar 7-day grid needs scroll */
    [style*="grid-template-columns:repeat(7"] {
        grid-template-columns: repeat(7, minmax(38px, 1fr)) !important;
        font-size: 10px !important;
    }

    /* Kanban card compact */
    .kanban-card { padding: 10px; font-size: 12px; }
    .kanban-column-header { padding: 10px 12px; font-size: 11px; }
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

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

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

/* ─── Estimate Builder ─── */
.estimate-builder .card h3 { font-size: 16px; font-weight: 600; }
.estimate-builder .card h4 { font-size: 14px; font-weight: 600; }
.estimate-builder .form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.estimate-builder table { font-size: 13px; }
.estimate-builder table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); }
@media (max-width: 768px) {
    .estimate-builder .form-grid { grid-template-columns: 1fr !important; }
}
@media (max-width: 480px) {
    .estimate-builder .form-grid { grid-template-columns: 1fr !important; }
    .estimate-builder .card h3 { font-size: 14px; }
    .estimate-builder table { font-size: 12px; }
}

/* ─── Unread Badge ─── */
.unread-badge {
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    padding: 0 5px;
}

/* ─── Message styles ─── */
.badge-orange { background: rgba(232,122,46,0.12); color: var(--primary); }

/* Drag and Drop Pipeline */
.kanban-card[draggable="true"] {
    cursor: grab;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.kanban-card[draggable="true"]:active {
    cursor: grabbing;
}
.kanban-card.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.kanban-column.drag-over {
    background: rgba(232, 101, 45, 0.08);
    border: 2px dashed var(--primary);
    border-radius: 12px;
}
.kanban-column.drag-over .kanban-column-header {
    color: var(--primary);
}

/* ═══════════════════════════════════════════
   PRINT / PDF STYLES — Proposal Layout
   Removes browser headers/footers, enforces
   3-page layout: Proposal → Financing → T&C
   ═══════════════════════════════════════════ */

/* ─── ON-SCREEN PROPOSAL PAGE PREVIEW ─── */
#proposal-printable,
#proposal-financing-page,
#proposal-tc-page {
    position: relative;
    background: #fff;
    box-shadow: 0 2px 16px rgba(0,0,0,0.10), 0 0 0 1px rgba(0,0,0,0.05);
    border-radius: 4px;
    min-height: 10.6in; /* slightly under letter page to account for padding */
    max-width: 8.5in;
    margin-left: auto;
    margin-right: auto;
}

/* Page break dividers between pages (screen only) */
.proposal-page-break {
    position: relative;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    max-width: 8.5in;
    user-select: none;
}
.proposal-page-break::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    background: repeating-linear-gradient(90deg, #E87A2E 0, #E87A2E 8px, transparent 8px, transparent 16px);
}
.proposal-page-break span {
    position: relative;
    background: var(--bg-card, #f8f8f8);
    padding: 2px 14px;
    font-size: 11px;
    font-weight: 700;
    color: #E87A2E;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 12px;
    border: 1.5px solid #E87A2E;
}

/* Prevent content from breaking inside key sections during print */
#proposal-printable [style*="grid-template-columns:1fr auto 1fr"],
#proposal-printable [style*="grid-template-columns:1fr 1fr"][style*="gap:20px"],
#proposal-printable [style*="grid-template-columns:1fr 1fr"][style*="gap:40px"],
#proposal-printable [style*="background:#FFF3E0"],
#proposal-financing-page [style*="background:#FFF3E0"],
#proposal-financing-page [style*="grid-template-columns:1fr 1fr"][style*="gap:40px"],
#proposal-tc-page [style*="grid-template-columns:1fr 1fr"][style*="gap:40px"] {
    break-inside: avoid;
    page-break-inside: avoid;
}
@media print {
    @page {
        margin: 0 !important;
        size: letter;
    }

    /* CRITICAL: Force overflow:visible on EVERY element in the chain.
       Page breaks do NOT work inside overflow:auto/hidden containers. */
    html, body, .app-layout, .main-content,
    .modal-overlay, .modal-overlay.active,
    .modal, .modal-lg, .wide,
    .modal-body, .modal-content {
        overflow: visible !important;
        overflow-y: visible !important;
        overflow-x: visible !important;
        max-height: none !important;
        height: auto !important;
        position: static !important;
        display: block !important;
    }

    /* Hide everything except proposal content */
    body {
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .sidebar,
    .topbar,
    .toast-container,
    #proposal-action-buttons,
    #proposal-save-status,
    #proposal-edit-toolbar,
    .modal-header,
    .modal-close,
    .proposal-page-break,
    .no-print {
        display: none !important;
    }

    /* Reset on-screen page styling for print */
    #proposal-printable,
    #proposal-financing-page,
    #proposal-tc-page {
        box-shadow: none !important;
        border-radius: 0 !important;
        min-height: 0 !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0.3in 0.4in 0.2in !important; /* Override inline padding:40px */
    }

    /* Strip all modal visual styling for print */
    .modal-overlay,
    .modal-overlay.active {
        background: none !important;
        inset: auto !important;
        z-index: auto !important;
    }
    .modal, .modal-lg, .wide {
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: none !important;
        transform: none !important;
    }
    .modal-body {
        padding: 0 !important;
    }

    /* ── PAGE 1: Main proposal ── */
    #proposal-printable {
        padding: 0.25in 0.35in 0.15in !important;
        page-break-after: always !important;
        break-after: page !important;
    }

    /* Compact DUKE header */
    #proposal-printable [style*="font-size:48px"],
    #proposal-printable [style*="font-size:42px"] {
        font-size: 28px !important;
        margin-bottom: 2px !important;
    }
    #proposal-printable [style*="margin-bottom:28px"]:first-child,
    #proposal-printable [style*="margin-bottom:20px"]:first-child {
        margin-bottom: 6px !important;
    }
    /* Compact header grid (salesperson / DUKE / company) */
    #proposal-printable > [style*="grid-template-columns:1fr auto 1fr"] {
        margin-bottom: 8px !important;
        gap: 8px !important;
    }
    #proposal-printable > [style*="grid-template-columns:1fr auto 1fr"] [style*="padding:8px 12px"] {
        padding: 4px 8px !important;
    }
    #proposal-printable > [style*="grid-template-columns:1fr auto 1fr"] [style*="font-size:12px"] {
        font-size: 10px !important;
    }
    #proposal-printable > [style*="grid-template-columns:1fr auto 1fr"] [style*="padding:6px 22px"] {
        padding: 3px 14px !important;
        font-size: 10px !important;
    }

    /* Compact client/project info cards */
    #proposal-printable [style*="grid-template-columns:1fr 1fr"][style*="gap:20px"] {
        gap: 6px !important;
        margin-bottom: 6px !important;
    }
    #proposal-printable [style*="padding:20px"][style*="border:1px solid"] {
        padding: 6px 10px !important;
    }
    #proposal-printable [style*="line-height:2"] {
        line-height: 1.35 !important;
    }

    /* Compact scope of work — biggest space saver */
    #proposal-printable [style*="margin-bottom:18px"] {
        margin-bottom: 3px !important;
    }
    #proposal-printable [style*="margin-bottom:8px"][style*="display:flex"][style*="align-items:center"] {
        margin-bottom: 1px !important;
    }
    #proposal-printable [style*="font-size:12px"][style*="font-weight:800"][style*="letter-spacing"] {
        font-size: 9px !important;
    }
    #proposal-printable .scope-bullet-list,
    #proposal-printable [style*="padding-left:28px"][style*="font-size:11px"] {
        line-height: 1.15 !important;
        font-size: 8.5px !important;
        padding-left: 16px !important;
    }
    #proposal-printable .scope-bullet-list > div,
    #proposal-printable [style*="margin-bottom:4px"][style*="display:flex"] {
        margin-bottom: 0 !important;
    }
    #proposal-printable [style*="font-size:16px"][style*="margin-right:6px"] {
        font-size: 11px !important;
    }

    /* Compact the two-column body (scope left + price right) */
    #proposal-printable [style*="grid-template-columns:1.2fr 1fr"] {
        gap: 8px !important;
        margin-bottom: 4px !important;
    }

    /* Compact right column price cards */
    #proposal-printable [style*="font-size:28px"][style*="font-weight:900"] {
        font-size: 16px !important;
        margin-bottom: 3px !important;
    }
    #proposal-printable [style*="font-size:40px"][style*="font-weight:900"] {
        font-size: 22px !important;
    }
    #proposal-printable [style*="margin-bottom:16px"][style*="border:1px solid"] {
        margin-bottom: 4px !important;
        padding: 6px 8px !important;
    }
    #proposal-printable [style*="line-height:2.2"] {
        line-height: 1.3 !important;
    }

    /* Compact Total Investment box */
    #proposal-printable [style*="background:#FFF3E0"][style*="border:2px solid"] {
        padding: 6px 8px !important;
        margin-bottom: 4px !important;
    }

    /* Compact warranty section */
    #proposal-printable [style*="margin-top:16px"][style*="border-top:1px solid"],
    #proposal-printable [style*="margin-top:12px"][style*="border-top:1px solid"] {
        margin-top: 4px !important;
        padding-top: 4px !important;
    }

    /* Compact signature blocks */
    #proposal-printable [style*="grid-template-columns:1fr 1fr"][style*="gap:40px"][style*="margin-top"] {
        margin-top: 4px !important;
        padding-top: 2px !important;
        gap: 20px !important;
    }
    #proposal-printable [style*="border-top:2px solid #000"][style*="height:54px"] {
        height: 24px !important;
    }
    #proposal-printable [style*="height:34px"][style*="border-bottom:1px solid"] {
        height: 20px !important;
    }

    /* ── PAGE 2: Financing Options ── */
    #proposal-financing-page {
        padding: 0.25in 0.35in 0.15in !important;
        page-break-before: always !important;
        break-before: page !important;
        page-break-after: always !important;
        break-after: page !important;
        margin-top: 0 !important;
    }
    #proposal-financing-page [style*="font-size:42px"] {
        font-size: 28px !important;
    }
    #proposal-financing-page [style*="padding:6px 22px"] {
        padding: 3px 14px !important;
        font-size: 10px !important;
    }

    /* ── PAGE 3: Terms & Conditions ── */
    #proposal-tc-page {
        padding: 0.25in 0.35in 0.15in !important;
        page-break-before: always !important;
        break-before: page !important;
        margin-top: 0 !important;
    }
    #proposal-tc-page [style*="font-size:42px"] {
        font-size: 28px !important;
    }
    #proposal-tc-page [style*="padding:6px 22px"] {
        padding: 3px 14px !important;
        font-size: 10px !important;
    }
    /* Compact T&C text */
    #proposal-tc-page [style*="font-size:9px"],
    #proposal-tc-page [style*="font-size:10px"] {
        font-size: 8px !important;
        line-height: 1.3 !important;
    }

    /* Force color printing */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* ===========================================================
   Notes section — darker, higher-contrast gray text overrides
   Scoped to .notes-page so the rest of the app is unaffected.
   =========================================================== */
.notes-page {
    --notes-gray-strong: #334155;  /* slate-700, much darker than #6B7280 */
    --notes-gray-medium: #475569;  /* slate-600 */
}

.notes-page .notes-muted,
.notes-page .notes-composer-collapsed-input,
.notes-page .note-link-header p,
.notes-page .note-linked-lead-card div,
.notes-page .note-attachment-card figcaption,
.notes-page .note-dropzone p,
.notes-page .note-card-pin,
.notes-page .note-card-meta,
.notes-page .note-card-timestamp,
.notes-page .note-card-more,
.notes-page .note-card-body,
.notes-page .note-card-checklist-item,
.notes-page .notes-section-header p,
.notes-page .notes-toolbar-summary,
.notes-page .notes-inline-field label,
.notes-page .note-lead-suggestion span {
    color: var(--notes-gray-strong) !important;
    opacity: 1 !important;
}

/* Make subtle placeholder / hint text readable without going full black */
.notes-page .note-dropzone p,
.notes-page .notes-muted,
.notes-page .notes-composer-collapsed-input {
    font-weight: 500;
}

/* Ensure note body text in cards is fully dark (not semi-transparent) */
.notes-page .note-card-body,
.notes-page .note-card-title {
    color: #0f172a; /* slate-900 for primary body/title */
}

/* Slightly darker borders so cards stand out */
.notes-page .notes-draft-meta {
    border-top-color: rgba(15, 23, 42, 0.12);
}

/* ===========================================================
   Note attachments — PDF preview cards
   =========================================================== */
.note-attachment-card.is-pdf {
    display: block;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
    min-height: 220px;
}

.note-attachment-card.is-pdf .note-attachment-pdf-embed {
    width: 100%;
    height: 260px;
    border: 0;
    display: block;
    background: #f8fafc;
}

.note-attachment-card.is-pdf .note-attachment-pdf-caption {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    color: #334155;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    background: #f8fafc;
}

.note-attachment-card.is-pdf .note-attachment-pdf-icon {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: rgba(220, 38, 38, 0.12);
    color: #dc2626;
    flex: 0 0 auto;
}

.note-attachment-card.is-pdf .note-attachment-pdf-icon svg {
    width: 14px;
    height: 14px;
}

.note-attachment-card.is-pdf .note-attachment-pdf-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
}

.note-attachment-card.is-pdf .note-attachment-pdf-open {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
    font-size: 12px;
}

.note-attachment-card.is-pdf .note-attachment-pdf-open:hover {
    text-decoration: underline;
}

/* PDF chip inside card preview */
.note-card-attachment-pdf {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(220, 38, 38, 0.08);
    color: #991b1b;
    font-size: 11px;
    font-weight: 700;
    max-width: 100%;
    overflow: hidden;
}

.note-card-attachment-pdf svg {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
}

.note-card-attachment-pdf span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

/* Highlight the whole composer / editor while a file is dragged over it */
.notes-composer-expanded.drag-active,
.note-editor.drag-active {
    outline: 2px dashed rgba(232, 122, 46, 0.6);
    outline-offset: 4px;
    background: rgba(255, 247, 240, 0.6);
    border-radius: 18px;
}


/* ══════════════════════════════════════════════════════════════════════
   PWA + iPhone polish (mobile sidebar slide-off, bottom nav, safe areas)
   ══════════════════════════════════════════════════════════════════════ */

/* iPhone notch / home indicator safe areas. When running as a PWA (Add to Home
   Screen), the app fills the whole screen — these reserve room for the system UI. */
@supports (padding: max(0px)) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Mobile-only enhancements */
@media (max-width: 768px) {

    /* ── Sidebar slide-off polish ── */
    .sidebar {
        z-index: 100;             /* above content + below modal */
        box-shadow: 4px 0 24px rgba(0,0,0,0.25);
        padding-top: max(12px, env(safe-area-inset-top));   /* respect notch */
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    /* Larger touch targets (Apple HIG = 44pt minimum) */
    .hamburger-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 10px;
        border-radius: 8px;
    }
    .hamburger-btn:active { background: rgba(0,0,0,0.08); }

    /* Nav items in the slide-out drawer — more touchable */
    .sidebar .nav-item {
        min-height: 48px;
        font-size: 15px;
    }

    /* Close button (X) inside the sidebar — bigger, easier to thumb */
    .sidebar-close-btn {
        min-width: 44px;
        min-height: 44px;
    }

    /* The top bar's avatar + bell + envelope buttons — bump touch target */
    .top-bar #notif-bell-wrap,
    .top-bar #topbar-messages-btn,
    .top-bar #topbar-avatar-btn {
        width: 42px !important;
        height: 42px !important;
    }

    /* ── Bottom navigation bar (mobile only) ── */
    /* Fixed at the screen bottom on phones. Shows the 5 most-used pages so the
       user rarely needs to open the hamburger drawer. Hidden on desktop. */
    .bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 90;
        display: flex;
        justify-content: space-around;
        background: #ffffff;
        border-top: 1px solid var(--border, #e5e7eb);
        padding-top: 6px;
        padding-bottom: calc(6px + env(safe-area-inset-bottom));
        box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
    }
    .bottom-nav__item {
        flex: 1;
        background: none;
        border: none;
        padding: 6px 4px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        font-size: 10px;
        color: var(--text-secondary, #6b7280);
        cursor: pointer;
        min-height: 50px;
        transition: color 0.15s;
    }
    .bottom-nav__item.active { color: var(--primary, #e8652d); font-weight: 700; }
    .bottom-nav__item:active { background: rgba(0,0,0,0.04); }
    .bottom-nav__item svg { width: 22px; height: 22px; }
    .bottom-nav__item span { line-height: 1.1; white-space: nowrap; }

    /* Lift the main page content above the bottom nav so the last row isn't hidden */
    .page-content {
        padding-bottom: calc(76px + env(safe-area-inset-bottom)) !important;
    }
}

/* Bottom nav is mobile-only — completely hidden above the breakpoint */
@media (min-width: 769px) {
    .bottom-nav { display: none !important; }
}

/* ── PWA standalone-mode tweaks ──
   When the user opens the app from their home screen, give the top bar a bit more
   breathing room so the notch / status-bar area doesn't crash into the title. */
@media all and (display-mode: standalone) {
    .top-bar {
        padding-top: calc(10px + env(safe-area-inset-top));
    }
}

/* ── Mobile-only: stack table rows as cards so nothing gets cut off ──
   We don't replace any HTML — we just restyle the table so each <tr> reads as a
   stacked card with each <td> labeled by its column header (via data-label, when
   set) or just stacked. Tables explicitly marked .no-mobile-cards or that already
   live inside a horizontal scroller (.table-wrapper-horizontal) keep their native
   table layout. */
@media (max-width: 768px) {
    table:not(.no-mobile-cards) {
        display: block;
    }
    table:not(.no-mobile-cards) thead {
        display: none;  /* hide header row — labels live inline */
    }
    table:not(.no-mobile-cards) tbody,
    table:not(.no-mobile-cards) tr {
        display: block;
        width: 100%;
    }
    table:not(.no-mobile-cards) tr {
        margin-bottom: 10px;
        border: 1px solid var(--border, #e5e7eb);
        border-radius: 10px;
        padding: 10px 12px;
        background: #fff;
        box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    }
    table:not(.no-mobile-cards) td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        padding: 4px 0;
        border: none;
        font-size: 13px;
        text-align: left;
    }
    /* When a <td> has data-label, surface that as a small left-side label */
    table:not(.no-mobile-cards) td[data-label]::before {
        content: attr(data-label);
        font-size: 11px;
        text-transform: uppercase;
        color: var(--text-light, #9ca3af);
        letter-spacing: 0.3px;
        font-weight: 600;
        flex-shrink: 0;
        min-width: 80px;
    }
    /* Tables inside .table-wrapper already get horizontal scroll — keep them
       as-is when authors specifically chose that pattern. */
    .table-wrapper-horizontal table {
        display: table;
    }
    .table-wrapper-horizontal table thead { display: table-header-group; }
    .table-wrapper-horizontal table tbody { display: table-row-group; }
    .table-wrapper-horizontal table tr {
        display: table-row;
        margin: 0;
        border: initial;
        border-radius: 0;
        padding: 0;
        background: transparent;
        box-shadow: none;
    }
    .table-wrapper-horizontal table td {
        display: table-cell;
        padding: 8px;
    }
}

/* ══════════════════════════════════════════════════════════════════════
   Customer Profile — mobile-friendly stacked layout
   On phone, the inner sidebar becomes a horizontal scrolling tab strip at
   the top, and the main content takes the full width below it.
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* Outer shell: stack vertically instead of side-by-side */
    .cp-shell {
        flex-direction: column !important;
        gap: 12px !important;
        min-height: 0 !important;
    }

    /* Inner sidebar shrinks to a horizontal strip */
    .cp-sidebar {
        width: 100% !important;
        min-width: 0 !important;
        border-right: none !important;
        border-radius: 10px !important;
    }
    .cp-sidebar__header {
        padding: 14px 16px !important;
    }
    /* The nav: turn into a horizontally scrolling chip row */
    .cp-sidebar__nav {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        padding: 8px 8px !important;
        gap: 4px;
        scrollbar-width: thin;
    }
    .cp-sidebar__nav::-webkit-scrollbar { height: 4px; }
    .cp-sidebar__nav::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); border-radius: 2px; }

    /* Each section link becomes a pill chip */
    .cp-sidebar__nav > a {
        flex: 0 0 auto !important;
        white-space: nowrap;
        padding: 8px 12px !important;
        border-left: none !important;
        border-bottom: 3px solid transparent !important;
        border-radius: 8px !important;
        font-size: 13px !important;
        min-height: 40px;
        display: inline-flex !important;
        align-items: center;
    }
    /* The active section gets the orange underline */
    .cp-sidebar__nav > a[id^="prof-nav-"][style*="var(--primary)"] {
        border-bottom-color: var(--primary) !important;
    }

    /* Main content takes full width, less side padding */
    .cp-main {
        padding: 0 !important;
        min-width: 0 !important;
    }

    /* Pipeline stage strip: make sure cards stay full-size and just scroll horizontally */
    .cp-stage-strip {
        margin-bottom: 14px !important;
        padding: 4px 0 8px !important;
    }
    .cp-stage-strip > div {
        flex: 0 0 auto !important;
        min-width: 110px !important;
        font-size: 12px !important;
    }

    /* Task cards inside profile should be full-width with proper text wrap */
    #profile-section-content .card,
    #profile-section-content > div {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    /* Don't break words mid-character — only at natural boundaries */
    #profile-section-content * {
        overflow-wrap: anywhere;
        word-break: normal;
    }
    /* Task cards specifically — the action buttons row should wrap cleanly */
    #profile-section-content .card > div[style*="display:flex"][style*="justify-content:space-between"] {
        flex-wrap: wrap;
        gap: 8px;
    }
}

/* ══════════════════════════════════════════════════════════════════════
   Top-bar mobile fix: guarantee bell/envelope/avatar are always visible
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* Lock the icon row so its width is sacred — nothing else can push it offscreen */
    .top-bar > div:last-child {
        flex-shrink: 0 !important;
        flex-wrap: nowrap;
    }
    /* Each icon button must keep its full size, never shrink */
    .top-bar #notif-bell-wrap,
    .top-bar #topbar-messages-btn,
    .top-bar #topbar-avatar-btn {
        flex-shrink: 0 !important;
    }
    /* Left side (hamburger + title) is what gets squeezed if anything does */
    .top-bar > div:first-child {
        min-width: 0;                /* allow text to truncate inside */
        flex: 1 1 auto;
    }
    .top-bar .page-title {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-width: 0;
    }
    /* On very narrow phones, hide the page-specific action buttons in
       top-bar-actions — they push the icons off. Each page has its own
       primary action accessible inside the page anyway. */
    @media (max-width: 480px) {
        .top-bar-actions { display: none !important; }
    }
}
