/* ═══════════════════════════════════════════════════════════════════════════
   DATASHEET MAKER — Redesigned Style System
   - Accordion form sections
   - 2-column dense field layout
   - Compact template tab switcher
   - Library panel
═══════════════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ────────────────────────────────────────────────────── */
:root {
    --primary: #111827;
    --accent: #16a34a;
    /* green */
    --accent-light: #dcfce7;
    --accent-mid: #22c55e;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --border-2: #cbd5e1;
    --text-main: #1e293b;
    --text-sub: #64748b;
    --text-xs: #94a3b8;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.10);
    --radius: 8px;
    --radius-sm: 5px;
    --radius-lg: 12px;
}

/* ── Reset ────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    font-size: 13px;
    line-height: 1.5;
}

/* ── App Shell ────────────────────────────────────────────────────────── */
.app-container {
    display: flex;
    height: 100vh;
}

/* ═══════════════════════════════════════════════════════════════════════
   LEFT PANEL — EDITOR
═══════════════════════════════════════════════════════════════════════ */
.editor-panel {
    width: 420px;
    min-width: 340px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    z-index: 10;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.06);
}

/* Editor Header ── */
.editor-header {
    padding: 0;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #0f3460 100%);
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
}

/* Top row: branding */
.editor-header-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 10px;
    gap: 8px;
}

/* App icon + text */
.editor-header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.editor-header-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.35);
}

.editor-header-text h2 {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.2px;
}

.editor-header-text p {
    margin: 1px 0 0;
    color: rgba(255, 255, 255, 0.45);
    font-size: 10px;
    letter-spacing: 0.1px;
}

/* Bottom row: action buttons */
.editor-header-actions {
    display: flex;
    gap: 6px;
    padding: 0 14px 10px;
}

/* ── Header Action Buttons (Settings & Reports) ─────────────────────── */
.header-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 11px;
    border-radius: 20px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.18s ease;
    letter-spacing: 0.2px;
    white-space: nowrap;
    flex-shrink: 0;
    text-decoration: none;
}

/* Settings = outlined ghost */
.header-action-btn#openSettingsBtn {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.85);
}

.header-action-btn#openSettingsBtn:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.35);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

/* Reports = accent green filled */
.header-action-btn#openReportsBtn {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.30);
}

.header-action-btn#openReportsBtn:hover {
    background: linear-gradient(135deg, #16a34a, #15803d);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.45);
}

/* Save = blue/indigo filled */
.header-action-btn#saveProductBtn {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.30);
}

.header-action-btn#saveProductBtn:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
}

.header-action-btn:active {
    transform: translateY(0) !important;
}

/* Current product name in header */
.current-product-name {
    font-size: 10px;
    font-weight: 600;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 20px;
    padding: 3px 10px;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.current-product-name:hover {
    background: rgba(34, 197, 94, 0.20);
    border-color: rgba(34, 197, 94, 0.5);
}

/* ── Template Tab Switcher (compact 2-tab strip) ────────────────────── */
.template-tabs-strip {
    display: flex;
    gap: 0;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    flex-shrink: 0;
}

.tmpl-tab {
    flex: 1;
    padding: 9px 12px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-sub);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.18s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.tmpl-tab:hover {
    color: var(--text-main);
}

.tmpl-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.tmpl-tab-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.6;
}

/* Form scroll area */
#datasheetForm {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0 80px;
    scroll-behavior: smooth;
}

/* ═══════════════════════════════════════════════════════════════════════
   ACCORDION SECTIONS
═══════════════════════════════════════════════════════════════════════ */
.accordion-section {
    border-bottom: 1px solid var(--border);
}

.accordion-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 11px 16px;
    background: var(--surface-2);
    border: none;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--text-sub);
    transition: background 0.15s, color 0.15s;
    position: relative;
}

.accordion-header:hover {
    background: #f0f4f8;
    color: var(--text-main);
}

.accordion-section.open>.accordion-header {
    color: var(--text-main);
    background: var(--surface);
    border-left: 3px solid var(--accent);
    padding-left: 13px;
}

