/* Stream Weave — Design System */

:root {
    /* Brand */
    --brand-primary: #4F46E5;
    --brand-primary-hover: #4338CA;
    --brand-primary-dark: #3730A3;
    --brand-tint: #EEF2FF;
    --brand-secondary: #0EA5E9;
    /* Text */
    --text-primary: #0F172A;
    --text-secondary: #334155;
    --text-tertiary: #64748B;
    /* Surface */
    --border: #E2E8F0;
    --border-strong: #CBD5E1;
    --divider: #F1F5F9;
    --surface: #FFFFFF;
    --surface-muted: #F8FAFC;
    /* Status */
    --danger: #DC2626;
    --danger-bg: #FEF2F2;
    --danger-text: #991B1B;
    --warning: #D97706;
    --warning-bg: #FFFBEB;
    --warning-text: #92400E;
    --success: #16A34A;
    --success-bg: #F0FDF4;
    --success-text: #166534;
    --info: #0EA5E9;
    --info-bg: #F0F9FF;
    --info-text: #075985;
    /* Geometry */
    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
    --sidebar-width: 256px;
    --sidebar-width-collapsed: 64px;
    --touch-min: 44px;
}

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

html, body {
    height: 100%;
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--surface-muted);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--brand-primary);
    text-decoration: none;
}
a:hover {
    color: var(--brand-primary-hover);
    text-decoration: underline;
}

h1 { font-size: 28px; font-weight: 700; line-height: 1.3; }
h2 { font-size: 20px; font-weight: 600; line-height: 1.4; margin-bottom: 0.5rem; }
h3 { font-size: 16px; font-weight: 600; line-height: 1.4; margin-bottom: 0.5rem; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: width 0.2s ease;
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 20px 20px 24px;
    border-bottom: 1px solid var(--border);
}

/* Toggle button */
.sidebar-toggle {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
    flex-shrink: 0;
}
.sidebar-toggle:hover { color: var(--text-primary); background: var(--surface-muted); }
.sidebar-toggle-icon {
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
}

/* Collapsed state */
.sidebar.is-collapsed {
    width: var(--sidebar-width-collapsed);
}
.sidebar.is-collapsed .sidebar-collapsible {
    display: none;
}
.sidebar.is-collapsed .sidebar-brand {
    justify-content: center;
    padding: 20px 14px 24px;
    gap: 0;
}
.sidebar.is-collapsed .sidebar-toggle {
    margin-left: 0;
}
.sidebar.is-collapsed .sidebar-toggle-icon {
    transform: rotate(180deg);
}
.sidebar.is-collapsed .sidebar-nav {
    padding: 16px 8px;
}
.sidebar.is-collapsed .nav-item {
    justify-content: center;
    padding: 10px;
}
.sidebar.is-collapsed .sidebar-user {
    justify-content: center;
    padding: 16px 8px;
}
.sidebar-logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--brand-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
}
.sidebar-title strong {
    display: block;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
}
.sidebar-title span {
    display: block;
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}
.nav-item:hover {
    background: var(--surface-muted);
    color: var(--text-primary);
    text-decoration: none;
}
.nav-item.is-active {
    background: var(--brand-tint);
    color: var(--brand-primary-dark);
    font-weight: 600;
}
.nav-item.is-disabled {
    color: var(--text-tertiary);
    cursor: not-allowed;
}
.nav-item.is-disabled:hover {
    background: transparent;
    color: var(--text-tertiary);
}
.nav-item svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}
.sidebar-user .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}
.sidebar-user strong {
    display: block;
    font-size: 13px;
    color: var(--text-primary);
}
.sidebar-user span {
    display: block;
    font-size: 11px;
    color: var(--text-tertiary);
}
.btn-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--text-tertiary);
    font-size: 11px;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.btn-link:hover {
    color: var(--brand-primary-dark);
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.main-inner {
    flex: 1;
    padding: 32px 40px;
    width: 100%;
}
.main-inner.narrow {
    max-width: 880px;
    margin: 0 auto;
}

/* Guest layout for external reviewer */
.topbar-guest {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar-guest-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text-primary);
}
.topbar-guest-user {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    gap: 12px;
    align-items: center;
}
.guest-shell {
    background: var(--surface-muted);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.guest-content {
    max-width: 880px;
    margin: 0 auto;
    padding: 48px 32px;
    width: 100%;
    flex: 1;
}

.footer {
    padding: 16px 40px;
    color: var(--text-tertiary);
    font-size: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 24px;
    justify-content: center;
    flex-wrap: wrap;
}
.footer-trust {
    display: flex;
    gap: 16px;
    color: var(--text-tertiary);
}

/* ============================================================
   BREADCRUMB & PAGE HEADER
   ============================================================ */
.breadcrumb {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.breadcrumb a {
    color: var(--text-secondary);
}
.breadcrumb-sep {
    margin: 0 6px;
    color: var(--text-tertiary);
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}
.page-header-text h1 {
    margin-bottom: 4px;
}
.page-header-text .subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}
.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.error-card {
    border-left: 3px solid var(--danger);
}
.error-card h1 {
    color: var(--danger);
}

/* Budget card */
.budget-card {
    background: var(--brand-tint);
    border-color: #bde4de;
}
.budget-amount {
    font-size: 22px;
    font-weight: 700;
    color: var(--brand-primary-dark);
    margin: 4px 0;
}
.budget-amount small {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}
.budget-bar {
    height: 6px;
    background: rgba(40, 106, 100, 0.15);
    border-radius: 999px;
    overflow: hidden;
    margin: 8px 0 4px;
}
.budget-bar-fill {
    height: 100%;
    background: var(--brand-primary);
}
.budget-note {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ============================================================
   CHIPS / BADGES
   ============================================================ */
.badge, .chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
}
.badge-in_revisione { background: var(--warning-bg); color: var(--warning-text); }
.badge-approvato    { background: var(--success-bg); color: var(--success-text); }
.badge-rifiutata    { background: var(--danger-bg);  color: var(--danger-text); }
.badge-fallita      { background: var(--danger-bg);  color: var(--danger-text); }
.badge-in_generazione { background: #f3f4f6; color: #374151; }
.badge-formato      { background: var(--brand-tint); color: var(--brand-primary-dark); }
.badge-hashtag      { background: #eef2ff; color: #3730a3; }

.chip-filter {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}
.chip-filter:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary-dark);
    text-decoration: none;
}
.chip-filter.is-active {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}

/* ============================================================
   TABLES
   ============================================================ */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}
