@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg: #f6f6f4;
    --surface: #ffffff;
    --surface-alt: #fbfaf8;
    --border: #e6e4dd;
    --text: #232320;
    --text-muted: #746f62;
    --accent: #c8102e;          /* rosso EAV */
    --accent-dark: #9c0c24;
    --accent-soft: rgba(200, 16, 46, 0.08);
    --grey-brand: #7c7b6d;      /* grigio-tortora del logo */
    --green: #1a9c6b;
    --red: #c8102e;
    --radius: 10px;
    --font-heading: 'Plus Jakarta Sans', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --shadow-sm: 0 1px 2px rgba(35,35,32,0.04), 0 1px 1px rgba(35,35,32,0.03);
    --shadow-md: 0 4px 16px rgba(35,35,32,0.06), 0 2px 6px rgba(35,35,32,0.04);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

h1 { font-family: var(--font-heading); font-size: 1.6rem; font-weight: 700; margin: 0 0 4px 0; letter-spacing: -0.01em; }
h2 { font-family: var(--font-heading); font-size: 1.2rem; font-weight: 700; margin: 0; }
h3 { font-family: var(--font-heading); font-size: 1rem; font-weight: 700; margin: 0; }

/* ---------- TOPBAR ---------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-brand { display: flex; align-items: center; gap: 16px; }
.brand-logo { width: 200px; height: auto; display: block; }
.brand-name { font-family: var(--font-heading); font-weight: 800; letter-spacing: -0.01em; font-size: 1.05rem; color: var(--text); }
.brand-sub { color: var(--text-muted); font-size: 0.82rem; margin-left: 2px; display: block; }
.brand-text-block { display: flex; flex-direction: column; line-height: 1.25; }

/* Logo usato solo sulla topbar in questa versione: il pallino brand non serve piu' */
.brand-dot { display: none; }

.topbar-nav { display: flex; gap: 26px; }
.nav-link {
    color: var(--text-muted); font-weight: 600; font-size: 0.9rem; transition: color 0.15s;
    padding-bottom: 4px; border-bottom: 2px solid transparent;
}
.nav-link:hover { color: var(--accent); border-bottom-color: var(--accent); }

