/* BigQuotes · Admin CSS · M0 baseline
   Stile: gestionale moderno, pulito, premium. Vanilla, no framework.
   Brand: giallo BigFive + nero + grigi morbidi. */

:root {
    --color-bg:        #f7f8fa;
    --color-surface:   #ffffff;
    --color-text:      #0e1116;
    --color-muted:     #5b6472;
    --color-border:    #e5e7eb;
    --color-border-2:  #d1d5db;
    --color-primary:   #0e1116;          /* nero pieno, "BigFive corporate" */
    --color-accent:    #FCE800;          /* giallo BigFive */
    --color-accent-dk: #d8c500;
    --color-success:   #166534;
    --color-success-bg:#dcfce7;
    --color-warning:   #92400e;
    --color-warning-bg:#fef3c7;
    --color-info:      #1e40af;
    --color-info-bg:   #dbeafe;
    --color-danger:    #991b1b;
    --color-danger-bg: #fee2e2;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow:    0 4px 16px rgba(0,0,0,0.06);
    --radius:    10px;
    --radius-sm: 6px;
    --space:     16px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--color-primary); }

/* ╭─ Topbar / Nav ─╮ */
.topbar {
    background: #0e1116;
    color: #fff;
    border-bottom: 4px solid var(--color-accent);
}
.topbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 24px;
    height: 60px;
}
.brand {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: #fff;
    letter-spacing: 0.5px;
    font-weight: 800;
    font-size: 18px;
}
.brand-mark { color: #fff; }
.brand-mark-alt { color: var(--color-accent); }
.topnav {
    display: flex;
    gap: 4px;
    margin-left: 20px;
    flex: 1;
}
.topnav-link {
    color: #d6d8db;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
}
.topnav-link:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}
.topnav-link.is-active {
    background: var(--color-accent);
    color: #0e1116;
    font-weight: 600;
}
.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #cdd0d4;
}
.user-logout {
    color: #cdd0d4;
    text-decoration: none;
    font-size: 16px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
}
.user-logout:hover { background: rgba(255,255,255,0.08); color: #fff; }

/* ╭─ Main / Pagine ─╮ */
.main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px 24px 80px;
}
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}
.page-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
}

/* ╭─ Card ─╮ */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.card-title {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
}

/* ╭─ Stats ─╮ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 4px;
    background: var(--color-border-2);
}
.stat-card.stat-bozza::before     { background: #94a3b8; }
.stat-card.stat-inviato::before   { background: var(--color-info); }
.stat-card.stat-visto::before     { background: var(--color-accent); }
.stat-card.stat-accettato::before { background: var(--color-success); }
.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 6px;
}
.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-muted);
}

/* ╭─ Tabelle ─╮ */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table th, .table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border);
}
.table th {
    font-weight: 600;
    color: var(--color-muted);
    background: var(--color-bg);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.3px;
}
.table tbody tr:hover { background: var(--color-bg); }

/* ╭─ Badge stati ─╮ */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: var(--color-border);
    color: var(--color-text);
}
.badge-bozza      { background: #f1f5f9; color: #475569; }
.badge-inviato    { background: var(--color-info-bg);    color: var(--color-info); }
.badge-visto      { background: #fef9c3; color: #854d0e; }
.badge-accettato  { background: var(--color-success-bg); color: var(--color-success); }
.badge-rifiutato  { background: var(--color-danger-bg);  color: var(--color-danger); }
.badge-archiviato { background: #e5e7eb; color: #6b7280; }

/* ╭─ Bottoni ─╮ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid var(--color-border-2);
    background: var(--color-surface);
    color: var(--color-text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.12s ease, transform 0.12s ease;
}
.btn:hover { background: var(--color-bg); }
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.btn-primary:hover { background: #25292f; }
.btn-accent {
    background: var(--color-accent);
    color: #0e1116;
    border-color: var(--color-accent);
    font-weight: 600;
}
.btn-accent:hover { background: var(--color-accent-dk); }
.btn-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border-color: #fecaca;
}
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ╭─ Form ─╮ */
.field { display: block; margin-bottom: 16px; }
.field-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}
.field input, .field textarea, .field select,
.input, .textarea, .select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border-2);
    border-radius: var(--radius-sm);
    font: inherit;
    background: #fff;
    color: var(--color-text);
}
.field input:focus, .field textarea:focus, .field select:focus,
.input:focus, .textarea:focus, .select:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: -1px;
    border-color: transparent;
}