.table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-tertiary);
    font-weight: 500;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-muted);
}
.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: middle;
}
.table tbody tr:hover {
    background: var(--surface-muted);
}
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.table-empty {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-tertiary);
}

/* ============================================================
   FORMS & BUTTONS
   ============================================================ */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-primary);
}
.form-group .hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}
.form-group input:not([type="radio"]):not([type="checkbox"]):not([type="file"]),
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--surface);
}
.form-group input:not([type="radio"]):not([type="checkbox"]):not([type="file"]):focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: 2px solid var(--brand-primary-hover);
    outline-offset: -1px;
    border-color: var(--brand-primary);
}
.form-group textarea {
    resize: vertical;
    min-height: 96px;
}
.form-group textarea.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
}

.search-box {
    position: relative;
    max-width: 320px;
    width: 100%;
}
.search-box input[type="search"] {
    width: 100%;
    height: 36px;
    padding: 0 36px 0 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    line-height: 1;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
    -webkit-appearance: none;
}
.search-box input[type="search"]::placeholder {
    color: var(--text-tertiary);
}
.search-box input[type="search"]:hover {
    border-color: var(--border-strong);
}
.search-box input[type="search"]:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(40, 106, 100, 0.15);
}
.search-box input[type="search"]::-webkit-search-cancel-button {
    cursor: pointer;
}
.search-box svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}
.search-box:focus-within svg {
    color: var(--brand-primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-primary {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}
.btn-primary:hover {
    background: var(--brand-primary-hover);
    border-color: var(--brand-primary-hover);
    color: #fff;
    text-decoration: none;
}
.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--border-strong);
}
.btn-secondary:hover {
    background: var(--surface-muted);
    border-color: var(--text-tertiary);
    text-decoration: none;
}
.btn-danger {
    background: var(--surface);
    color: var(--danger);
    border-color: var(--danger);
}
.btn-danger:hover {
    background: var(--danger-bg);
    text-decoration: none;
}
.btn-success {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}
.btn-success:hover {
    background: var(--brand-primary-hover);
    border-color: var(--brand-primary-hover);
}
.btn-warning {
    background: var(--warning);
    color: #fff;
    border-color: var(--warning);
}
.btn-warning:hover {
    background: #d97706;
    border-color: #d97706;
}
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}
.btn-ghost:hover {
    background: var(--surface-muted);
    color: var(--text-primary);
    border-color: var(--border);
    text-decoration: none;
}
.btn-lg {
    padding: 10px 20px;
    font-size: 15px;
}

