/* ===========================
   CustomQuote — Apple-like theme
   Clean, minimal, light UI
   =========================== */

/* ---- Body: offset below fixed navbar + toolbar ---- */
body {
    background: #f5f5f7;
    color: #1d1d1f;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    min-height: 100vh;
    padding-top: 112px;
}

/* ---- Override navbar: always dark, no transparency ---- */
.cq-navbar {
    background: #0a0a0f !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding-top: 12px !important;
    padding-bottom: 12px !important;
}

.cq-navbar.scrolled {
    background: #0a0a0f !important;
}

/* ---- Toolbar: sits below fixed navbar ---- */
.cq-toolbar {
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    z-index: 99;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding: 0 24px;
}

.cq-toolbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.cq-toolbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cq-toolbar-icon {
    width: 20px;
    height: 20px;
    color: #1d1d1f;
}

.cq-toolbar-title {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.01em;
}

.cq-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.cq-toolbar-divider {
    width: 1px;
    height: 20px;
    background: rgba(0, 0, 0, 0.1);
    margin: 0 6px;
}

/* ---- Buttons ---- */
.cq-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    white-space: nowrap;
}

.cq-btn svg {
    width: 16px;
    height: 16px;
}

.cq-btn-ghost {
    background: transparent;
    color: #1d1d1f;
}

.cq-btn-ghost:hover {
    background: rgba(0, 0, 0, 0.05);
}

.cq-btn-ghost:active {
    background: rgba(0, 0, 0, 0.08);
}

.cq-btn-primary {
    background: #6366f1;
    color: white;
}

.cq-btn-primary:hover {
    background: #5558e6;
}

.cq-btn-primary:active {
    background: #4f46e5;
}

.cq-btn-outline {
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.15);
    color: #1d1d1f;
}

.cq-btn-outline:hover {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.25);
}

.cq-btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.cq-btn-danger {
    background: transparent;
    color: #ff3b30;
}

.cq-btn-danger:hover {
    background: rgba(255, 59, 48, 0.08);
}

.cq-btn-full {
    width: 100%;
    justify-content: center;
}

/* ---- Layout ---- */
.cq-layout {
    display: grid;
    grid-template-columns: 340px 1fr 200px;
    height: calc(100vh - 112px);
    max-width: 1600px;
    margin: 0 auto;
}

/* ---- Sidebar ---- */
.cq-sidebar {
    background: #ffffff;
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cq-sidebar-right {
    background: #ffffff;
    border-left: 1px solid rgba(0, 0, 0, 0.06);
    border-right: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cq-sidebar-right-header {
    padding: 12px 16px 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

.cq-sidebar-right-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #86868b;
}

.cq-sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    overscroll-behavior: contain;
}

.cq-sidebar-scroll::-webkit-scrollbar {
    width: 4px;
}

.cq-sidebar-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.cq-sidebar-scroll::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

/* ---- Panels ---- */
.cq-panel {
    margin-bottom: 4px;
    border-radius: 12px;
    overflow: hidden;
}

.cq-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.02);
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease;
}

.cq-panel-header:hover {
    background: rgba(0, 0, 0, 0.04);
}

.cq-panel-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: #1d1d1f;
}

.cq-chevron {
    width: 16px;
    height: 16px;
    color: #86868b;
    transition: transform 0.2s ease;
}

.cq-panel-header[aria-expanded="false"] .cq-chevron {
    transform: rotate(-90deg);
}

.cq-panel-body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s ease;
    overflow: hidden;
}

.cq-panel-body.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

/* ---- Form Fields ---- */
.cq-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cq-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.cq-label {
    font-size: 11px;
    font-weight: 500;
    color: #86868b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.cq-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    background: #f5f5f7;
    color: #1d1d1f;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
}

.cq-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.cq-input::placeholder {
    color: #b0b0b5;
}

.cq-textarea {
    resize: vertical;
    min-height: 56px;
}