/* ╭─ Flash (legacy, mantenuto per casi rari di rendering inline) ─╮ */
.flash {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 500;
}
.flash-success { background: var(--color-success-bg); color: var(--color-success); }
.flash-error   { background: var(--color-danger-bg);  color: var(--color-danger); }
.flash-info    { background: var(--color-info-bg);    color: var(--color-info); }
.flash-warning { background: var(--color-warning-bg); color: var(--color-warning); }

/* ╭─ Toast notifiche bottom-right ─╮ */
#toast-stack {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    pointer-events: none;
    max-width: calc(100vw - 48px);
}
.toast {
    pointer-events: auto;
    min-width: 280px;
    max-width: 440px;
    background: var(--color-surface);
    color: var(--color-text);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-muted);
    box-shadow: 0 8px 28px rgba(0,0,0,0.15);
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 13px;
    line-height: 1.45;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.22s ease, transform 0.22s ease;
    cursor: pointer;
}
.toast.is-show {
    opacity: 1;
    transform: translateX(0);
}
.toast.is-hide {
    opacity: 0;
    transform: translateX(20px);
}
.toast-icon {
    flex-shrink: 0;
    font-size: 16px;
    line-height: 1.4;
    font-weight: 700;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    background: var(--color-muted);
}
.toast-body { flex: 1; min-width: 0; word-break: break-word; }
.toast-success { border-left-color: var(--color-success); }
.toast-success .toast-icon { background: var(--color-success); }
.toast-error   { border-left-color: var(--color-danger); }
.toast-error   .toast-icon { background: var(--color-danger); }
.toast-warning { border-left-color: var(--color-warning); }
.toast-warning .toast-icon { background: var(--color-warning); }
.toast-info    { border-left-color: var(--color-info); }
.toast-info    .toast-icon { background: var(--color-info); }

@media (max-width: 600px) {
    #toast-stack { bottom: 12px; right: 12px; left: 12px; }
    .toast { min-width: 0; max-width: 100%; }
}

/* ╭─ Login ─╮ */
.login-body {
    background: linear-gradient(135deg, #0e1116 0%, #1f2937 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-card {
    background: #fff;
    width: 100%;
    max-width: 380px;
    padding: 36px 32px;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.login-brand {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.login-sub {
    color: var(--color-muted);
    font-size: 13px;
    margin: 0 0 24px;
}

/* ╭─ Utility ─╮ */
.muted { color: var(--color-muted); }
.text-sm { font-size: 12px; }
.text-right { text-align: right; }
.empty-state {
    text-align: center;
    padding: 40px 24px;
    color: var(--color-muted);
}
.empty-state p { margin: 0 0 16px; }

/* ╭─ Footer ─╮ */
.footer {
    margin-top: 60px;
    padding: 20px 24px;
    color: var(--color-muted);
    font-size: 12px;
    text-align: center;
}
.footer-inner { max-width: 1280px; margin: 0 auto; }
.footer-sep { margin: 0 8px; opacity: 0.4; }

/* ╭─ Link primario ─╮ */
.link-primary {
    color: var(--color-text);
    text-decoration: none;
    font-weight: 600;
}
.link-primary:hover { color: var(--color-info); text-decoration: underline; }

.back-link {
    display: inline-block;
    font-size: 13px;
    color: var(--color-muted);
    text-decoration: none;
    margin-bottom: 6px;
}
.back-link:hover { color: var(--color-text); }

/* ╭─ Filter bar lista preventivi ─╮ */
.filter-bar {
    padding: 14px 18px;
    margin-bottom: 18px;
}
.filter-form { display: flex; flex-direction: column; gap: 12px; }
.filter-search {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.filter-search input[type=search] {
    flex: 1;
    min-width: 240px;
    padding: 9px 12px;
    border: 1px solid var(--color-border-2);
    border-radius: var(--radius-sm);
    font: inherit;
    background: #fff;
}
.filter-search input[type=search]:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: -1px;
}
.filter-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: #fff;
    color: var(--color-text);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.12s ease;
}
.chip:hover { background: var(--color-bg); }
.chip-active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.chip-count {
    background: rgba(0,0,0,0.08);
    color: inherit;
    padding: 0 7px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 18px;
}
.chip-active .chip-count {
    background: rgba(255,255,255,0.2);
}

/* ╭─ Tabelle preventivi ─╮ */
.table-quotes th { font-weight: 600; }
.table-quotes .th-sort {
    color: var(--color-muted);
    text-decoration: none;
    display: block;
}
.table-quotes .th-sort:hover { color: var(--color-text); }
.table-quotes td { vertical-align: top; }

.row-actions {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}
.row-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--color-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 15px;
    line-height: 1;
}
.row-action:hover {
    background: var(--color-bg);
    color: var(--color-text);
    border-color: var(--color-border);
}
.row-action-danger:hover {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border-color: #fecaca;
}
.inline-form {
    display: inline-block;
    margin: 0;
}

.is-copied {
    background: var(--color-success-bg) !important;
    color: var(--color-success) !important;
    border-color: #86efac !important;
}

/* ╭─ Combobox (input + dropdown searchable) ─╮ */
.combo {
    position: relative;
    display: block;
}
.combo-input {
    width: 100%;
    padding: 10px 38px 10px 12px;
    border: 1px solid var(--color-border-2);
    border-radius: var(--radius-sm);
    font: inherit;
    background: #fff;
    color: var(--color-text);
}
.combo-input:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: -1px;
    border-color: transparent;
}
.combo-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    color: var(--color-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 12px;
    line-height: 1;
    transition: transform 0.15s ease;
}
.combo-toggle:hover { background: var(--color-bg); color: var(--color-text); }
.combo.is-open .combo-toggle { transform: translateY(-50%) rotate(180deg); }