.topbar-user { display: flex; align-items: center; gap: 14px; }
.user-name { font-size: 0.88rem; color: var(--text-muted); font-weight: 500; }
.logout-link {
    font-size: 0.82rem; color: var(--accent); border: 1px solid rgba(200,16,46,0.25);
    padding: 6px 14px; border-radius: 20px; font-weight: 600; transition: all 0.15s;
}
.logout-link:hover { background: var(--accent); color: #fff; }

.password-link {
    font-size: 0.82rem; color: var(--grey-brand); border: 1px solid rgba(124,123,109,0.3);
    padding: 6px 14px; border-radius: 20px; font-weight: 600; transition: all 0.15s;
}
.password-link:hover { background: var(--grey-brand); color: #fff; }

.user-badge {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px;
    padding: 4px 11px; border-radius: 20px; font-weight: 700;
}
.user-badge.role-amministratore { background: var(--accent-soft); color: var(--accent); }
.user-badge.role-utente { background: rgba(124,123,109,0.14); color: var(--grey-brand); }

/* ---------- LAYOUT ---------- */

.page-container { max-width: 1180px; margin: 0 auto; padding: 32px 24px 40px; min-height: calc(100vh - 160px); }

.page-header {
    display: flex; justify-content: space-between; align-items: flex-end;
    margin-bottom: 28px; gap: 16px; flex-wrap: wrap;
}
.page-subtitle { color: var(--text-muted); margin: 4px 0 0 0; font-size: 0.95rem; }

.breadcrumb {
    display: flex; gap: 8px; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 16px;
}
.breadcrumb a:hover { color: var(--accent); }

/* ---------- FOOTER ---------- */

.site-footer {
    text-align: center; padding: 22px 24px; color: var(--text-muted);
    font-size: 0.8rem; border-top: 1px solid var(--border); background: var(--surface);
}
.site-footer strong { color: var(--grey-brand); }

/* ---------- FLASH MESSAGES ---------- */

.flash-stack { margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.flash {
    padding: 12px 16px; border-radius: var(--radius); font-size: 0.9rem;
    border: 1px solid transparent; font-weight: 500;
}
.flash-success { background: rgba(26,156,107,0.08); color: var(--green); border-color: rgba(26,156,107,0.25); }
.flash-danger { background: rgba(200,16,46,0.08); color: var(--accent); border-color: rgba(200,16,46,0.25); }
.flash-warning { background: rgba(124,123,109,0.1); color: var(--grey-brand); border-color: rgba(124,123,109,0.3); }
.flash-info { background: rgba(35,35,32,0.05); color: var(--text-muted); border-color: var(--border); }

/* ---------- BUTTONS ---------- */

.btn {
    display: inline-block; padding: 10px 20px; border-radius: 24px;
    font-size: 0.88rem; font-weight: 700; border: 1px solid transparent;
    cursor: pointer; transition: all 0.15s; font-family: var(--font-body);
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: transparent; border-color: var(--border); color: var(--text); }
.btn-secondary:hover { border-color: var(--grey-brand); }
.btn-danger { background: transparent; border-color: rgba(200,16,46,0.3); color: var(--accent); }
.btn-danger:hover { background: var(--accent-soft); }
.btn-small { padding: 6px 14px; font-size: 0.78rem; border-radius: 20px; }
.btn-block { width: 100%; text-align: center; }

/* ---------- LOGIN ---------- */

.login-wrapper { display: flex; justify-content: center; align-items: center; min-height: 70vh; }
.login-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 40px; width: 100%; max-width: 400px;
    box-shadow: var(--shadow-md);
}
.login-header { text-align: center; margin-bottom: 24px; }
.login-header .brand-logo { width: 200px; margin: 0 auto 16px; }
.login-header h1 { font-size: 1.3rem; }
.login-header p { color: var(--text-muted); font-size: 0.88rem; margin-top: 4px; }

.login-form { display: flex; flex-direction: column; gap: 6px; }
.login-form label { font-size: 0.82rem; color: var(--text-muted); margin-top: 10px; font-weight: 600; }
.login-form input {
    background: var(--surface-alt); border: 1px solid var(--border); color: var(--text);
    padding: 11px 14px; border-radius: var(--radius); font-size: 0.95rem;
}
.login-form input:focus { outline: none; border-color: var(--accent); background: #fff; }
.login-form button { margin-top: 20px; }

/* ---------- SSE GRID (dashboard) ---------- */

.sse-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 18px;
}
.sse-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 22px; transition: all 0.18s;
    display: flex; flex-direction: column; gap: 10px;
    box-shadow: var(--shadow-sm);
}
.sse-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-2px); }

.sse-card-top { display: flex; align-items: center; gap: 8px; }
.sse-status-label { font-size: 0.74rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }
.sse-name { margin-top: 2px; }
.sse-description { color: var(--text-muted); font-size: 0.85rem; margin: 0; flex-grow: 1; }
.sse-card-footer {
    display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--text-muted);
    border-top: 1px solid var(--border); padding-top: 10px; font-weight: 600;
}

.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.status-online { background: var(--green); box-shadow: 0 0 0 3px rgba(26,156,107,0.15); }
.status-offline { background: var(--accent); box-shadow: 0 0 0 3px rgba(200,16,46,0.15); }

/* ---------- SENSOR GRID ---------- */

.sensor-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
.sensor-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 22px; text-align: center; transition: all 0.18s;
    box-shadow: var(--shadow-sm);
}
.sensor-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.sensor-icon {
    font-size: 1.3rem; margin-bottom: 10px; width: 44px; height: 44px; line-height: 44px;
    border-radius: 50%; background: var(--accent-soft); margin-left: auto; margin-right: auto;
}
.sensor-table { color: var(--text-muted); font-size: 0.78rem; margin-top: 6px; }

/* ---------- EMPTY STATE ---------- */

.empty-state {
    background: var(--surface); border: 1px dashed var(--border); border-radius: 14px;
    padding: 48px 24px; text-align: center; color: var(--text-muted);
}
.empty-state .btn { margin-top: 12px; }

/* ---------- CHART PAGE ---------- */