.accordion-icon {
    font-size: 15px;
    flex-shrink: 0;
}

.accordion-title {
    flex: 1;
}

.accordion-chevron {
    font-size: 11px;
    color: var(--text-xs);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.accordion-section.open>.accordion-header .accordion-chevron {
    transform: rotate(180deg);
    color: var(--accent);
}

/* Accordion body */
.accordion-body {
    display: none;
    padding: 14px 16px 18px;
    background: var(--surface);
    animation: fadeSlideIn 0.18s ease;
}

.accordion-section.open>.accordion-body {
    display: block;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   FORM CONTROLS
═══════════════════════════════════════════════════════════════════════ */

/* Field rows */
.form-group {
    margin-bottom: 12px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.form-row .form-group,
.form-row-3 .form-group {
    margin-bottom: 0;
}

label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-sub);
    letter-spacing: 0.2px;
}

label .unit {
    font-weight: 400;
    color: var(--text-xs);
    font-size: 10px;
}

.input-field {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 12px;
    color: var(--text-main);
    background: var(--surface-2);
    transition: all 0.15s;
}

.input-field:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
    background: var(--surface);
}

.input-field[readonly] {
    background: #f0fdf4;
    color: var(--accent);
    font-weight: 600;
    cursor: default;
}

textarea.input-field {
    resize: vertical;
    min-height: 70px;
}

select.input-field {
    cursor: pointer;
}

/* File upload */
.file-upload-wrapper {
    position: relative;
    height: 60px;
    border: 1.5px dashed var(--border-2);
    border-radius: var(--radius);
    background: var(--surface-2);
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
}

.file-upload-wrapper:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.file-upload-wrapper input {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.file-upload-visual {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 11px;
    color: var(--text-sub);
    pointer-events: none;
}

.file-upload-visual .upload-icon {
    font-size: 18px;
}

.file-upload-wrapper.has-file {
    border-color: var(--accent);
    background: var(--accent-light);
}

.file-upload-wrapper.has-file .file-upload-visual {
    color: var(--accent);
    font-weight: 600;
}

/* ── Checkbox Grid ────────────────────────────────────────────────────── */
.cert-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.cert-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-sub);
    background: var(--surface-2);
    user-select: none;
}

.cert-item:hover {
    border-color: var(--accent);
}

.cert-item input[type="checkbox"] {
    display: none;
}

.cert-item .cert-check {
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--border-2);
    border-radius: 3px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.cert-item input:checked~.cert-check {
    background: var(--accent);
    border-color: var(--accent);
}

.cert-item input:checked~.cert-check::after {
    content: '✓';
    color: white;
    font-size: 9px;
    font-weight: 700;
}

.cert-item input:checked~span:last-child {
    color: var(--text-main);
    font-weight: 600;
}

.cert-item:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-light);
}

/* ── Dimension Table ─────────────────────────────────────────────────── */
.dim-table-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 32px;
    gap: 6px;
    padding: 0 0 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}

.dim-table-header span {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dim-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 32px;
    gap: 6px;
    margin-bottom: 6px;
    align-items: center;
}

.dim-row .input-field {
    padding: 6px 8px;
    font-size: 12px;
}

.dim-delete-btn {
    background: none;
    border: 1px solid #fca5a5;
    color: #ef4444;
    border-radius: var(--radius-sm);
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}

.dim-delete-btn:hover {
    background: #fff0f0;
}

.btn-add-row {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1.5px dashed var(--border-2);
    color: var(--text-sub);
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.15s;
    margin-top: 4px;
    width: 100%;
    justify-content: center;
}

.btn-add-row:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

/* ── Mounting / Distribution icons ───────────────────────────────────── */
.mount-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.mount-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 4px;
    transition: all 0.15s;
    font-size: 10px;
    text-align: center;
    color: var(--text-sub);
    background: var(--surface-2);
}

.mount-option:hover,
.mount-option.selected {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}