/* Action bar: azioni primarie della bozza, sticky sotto l'header */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 14px;
    margin-bottom: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 10;
}
.action-bar-main {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.action-bar-status {
    white-space: nowrap;
}

/* Progressive disclosure: sezioni collassabili uniformi */
.section-collapsible {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
}
.section-collapsible > summary {
    list-style: none;
    cursor: pointer;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text-primary);
    user-select: none;
}
.section-collapsible > summary::-webkit-details-marker {
    display: none;
}
.section-collapsible > summary::before {
    content: "▸";
    color: var(--text-tertiary);
    font-size: 12px;
    transition: transform 0.15s;
    display: inline-block;
}
.section-collapsible[open] > summary::before {
    transform: rotate(90deg);
}
.section-collapsible > summary:hover {
    background: var(--surface-muted);
}
.section-collapsible[open] > summary {
    border-bottom: 1px solid var(--border);
}
.section-collapsible .section-body {
    padding: 14px 16px;
}
.section-collapsible .section-count {
    color: var(--text-tertiary);
    font-weight: 400;
    font-size: 13px;
    margin-left: auto;
}

.section-divider {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

/* Header compatto della bozza */
.bozza-header {
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}
.bozza-title {
    font-size: 22px;
    margin: 0;
    font-weight: 600;
    line-height: 1.25;
}
.bozza-title .bozza-id {
    color: var(--text-tertiary);
    font-weight: 500;
    margin-right: 6px;
}
.bozza-subtitle {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
}
.header-meta {
    flex-shrink: 0;
}
.header-meta > summary {
    cursor: pointer;
    color: var(--text-secondary);
    list-style: none;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}
.header-meta > summary::-webkit-details-marker { display: none; }
.header-meta > summary:hover {
    background: var(--surface-muted);
}
.header-meta .meta-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px 12px;
    margin: 8px 0 0 0;
    font-size: 13px;
    padding: 10px 12px;
    background: var(--surface-muted);
    border-radius: var(--radius-sm);
}
.header-meta .meta-grid dt {
    color: var(--text-tertiary);
    font-weight: 500;
}
.header-meta .meta-grid dd {
    margin: 0;
    color: var(--text-primary);
}

/* Lista sorgenti compatta (dentro section-collapsible) */
.sorgenti-list .sorgente-row {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.sorgenti-list .sorgente-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}
.sorgenti-list .sorgente-row:first-child {
    padding-top: 0;
}
.sorgente-row-head {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.sorgente-row-title {
    flex: 1 1 200px;
    min-width: 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sorgente-row-title a {
    color: inherit;
}
.sorgente-row-toggle {
    flex-shrink: 0;
    font-size: 12px;
}
.sorgente-row-meta {
    margin-top: 4px;
    padding-left: 2px;
}
.sorgente-ruolo-riferimento {
    background: var(--brand-tint);
    color: var(--brand-primary-dark);
    border: none;
}
.sorgente-ruolo-ispirazione {
    background: #f3f4f6;
    color: #374151;
    border: none;
}
.badge-sintesi {
    background: #eef2ff;
    color: #3730a3;
    border: none;
}

/* Timeline: eventi tecnici collassati */
.timeline-tecnici {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}
.timeline-tecnici > summary {
    cursor: pointer;
    padding: 4px 0;
    list-style: none;
    user-select: none;
}
.timeline-tecnici > summary::-webkit-details-marker { display: none; }
.timeline-tecnici > summary::before {
    content: "▸ ";
    color: var(--text-tertiary);
    font-size: 10px;
    transition: transform 0.15s;
    display: inline-block;
}
.timeline-tecnici[open] > summary::before {
    transform: rotate(90deg);
}
.timeline-tecnici .timeline-entry.timeline-tech {
    opacity: 0.7;
}

/* AI editor dialog */
.editor-field-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.editor-expand-btn {
    font-size: 13px;
    color: var(--brand-primary);
}
.editor-expand-btn:hover {
    color: var(--brand-primary-hover);
}
.ai-editor-dialog {
    padding: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    max-width: 100vw;
    max-height: 100vh;
    width: 100vw;
    height: 100vh;
    margin: 0;
    overflow: hidden;
    background: var(--surface);
}
.ai-editor-dialog::backdrop {
    background: rgba(17, 24, 39, 0.45);
}
.ai-editor-wrap {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
}
.ai-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.ai-editor-title {
    margin: 0 0 2px 0;
    font-size: 18px;
}
.ai-editor-body {
    position: relative;
    flex: 1;
    min-height: 0;
    padding: 16px 20px;
    overflow: hidden;
}
.ai-editor-textarea {
    width: 100%;
    height: 100%;
    padding: 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    background: var(--surface);
    color: var(--text-primary);
}
.ai-editor-textarea:focus {
    outline: 2px solid var(--brand-primary-hover);
    outline-offset: -1px;
    border-color: var(--brand-primary);
}
.ai-selection-toolbar {
    position: absolute;
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--text-primary);
    color: #fff;
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 20px rgba(17, 24, 39, 0.35);
    z-index: 20;
}
.ai-selection-toolbar[hidden] {
    display: none;
}
.ai-selection-toolbar .btn {
    background: transparent;
    color: #fff;
    border: 1px solid transparent;
    padding: 4px 10px;
    font-size: 12px;
}
.ai-selection-toolbar .btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.25);
}
.ai-editor-globals {
    padding: 12px 20px;
    background: var(--surface-muted);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ai-editor-globals-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}