.cq-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.cq-field-toggle {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.cq-field-toggle .cq-label {
    text-transform: none;
    font-size: 13px;
}

.cq-switch {
    position: relative;
    width: 40px;
    height: 24px;
    flex-shrink: 0;
}

.cq-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.cq-switch-slider {
    position: absolute;
    inset: 0;
    background: #d1d1d6;
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.cq-switch-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.cq-switch input:checked + .cq-switch-slider {
    background: #6366f1;
}

.cq-switch input:checked + .cq-switch-slider::before {
    transform: translateX(16px);
}

/* ---- Logo Upload ---- */
.cq-logo-upload {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cq-logo-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    border: 1.5px dashed rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s ease;
    flex: 1;
}

.cq-logo-placeholder:hover {
    border-color: #6366f1;
}

.cq-logo-placeholder svg {
    width: 20px;
    height: 20px;
    color: #86868b;
}

.cq-logo-placeholder span {
    font-size: 11px;
    color: #86868b;
}

.cq-logo-preview {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 6px;
}

.cq-logo-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(255, 59, 48, 0.08);
    border-radius: 50%;
    cursor: pointer;
    color: #ff3b30;
    transition: background 0.15s ease;
    flex-shrink: 0;
}

.cq-logo-remove:hover {
    background: rgba(255, 59, 48, 0.15);
}

.cq-logo-remove svg {
    width: 14px;
    height: 14px;
}

/* ---- Fields List ---- */
.cq-fields-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cq-field-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 8px;
    cursor: grab;
    transition: background 0.15s ease;
}

.cq-field-item:active {
    cursor: grabbing;
}

.cq-field-item:hover {
    background: rgba(0, 0, 0, 0.04);
}

.cq-field-item .cq-drag-handle {
    color: #b0b0b5;
    cursor: grab;
    flex-shrink: 0;
}

.cq-field-item .cq-drag-handle svg {
    width: 14px;
    height: 14px;
}

.cq-field-item label {
    flex: 1;
    font-size: 12px;
    font-weight: 500;
    color: #1d1d1f;
}

.cq-field-item .cq-field-edit-input {
    flex: 1;
    padding: 3px 6px;
    border: 1px solid #6366f1;
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
    background: #fff;
    outline: none;
}

.cq-field-item .cq-field-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.cq-field-item:hover .cq-field-actions {
    opacity: 1;
}

.cq-field-item .cq-field-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    color: #86868b;
    transition: background 0.15s ease, color 0.15s ease;
}

.cq-field-item .cq-field-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #1d1d1f;
}

.cq-field-item .cq-field-btn.cq-field-btn-danger:hover {
    background: rgba(255, 59, 48, 0.08);
    color: #ff3b30;
}

.cq-field-item .cq-field-btn svg {
    width: 14px;
    height: 14px;
}

/* ---- Color Picker ---- */
.cq-color-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cq-color-row input[type="color"] {
    width: 32px;
    height: 32px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    cursor: pointer;
    padding: 2px;
    background: #f5f5f7;
}

.cq-color-hex {
    font-size: 13px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: #86868b;
}

/* ---- Preview Area ---- */
.cq-preview-area {
    background: #f5f5f7;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

.cq-preview-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    display: flex;
    justify-content: center;
    overscroll-behavior: contain;
}

.cq-preview-page {
    width: 210mm;
    min-height: 297mm;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.08);
    padding: 48px;
    box-sizing: border-box;
    font-size: 14px;
    line-height: 1.5;
}

/* ---- Rendered Quote Styles ---- */
.cq-quote {
    width: 100%;
}

.cq-quote-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--cq-accent, #6366f1);
}

.cq-quote-company {
    flex: 1;
}

.cq-quote-company-logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    margin-bottom: 8px;
}

.cq-quote-company-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--cq-accent, #6366f1);
    letter-spacing: -0.02em;
    margin: 0;
}

.cq-quote-company-info {
    font-size: 12px;
    color: #86868b;
    margin-top: 4px;
    line-height: 1.6;
}

.cq-quote-meta {
    text-align: right;
}

.cq-quote-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--cq-accent, #6366f1);
    letter-spacing: -0.03em;
    margin: 0 0 8px;
}

.cq-quote-meta-row {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    font-size: 12px;
    color: #86868b;
    margin-top: 4px;
}

.cq-quote-meta-label {
    font-weight: 500;
}