.combo-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--color-border-2);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    max-height: 280px;
    overflow-y: auto;
    z-index: 100;
}
.combo-panel[hidden] { display: none; }

.combo-list {
    list-style: none;
    margin: 0;
    padding: 4px 0;
}
.combo-item {
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13px;
    color: var(--color-text);
    border-left: 3px solid transparent;
}
.combo-item:hover,
.combo-item.is-active {
    background: var(--color-bg);
    border-left-color: var(--color-accent);
}
.combo-item.is-hidden { display: none; }
.combo-empty {
    padding: 14px;
    text-align: center;
    color: var(--color-muted);
    font-size: 12px;
    font-style: italic;
}

/* ╭─ Chip toggle (per multi-select tipo categorie) ─╮ */
.chip-toggles {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.chip-toggle {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border: 1px solid var(--color-border-2);
    border-radius: 999px;
    background: #fff;
    color: var(--color-text);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.12s ease;
    user-select: none;
}
.chip-toggle:hover { background: var(--color-bg); }
.chip-toggle input { display: none; }
.chip-toggle.is-on {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    font-weight: 600;
}
.chip-toggle.is-ghost {
    background: var(--color-warning-bg);
    color: var(--color-warning);
    border-color: #fed7aa;
    border-style: dashed;
}
.chip-toggle.is-ghost.is-on::after {
    content: ' (ghost)';
    font-size: 10px;
    opacity: 0.7;
    margin-left: 4px;
}

/* ╭─ Markdown lite editor (toolbar sopra textarea) ─╮ */
.md-editor-wrap { position: relative; }
.md-toolbar {
    display: flex;
    gap: 4px;
    padding: 6px;
    border: 1px solid var(--color-border-2);
    border-bottom: none;
    background: var(--color-bg);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.md-toolbar button {
    background: transparent;
    border: 1px solid transparent;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-sm);
    color: var(--color-text);
}
.md-toolbar button:hover {
    background: #fff;
    border-color: var(--color-border);
}
.md-toolbar .md-sep {
    border-left: 1px solid var(--color-border);
    margin: 4px 4px;
}
.md-editor-wrap textarea {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    font-family: ui-monospace, Menlo, monospace;
    font-size: 13px;
    line-height: 1.5;
    margin-top: -1px;
}
.md-editor-hint {
    margin-top: 4px;
    color: var(--color-muted);
    font-size: 10px;
    font-style: italic;
}

/* ╭─ Libreria moduli (cards grid) ─╮ */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.module-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.module-card:hover {
    border-color: var(--color-border-2);
    box-shadow: var(--shadow);
}
.module-card.is-inactive { opacity: 0.6; }
.module-card-icon {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    background: var(--color-bg);
    border-radius: 50%;
    border: 2px solid var(--color-accent);
    overflow: hidden;
    padding: 11px;
    box-sizing: border-box;
    position: relative;
}
.module-card-icon img,
.module-card-icon svg {
    position: absolute;
    inset: 11px;
    width: calc(100% - 22px);
    height: calc(100% - 22px);
    object-fit: contain;
    display: block;
}
.module-icon-placeholder {
    color: var(--color-muted);
    font-size: 22px;
}
.module-card-body { flex: 1; }
.module-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.module-card-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}
.module-card-title a {
    color: var(--color-text);
    text-decoration: none;
}
.module-card-title a:hover { color: var(--color-info); }
.module-cats {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.module-cat {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-muted);
    background: var(--color-bg);
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}
.module-card-desc {
    margin: 0;
    font-size: 12px;
    color: var(--color-muted);
    line-height: 1.5;
}
.module-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 6px;
}
.tag-pill {
    font-size: 10px;
    background: var(--color-info-bg);
    color: var(--color-info);
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 500;
}
.module-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--color-border);
    padding-top: 10px;
    margin-top: auto;
}
.module-card-actions { display: flex; gap: 2px; }