.ai-editor-globals-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.ai-editor-user-prompt {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
}
.ai-editor-user-prompt:focus {
    outline: 2px solid var(--brand-primary-hover);
    outline-offset: -1px;
    border-color: var(--brand-primary);
}
.ai-editor-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.btn.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}
.btn-block {
    width: 100%;
    justify-content: center;
}

/* Radio cards (for canale / modalita / KPI) */
.radio-cards {
    display: grid;
    gap: 12px;
}
.radio-cards.cols-3 { grid-template-columns: repeat(3, 1fr); }
.radio-cards.cols-4 { grid-template-columns: repeat(4, 1fr); }
.radio-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    transition: all 0.15s;
}
.radio-card:hover {
    border-color: var(--brand-primary-hover);
    background: var(--brand-tint);
}
.radio-card input[type="radio"] {
    accent-color: var(--brand-primary);
}
.radio-card input[type="radio"]:checked + .radio-card-body,
.radio-card.is-selected {
    border-color: var(--brand-primary);
    background: var(--brand-tint);
}
.radio-card-label {
    font-weight: 600;
    color: var(--text-primary);
    display: block;
}
.radio-card-desc {
    font-size: 12px;
    color: var(--text-secondary);
    display: block;
}

/* Info note box */
.info-note {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.info-note svg { flex-shrink: 0; margin-top: 2px; color: var(--brand-primary); }

.welcome-banner {
    background: var(--brand-tint);
    border: 1px solid #bde4de;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 24px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.welcome-banner svg { color: var(--brand-primary); flex-shrink: 0; margin-top: 2px; }

/* ============================================================
   TOASTS
   ============================================================ */
.toast {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid;
}
.toast-success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: #a7f3d0;
}
.toast-info {
    background: var(--info-bg);
    color: var(--info-text);
    border-color: #bfdbfe;
}
.toast-error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-color: #fecaca;
}

/* ============================================================
   HEADER BOZZA (existing component)
   ============================================================ */
.header-bozza h1 {
    margin-bottom: 6px;
}
.meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 16px;
}

/* Corpo bozza */
.corpo-content {
    margin: 16px 0;
    color: var(--text-primary);
}
.corpo-content p { margin-bottom: 0.75rem; }
.corpo-content ul, .corpo-content ol { margin: 0.5rem 0 0.75rem 1.5rem; }

.cta-box {
    background: var(--brand-tint);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-top: 12px;
    border-left: 3px solid var(--brand-primary);
}
.hashtag-list {
    margin-top: 12px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* Warning panel */
.warning-panel {
    border-left: 3px solid var(--warning);
}
.warning-list { list-style: none; padding: 0; }
.warning-item {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}
.warning-item:last-child { border-bottom: none; }
.warning-warn  { color: var(--warning-text); }
.warning-error { color: var(--danger-text); }
.warning-info  { color: var(--info-text); }

/* Critica panel */
.critica-panel {
    border-left: 3px solid #7c3aed;
}
details summary {
    cursor: pointer;
    font-weight: 600;
    padding: 0.25rem 0;
    color: var(--text-primary);
}
details pre {
    background: var(--surface-muted);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 13px;
    margin-top: 0.5rem;
    border: 1px solid var(--border);
}
.text-error { color: var(--danger); }

/* Versioni & commenti */
.versioni-list, .commenti-list {
    list-style: none;
    padding: 0;
}
.commento-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.commento-item:last-child { border-bottom: none; }
.commento-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* KPI panel */
.kpi-panel { padding: 0.5rem 0; }
.kpi-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}
.kpi-options label { cursor: pointer; }