.cq-quote-client {
    margin-bottom: 32px;
    padding: 16px;
    background: #f5f5f7;
    border-radius: 8px;
}

.cq-quote-client-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #86868b;
    margin-bottom: 4px;
}

.cq-quote-client-name {
    font-size: 15px;
    font-weight: 600;
    color: #1d1d1f;
}

/* ---- Table ---- */
.cq-quote-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}

.cq-quote-table thead th {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #86868b;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: #f5f5f7;
}

.cq-quote-table thead th:first-child {
    border-radius: 8px 0 0 0;
}

.cq-quote-table thead th:last-child {
    border-radius: 0 8px 0 0;
    text-align: right;
}

.cq-quote-table tbody td {
    padding: 8px 12px;
    font-size: 13px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    color: #1d1d1f;
    vertical-align: middle;
}

.cq-quote-table tbody td:last-child {
    text-align: right;
    font-weight: 500;
}

.cq-quote-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.03);
}

.cq-quote-table .cq-qty-input,
.cq-quote-table .cq-rate-input {
    width: 70px;
    padding: 5px 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: #f5f5f7;
    text-align: right;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cq-quote-table .cq-qty-input:focus,
.cq-quote-table .cq-rate-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
    background: #fff;
}

.cq-quote-table .cq-desc-input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: #f5f5f7;
    outline: none;
    resize: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cq-quote-table .cq-desc-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
    background: #fff;
}

.cq-quote-table .cq-generic-input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: #f5f5f7;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cq-quote-table .cq-generic-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
    background: #fff;
}

.cq-quote-table .cq-delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: #b0b0b5;
    transition: all 0.15s ease;
}

.cq-quote-table .cq-delete-btn:hover {
    background: rgba(255, 59, 48, 0.08);
    color: #ff3b30;
}

.cq-quote-table .cq-delete-btn svg {
    width: 14px;
    height: 14px;
}

/* ---- Totals ---- */
.cq-quote-totals {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    padding-top: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    margin-bottom: 32px;
}

.cq-quote-total-row {
    display: flex;
    justify-content: space-between;
    width: 240px;
    font-size: 13px;
    color: #86868b;
}

.cq-quote-total-row.cq-grand-total {
    font-size: 18px;
    font-weight: 700;
    color: var(--cq-accent, #6366f1);
    padding-top: 8px;
    border-top: 2px solid var(--cq-accent, #6366f1);
    margin-top: 4px;
}

.cq-quote-notes {
    padding: 16px;
    background: #f5f5f7;
    border-radius: 8px;
    font-size: 12px;
    color: #86868b;
    line-height: 1.6;
}

.cq-quote-notes-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #b0b0b5;
    margin-bottom: 4px;
}

/* ---- Add item button ---- */
.cq-add-item-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px;
    border: 1.5px dashed rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: #86868b;
    font-family: inherit;
    transition: all 0.15s ease;
    margin-bottom: 24px;
}

.cq-add-item-btn:hover {
    border-color: #6366f1;
    color: #6366f1;
    background: rgba(99, 102, 241, 0.03);
}

.cq-add-item-btn svg {
    width: 14px;
    height: 14px;
}

/* ---- Empty State ---- */
.cq-empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #b0b0b5;
}

.cq-empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.cq-empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    color: #86868b;
    margin: 0 0 4px;
}

.cq-empty-state p {
    font-size: 13px;
    margin: 0;
}

/* ---- Toast ---- */
.cq-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 20px;
    background: #1d1d1f;
    color: white;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.cq-toast.cq-toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.cq-toast.cq-toast-error {
    background: #ff3b30;
}

.cq-toast.cq-toast-success {
    background: #30d158;
}

/* ---- Save Status ---- */
.cq-save-status {
    font-size: 12px;
    color: #86868b;
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .cq-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .cq-sidebar,
    .cq-sidebar-right {
        border-right: none;
        border-left: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    }

    .cq-sidebar-right-header {
        display: none;
    }

    .cq-sidebar-scroll {
        max-height: 50vh;
    }

    .cq-preview-scroll {
        padding: 16px;
    }

    .cq-preview-page {
        width: 100%;
        min-height: auto;
        padding: 24px;
    }

    .cq-themes-list {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
    }

    .cq-theme-item {
        padding: 8px 10px;
    }
}