.mount-option input {
    display: none;
}

.mount-icon {
    font-size: 20px;
}

/* ── Field Divider & Sub-header label (used in Certifications, Variants) ─ */
.field-divider {
    height: 1px;
    background: var(--border);
    margin: 14px 0 10px;
    border: none;
}

.field-group-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--text-xs);
    margin-bottom: 8px;
    margin-top: 2px;
}

/* ── form-input alias (used by variants.js dynamic HTML) ────────────────── */
.form-input {
    width: 100%;
    padding: 7px 9px;
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 12px;
    color: var(--text-main);
    background: var(--surface-2);
    transition: all 0.15s;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
    background: var(--surface);
}

.form-input[readonly] {
    background: #f0fdf4;
    color: var(--accent);
    font-weight: 600;
    cursor: default;
}

/* ── Variant Matrix (inside accordion body) ─────────────────────────────── */
.variant-group-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    overflow: hidden;
}

.variant-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 12px;
}

.variant-group-body {
    padding: 8px;
}

.variant-row {
    display: grid;
    grid-template-columns: 60px 70px 70px 60px 70px 90px 1fr 22px;
    gap: 4px;
    align-items: center;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--border);
}

.variant-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.variant-row .form-input {
    padding: 5px 7px;
    font-size: 11px;
}

.variant-sku-badge {
    font-size: 10px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-light);
    border: 1px solid #bbf7d0;
    border-radius: 4px;
    padding: 2px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.variant-warn-badge {
    font-size: 9px;
    font-weight: 600;
    color: #d97706;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 4px;
    padding: 2px 5px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.variant-group-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.variant-group-actions button,
.btn-add-variant-group {
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1.5px solid var(--border-2);
    background: none;
    color: var(--text-sub);
    transition: all 0.15s;
}

.variant-group-actions button:hover,
.btn-add-variant-group:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.btn-remove-group {
    border-color: #fca5a5 !important;
    color: #ef4444 !important;
}

.btn-remove-group:hover {
    background: #fff0f0 !important;
    border-color: #ef4444 !important;
}

.btn-remove-variant {
    background: none;
    border: 1px solid #fca5a5;
    color: #ef4444;
    border-radius: 3px;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
    padding: 0;
}

.btn-remove-variant:hover {
    background: #fff0f0;
}

.variant-col-headers {
    display: grid;
    grid-template-columns: 60px 70px 70px 60px 70px 90px 1fr 22px;
    gap: 4px;
    margin-bottom: 4px;
}

.variant-col-headers span {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* ── Variant Builder Table (generated by variants.js) ───────────────────── */
.variant-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-xs);
    font-size: 12px;
    border: 1.5px dashed var(--border-2);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.variant-group {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
    background: var(--surface);
}

.variant-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.variant-watt-badge {
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-radius: 6px;
    padding: 2px 9px;
    letter-spacing: 0.3px;
    box-shadow: 0 1px 4px rgba(34, 197, 94, 0.30);
}

.variant-table-wrap {
    overflow-x: auto;
    padding: 8px;
}

.variant-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    min-width: 560px;
}

.variant-table thead tr {
    background: var(--surface-2);
}

.variant-table th {
    padding: 5px 7px;
    text-align: left;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-xs);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.variant-table td {
    padding: 4px;
    border-bottom: 1px dashed var(--border);
    vertical-align: middle;
}

.variant-row:last-child td {
    border-bottom: none;
}

.variant-row.dup-sku {
    background: #fff5f5;
}

/* compact inputs inside variant table */
.v-input {
    width: 100%;
    padding: 5px 6px;
    border: 1px solid var(--border-2);
    border-radius: 4px;
    font-family: inherit;
    font-size: 11px;
    color: var(--text-main);
    background: var(--surface-2);
    transition: border-color 0.15s;
    min-width: 0;
}

.v-input:focus {
    outline: none;
    border-color: var(--accent);
    background: #fff;
}

.v-input.v-cct,
.v-input.v-beam,
.v-input.v-finish {
    cursor: pointer;
}