/* Timeline */
.timeline { padding: 8px 0; }
.timeline-entry {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.timeline-entry:last-child { border-bottom: none; }
.timeline-agent {
    background: var(--surface-muted);
    padding: 8px;
    border-radius: var(--radius-sm);
}
.timeline-icon {
    font-size: 16px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}
.timeline-action {
    font-weight: 500;
    color: var(--text-primary);
}
.timeline-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin: 24px 0;
}
.pagination a,
.pagination span {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--surface);
}
.pagination a:hover {
    background: var(--surface-muted);
    text-decoration: none;
}
.pagination .is-active {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}
.pagination .is-disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ============================================================
   LAYOUT HELPERS
   ============================================================ */
.grid { display: grid; gap: 16px; }
.grid-2col { grid-template-columns: minmax(0, 1fr) 320px; }
.grid-3col { grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr) 280px; }
.flex { display: flex; gap: 12px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 16px; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }

/* ============================================================
   PROGRESS TIMELINE (generazione async)
   ============================================================ */
.progress-card { padding: 24px; }
.progress-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}
.progress-header .card-title { margin: 0; }
.progress-live-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: progress-pulse 1.5s infinite;
}
@keyframes progress-pulse {
    0%   { box-shadow: 0 0 0 0   rgba(16, 185, 129, 0.6); }
    70%  { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);   }
    100% { box-shadow: 0 0 0 0   rgba(16, 185, 129, 0);   }
}

.progress-timeline {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.progress-item {
    display: grid;
    grid-template-columns: 22px 1fr auto;
    align-items: baseline;
    gap: 10px;
    padding: 6px 4px 6px 14px;
    border-left: 2px solid var(--border);
    margin-left: 6px;
    position: relative;
}

.progress-item-icon {
    font-family: ui-monospace, "SF Mono", Monaco, monospace;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1;
    display: inline-flex;
    justify-content: center;
    width: 22px;
}
.progress-item-body {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: baseline;
}
.progress-item-label {
    font-weight: 500;
    font-size: 14px;
}
.progress-item-detail {
    font-size: 13px;
    color: var(--text-secondary);
}
.progress-item-time {
    font-family: ui-monospace, "SF Mono", Monaco, monospace;
    font-size: 12px;
    color: var(--text-secondary);
}

.progress-item--ok .progress-item-icon { color: #10b981; }
.progress-item--warn .progress-item-icon { color: #d97706; }
.progress-item--error .progress-item-icon { color: var(--danger); }
.progress-item--error .progress-item-label { color: var(--danger-text); }

.progress-spinner {
    display: inline-block;
    width: 12px; height: 12px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--text-secondary);
    border-radius: 50%;
    animation: progress-spin 0.8s linear infinite;
}
@keyframes progress-spin {
    to { transform: rotate(360deg); }
}

.progress-footer {
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--danger-bg);
    color: var(--danger-text);
    border-radius: 6px;
}

/* ============================================================
   REVIEWER COMPONENTS
   ============================================================ */
.reviewer-input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.reviewer-input-row .input { flex: 1; }

.reviewer-chips {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.reviewer-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-primary);
}
.reviewer-chip-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    color: var(--text-tertiary);
    padding: 0 2px;
}
.reviewer-chip-remove:hover { color: var(--danger); }

.reviewer-list {
    list-style: none;
    padding: 0;
    margin: 0 0 12px;
}
.reviewer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.reviewer-item:last-child { border-bottom: none; }
.reviewer-info { display: flex; flex-direction: column; gap: 2px; }
.reviewer-email { font-size: 14px; font-weight: 500; }

/* ============================================================
   INLINE COMMENTS (highlighting)
   ============================================================ */
.inline-highlight {
    background: rgba(255, 213, 79, 0.35);
    border-bottom: 2px solid #f59e0b;
    cursor: pointer;
    border-radius: 2px;
    transition: background 0.15s;
}
.inline-highlight:hover {
    background: rgba(255, 213, 79, 0.55);
}

.inline-popover {
    position: absolute;
    z-index: 100;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 12px;
    width: 320px;
    max-width: 90vw;
}
.inline-popover-quote {
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 8px;
    padding: 6px 10px;
    background: var(--surface-muted);
    border-radius: var(--radius-sm);
    border-left: 3px solid #f59e0b;
    word-break: break-word;
}
.inline-popover-textarea {
    width: 100%;
    margin-bottom: 8px;
    font-size: 13px;
    resize: vertical;
}
.inline-popover-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.commento-citazione {
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
    padding: 6px 10px;
    margin: 0 0 6px;
    background: var(--surface-muted);
    border-radius: var(--radius-sm);
    border-left: 3px solid #f59e0b;
    word-break: break-word;
}