@media (max-width: 640px) {
    .cq-toolbar-inner {
        flex-wrap: wrap;
        height: auto;
        padding: 8px 0;
        gap: 8px;
    }

    .cq-toolbar-actions {
        width: 100%;
        justify-content: center;
    }

    .cq-preview-page {
        padding: 16px;
    }

    .cq-quote-header {
        flex-direction: column;
        gap: 16px;
    }

    .cq-quote-meta {
        text-align: left;
    }

    .cq-quote-meta-row {
        justify-content: flex-start;
    }

    .cq-quote-totals {
        align-items: stretch;
    }

    .cq-quote-total-row {
        width: 100%;
    }
}

/* ---- Print ---- */
@media print {
    .cq-toolbar,
    .cq-navbar,
    .cq-sidebar,
    .cq-sidebar-right,
    .cq-footer,
    .cq-add-item-btn,
    .cq-delete-btn,
    .cq-loading-overlay {
        display: none !important;
    }

    body {
        padding-top: 0 !important;
    }

    .cq-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .cq-preview-area {
        padding: 0;
    }

    .cq-preview-scroll {
        padding: 0;
        overflow: visible;
    }

    .cq-preview-page {
        box-shadow: none;
        border-radius: 0;
        padding: 0;
        width: 100%;
    }

    .cq-quote-table .cq-qty-input,
    .cq-quote-table .cq-rate-input,
    .cq-quote-table .cq-desc-input,
    .cq-quote-table .cq-generic-input {
        border: none;
        background: transparent;
        padding: 0;
        box-shadow: none;
    }
}

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

/* ---- Reduced motion: loading overlay ---- */
@media (prefers-reduced-motion: reduce) {
    .cq-loading-spinner {
        animation: none;
        border-top-color: rgba(99, 102, 241, 0.5);
    }
    .cq-loading-bar-fill {
        animation: none;
        width: 100%;
    }
}

/* ---- Shared Tooltip Element ---- */
#cq-tooltip {
    position: fixed;
    padding: 6px 12px;
    background: #1d1d1f;
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 6px;
    border: 1px solid #ffffff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    pointer-events: none;
    z-index: 100000;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}
#cq-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Focus visible ---- */
.cq-btn:focus-visible,
.cq-input:focus-visible,
.cq-panel-header:focus-visible,
.cq-add-item-btn:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* ---- Drag states ---- */
.cq-field-item.cq-drag-over {
    border-top: 2px solid #6366f1;
}

.cq-field-item.cq-dragging {
    opacity: 0.4;
}

    /* ============================
    THEMES ACCORDION (Right Sidebar)
    ============================ */

.cq-accordion {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0;
    transition: opacity 0.2s ease;
}
.cq-accordion.cq-accordion-loading {
    pointer-events: none;
    opacity: 0.5;
}

.cq-accordion-section {
    border-radius: 10px;
    overflow: hidden;
    transition: background 0.15s ease;
}
.cq-accordion-section.open {
    background: rgba(0, 0, 0, 0.02);
}

.cq-accordion-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: #1d1d1f;
    text-align: left;
    transition: all 0.15s ease;
}
.cq-accordion-trigger:hover {
    background: rgba(0, 0, 0, 0.04);
}
.cq-accordion-trigger.active {
    color: #6366f1;
    font-weight: 600;
}
.cq-accordion-trigger:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: -2px;
    border-radius: 8px;
}

.cq-accordion-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 12px;
    color: #86868b;
}
.cq-accordion-trigger.active .cq-accordion-icon {
    color: #6366f1;
}

.cq-accordion-name {
    flex: 1;
}

.cq-accordion-chevron {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: #b0b0b5;
    transition: transform 0.2s ease;
}
.cq-accordion-trigger.active .cq-accordion-chevron {
    transform: rotate(180deg);
    color: #6366f1;
}

.cq-accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}
.cq-accordion-section.open .cq-accordion-body {
    max-height: 600px;
}