/* efficacy cell (read-only) */
.efficacy-cell {
    font-weight: 600;
    font-size: 10px;
    color: var(--accent);
    white-space: nowrap;
    padding: 4px 7px;
}

/* SKU cell */
.sku-cell {
    font-family: 'Courier New', monospace;
    font-size: 10px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    padding: 4px 7px;
}

.sku-cell.dup {
    color: #ef4444;
}

.dup-badge {
    font-size: 9px;
    font-weight: 700;
    color: #dc2626;
    background: #fee2e2;
    border-radius: 3px;
    padding: 1px 4px;
    margin-left: 4px;
}

/* mA warning */
.ma-cell {
    position: relative;
    display: flex;
    align-items: center;
    gap: 3px;
}

.ma-warning {
    font-size: 12px;
    color: #d97706;
    cursor: help;
    flex-shrink: 0;
}

/* Variant group action buttons */
.vg-btn-add,
.vg-btn-fillma,
.vg-btn-remove {
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.vg-btn-add {
    background: none;
    border: 1.5px solid var(--border-2);
    color: var(--text-sub);
}

.vg-btn-add:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.vg-btn-fillma {
    background: none;
    border: 1.5px solid #fde68a;
    color: #d97706;
}

.vg-btn-fillma:hover {
    background: #fffbeb;
    border-color: #fbbf24;
}

.vg-btn-remove {
    background: none;
    border: 1.5px solid #fca5a5;
    color: #ef4444;
}

.vg-btn-remove:hover {
    background: #fff0f0;
    border-color: #ef4444;
}

.row-del {
    padding: 2px 6px !important;
    font-size: 12px !important;
}

/* Variant summary bar */
#variantSummary {
    font-size: 11px;
    color: var(--text-sub);
    padding: 6px 10px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 8px;
}

/* ── Action Buttons ────────────────────────────────────────────────────── */
.form-actions {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    bottom: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 11px 20px;
    border-radius: var(--radius);
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.18s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    letter-spacing: 0.2px;
}

.btn-primary:hover {
    background: #000;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-save-lib {
    background: var(--accent);
    color: white;
    border: none;
    padding: 9px 20px;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    font-size: 12px;
    font-family: inherit;
    transition: all 0.18s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-save-lib:hover {
    background: #15803d;
}

/* ── Library Toggle Button ──────────────────────────────────────────── */
.lib-toggle-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--surface-2);
    border: 1px solid var(--border-2);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-sub);
    white-space: nowrap;
    transition: all 0.18s;
    flex-shrink: 0;
    font-family: inherit;
}

.lib-toggle-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.lib-product-count {
    background: var(--accent);
    color: white;
    border-radius: 10px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 700;
}

/* ═══════════════════════════════════════════════════════════════════════
   RIGHT PANEL — PREVIEW
═══════════════════════════════════════════════════════════════════════ */
.preview-panel {
    flex: 1;
    background: #dde1e7;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    overflow: hidden;
}

.preview-header {
    width: 100%;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
    z-index: 5;
}

.preview-header-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-sub);
    text-transform: uppercase;
}

.preview-badge {
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-sub);
    transition: all 0.3s;
}

.preview-zoom {
    margin-left: auto;
    display: flex;
    gap: 6px;
    align-items: center;
}

.preview-zoom-btn {
    background: none;
    border: 1px solid var(--border-2);
    border-radius: 5px;
    width: 26px;
    height: 26px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-sub);
    transition: all 0.15s;
}

.preview-zoom-btn:hover {
    background: white;
    color: var(--text-main);
}

.preview-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 40px;
}

.preview-wrapper {
    width: 210mm;
    min-height: 297mm;
    background: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    transform-origin: top center;
    transition: transform 0.2s;
}

iframe {
    width: 210mm;
    height: 297mm;
    border: none;
    display: block;
}

/* ═══════════════════════════════════════════════════════════════════════
   PRODUCT LIBRARY PANEL
═══════════════════════════════════════════════════════════════════════ */