.commento-flash {
    animation: commento-flash-anim 1.5s ease;
}
@keyframes commento-flash-anim {
    0%   { background: rgba(255, 213, 79, 0.3); }
    100% { background: transparent; }
}

/* Triage stato commenti */
.commento-meta-sep { color: var(--border-strong); }

.commento-stato--rifiutato .commento-testo {
    opacity: 0.45;
    text-decoration: line-through;
    text-decoration-color: var(--danger-text);
}
.commento-stato--risolto { opacity: 0.6; }
.commento-stato--risolto .commento-testo { text-decoration: line-through; }

/* Only risolto badge remains on meta line; accettato/rifiutato communicated by button state */
.badge-risolto { background: #e5e7eb; color: #374151; font-size: 11px; padding: 2px 8px; border-radius: 10px; }
/* Kept for any legacy usage */
.badge-rifiutato { background: var(--danger-bg); color: var(--danger-text); font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.badge-accettato { background: var(--success-bg); color: var(--success-text); font-size: 11px; padding: 2px 8px; border-radius: 10px; }

/* Triage footer */
.commento-triage { margin-top: 10px; }

.triage-btn-group {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.triage-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    border: none;
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
}
.triage-btn + .triage-btn {
    border-left: 1px solid var(--border);
}
.triage-btn:hover {
    background: var(--surface-muted);
    color: var(--text-primary);
}
.triage-btn--accetta.is-active {
    background: var(--success-bg);
    color: var(--success-text);
}
.triage-btn--rifiuta.is-active {
    background: var(--danger-bg);
    color: var(--danger-text);
}

/* Inline AI instructions textarea (visible when comment is accepted) */
.triage-istruzioni { margin-top: 8px; }
.triage-istruzioni-textarea {
    width: 100%;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--surface-muted);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    resize: vertical;
    transition: border-color 0.15s, background 0.15s;
}
.triage-istruzioni-textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
    background: var(--surface);
    color: var(--text-primary);
}

/* Rewrite box */
.rewrite-box { border-left: 3px solid var(--brand-primary); }
.rewrite-box-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.rewrite-box-header svg { color: var(--brand-primary); flex-shrink: 0; }

.reviewer-add-form { margin-top: 8px; }
.reviewer-add-inline {
    display: flex;
    gap: 8px;
}
.reviewer-add-inline .input { flex: 1; }
.reviewer-visibility-options {
    display: flex;
    gap: 16px;
    margin-top: 8px;
}
.reviewer-check-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
}
.reviewer-check-label input[type="checkbox"] {
    accent-color: var(--brand-primary);
    cursor: pointer;
}

/* ============================================================
   BULK ACTIONS (lista bozze)
   ============================================================ */
.bulk-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin-bottom: 12px;
    background: var(--bg-secondary, #f3f4f6);
    border: 1px solid var(--border);
    border-radius: 8px;
    position: sticky;
    top: 0;
    z-index: 5;
}
.bulk-bar[hidden] { display: none; }
.bulk-bar-count { font-size: 14px; color: var(--text); }
.bulk-bar-count strong { color: var(--text); margin-right: 4px; }
.bulk-bar-clear {
    margin-left: auto;
    font-size: 13px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 6px;
}
.bulk-bar-clear:hover { color: var(--text); text-decoration: underline; }
.bulk-form { display: inline; margin: 0; }
.bulk-btn-danger {
    background: var(--danger);
    color: #fff;
    border: 1px solid var(--danger);
}
.bulk-btn-danger:hover { filter: brightness(0.95); }