.range-select { display: flex; align-items: center; gap: 8px; }
.range-select label { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.range-select select {
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
    padding: 9px 14px; border-radius: var(--radius); font-size: 0.88rem; font-weight: 500;
}

.chart-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    padding: 24px; position: relative; margin-bottom: 24px;
    height: 560px; display: flex; flex-direction: column;
    box-shadow: var(--shadow-sm);
}
.chart-card canvas { flex-grow: 1; min-height: 0; }
.chart-status {
    position: absolute; top: 24px; left: 24px; right: 24px; text-align: center;
    color: var(--text-muted); font-size: 0.9rem; padding-top: 60px;
}
.chart-error { color: var(--accent); }

.loading-spinner {
    width: 32px; height: 32px; margin: 0 auto 14px;
    border: 3px solid var(--border); border-top-color: var(--accent);
    border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-bar-track {
    width: 240px; height: 6px; margin: 14px auto 0; border-radius: 4px;
    background: var(--surface-alt); overflow: hidden;
}
.loading-bar-fill {
    height: 100%; width: 30%; border-radius: 4px; background: var(--accent);
    animation: loading-slide 1.1s ease-in-out infinite;
}
@keyframes loading-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(400%); }
}

.zoom-slider-wrapper { display: flex; align-items: center; gap: 14px; margin-top: 22px; }
.zoom-label { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; font-weight: 600; }
#zoom-slider { flex-grow: 1; }

.noUi-target { background: var(--surface-alt); border: 1px solid var(--border); box-shadow: none; }
.noUi-connect { background: var(--accent); }
.noUi-handle {
    background: var(--accent) !important; border: 2px solid #fff !important;
    box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm) !important;
    width: 16px !important; height: 16px !important; top: -5px !important;
    border-radius: 50% !important; cursor: grab;
}
.noUi-handle::before, .noUi-handle::after { display: none; }

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.stat-box {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.stat-label { display: block; font-size: 0.78rem; color: var(--text-muted); margin-bottom: 6px; font-weight: 600; }
.stat-value { font-family: var(--font-heading); font-size: 1.6rem; font-weight: 800; color: var(--accent); }
.stat-unit { font-size: 0.85rem; color: var(--text-muted); margin-left: 4px; }

/* ---------- TABLES ---------- */

.table-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    overflow: hidden; box-shadow: var(--shadow-sm);
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted); padding: 14px 20px; border-bottom: 1px solid var(--border);
    background: var(--surface-alt); font-weight: 700;
}
.data-table td { padding: 14px 20px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-alt); }
.table-subtext { color: var(--text-muted); font-size: 0.78rem; margin-top: 2px; }

.note-box {
    background: var(--surface-alt);
    border-left: 3px solid var(--grey-brand);
    border-radius: 6px;
    padding: 12px 16px;
    margin: 4px 0 16px;
}
.note-box p { margin: 4px 0; }
.note-box code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
}
.table-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- FORMS ---------- */

.form-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    padding: 32px; max-width: 640px; box-shadow: var(--shadow-sm);
}
.stacked-form { display: flex; flex-direction: column; gap: 4px; margin-top: 20px; }
.stacked-form label { font-size: 0.82rem; color: var(--text-muted); margin-top: 14px; font-weight: 600; }
.stacked-form input, .stacked-form select {
    background: var(--surface-alt); border: 1px solid var(--border); color: var(--text);
    padding: 11px 14px; border-radius: var(--radius); font-size: 0.95rem; margin-top: 4px;
}
.stacked-form input:focus, .stacked-form select:focus { outline: none; border-color: var(--accent); background: #fff; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-actions { display: flex; gap: 12px; margin-top: 28px; justify-content: flex-end; }

@media (max-width: 640px) {
    .topbar { flex-direction: column; gap: 12px; align-items: flex-start; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .brand-logo { width: 140px; }
}

/* ---------- MAPPA ---------- */

.map-legend { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 16px; }
.map-legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.line-swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; flex-shrink: 0; }

.map-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    padding: 16px; box-shadow: var(--shadow-sm); overflow: auto;
}
.map-svg { width: 100%; height: auto; display: block; min-height: 480px; }