/* ╭─ Upload icona ─╮ */
.icon-upload {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 16px;
    align-items: start;
}
.icon-preview {
    width: 100px;
    height: 100px;
    flex-shrink: 0;
    background: var(--color-bg);
    border: 2px solid var(--color-accent);
    border-radius: 50%;
    overflow: hidden;
    padding: 18px;
    box-sizing: border-box;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-preview img,
.icon-preview svg {
    position: absolute;
    inset: 18px;
    width: calc(100% - 36px);
    height: calc(100% - 36px);
    object-fit: contain;
    display: block;
}
.icon-preview .muted {
    font-size: 11px;
    width: auto;
    height: auto;
    position: static;
}

/* ╭─ Tab Moduli editor preventivo ─╮ */
.modules-tab-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}
.modules-tab-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

.quote-modules-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.quote-module-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    position: relative;
    transition: box-shadow 0.12s ease, transform 0.15s ease, opacity 0.15s ease;
    display: flex;
    align-items: stretch;
}
.quote-module-card.is-hidden { opacity: 0.55; background: repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(0,0,0,0.02) 8px, rgba(0,0,0,0.02) 16px), var(--color-surface); }
.quote-module-card.is-dragging { opacity: 0.5; transform: scale(0.98); }
.quote-module-card.drag-over-top { box-shadow: 0 -3px 0 var(--color-accent); }
.quote-module-card.drag-over-bottom { box-shadow: 0 3px 0 var(--color-accent); }

.qm-handle {
    width: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-border-2);
    cursor: grab;
    font-size: 14px;
    border-right: 1px solid var(--color-border);
    user-select: none;
}
.qm-handle:hover { color: var(--color-text); background: var(--color-bg); }
.qm-handle:active { cursor: grabbing; }

.qm-details {
    flex: 1;
    min-width: 0;
}
.qm-summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
}
.qm-summary::-webkit-details-marker { display: none; }
.qm-summary:hover { background: var(--color-bg); }
.qm-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    background: var(--color-bg);
    border: 2px solid var(--color-accent);
    border-radius: 50%;
    overflow: hidden;
    padding: 9px;
    box-sizing: border-box;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.qm-icon img,
.qm-icon svg {
    position: absolute;
    inset: 9px;
    width: calc(100% - 18px);
    height: calc(100% - 18px);
    object-fit: contain;
    display: block;
}
.qm-icon .module-icon-placeholder { font-size: 16px; width: auto; height: auto; position: static; }
.qm-summary-text { flex: 1; min-width: 0; }
.qm-title-line { display: flex; align-items: center; gap: 8px; }
.qm-desc {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.qm-price { flex-shrink: 0; min-width: 100px; text-align: right; }
.qm-quick-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    padding: 0 10px;
    border-left: 1px solid var(--color-border);
}
.qm-toggle-icon {
    flex-shrink: 0;
    color: var(--color-muted);
    transition: transform 0.15s ease;
    font-size: 14px;
}
.qm-details[open] .qm-toggle-icon { transform: rotate(180deg); }

.qm-form {
    padding: 8px 18px 18px;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}
.qm-form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