/* Overlay */
.lib-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 998;
    display: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.lib-overlay.open {
    display: block;
    opacity: 1;
}

/* Panel */
.lib-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 380px;
    height: 100vh;
    background: var(--surface);
    z-index: 999;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 40px rgba(0, 0, 0, 0.20);
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.lib-panel.open {
    transform: translateX(0);
}

/* Panel Header */
.lib-panel-header {
    padding: 16px 18px 14px;
    background: linear-gradient(135deg, #0f172a, #1e3a5f);
    color: white;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
}

.lib-panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.lib-panel-header p {
    margin: 2px 0 0;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.55);
}

.lib-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    border-radius: var(--radius-sm);
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.lib-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Current product badge inside panel */
.lib-current-badge {
    margin: 8px 14px;
    padding: 7px 12px;
    background: var(--accent-light);
    border: 1px solid #86efac;
    border-radius: var(--radius);
    font-size: 11px;
    font-weight: 600;
    color: #15803d;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Panel actions */
.lib-actions {
    display: flex;
    gap: 8px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.lib-btn-new,
.lib-btn-save {
    flex: 1;
    border: none;
    border-radius: var(--radius);
    padding: 9px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.18s;
}

.lib-btn-new {
    background: var(--accent);
    color: white;
}

.lib-btn-new:hover {
    background: #15803d;
}

.lib-btn-save {
    background: #0f172a;
    color: white;
}

.lib-btn-save:hover {
    background: #1e293b;
}

/* Search */
.lib-search {
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.lib-search input {
    width: 100%;
    padding: 7px 11px;
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    font-size: 12px;
    font-family: inherit;
    background: var(--surface-2);
    transition: all 0.15s;
}

.lib-search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.12);
}

/* DB Status Badge */
.lib-db-status {
    padding: 5px 14px;
    font-size: 10px;
    color: var(--text-xs);
    display: flex;
    align-items: center;
    gap: 5px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.lib-db-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
}

.lib-db-dot.connected {
    background: var(--accent);
}

.lib-db-dot.offline {
    background: #f59e0b;
}

/* Product list */
.lib-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

/* Product card */
.lib-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.18s;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-2);
}

.lib-card:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.lib-card.active {
    border-color: var(--accent);
    background: var(--accent-light);
    box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.2);
}

.lib-card-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #0f172a, #1e3a5f);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4ade80;
    font-size: 16px;
    flex-shrink: 0;
}

.lib-card-body {
    flex: 1;
    min-width: 0;
}

.lib-card-name {
    font-weight: 600;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 1px;
}

.lib-card-meta {
    font-size: 10px;
    color: var(--text-sub);
    display: flex;
    gap: 4px;
}

.lib-card-template {
    background: var(--border);
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 9px;
}

.lib-card-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.lib-icon-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    width: 26px;
    height: 26px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    color: var(--text-sub);
}

.lib-icon-btn:hover {
    background: #f0f0f0;
    color: var(--text-main);
}

.lib-icon-btn.del:hover {
    background: #fff0f0;
    border-color: #fca5a5;
    color: #ef4444;
}

/* Empty state */
.lib-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    gap: 10px;
    color: var(--text-sub);
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

.lib-empty-icon {
    font-size: 36px;
    opacity: 0.4;
}

/* ═══════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATION
═══════════════════════════════════════════════════════════════════════ */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: #1e293b;
    color: white;
    padding: 9px 18px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.25s;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    background: #15803d;
}

.toast.error {
    background: #dc2626;
}

.toast.info {
    background: #1e3a5f;
}

/* ── Auto-standards button ────────────────────────────────────────────── */
.btn-auto-gen {
    background: #0f172a;
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 6px 11px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
    flex-shrink: 0;
}

.btn-auto-gen:hover {
    background: #1e293b;
}

/* Section divider for logical grouping within accordion body */
.field-divider {
    height: 1px;
    background: var(--border);
    margin: 12px 0;
}