.map-node { cursor: pointer; }
.map-node-selected .map-dot { stroke: var(--accent); stroke-width: 3; }
.map-station-node { cursor: default; }
.map-dot { stroke: #fff; stroke-width: 2; }
.map-dot-online { fill: var(--green); }
.map-dot-offline { fill: var(--accent); }
.map-dot-editable-sse { fill: var(--accent-dark); cursor: grab; }
.map-dot-editable-stazione { fill: var(--grey-brand); cursor: grab; }
.map-label {
    font-family: var(--font-body); font-size: 12px; font-weight: 600; fill: var(--text);
    paint-order: stroke; stroke: var(--surface); stroke-width: 3px;
}
.map-station-dot { fill: var(--grey-brand); stroke: #fff; stroke-width: 1.5; opacity: 0.85; }
.map-station-label { font-weight: 500; font-size: 11px; fill: var(--text-muted); }

.tipo-badge {
    font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.4px;
    padding: 3px 9px; border-radius: 20px; font-weight: 700;
}
.tipo-badge-sse { background: var(--accent-soft); color: var(--accent); }
.tipo-badge-stazione { background: rgba(124,123,109,0.14); color: var(--grey-brand); }

.map-selection-strip {
    display: flex; gap: 12px; overflow-x: auto; margin-top: 16px; padding-top: 16px;
    border-top: 1px solid var(--border);
}
.map-selection-strip:empty { display: none; margin: 0; padding: 0; border: none; }

.map-strip-card {
    background: var(--surface-alt); border: 1px solid var(--border); border-radius: 12px;
    min-width: 260px; max-width: 300px; flex-shrink: 0; overflow: hidden;
}
.map-strip-header {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    padding: 8px 12px; font-weight: 700; font-family: var(--font-heading); font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}
.map-strip-body { padding: 8px 12px; font-size: 0.8rem; }
.map-strip-sensor-block { padding: 6px 0; border-bottom: 1px solid var(--border); }
.map-strip-sensor-block:last-child { border-bottom: none; }
.map-strip-sensor {
    display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.map-strip-sensor strong { min-width: 64px; }
.map-strip-alert { color: var(--accent); }

.map-strip-range { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.map-strip-range-input { flex: 1; accent-color: var(--accent); height: 4px; cursor: pointer; }
.map-strip-range-label { font-size: 0.68rem; color: var(--text-muted); font-weight: 700; white-space: nowrap; min-width: 34px; text-align: right; }

.map-strip-chart-label {
    font-size: 0.62rem; color: var(--text-muted); font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.3px; margin-top: 6px;
}
.map-strip-chart { height: 46px; margin-top: 2px; }

.map-strip-stats {
    display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px;
    font-size: 0.72rem; color: var(--text-muted); margin-top: 8px;
}
.map-strip-stats strong { color: var(--text); font-weight: 700; }
.map-strip-chart-link {
    display: inline-block; margin-top: 6px; font-size: 0.72rem; font-weight: 600; color: var(--accent);
}
.map-strip-chart-link:hover { color: var(--accent-dark); }

.map-popup-close { background: none; border: none; font-size: 1.1rem; line-height: 1; color: var(--text-muted); cursor: pointer; padding: 0; }
.map-popup-close:hover { color: var(--accent); }
.map-popup-ts { color: var(--text-muted); font-size: 0.75rem; margin-top: 2px; }

.map-editor-layout { display: grid; grid-template-columns: 1fr 260px; gap: 20px; align-items: start; }
.map-editor-sidebar {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    padding: 20px; box-shadow: var(--shadow-sm);
}
.map-unplaced-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.map-unplaced-list li {
    background: var(--surface-alt); border: 1px dashed var(--border); border-radius: 8px;
    padding: 8px 12px; font-size: 0.85rem; font-weight: 600; cursor: grab;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.map-unplaced-delete {
    background: none; border: none; color: var(--accent); font-weight: 700;
    cursor: pointer; font-size: 0.9rem; line-height: 1; padding: 2px 4px; flex-shrink: 0;
}
.map-unplaced-delete:hover { color: var(--accent-dark); }

.map-node-delete {
    fill: var(--accent); font-size: 12px; font-weight: 700; cursor: pointer;
    paint-order: stroke; stroke: var(--surface); stroke-width: 3px;
}
.map-node-delete:hover { fill: var(--accent-dark); }

@media (max-width: 640px) {
    .map-editor-layout { grid-template-columns: 1fr; }
}

/* ---------- MANUALE ---------- */

.manual-toc {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 20px 24px; margin-bottom: 28px; box-shadow: var(--shadow-sm);
}
.manual-toc-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 12px; }
.manual-toc-title {
    display: block; font-family: var(--font-heading); font-weight: 700; font-size: 0.82rem;
    color: var(--accent); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 8px;
}
.manual-toc-cols div { display: flex; flex-direction: column; gap: 4px; }
.manual-toc-cols a { color: var(--text-muted); font-size: 0.88rem; padding: 2px 0; }
.manual-toc-cols a:hover { color: var(--accent); }

.manual-wrap { max-width: 800px; }
.manual-section {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    padding: 32px; margin-bottom: 20px; box-shadow: var(--shadow-sm);
}
.manual-section h2 {
    font-size: 1.3rem; padding-bottom: 12px; margin-bottom: 16px; border-bottom: 1px solid var(--border);
    scroll-margin-top: 90px;
}
.manual-section h3 { font-size: 1.05rem; margin: 26px 0 10px; scroll-margin-top: 90px; }
.manual-section h4 { font-size: 0.92rem; margin: 20px 0 8px; color: var(--text); }
.manual-section h3:first-child, .manual-section h4:first-child { margin-top: 0; }
.manual-section p { margin: 0 0 14px; line-height: 1.65; color: var(--text); }
.manual-section ul { margin: 0 0 16px; padding-left: 22px; line-height: 1.6; }
.manual-section li { margin-bottom: 6px; }
.manual-section .note-box { margin: 4px 0 18px; }
.manual-section code {
    background: var(--surface-alt); border: 1px solid var(--border); border-radius: 4px;
    padding: 1px 6px; font-size: 0.85em;
}

.manual-divider {
    display: flex; align-items: center; gap: 16px; margin: 40px 0 24px;
    color: var(--accent); font-family: var(--font-heading); font-weight: 800;
    font-size: 1.1rem; text-transform: uppercase; letter-spacing: 0.5px;
}
.manual-divider::before, .manual-divider::after { content: ""; flex: 1; height: 2px; background: var(--accent-soft); }

@media (max-width: 640px) {
    .manual-toc-cols { grid-template-columns: 1fr; }
    .manual-section { padding: 22px; }
}

/* ---------- STAT CARDS (dashboard riepilogo) ---------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}
.stat-card .stat-value { font-family: var(--font-heading); font-size: 1.8rem; font-weight: 800; }
.stat-card .stat-label { color: var(--text-muted); font-size: 0.82rem; margin-top: 2px; }
.stat-card.stat-accent .stat-value { color: var(--accent); }

/* ---------- BADGE AZIONE (chiama / ignora / nessuna regola) ---------- */

.azione-badge {
    display: inline-block; padding: 3px 10px; border-radius: 20px;
    font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
}
.azione-badge.azione-chiama { background: rgba(200,16,46,0.1); color: var(--accent); }
.azione-badge.azione-ignora { background: rgba(124,123,109,0.14); color: var(--grey-brand); }
.azione-badge.azione-nessuna_regola { background: rgba(35,35,32,0.06); color: var(--text-muted); }

/* ---------- COSTRUTTORE CONDIZIONI REGOLA ---------- */

.condizioni-list { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 20px; }
.condizione-row {
    display: grid; grid-template-columns: 1fr 1fr 2fr auto; gap: 10px; align-items: center;
}
.condizione-row select, .condizione-row input {
    padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-family: var(--font-body); font-size: 0.88rem; background: var(--surface-alt);
}
.condizione-row select:focus, .condizione-row input:focus { outline: none; border-color: var(--accent); background: #fff; }
.btn-remove-condizione {
    background: transparent; border: 1px solid rgba(200,16,46,0.25); color: var(--accent);
    border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 1rem; line-height: 1;
}
.btn-remove-condizione:hover { background: var(--accent-soft); }

/* ---------- FILTRI STORICO ---------- */

.filter-bar {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 20px; margin-bottom: 20px;
}
.filter-bar .filter-field { display: flex; flex-direction: column; gap: 4px; }
.filter-bar label { font-size: 0.76rem; color: var(--text-muted); font-weight: 600; }
.filter-bar input, .filter-bar select {
    padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 0.85rem;
}

.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 20px; }

/* ---------- STATO WATCHER (topbar) ---------- */

.watcher-status {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.82rem; color: var(--text-muted); font-weight: 600;
    cursor: default;
}
.watcher-status .status-dot { width: 8px; height: 8px; }