.col-check { width: 36px; text-align: center; }
.col-check input[type="checkbox"] {
    cursor: pointer;
    accent-color: var(--primary, #111827);
}

/* ============================================================
   FONTI MONITORATE — azioni, bulk bar, toast inline
   ============================================================ */

/* Colonna checkbox */
.col-check {
    width: 40px;
    text-align: center;
    padding-left: 12px !important;
    padding-right: 4px !important;
}
.col-check input[type="checkbox"] {
    cursor: pointer;
    accent-color: var(--brand-primary);
    width: 15px;
    height: 15px;
}

/* Chip stato disattiva (grigio neutro) */
.chip-muted {
    background: #f3f4f6;
    color: var(--text-secondary);
}
.chip-success {
    background: var(--success-bg);
    color: var(--success-text);
}
.chip-warning {
    background: #fef3c7;
    color: #92400e;
}

/* Riga azioni: bottoni su una sola riga, compatti */
.fonti-azioni {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: nowrap;
    justify-content: flex-end;
}
.fonti-azioni .btn.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    white-space: nowrap;
    min-height: 30px;
}
/* Variante icon-only: solo icona, label via aria-label/title */
.btn-icon {
    padding: 6px !important;
    width: 30px;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.btn-icon svg {
    display: block;
}
/* Form inline dentro .fonti-azioni: trasparente al flex parent */
.fonti-action-form {
    display: contents;
    margin: 0;
}
/* Variante "danger" per icon-button: hover rosso */
.btn-icon-danger:hover,
.btn-icon-danger:focus-visible {
    color: var(--danger-text) !important;
    background: var(--danger-bg) !important;
    border-color: var(--danger-text) !important;
}
/* Variante danger per il bottone bulk Elimina */
.fonti-bulk-btn-danger:hover,
.fonti-bulk-btn-danger:focus-visible {
    color: #fff !important;
    background: var(--danger-text) !important;
    border-color: var(--danger-text) !important;
}
/* Cella data e cella numerica: niente wrap */
.col-date,
.col-numeric {
    white-space: nowrap;
}
.col-numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
/* Errore fetch compatto: una riga + ellipsis, dettaglio in tooltip */
.fonti-error-line {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    max-width: 100%;
    color: var(--danger-text);
    font-size: 12px;
    line-height: 1.3;
    cursor: help;
}
.fonti-error-line .fonti-error-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 28ch;
}
.fonti-error-line svg {
    flex-shrink: 0;
}
/* Bottone "Attiva" evidenziato con colore primario tenue */
.fonti-btn-attiva {
    color: var(--brand-primary-dark) !important;
    background: var(--brand-tint) !important;
    border-color: #bde4de !important;
}
.fonti-btn-attiva:hover {
    background: var(--brand-primary) !important;
    color: #fff !important;
    border-color: var(--brand-primary) !important;
}

/* Bulk bar — barra azioni di massa */
.fonti-bulk-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 16px;
    margin-bottom: 12px;
    background: var(--brand-tint);
    border: 1px solid #bde4de;
    border-radius: var(--radius-sm);
    position: sticky;
    top: 0;
    z-index: 8;
}
.fonti-bulk-bar[hidden] { display: none; }

.fonti-bulk-count {
    font-size: 14px;
    color: var(--brand-primary-dark);
    font-weight: 500;
    white-space: nowrap;
}
.fonti-bulk-count strong {
    font-weight: 700;
}

.fonti-bulk-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.fonti-bulk-form {
    display: inline;
    margin: 0;
}

.fonti-bulk-clear {
    margin-left: auto;
    background: none;
    border: none;
    font: inherit;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
}
.fonti-bulk-clear:hover {
    color: var(--text-primary);
    background: rgba(0,0,0,0.04);
}

/* Toast inline per conferme azione (singola riga e area globale) */
.fonti-toast {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 12px;
    border: 1px solid;
}
.fonti-toast-success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: #a7f3d0;
}
.fonti-toast-info {
    background: var(--info-bg);
    color: var(--info-text);
    border-color: #bfdbfe;
}
.fonti-toast-error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-color: #fecaca;
}