.field-group-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-xs);
    margin: 12px 0 8px;
}

/* ═══════════════════════════════════════════════════════════════════════
   DIMENSION DRAWING MODE TABS (in Visuals accordion)
═══════════════════════════════════════════════════════════════════════ */
.dim-mode-tabs {
    display: flex;
    gap: 0;
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 10px;
}

.dim-mode-tab {
    flex: 1;
    padding: 8px 10px;
    border: none;
    background: var(--surface-2);
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-sub);
    cursor: pointer;
    transition: all 0.18s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.dim-mode-tab:first-child {
    border-right: 1px solid var(--border-2);
}

.dim-mode-tab.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

/* Saved drawing preview thumbnail */
.dim-saved-preview {
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}

.dim-saved-preview img {
    width: 100%;
    display: block;
    border-radius: var(--radius) var(--radius) 0 0;
}

.dim-saved-preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 8px;
    background: var(--surface-2);
    font-size: 11px;
    color: var(--text-sub);
}

.dim-edit-btn {
    background: none;
    border: 1px solid var(--border-2);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 10px;
    font-family: inherit;
    cursor: pointer;
    color: var(--text-sub);
    transition: all 0.15s;
}

.dim-edit-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-open-editor {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #0f172a, #1e3a5f);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    letter-spacing: 0.3px;
    transition: all 0.18s;
    margin-top: 6px;
}

.btn-open-editor:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-use-product {
    width: 100%;
    padding: 7px 10px;
    background: var(--surface-2);
    border: 1px dashed var(--border-2);
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-sub);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn-use-product:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

/* ═══════════════════════════════════════════════════════════════════════
   DIMENSION EDITOR MODAL
═══════════════════════════════════════════════════════════════════════ */

/* Full-screen overlay */
.dim-editor-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.dim-editor-overlay.open {
    display: flex;
}

/* Modal box */
.dim-editor-modal {
    background: #0f172a;
    border-radius: 14px;
    width: 95vw;
    max-width: 1200px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Header */
.dim-editor-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: linear-gradient(135deg, #0f172a, #1e3a5f);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.dim-editor-title {
    flex: 1;
    font-size: 15px;
    font-weight: 700;
    color: white;
}

.dim-editor-header-sub {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
}

.dim-editor-toast {
    flex: 1;
    font-size: 11px;
    padding: 4px 12px;
    border-radius: 12px;
    opacity: 0;
    transition: opacity 0.3s;
    text-align: center;
    font-weight: 600;
}

.dim-editor-toast.ok {
    background: #14532d;
    color: #4ade80;
}

.dim-editor-toast.err {
    background: #7f1d1d;
    color: #f87171;
}

.dim-editor-toast.warn {
    background: #78350f;
    color: #fcd34d;
}

.dim-editor-close {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    width: 30px;
    height: 30px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.dim-editor-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* Body: sidebar + canvas */
.dim-editor-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar toolbar */
.dim-editor-sidebar {
    width: 180px;
    min-width: 180px;
    background: #0a0f1e;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    padding: 14px 10px;
    gap: 6px;
    overflow-y: auto;
    flex-shrink: 0;
}

.dim-sidebar-section {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.25);
    padding: 0 4px 4px;
    margin-top: 10px;
}

.dim-sidebar-section:first-child {
    margin-top: 0;
}

/* Tool buttons */
.dim-tool-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 7px;
    color: rgba(255, 255, 255, 0.6);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s;
    text-align: left;
}

.dim-tool-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.12);
}

.dim-tool-btn.active {
    background: #16a34a22;
    border-color: #16a34a;
    color: #4ade80;
    font-weight: 700;
}

.dim-tool-icon {
    font-size: 15px;
    flex-shrink: 0;
}

/* Threshold slider */
.dim-threshold-wrap {
    padding: 6px 4px;
}

.dim-threshold-wrap label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.dim-threshold-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dim-threshold-wrap input[type="range"] {
    flex: 1;
    accent-color: #16a34a;
    height: 4px;
    border-radius: 4px;
}