/* ╭─ Modal libreria (overlay) ─╮ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1000;
}
.modal-overlay[hidden] { display: none; }
.modal {
    background: #fff;
    border-radius: var(--radius);
    width: 100%;
    max-width: 920px;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 60px rgba(0,0,0,0.4);
}
.modal-head {
    padding: 18px 24px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.modal-close {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 24px;
    color: var(--color-muted);
    border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--color-bg); color: var(--color-text); }
.modal-body { padding: 20px 24px; overflow-y: auto; }
.modal-search {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border-2);
    border-radius: var(--radius-sm);
    font: inherit;
    margin-bottom: 16px;
}
.modal-search:focus { outline: 2px solid var(--color-accent); outline-offset: -1px; }

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}
.library-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.library-card.is-hidden { display: none; }
.library-card-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    background: var(--color-bg);
    border: 2px solid var(--color-accent);
    border-radius: 50%;
    overflow: hidden;
    padding: 10px;
    box-sizing: border-box;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.library-card-icon img,
.library-card-icon svg {
    position: absolute;
    inset: 10px;
    width: calc(100% - 20px);
    height: calc(100% - 20px);
    object-fit: contain;
    display: block;
}
.library-card-title { margin: 0; font-size: 14px; font-weight: 700; }
.library-card-cat {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--color-muted);
    letter-spacing: 0.5px;
}
.library-card-desc {
    font-size: 12px;
    color: var(--color-muted);
    margin: 0;
    line-height: 1.4;
}
.library-card-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--color-border);
    padding-top: 10px;
    margin-top: auto;
}

@media (max-width: 800px) {
    .qm-summary { flex-wrap: wrap; }
    .qm-price { width: 100%; text-align: left; }
}

/* ╭─ Editor preventivo ─╮ */
.quote-editor { display: block; }

.editor-head {
    margin-bottom: 0;
    padding: 18px 24px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: none;
}
.editor-head .page-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}
.editor-head .page-title .badge {
    font-size: 11px;
}
.editor-head-info { flex: 1; min-width: 0; }
.editor-head-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: center;
    flex-wrap: wrap;
}

.editor-tabs {
    display: flex;
    gap: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-bottom: none;
    padding: 0 16px;
    overflow-x: auto;
}
.editor-tab {
    padding: 12px 18px;
    color: var(--color-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
}
.editor-tab:hover { color: var(--color-text); }
.editor-tab.is-active {
    color: var(--color-text);
    border-bottom-color: var(--color-accent);
    font-weight: 600;
}

.editor-body {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 24px 28px;
    min-height: 360px;
}
.editor-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-top: 1px solid var(--color-border);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.tab-section { margin-bottom: 28px; padding-bottom: 4px; }
.tab-section:last-child { margin-bottom: 0; }
.section-title {
    margin: 0 0 14px;
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 2px solid var(--color-accent);
    padding-bottom: 6px;
    display: inline-block;
}

.form-grid {
    display: grid;
    gap: 14px 18px;
}
.form-grid-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid .field { margin: 0; }
.field-hint {
    display: block;
    margin-top: 4px;
    color: var(--color-muted);
    font-size: 11px;
}
.check-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--color-text);
}
.check-row input { width: auto; }

.tab-placeholder { text-align: center; padding: 40px 16px; }
.placeholder-box {
    background: var(--color-bg);
    border: 2px dashed var(--color-border-2);
    border-radius: var(--radius);
    padding: 32px 24px;
    max-width: 540px;
    margin: 0 auto;
}
.placeholder-pill {
    display: inline-block;
    background: var(--color-accent);
    color: #0e1116;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 999px;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preview-pill {
    display: inline-block;
    padding: 8px 16px;
    background: var(--color-bg);
    border: 1px solid var(--color-border-2);
    border-radius: var(--radius-sm);
    font-family: ui-monospace, Menlo, monospace;
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text);
}

/* ╭─ Responsive ─╮ */
@media (max-width: 800px) {
    .topbar-inner { gap: 12px; padding: 0 14px; }
    .topnav { display: none; } /* TODO: menu mobile in M1+ */
    .main { padding: 18px 14px 60px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid-2 { grid-template-columns: 1fr; }
    .editor-head { flex-direction: column; align-items: flex-start; }
    .editor-head-actions { width: 100%; }
}