/* BW-FONTI-VR-01: expand row sotto la fonte con timeline verifica live */
.fonte-run-expand > td {
    background: var(--surface-muted);
    padding: 10px 16px;
    border-top: 0;
}
.fonte-run-panel {
    /* La timeline gia' applica il suo padding/spaziatura;
       qui mantengo i toast finali con un margin top compatto. */
}
.fonte-run-panel .fonti-toast {
    margin-top: 8px;
    margin-bottom: 0;
}
/* Collapsible + scroll wrapper attorno alla timeline */
.fonte-run-details > summary {
    cursor: pointer;
    padding: 4px 0 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.fonte-run-details > summary::-webkit-details-marker { display: none; }
.fonte-run-summary-chevron {
    display: inline-block;
    transition: transform 0.15s ease;
    color: var(--text-tertiary, var(--text-secondary));
    font-size: 11px;
    transform: rotate(-90deg);
}
.fonte-run-details[open] > summary .fonte-run-summary-chevron {
    transform: rotate(0deg);
}
.fonte-run-scroll {
    max-height: 280px;
    overflow-y: auto;
    padding-right: 4px;
}
/* Spinner inline nel bottone icona durante verifica */
.btn-icon[aria-busy="true"] {
    cursor: default;
}
.btn-icon[aria-busy="true"] .progress-spinner {
    width: 14px;
    height: 14px;
}

/* NOTE: il blocco responsive e' stato spostato in /static/_responsive.css
   per supportare 3 breakpoint (mobile <=640, tablet 641-1024, desktop >=1025)
   e per evitare l'override dovuto a regole non-responsive dichiarate dopo
   la media query (es. .audit-fonti-table piu' sotto). */

/* ============================================================
   AUDIT POLLER PAGE
   ============================================================ */

/* Chip per StatoArticoloVisto */
.chip-articolo-nuovo               { background: #fef3c7; color: #92400e; }
.chip-articolo-classificato_rilevante   { background: var(--success-bg); color: var(--success-text); }
.chip-articolo-classificato_non_rilevante { background: #f3f4f6; color: var(--text-secondary); }
.chip-articolo-proposta_inviata    { background: var(--info-bg); color: var(--info-text); }
.chip-articolo-accettata           { background: #dbeafe; color: #1e40af; }
.chip-articolo-rifiutata           { background: var(--danger-bg); color: var(--danger-text); }
.chip-articolo-errore              { background: var(--danger-bg); color: var(--danger-text); font-weight: 600; }

/* Riepilogo fonti: tabella compatta */
.audit-fonti-table th,
.audit-fonti-table td {
    font-size: 13px;
    padding: 8px 12px;
}

/* Timeline articoli: card compatta */
.articolo-card {
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px 14px;
    align-items: start;
}
.articolo-card:last-child { border-bottom: none; }

.articolo-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

/* Motivazione collassabile */
.motivazione-testo {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
    line-height: 1.5;
}
.motivazione-expand-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 12px;
    color: var(--brand-primary);
    text-decoration: underline;
}
.motivazione-expand-btn:hover { color: var(--brand-primary-hover); }

/* LLM error highlight */
.articolo-llm-error {
    border-left: 3px solid var(--danger);
    padding-left: 10px;
}

/* Box costo mese */
.audit-budget-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}
.audit-budget-kpi {
    text-align: center;
}
.audit-budget-kpi .kpi-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--brand-primary-dark);
    line-height: 1.2;
}
.audit-budget-kpi .kpi-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Filtri form */
.audit-filtri {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}
.audit-filtri .form-group {
    margin-bottom: 0;
    min-width: 140px;
}
.audit-filtri label {
    font-size: 12px;
}

/* ============================================================
   CONFIRM DIALOG (modale conferma globale)
   ============================================================ */
.confirm-dialog {
    /* margin:auto ripristina il centratura UA del <dialog> dopo il
       reset universale `* { margin: 0 }`. Senza, il modal finisce
       in alto a sinistra. */
    margin: auto;
    border: none;
    border-radius: var(--radius);
    padding: 0;
    max-width: 480px;
    width: calc(100% - 32px);
    box-shadow: var(--shadow-md);
    background: var(--surface);
    color: var(--text-primary);
}
.confirm-dialog::backdrop {
    background: rgba(17, 24, 39, 0.5);
}
.confirm-dialog-body {
    display: flex;
    gap: 14px;
    padding: 24px 24px 16px;
}
.confirm-dialog-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--danger-bg);
    color: var(--danger-text);
    display: flex;
    align-items: center;
    justify-content: center;
}
.confirm-dialog-content { flex: 1; min-width: 0; }
.confirm-dialog-title {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}
.confirm-dialog-message {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.confirm-dialog-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 12px 20px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-muted);
    border-radius: 0 0 var(--radius) var(--radius);
}

/* LinkedIn preview dialog (BW-PUB-07) */
.li-preview-dialog {
    margin: auto;
    border: none;
    border-radius: var(--radius);
    padding: 0;
    max-width: 600px;
    width: calc(100% - 32px);
    box-shadow: var(--shadow-md);
    background: var(--surface);
    color: var(--text-primary);
}
.li-preview-dialog::backdrop {
    background: rgba(17, 24, 39, 0.5);
}
.li-preview-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.li-preview-dialog-head h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}
.li-preview-dialog-body {
    padding: 16px 20px 20px;
}

/* ============================================================
   TOAST AREA (errori HTMX + segnali sistema)
   ============================================================ */
.bw-toast-area {
    position: fixed;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 60;
    pointer-events: none;
    max-width: calc(100vw - 32px);
}
.bw-toast {
    pointer-events: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--brand-primary);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    min-width: 240px;
    max-width: 360px;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.2s, transform 0.2s;
}
.bw-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}
.bw-toast-error {
    border-left-color: var(--danger);
    background: var(--danger-bg);
    color: var(--danger-text);
}
.bw-toast-success {
    border-left-color: #10b981;
    background: var(--success-bg);
    color: var(--success-text);
}
.bw-toast-info {
    border-left-color: var(--brand-primary);
}