.dim-threshold-val {
    font-size: 11px;
    font-weight: 700;
    color: #4ade80;
    min-width: 24px;
    text-align: right;
}

/* Image load buttons inside sidebar */
.dim-sidebar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: 7px;
    color: rgba(255, 255, 255, 0.5);
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}

.dim-sidebar-btn:hover {
    border-color: #16a34a;
    color: #4ade80;
    background: #16a34a11;
}

/* Canvas area */
.dim-editor-canvas-wrap {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 16px;
    background: #1a1f2e;
}

#dimEditorCanvas {
    background: white;
    border-radius: 4px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    max-width: 100%;
    max-height: calc(90vh - 120px);
    display: block;
    cursor: crosshair;
}

/* Footer */
.dim-editor-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 10px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: #0a0f1e;
    flex-shrink: 0;
}

.dim-footer-info {
    flex: 1;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.25);
}

.dim-footer-hint {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.18);
}

.dim-btn-cancel {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.5);
    padding: 9px 18px;
    border-radius: 7px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.dim-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.dim-btn-save {
    background: #16a34a;
    border: none;
    color: white;
    padding: 9px 22px;
    border-radius: 7px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.18s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dim-btn-save:hover {
    background: #15803d;
    transform: translateY(-1px);
}

/* ─── Inline Label Popup (replaces browser prompt()) ─────────────────────── */
.dim-label-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3000;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    padding: 18px 20px;
    min-width: 270px;
    max-width: 340px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(99, 202, 133, 0.15);
    animation: dimPopupIn 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dim-label-popup.visible {
    display: block;
}

@keyframes dimPopupIn {
    from {
        opacity: 0;
        transform: translate(-50%, -52%) scale(0.94);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.dim-label-title {
    font-size: 12px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 10px;
    letter-spacing: 0.2px;
}

.dim-label-input {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 7px;
    color: white;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    outline: none;
    transition: border-color 0.15s;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.dim-label-input:focus {
    border-color: #4ade80;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.15);
}

.dim-label-input::placeholder {
    color: rgba(255, 255, 255, 0.25);
    font-weight: 400;
}

.dim-label-actions {
    display: flex;
    gap: 8px;
}

.dim-label-cancel {
    flex: 1;
    padding: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 7px;
    color: rgba(255, 255, 255, 0.5);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.dim-label-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.dim-label-ok {
    flex: 2;
    padding: 8px;
    background: #16a34a;
    border: none;
    border-radius: 7px;
    color: white;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}

.dim-label-ok:hover {
    background: #15803d;
}

.dim-label-hint {
    margin-top: 8px;
    font-size: 9px;
    color: rgba(255, 255, 255, 0.2);
    text-align: center;
    letter-spacing: 0.3px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   NEW HEADER BUTTONS (Settings / Reports)
═══════════════════════════════════════════════════════════════════════════ */
.header-action-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.7);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
    border-color: rgba(255, 255, 255, 0.25);
}

/* ═══════════════════════════════════════════════════════════════════════════
   SETTINGS OVERLAY
═══════════════════════════════════════════════════════════════════════════ */
.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.settings-overlay.open {
    opacity: 1;
    visibility: visible;
}

.settings-panel {
    width: 500px;
    max-width: 90vw;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.settings-overlay.open .settings-panel {
    transform: translateY(0);
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: #0b1120;
    border-radius: 12px 12px 0 0;
}

.settings-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.settings-close-btn {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    transition: color 0.15s;
}

.settings-close-btn:hover {
    color: white;
}

.settings-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.settings-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #cbd5e1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-footer {
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: #0b1120;
    border-radius: 0 0 12px 12px;
    display: flex;
    justify-content: flex-end;
}

.btn-save-settings {
    background: #2563eb;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-save-settings:hover {
    background: #1d4ed8;
}

/* ═══════════════════════════════════════════════════════════════════════════
   REPORTS OVERLAY (Full Grid)
═══════════════════════════════════════════════════════════════════════════ */
.reports-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    z-index: 8500;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.reports-overlay.open {
    opacity: 1;
    visibility: visible;
}

.reports-panel {
    width: 900px;
    max-width: 95vw;
    height: 85vh;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.reports-overlay.open .reports-panel {
    transform: translateY(0);
}

.reports-header {
    padding: 24px 32px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: #0b1120;
    border-radius: 12px 12px 0 0;
}

.reports-body {
    padding: 32px;
    overflow-y: auto;
    flex: 1;
}

/* Reports Grid */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.report-card {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.2s;
    position: relative;
}

.report-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.2);
}

.report-card.active {
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px #3b82f6;
}

.report-card-active-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #3b82f6;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.report-card-img {
    height: 140px;
    background-size: cover;
    background-position: center;
    background-color: #0f172a;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
}

.report-card-img.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    opacity: 0.3;
}

.report-card-img::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(15, 23, 42, 1) 0%, rgba(15, 23, 42, 0) 50%);
}