.cq-accordion-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 4px 8px 8px;
}

.cq-theme-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: transparent;
    width: 100%;
    text-align: left;
    font-family: inherit;
    position: relative;
}
.cq-theme-item:hover:not(.active) {
    background: rgba(0, 0, 0, 0.04);
}
.cq-theme-item.active {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.05);
}
.cq-theme-item:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: -2px;
}
.cq-theme-swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.cq-theme-label {
    flex: 1;
    font-size: 11px;
    font-weight: 500;
    color: #1d1d1f;
    line-height: 1;
}
.cq-theme-check {
    width: 14px;
    height: 14px;
    color: #6366f1;
    flex-shrink: 0;
}

.cq-accordion-loading-msg {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 10px;
    font-size: 11px;
    color: #86868b;
}
.cq-accordion-loading-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0, 0, 0, 0.06);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: cqSpin 0.6s linear infinite;
}

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

@keyframes cqCheckIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

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

.cq-loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.cq-loading-overlay[hidden] {
    display: none;
}

.cq-loading-visible {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.cq-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.cq-loading-spinner {
    width: 32px;
    height: 32px;
    border: 2.5px solid rgba(99, 102, 241, 0.15);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: cqSpin 0.7s linear infinite;
}

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

.cq-loading-text {
    font-size: 13px;
    font-weight: 500;
    color: #86868b;
}

.cq-loading-bar {
    width: 120px;
    height: 2px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 2px;
    overflow: hidden;
}

.cq-loading-bar-fill {
    height: 100%;
    width: 0%;
    background: #6366f1;
    border-radius: 2px;
    animation: cqLoadProgress 0.6s ease-out forwards;
}

@keyframes cqLoadProgress {
    0% { width: 0%; }
    50% { width: 80%; }
    100% { width: 100%; }
}

/* ============================
   THEMES PANEL
   ============================ */

/* ============================
   THEME: MINIMALIST
   ============================ */
.cq-theme-minimalist { font-family: 'Inter', -apple-system, sans-serif; }

/* ============================
   THEME: CORPORATE
   ============================ */
.cq-theme-corporate .cq-quote-table thead th {
    background: #1d1d1f;
    color: #fff;
    border: none;
}
.cq-theme-corporate .cq-quote-table thead th:first-child { border-radius: 0; }
.cq-theme-corporate .cq-quote-table thead th:last-child { border-radius: 0; }
.cq-theme-corporate .cq-quote-total-row.cq-grand-total {
    border-top-color: #1d1d1f;
}

/* ============================
   THEME: SIDEBAR
   ============================ */
.cq-theme-sidebar .cq-quote-table thead th {
    background: transparent;
    border-bottom: 2px solid var(--cq-accent, #6366f1);
}

/* ============================
   THEME: BOLD HEADER
   ============================ */
.cq-theme-bold .cq-quote-table thead th {
    background: var(--cq-accent, #6366f1);
    color: #fff;
    border-radius: 6px 6px 0 0;
}
.cq-theme-bold .cq-add-item-btn {
    border-color: var(--cq-accent, #6366f1);
}
.cq-theme-bold .cq-add-item-btn:hover {
    color: var(--cq-accent, #6366f1);
}

/* ============================
   THEME: LUXURY
   ============================ */
.cq-theme-luxury {
    font-family: 'Georgia', 'Times New Roman', serif;
}
.cq-theme-luxury .cq-quote-table {
    border-top: 1px solid #C9A227;
    border-bottom: 1px solid #C9A227;
}
.cq-theme-luxury .cq-quote-table thead th {
    background: transparent;
    color: #C9A227;
    border-bottom: 1px solid #C9A22740;
    font-family: 'Georgia', serif;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.cq-theme-luxury .cq-quote-table tbody td {
    border-bottom: 1px solid #C9A22720;
    font-family: 'Inter', sans-serif;
}
.cq-theme-luxury .cq-quote-total-row.cq-grand-total {
    border-top-color: #C9A227;
    color: #C9A227;
}
.cq-theme-luxury .cq-add-item-btn {
    border-color: #C9A22740;
    color: #C9A227;
}

/* ============================
   THEME: TECH DARK
   ============================ */
.cq-theme-tech .cq-quote-table thead th {
    background: #0a0a0f;
    color: #6366f1;
    font-family: 'SF Mono', 'Fira Code', monospace;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #27272a;
}
.cq-theme-tech .cq-quote-table tbody td {
    border-bottom: 1px solid #e4e4e7;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
}
.cq-theme-tech .cq-quote-table tbody tr:hover {
    background: #f4f4f5;
}
.cq-theme-tech .cq-quote-total-row {
    font-family: 'SF Mono', 'Fira Code', monospace;
}
.cq-theme-tech .cq-quote-total-row.cq-grand-total {
    border-top-color: #0a0a0f;
    font-weight: 700;
}
.cq-theme-tech .cq-add-item-btn {
    border-color: #e4e4e7;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ============================
   THEME: GEOMETRIC
   ============================ */
.cq-theme-geometric .cq-quote-table thead th {
    background: var(--cq-accent, #6366f1);
    color: #fff;
    border-radius: 0;
    clip-path: polygon(0 0, 100% 0, 95% 100%, 5% 100%);
    padding: 10px 20px;
}
.cq-theme-geometric .cq-quote-table thead th:first-child {
    clip-path: polygon(0 0, 100% 0, 95% 100%, 0 100%);
}
.cq-theme-geometric .cq-quote-table thead th:last-child {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 5% 100%);
}
.cq-theme-geometric .cq-add-item-btn {
    border-color: var(--cq-accent, #6366f1);
}

/* ============================
   THEME: SPLIT
   ============================ */
.cq-theme-split .cq-quote-table thead th {
    background: var(--cq-accent, #6366f1);
    color: #fff;
}
.cq-theme-split .cq-quote-total-row.cq-grand-total {
    border-top-color: var(--cq-accent, #6366f1);
}

/* ============================
   THEME: ECO SOFT
   ============================ */
.cq-theme-eco .cq-quote-table {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.06);
}
.cq-theme-eco .cq-quote-table thead th {
    background: var(--cq-accent, #6366f1);
    color: #fff;
    border-radius: 0;
    font-weight: 500;
}
.cq-theme-eco .cq-quote-table thead th:first-child { border-radius: 12px 0 0 0; }
.cq-theme-eco .cq-quote-table thead th:last-child { border-radius: 0 12px 0 0; }
.cq-theme-eco .cq-quote-table tbody td {
    border-bottom: 1px solid rgba(0,0,0,0.03);
}
.cq-theme-eco .cq-quote-table .cq-qty-input,
.cq-theme-eco .cq-quote-table .cq-rate-input,
.cq-theme-eco .cq-quote-table .cq-desc-input,
.cq-theme-eco .cq-quote-table .cq-generic-input {
    border-radius: 8px;
}
.cq-theme-eco .cq-quote-total-row.cq-grand-total {
    border-top-color: var(--cq-accent, #6366f1);
}
.cq-theme-eco .cq-add-item-btn {
    border-radius: 12px;
    border-color: var(--cq-accent, #6366f1);
}

/* ============================
   THEME: DATA DENSE
   ============================ */
.cq-theme-data {
    font-size: 12px !important;
}
.cq-theme-data .cq-quote-table thead th {
    padding: 6px 8px;
    font-size: 10px;
    background: #f5f5f7;
}
.cq-theme-data .cq-quote-table tbody td {
    padding: 6px 8px;
    font-size: 12px;
}
.cq-theme-data .cq-quote-table .cq-qty-input,
.cq-theme-data .cq-quote-table .cq-rate-input,
.cq-theme-data .cq-quote-table .cq-generic-input {
    padding: 3px 6px;
    font-size: 12px;
    width: 60px;
}
.cq-theme-data .cq-quote-totals {
    padding-top: 10px;
}
.cq-theme-data .cq-quote-total-row {
    font-size: 12px;
}
.cq-theme-data .cq-quote-total-row.cq-grand-total {
    font-size: 14px;
    padding-top: 6px;
}
.cq-theme-data .cq-add-item-btn {
    padding: 8px;
    font-size: 11px;
    margin-bottom: 16px;
}