.report-card-body {
    padding: 16px;
    flex: 1;
}

.report-card-title {
    font-size: 15px;
    font-weight: 600;
    color: white;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.report-card-meta {
    font-size: 12px;
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.report-card-actions {
    display: flex;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: #0f172a;
}

.btn-report-action {
    flex: 1;
    background: none;
    border: none;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    padding: 10px 0;
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-report-action:last-child {
    border-right: none;
}

.btn-report-action:hover {
    background: rgba(255, 255, 255, 0.04);
    color: white;
}

.btn-report-action.primary {
    color: #60a5fa;
    font-weight: 600;
}

.btn-report-action.primary:hover {
    color: #93c5fd;
    background: rgba(96, 165, 250, 0.1);
}

.btn-report-action.danger:hover {
    color: #fca5a5;
    background: rgba(248, 113, 113, 0.1);
}

/* ─── Reports Full-Screen Overlay ─────────────────────────────────────── */
.reports-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.reports-overlay.open {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.reports-panel {
    width: 100%;
    max-width: 1100px;
    background: #1a1a2e;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    min-height: 500px;
}

.reports-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 28px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
}

.reports-header h2 {
    margin: 0 0 4px 0;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

.reports-header p {
    margin: 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
}

.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    padding: 24px 28px;
}

.report-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.2s, transform 0.15s;
    position: relative;
}

.report-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.report-card.active {
    border-color: var(--accent, #5abf5a);
}

.report-card-active-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--accent, #5abf5a);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.report-card-img {
    height: 130px;
    background: rgba(255, 255, 255, 0.03);
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: rgba(255, 255, 255, 0.2);
}

.report-card-body {
    padding: 14px 16px;
}

.report-card-title {
    font-size: 14px;
    font-weight: 600;
    color: #f1f5f9;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.report-card-meta {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
}

.report-card-actions {
    display: flex;
    gap: 6px;
    padding: 10px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ── Searchable Dropdown ── */
.searchable-dropdown {
    position: relative;
    width: 100%;
}
.dropdown-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1000;
    background: #0f172a;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.25);
}
.dropdown-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    color: #e2e8f0;
    text-align: left;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.dropdown-item:last-child {
    border-bottom: none;
}
.dropdown-item:hover {
    background: rgba(255,255,255,0.05);
    color: #ffffff;
}
.dropdown-item.no-results {
    color: #94a3b8;
    cursor: default;
    background: transparent;
}

/* Category Manage Modal Enhancements */
.category-chevron {
    transition: transform 0.2s ease;
}
.searchable-dropdown:focus-within .category-chevron {
    transform: rotate(180deg);
}
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}

/* ── Category Manage List ── */
.category-list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}
.category-list-row:last-child {
    border-bottom: none;
}
.category-list-row:hover {
    background: rgba(255,255,255,0.03);
}

.btn-icon-sm.delete {
    background: transparent;
    border: none;
    color: #64748b;
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.btn-icon-sm.delete:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}