/* ═══════════════════════════════════════════════════════════════
   MAS — Sportello assistenza · tema editoriale
   Carta calda, inchiostro, un solo accento petrolio. Niente glow,
   niente gradienti vistosi, niente estetica "chatbot".
   ═══════════════════════════════════════════════════════════════ */

:root {
    /* ── Palette ── */
    --mas-paper:       #eef3ee;
    --mas-sheet:       #fbfdfa;
    --mas-ink:         #0b2a2e;
    --mas-ink-2:       rgba(11, 42, 46, .84);
    --mas-faint:       rgba(11, 42, 46, .76);
    --mas-ghost:       rgba(11, 42, 46, .72);
    --mas-line:        #cbdad2;
    --mas-line-soft:   #dce8e1;
    --mas-chip:        #e1ece5;
    --mas-field:       #fdfffc;
    --mas-accent:      #0f5e63;
    --mas-saffron:     #e9a820;
    --mas-saffron-ink: #8a5a00;
    --mas-saffron-wash:#fbf1d8;
    --mas-desk:        #0b2a2e;
    --mas-accent-deep: #0a4247;
    --mas-accent-wash: #e0eeeb;
    --mas-green:       #1e7a4c;
    --mas-green-wash:  #e9f1ea;
    --mas-red:         #a83a32;
    --mas-red-wash:    #f5e9e6;
    --mas-amber:       #8a5a00;
    --mas-amber-wash:  #fbf1d8;

    /* ── Tipi ── */
    --mas-serif: 'Instrument Serif', 'DM Serif Display', Georgia, 'Times New Roman', serif;
    --mas-sans:  'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mas-mono:  'IBM Plex Mono', 'SF Mono', Menlo, Consolas, monospace;

    /* ── Alias legacy (stili inline in interact.php) ── */
    --bg:       var(--mas-paper);
    --surface:  var(--mas-sheet);
    --surface2: var(--mas-chip);
    --border:   var(--mas-line);
    --border2:  #b4c9bf;
    --white:    var(--mas-ink);
    --text:     var(--mas-ink);
    --text-secondary: var(--mas-ink-2);
    --muted:    var(--mas-faint);
    --accent:   var(--mas-accent);
    --accent-d: var(--mas-accent-deep);
    --accent-l: var(--mas-accent-wash);
    --accent-glow: rgba(15, 94, 99, .10);
    --teal:     var(--mas-accent);
    --green:    var(--mas-green);
    --green-l:  var(--mas-green-wash);
    --red:      var(--mas-red);
    --red-l:    var(--mas-red-wash);
    --amber:    var(--mas-amber);
    --sans:     var(--mas-sans);
    --mono:     var(--mas-mono);
}

*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; overflow-x: clip; }

body {
    /* Carta calda con una diagonale luminosa: base dello strato animato sotto. */
    background-color: var(--mas-paper);
    /* Carta millimetrata appena percettibile (solo CSS) */
    background-image:
        linear-gradient(rgba(15, 94, 99, .045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 94, 99, .045) 1px, transparent 1px);
    background-size: 28px 28px;
    color: var(--mas-ink);
    font-family: var(--mas-sans);
    font-size: 15.5px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    overflow-x: clip;
}

::selection { background: var(--mas-accent); color: #fff; }

:focus-visible {
    outline: 2px solid var(--mas-accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ═══ HEADER ═══ */
header {
    background: rgba(245, 242, 235, .97);
    border-bottom: 1px solid var(--mas-line);
    /* Pinned alla colonna contenuto (max 1000px, centrata come .content). */
    padding: 0 max(2rem, calc((100% - 1000px) / 2));
    min-height: 60px;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.hdr-left { display: flex; align-items: center; gap: .8rem; min-width: 0; }

.logo {
    font-family: 'DM Serif Display', Georgia, 'Times New Roman', serif;
    font-weight: 400;
    font-size: 1.45rem;
    line-height: 1;
    letter-spacing: .005em;
    color: var(--mas-ink);
    text-decoration: none;
    white-space: nowrap;
    display: inline-flex; align-items: center; min-height: 44px;
}
.logo span { color: var(--mas-accent); }

.back-arrow {
    color: var(--mas-faint);
    text-decoration: none;
    border: 1px solid var(--mas-line);
    border-radius: 9999px;
    width: 26px; height: 26px;
    display: inline-flex; align-items: center; justify-content: center;
    transition: color .15s, border-color .15s, background .15s;
    flex-shrink: 0;
}
.back-arrow svg { display: block; }
.back-arrow:hover { color: var(--mas-accent-deep); border-color: var(--mas-accent); background: #fff; }

.hdr-right { margin-left: auto; display: flex; align-items: center; gap: .8rem; min-width: 0; }

.badge-app {
    background: transparent;
    color: var(--mas-accent-deep);
    border: 1px solid rgba(14, 76, 92, .4);
    border-radius: 9999px;
    padding: 3px 12px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .14em;
    text-transform: uppercase;
    white-space: nowrap;
}

.hdr-title {
    color: var(--mas-faint);
    font-size: .85rem;
    font-style: italic;
    font-family: var(--mas-serif);
    white-space: nowrap;
}

/* ═══ TABS ═══ */
.tabs-bar {
    background: rgba(245, 242, 235, .97);
    border-bottom: 1px solid var(--mas-line);
    /* A tutta larghezza come l'header; le schede restano nella colonna da 1000px. */
    padding: 0 max(2rem, calc((100% - 1000px) / 2));
    display: flex;
    gap: .25rem;
    width: 100%;
    /* Fissa sotto l'header (60px desktop / 56px mobile): i tasti restano fermi. */
    position: sticky;
    top: 60px;
    z-index: 90;
}

.tab-link {
    padding: .85rem 1.1rem .75rem;
    font-size: .86rem;
    font-weight: 600;
    color: var(--mas-faint);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
}
.tab-link:hover { color: var(--mas-ink); }
.tab-link.active { color: var(--mas-accent-deep); border-bottom-color: var(--mas-accent); }

/* ═══ CONTENT ═══ */
.content {
    flex: 1;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
    position: relative;
    z-index: 1;
}

.sec-title {
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--mas-faint);
    border-bottom: 1px solid var(--mas-line);
    padding-bottom: .65rem;
    margin-bottom: 1.5rem;
}

/* ═══ HERO editoriale ═══ */
.mas-hero { max-width: 62ch; margin: 0 0 1.75rem; }

.mas-eyebrow {
    display: flex;
    align-items: center;
    gap: .7rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--mas-accent-deep);
    margin-bottom: .9rem;
}
.mas-eyebrow::after {
    content: '';
    height: 1px;
    width: 64px;
    background: rgba(14, 76, 92, .35);
}

.mas-hero h1 {
    font-family: var(--mas-serif);
    font-weight: 400;
    font-size: clamp(1.9rem, 4.5vw, 2.7rem);
    line-height: 1.12;
    letter-spacing: -.005em;
    margin-bottom: .7rem;
}
.mas-hero h1 em { font-style: italic; color: var(--mas-accent-deep); }

.mas-lede {
    color: var(--mas-ink-2);
    font-size: .98rem;
    line-height: 1.7;
    max-width: 58ch;
}

.mas-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.4rem;
    margin-top: 1.1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--mas-line-soft);
    font-size: .78rem;
    color: var(--mas-faint);
}
.mas-meta strong { color: var(--mas-ink-2); font-weight: 600; }
.mas-meta .mono { font-family: var(--mas-mono); font-size: .74rem; }

/* ═══ FORM ═══ */
.form-card {
    background: var(--mas-sheet);
    border: 1px solid var(--mas-line);
    border-radius: 14px;
    padding: 1.9rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 2px rgba(33, 29, 21, .06);
}

.form-card h2 {
    font-family: var(--mas-serif);
    font-weight: 400;
    font-size: 1.45rem;
    margin-bottom: .3rem;
    color: var(--mas-ink);
}

.form-card > p { color: var(--mas-ink-2); font-size: .9rem; margin-bottom: 1.5rem; max-width: 60ch; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.1rem;
}
.form-row > *, .form-row-full > * { min-width: 0; }
.form-row-full { margin-bottom: 1.1rem; }

.field label {
    display: block;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--mas-faint);
    margin-bottom: .45rem;
}
.field label .opt {
    font-size: .72rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--mas-ghost);
    font-style: italic;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    background: var(--mas-field);
    border: 1px solid var(--mas-line);
    border-radius: 10px;
    color: var(--mas-ink);
    font-family: var(--mas-sans);
    font-size: .93rem;
    padding: .68rem .95rem;
    min-height: 46px;
    outline: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.field textarea {
    resize: vertical;
    min-height: 118px;
    line-height: 1.65;
    -webkit-appearance: textarea;
    -moz-appearance: textarea;
    appearance: auto;
}

.field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235a544a' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}

.field input::placeholder,
.field textarea::placeholder { color: rgba(11, 42, 46, .45); font-style: italic; }

.field input:hover,
.field select:hover,
.field textarea:hover { border-color: var(--border2); }

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--mas-accent);
    box-shadow: 0 0 0 3px rgba(14, 76, 92, .12);
    background: #fff;
}

.field select option { background: #fff; color: var(--mas-ink); }

.field-hint { font-size: .76rem; color: var(--mas-faint); margin-top: .4rem; font-style: italic; }

.btn-go {
    width: 100%;
    padding: .85rem 1.5rem;
    background: var(--mas-accent);
    color: #fff;
    border: 1px solid var(--mas-accent);
    border-radius: 10px;
    font-family: var(--mas-sans);
    font-size: .95rem;
    font-weight: 600;
    letter-spacing: .02em;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.btn-go:hover:not(:disabled) { background: var(--mas-accent-deep); border-color: var(--mas-accent-deep); }
.btn-go:disabled { opacity: .45; cursor: not-allowed; }

/* ── Allegato ── */
.attachment-drop {
    background: var(--mas-field);
    border: 1px dashed var(--border2);
    border-radius: 10px;
    min-height: 46px;
    display: flex;
    align-items: center;
    padding: .55rem .95rem;
    transition: border-color .15s, background .15s;
    cursor: pointer;
    font-size: .87rem;
    min-width: 0;
}
.attachment-drop:hover { border-color: var(--mas-accent); background: #fff; }
.attachment-drop.drag-over { border-color: var(--mas-accent); border-style: solid; background: var(--mas-accent-wash); }

.attachment-placeholder {
    display: flex;
    align-items: center;
    gap: .45rem;
    color: var(--mas-faint);
    white-space: nowrap;
    overflow: hidden;
    min-width: 0;
    flex: 1 1 auto;
}
.attachment-icon { display: inline-flex; flex-shrink: 0; color: var(--mas-ghost); }
.attachment-icon svg { width: 15px; height: 15px; }

.attachment-browse {
    background: none;
    border: none;
    color: var(--mas-accent-deep);
    font-family: inherit;
    font-size: inherit;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    position: relative;
}
.attachment-browse::after { content: ""; position: absolute; inset: -14px -8px; }
.attachment-browse:hover { color: var(--mas-accent); }

.attachment-preview { display: flex; align-items: center; gap: .55rem; width: 100%; min-width: 0; }
.attachment-file-icon { display: inline-flex; flex-shrink: 0; color: var(--mas-accent); }
.attachment-file-icon svg { width: 15px; height: 15px; }
.attachment-name {
    font-size: .86rem;
    font-weight: 500;
    color: var(--mas-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    font-family: var(--mas-mono);
    font-size: .78rem;
}
.attachment-size { font-size: .74rem; color: var(--mas-faint); flex-shrink: 0; font-variant-numeric: tabular-nums; }

.attachment-remove {
    margin-left: auto;
    background: none;
    border: 1px solid var(--mas-line);
    color: var(--mas-faint);
    border-radius: 9999px;
    width: 24px; height: 24px;
    font-size: .95rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color .15s, border-color .15s;
    flex-shrink: 0;
    position: relative;
}
.attachment-remove::after { content: ""; position: absolute; inset: -10px; }
.attachment-remove:hover { color: var(--mas-red); border-color: var(--mas-red); }

/* ═══ CHAT / pratica ═══ */
.chat-container { display: none; flex-direction: column; }
.chat-container.show { display: flex; }

.ticket-bar {
    background: var(--mas-sheet);
    border: 1px solid var(--mas-line);
    border-radius: 12px;
    padding: .9rem 1.25rem;
    margin-bottom: 1.1rem;
    display: flex;
    align-items: center;
    gap: 1rem 1.25rem;
    flex-wrap: wrap;
}
.ticket-bar .tb-label {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--mas-ghost);
}
.ticket-bar .tb-val { font-size: .87rem; color: var(--mas-ink); font-weight: 500; }
.ticket-bar .tb-val.mono { font-family: var(--mas-mono); font-size: .8rem; }
.ticket-bar .tb-item { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }

.tb-divider { width: 1px; align-self: stretch; min-height: 30px; background: var(--mas-line-soft); }

.app-type-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    background: var(--mas-chip);
    color: var(--mas-ink-2);
    border: 1px solid var(--mas-line);
    white-space: nowrap;
}
.app-type-generic,
.app-type-fatture,
.app-type-easyfatt,
.app-type-cassacloud,
.app-type-getfiscal { background: var(--mas-chip); color: var(--mas-ink-2); }

/* ── Avanzamento pratica: passi numerati ── */
.phase-bar {
    display: flex;
    align-items: flex-start;
    gap: 0;
    padding: .4rem 0 .2rem;
    margin-bottom: 1.2rem;
    counter-reset: mas-step;
    overflow-x: auto;
    scrollbar-width: none;
}
.phase-bar::-webkit-scrollbar { display: none; }

.phase-step {
    counter-increment: mas-step;
    display: flex;
    align-items: baseline;
    gap: .45rem;
    font-size: .72rem;
    font-weight: 500;
    color: var(--mas-ghost);
    white-space: nowrap;
    padding: .2rem .1rem;
    transition: color .2s;
    flex-shrink: 0;
}
.phase-step::before {
    content: counter(mas-step, decimal-leading-zero);
    font-family: var(--mas-mono);
    font-size: .72rem;
    color: var(--mas-ghost);
}
.phase-step .phase-dot { display: none; }
.phase-step.active { color: var(--mas-accent-deep); font-weight: 700; }
.phase-step.active::before { color: var(--mas-accent-deep); }
.phase-step.done { color: var(--mas-ink-2); }
.phase-step.done::before { content: '✓'; color: var(--mas-green); font-family: var(--mas-sans); font-weight: 700; }

.phase-line { flex: 0 0 22px; min-width: 22px; height: 1px; background: var(--mas-line); margin: .68em .55rem 0; }

/* ── Messaggi: la domanda è una nota, la risposta è un foglio ── */
.chat-messages { display: flex; flex-direction: column; gap: 1rem; padding: .5rem 0 1rem; }

.msg { display: flex; gap: .6rem; max-width: 100%; animation: msgIn .35s cubic-bezier(.16, 1, .3, 1); }

@keyframes msgIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.msg-avatar { display: none; }

.msg-agent { align-self: stretch; }
.msg-user { align-self: flex-end; max-width: min(46rem, 100%); }

.msg-bubble { line-height: 1.7; word-break: break-word; }
.msg-user .msg-bubble {
    background: var(--mas-chip);
    border: 1px solid var(--mas-line);
    border-radius: 12px;
    padding: .8rem 1.1rem;
    font-size: .9rem;
    color: var(--mas-ink-2);
}
.msg-agent .msg-bubble {
    background: var(--mas-sheet);
    border: 1px solid var(--mas-line);
    border-radius: 14px;
    padding: 1.6rem 1.7rem;
    font-size: .95rem;
    color: var(--mas-ink);
    box-shadow: 0 1px 2px rgba(33, 29, 21, .06);
    white-space: pre-wrap;
}

/* Occhielli sobri, solo nel flusso Support (non nel Testing) */
#chat-messages .msg-user .msg-bubble::before {
    display: block;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--mas-ghost);
    margin-bottom: .6rem;
    content: var(--mas-lbl-you, '');
}

.msg-meta { font-size: .7rem; color: var(--mas-ghost); margin-top: .35rem; padding: 0 .2rem; font-variant-numeric: tabular-nums; }
.msg-agent .msg-meta { text-align: left; }
.msg-user .msg-meta { text-align: right; }

.msg-phase {
    display: inline-block;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--mas-faint);
    padding: 0;
    margin-bottom: .7rem;
}
.msg-phase::before { content: '— '; color: var(--mas-ghost); }

.phase-retrieve,
.phase-tools,
.phase-generate,
.phase-done { background: none; color: var(--mas-faint); }
.phase-escalated { background: none; color: var(--mas-red); }

.msg-loading .msg-bubble::after {
    content: '…';
    color: var(--mas-ghost);
    animation: dots 1.4s infinite;
}
@keyframes dots { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

.escalation-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: var(--mas-red-wash);
    color: var(--mas-red);
    border: 1px solid rgba(168, 58, 50, .3);
    border-radius: 8px;
    padding: 3px 10px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    margin-top: .5rem;
}

/* ── Foglio risposta / done ── */
.done-card {
    background: var(--mas-sheet);
    border: 1px solid var(--mas-line);
    border-radius: 14px;
    padding: 1.75rem;
    text-align: center;
    margin-top: 1rem;
    animation: msgIn .4s cubic-bezier(.16, 1, .3, 1);
}
.done-card .done-icon { display: none; }
.done-card h3 { font-family: var(--mas-serif); font-weight: 400; font-size: 1.2rem; margin-bottom: .4rem; }
.done-card p { color: var(--mas-ink-2); font-size: .88rem; }
.done-meta { display: flex; gap: 1rem; justify-content: center; margin-top: .75rem; flex-wrap: wrap; }
.done-meta .dm-item { font-size: .75rem; color: var(--mas-faint); }
.done-meta .dm-item span { color: var(--mas-ink); font-weight: 600; }

.btn-reset {
    margin-top: 1.25rem;
    padding: .6rem 1.6rem;
    background: transparent;
    color: var(--mas-accent-deep);
    border: 1px solid rgba(14, 76, 92, .45);
    border-radius: 10px;
    font-family: inherit;
    font-size: .86rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
    transition: background .15s, color .15s;
}
.btn-reset:hover { background: var(--mas-accent); border-color: var(--mas-accent); color: #fff; }

/* ═══ STATS ═══ */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-grid.stat-grid--reduced { grid-template-columns: repeat(2, 1fr); }

.stat-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    background: var(--mas-sheet);
    border: 1px solid var(--mas-line);
    border-radius: 12px;
    padding: 1.25rem 1rem 1.1rem;
    text-align: center;
    box-shadow: 0 1px 2px rgba(33, 29, 21, .04);
}
.stat-val {
    display: block;
    font-family: var(--mas-serif);
    font-weight: 400;
    font-size: 1.9rem;
    line-height: 1.1;
    color: var(--mas-ink);
    font-variant-numeric: tabular-nums;
}
.stat-label {
    display: block;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--mas-faint);
    margin-top: .45rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stat-val--est { color: var(--mas-ink-2); }
.stat-label .lbl-short { display: none; }
@media (max-width: 560px) {
    .stat-label .lbl-long { display: none; }
    .stat-label .lbl-short { display: inline; }
}

.chart-box {
    background: var(--mas-sheet);
    border: 1px solid var(--mas-line);
    border-radius: 12px;
    padding: 1.5rem 1.6rem;
    margin-bottom: 1.25rem;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(33, 29, 21, .04);
}
.chart-box canvas { display: block; max-width: 100%; }
.chart-box--fit { padding: 1.1rem 1.1rem .8rem; }
.chart-box--fit h3 { margin-bottom: .6rem; }
.chart-box h3 {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--mas-faint);
    margin-bottom: 1rem;
}
.chart-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: .9rem;
}
.chart-head h3 { margin: 0; }

.btn-sync {
    font-family: var(--mas-sans);
    font-size: .75rem;
    font-weight: 600;
    padding: .35rem .8rem;
    background: transparent;
    border: 1px solid var(--mas-line);
    border-radius: 8px;
    color: var(--mas-ink-2);
    cursor: pointer;
    position: relative;
    transition: border-color .15s, color .15s;
}
.btn-sync::after { content: ""; position: absolute; inset: -9px -4px; }
.btn-sync:hover:not(:disabled) { border-color: var(--mas-accent); color: var(--mas-accent-deep); }
.btn-sync:disabled { opacity: .5; cursor: wait; }
.sync-status { color: var(--mas-faint); font-size: .74rem; font-style: italic; }

.stats-table { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
.stats-table th {
    text-align: left;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--mas-faint);
    padding: .55rem .7rem;
    border-bottom: 1px solid var(--mas-line);
    white-space: nowrap;
}
.stats-table td { padding: .55rem .7rem; border-bottom: 1px solid var(--mas-line-soft); color: var(--mas-ink); }
.stats-table tr:last-child td { border-bottom: none; }
.stats-table tbody tr { transition: background .12s; }
.stats-table tbody tr:hover td { background: rgba(14, 76, 92, .035); }
.stats-table td.num, .stats-table th.num { text-align: right; white-space: nowrap; }
.stats-table td:first-child, .stats-table th:first-child { white-space: nowrap; }
.stats-table td.num, .stats-table th.num { padding-left: 1.4rem; }
.stats-table--recent td, .stats-table--recent th { white-space: nowrap; }
.stats-table--recent th:first-child { width: 42%; }
.stats-table--recent th:nth-child(3), .stats-table--recent td:nth-child(3) { width: 7rem; min-width: 5rem; }
.stats-table td { vertical-align: baseline; }

.st-paid { color: var(--mas-green); font-weight: 600; font-size: .78rem; }
.st-progress { color: var(--mas-accent-deep); font-weight: 600; font-size: .78rem; }
.st-unpaid { color: var(--mas-amber); font-weight: 600; font-size: .78rem; }
.st-logged { color: var(--mas-green); font-weight: 600; }
.st-guest { color: var(--mas-ghost); }

.dl-btn {
    background: none;
    border: 1px solid var(--mas-line);
    color: var(--mas-faint);
    border-radius: 8px;
    padding: 2px 10px;
    font-size: .74rem;
    font-family: inherit;
    cursor: pointer;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
}
.dl-btn:hover { color: var(--mas-accent-deep); border-color: var(--mas-accent); }

.empty-stats { text-align: center; padding: 2.5rem 1rem; color: var(--mas-faint); }
.empty-stats .empty-mark {
    display: block;
    font-family: var(--mas-serif);
    font-style: italic;
    font-size: 1.6rem;
    color: var(--mas-ghost);
    margin-bottom: .4rem;
}

/* ═══ INFO ═══ */
.info-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-bottom: 1.25rem; }

.info-card {
    background: var(--mas-sheet);
    border: 1px solid var(--mas-line);
    border-radius: 12px;
    padding: 1.5rem 1.6rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 2px rgba(33, 29, 21, .04);
}
.info-grid .info-card { margin-bottom: 0; padding: 1.35rem 1.5rem; }

.card-index {
    font-family: var(--mas-mono);
    font-size: .7rem;
    letter-spacing: .2em;
    color: var(--mas-accent);
    margin-bottom: .5rem;
}

.info-card h3 { font-size: 1.02rem; font-weight: 700; margin-bottom: .55rem; color: var(--mas-ink); letter-spacing: -.005em; }
.info-card p { font-size: .89rem; color: var(--mas-ink-2); line-height: 1.7; }
.info-card p + p { margin-top: .55rem; }
.info-card strong { color: var(--mas-ink); }
.info-card ol { margin: .6rem 0 0 1.25rem; color: var(--mas-ink-2); line-height: 1.8; font-size: .88rem; }
.info-card code {
    background: var(--mas-chip);
    border: 1px solid var(--mas-line-soft);
    padding: 1px 7px;
    border-radius: 5px;
    font-size: .8rem;
    font-family: var(--mas-mono);
    color: var(--mas-accent-deep);
}

.info-list { list-style: none; padding: 0; }
.info-list li {
    font-size: .88rem;
    color: var(--mas-ink-2);
    padding: .45rem 0;
    border-bottom: 1px solid var(--mas-line-soft);
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}
.info-list li:last-child { border: none; }
.info-list li span:last-child { color: var(--mas-ink); font-weight: 500; text-align: right; }

.no-ep {
    background: var(--mas-sheet);
    border: 1px solid var(--mas-line);
    border-radius: 14px;
    padding: 3.5rem 2rem;
    text-align: center;
    color: var(--mas-ink-2);
    box-shadow: 0 1px 2px rgba(33, 29, 21, .04);
}
.no-ep h3 { font-family: var(--mas-serif); font-weight: 400; font-size: 1.4rem; color: var(--mas-ink); margin-bottom: .5rem; }
.no-ep .empty-mark {
    display: block;
    font-family: var(--mas-serif);
    font-style: italic;
    font-size: 1.6rem;
    color: var(--mas-ghost);
    margin-bottom: .6rem;
}

.res-links { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1rem; }
.res-links > a,
.res-links > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .55rem 1.15rem;
    min-height: 44px;
    font-size: .8rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 9px;
    border: 1px solid var(--mas-line);
    background: transparent;
    color: var(--mas-ink);
    transition: background .15s, color .15s, border-color .15s;
    flex: 1 1 auto;
    min-width: 130px;
    text-align: center;
}
.res-links > a:hover { background: var(--mas-ink); border-color: var(--mas-ink); color: var(--mas-paper); }
.res-links > span {
    background: transparent;
    color: var(--mas-ghost);
    border-style: dashed;
    cursor: not-allowed;
}

#info-ai { scroll-margin-top: 130px; }

/* ── Trasparenza AI: tinta MAS (il base resta in ai-transparency.css) ── */
[data-theme="light"] .ai-notice {
    border-color: var(--mas-line);
    background: var(--mas-sheet);
    color: var(--mas-ink-2);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(33, 29, 21, .04);
}
[data-theme="light"] .ai-notice .ai-notice-link { color: var(--mas-accent-deep); font-weight: 700; }
[data-theme="light"] .ai-notice .ai-notice-link:hover { color: var(--mas-accent); }

[data-theme="light"] .ai-info-card {
    border-color: var(--mas-line);
    background: var(--mas-sheet);
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(33, 29, 21, .04);
}
[data-theme="light"] .ai-info-card h3 { color: var(--mas-ink); font-family: var(--mas-sans); font-weight: 700; }
[data-theme="light"] .ai-info-card .ai-field { border-color: var(--mas-line-soft); background: var(--mas-field); }
[data-theme="light"] .ai-info-card .ai-field-label { color: var(--mas-ghost); }
[data-theme="light"] .ai-info-card .ai-field-value { color: var(--mas-ink); }
[data-theme="light"] .ai-info-card .ai-limits {
    background: var(--mas-chip);
    border-color: var(--mas-line);
    color: var(--mas-ink-2);
}
[data-theme="light"] .ai-info-card .ai-limits strong { color: var(--mas-accent-deep); }
[data-theme="light"] .ai-info-card .ai-ref-line { color: var(--mas-ghost); }

/* ═══ TESTING (solo admin) ═══ */
.test-target { display: flex; flex-direction: column; gap: .7rem; }
.target-row { display: flex; gap: .9rem; align-items: baseline; flex-wrap: wrap; }
.target-k { color: var(--mas-faint); font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; min-width: 70px; }
.target-url { font-size: .83rem; color: var(--mas-ink); font-family: var(--mas-mono); word-break: break-all; }
.target-opts { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.target-opts label { display: inline-flex; align-items: center; gap: .45rem; color: var(--mas-ink); font-size: .84rem; cursor: pointer; min-height: 44px; padding-right: .5rem; }
.target-opts input[type="radio"] { accent-color: var(--mas-accent); width: 15px; height: 15px; }

#testing-payload {
    font-family: var(--mas-mono);
    font-size: .8rem;
    line-height: 1.65;
    min-height: 190px;
    background: #fbf9f4;
}

/* ═══ PREMIUM LOADER — sobrio ═══ */
.premium-loader { display: flex; flex-direction: column; align-items: center; padding: 2.2rem 1rem; }
.pl-ring-wrap { position: relative; width: 112px; height: 112px; margin-bottom: 1.1rem; }
.pl-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.pl-ring-bg { fill: none; stroke: var(--mas-line); stroke-width: 5; }
.pl-ring-fill { fill: none; stroke: var(--mas-accent); stroke-width: 5; stroke-linecap: round; transition: stroke .3s ease; }
.pl-time {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.15rem; font-weight: 600;
    color: var(--mas-ink);
    font-family: var(--mas-mono);
    font-variant-numeric: tabular-nums;
}
.pl-status-wrap { height: 1.5em; overflow: hidden; position: relative; width: 100%; max-width: 300px; margin-bottom: .6rem; }
.pl-status {
    font-size: .85rem; color: var(--mas-ink-2); font-style: italic;
    text-align: center; white-space: nowrap;
    position: absolute; left: 0; right: 0; top: 0;
    font-family: var(--mas-serif);
    font-size: .95rem;
}
.pl-dots { display: flex; gap: 6px; }
.pl-dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--mas-ghost); animation: plDotPulse 1.6s ease-in-out infinite; }
.pl-dots span:nth-child(2) { animation-delay: .2s; }
.pl-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes plDotPulse { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ═══ REVEAL sobrio ═══ */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .55s ease, transform .55s cubic-bezier(.16, 1, .3, 1); }
.reveal.visible { opacity: 1; transform: translateY(0); }
.reveal-stagger > *:nth-child(1) { transition-delay: 0s; }
.reveal-stagger > *:nth-child(2) { transition-delay: .07s; }
.reveal-stagger > *:nth-child(3) { transition-delay: .14s; }
.reveal-stagger > *:nth-child(4) { transition-delay: .21s; }
.reveal-stagger > *:nth-child(5) { transition-delay: .28s; }
.reveal-stagger > *:nth-child(6) { transition-delay: .35s; }

/* ── Elementi iniettati da /js/animations.js ── */
#scroll-progress {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--mas-accent);
    transform-origin: 0 50%;
    transform: scaleX(0);
    z-index: 300;
}
#to-top {
    position: fixed;
    right: 1.1rem;
    bottom: 1.1rem;
    width: 44px; height: 44px;
    border-radius: 9999px;
    border: 1px solid var(--mas-line);
    background: var(--mas-sheet);
    color: var(--mas-accent-deep);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity .2s, transform .2s, visibility .2s;
    z-index: 300;
    box-shadow: 0 1px 2px rgba(33, 29, 21, .12);
}
#to-top.is-visible { opacity: 1; visibility: visible; transform: none; }
#to-top:hover { border-color: var(--mas-accent); }

/* ═══ RESPONSIVE ═══ */
@media (max-width: 760px) {
    header { padding: 0 1rem; min-height: 56px; }
    .logo { font-size: 1.3rem; }
    .hdr-title { display: none; }
    .badge-app { padding: 2px 9px; font-size: .6rem; letter-spacing: .1em; flex-shrink: 0; }

    .tabs-bar { padding: 0 .75rem; overflow-x: auto; scrollbar-width: none; top: 56px; }
    .tabs-bar::-webkit-scrollbar { display: none; }
    .tab-link { padding: .8rem .85rem .7rem; font-size: .83rem; }
    #info-ai { scroll-margin-top: 118px; }

    .content { padding: 1.6rem .9rem 3rem; }

    .form-card { padding: 1.3rem 1.15rem; border-radius: 12px; }
    .form-row { grid-template-columns: 1fr; }
    .field input, .field select { min-height: 48px; font-size: 16px; }
    .field textarea { font-size: 16px; }
    .btn-go { padding: .95rem 1.25rem; }

    .ticket-bar { flex-direction: column; align-items: stretch; gap: .7rem; padding: 1rem 1.1rem; }
    .tb-divider { display: none; }
    .ticket-bar .tb-item { flex-direction: row; align-items: baseline; gap: .6rem; }
    .ticket-bar .tb-label { min-width: 74px; }

    .phase-bar { margin: 0 -.9rem 1.1rem; padding: .4rem .9rem .6rem; }
    .phase-step { font-size: .72rem; }
    .phase-step span { display: none; }
    .phase-step::before { font-size: .8rem; }
    .phase-line { flex-basis: 14px; min-width: 14px; margin-left: .4rem; margin-right: .4rem; }

    .msg, .msg-user { max-width: 100%; }
    .msg-agent .msg-bubble { padding: 1.2rem 1.15rem; font-size: .92rem; }

    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: .7rem; }
    .stat-card { padding: 1rem .6rem .9rem; }
    .stat-val { font-size: 1.45rem; }
    .stat-label { font-size: .72rem; }

    .chart-box { padding: 1.15rem 1rem; }
    .chart-box--fit { padding: .95rem .8rem .7rem; }

    /* Tabelle → schede impilate */
    .stats-table thead { display: none; }
    .stats-table, .stats-table tbody, .stats-table tr, .stats-table td { display: block; width: 100%; }
    .stats-table tr { border-bottom: 1px solid var(--mas-line); padding: .55rem 0; }
    .stats-table tr:last-child { border-bottom: none; }
    .stats-table td { border: none; padding: .18rem 0; display: flex; align-items: baseline; gap: .7rem; }
    .stats-table td::before {
        content: attr(data-label);
        flex: 0 0 96px;
        font-size: .72rem;
        font-weight: 700;
        letter-spacing: .12em;
        text-transform: uppercase;
        color: var(--mas-ghost);
    }
    .stats-table td.num, .stats-table th.num { text-align: left; padding-left: 0; }
    .stats-table--recent th:first-child { width: auto; }
    .stats-table--recent td:nth-child(3) { width: 100%; }

    .info-card { padding: 1.2rem 1.15rem; }
    .info-grid .info-card { padding: 1.15rem; }
    .res-links > a, .res-links > span { min-width: 0; flex: 1 1 100%; }

    .mas-meta { gap: .35rem 1.1rem; }
    .mas-hero h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); }
}

@media (min-width: 761px) and (max-width: 1024px) {
    .phase-step span { display: none; }
    .phase-step::before { font-size: .8rem; }
    .phase-line { flex-basis: 18px; min-width: 18px; }
}

@media (min-width: 1100px) {
    .content { max-width: 1040px; }
    .form-card { padding: 2.2rem 2.4rem; }
    .mas-hero { margin-bottom: 2.1rem; }
}

/* ── Movimento ridotto ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; }
    .reveal { opacity: 1; transform: none; }
}
/* Area di tocco 44px senza cambiare l aspetto */
.back-arrow { position: relative; }
.back-arrow::after { content: ""; position: absolute; inset: -9px; }

/* ═══════════════════════════════════════════════════════════════
   ROUND 3 — Sportello: carta millimetrata salvia, inchiostro petrolio,
   zafferano. Segnale: cartellini ticket (bordo perforato + tacche),
   banco scuro in testata, numeri e id in mono.
   ═══════════════════════════════════════════════════════════════ */
::selection { background: var(--mas-saffron); color: var(--mas-desk); }

/* ── Testata: banco scuro ── */
header {
    background: var(--mas-desk);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    transition: box-shadow .2s;
}
header.is-scrolled { box-shadow: 0 2px 0 var(--mas-saffron); }
header :focus-visible { outline-color: #f2b233; }

.logo {
    color: #eef5f0;
    border-radius: 4px;
    transition: color .18s ease;
}
.logo span { color: #f2b233; }
.logo:hover, .logo:focus-visible, .logo:active { color: #f2b233; }
.logo:focus-visible { outline: 2px solid #f2b233; outline-offset: 3px; }

.back-arrow { color: #cfe0d8; border-color: rgba(238, 245, 240, .35); }
.back-arrow:hover { color: var(--mas-desk); border-color: #f2b233; background: #f2b233; }
.badge-app {
    color: #f2b233;
    border: 1px solid rgba(242, 178, 51, .6);
    border-radius: 4px;
    font-family: var(--mas-mono);
    font-weight: 500;
    letter-spacing: .12em;
}
.hdr-title { color: rgba(238, 245, 240, .8); font-style: normal; font-size: 1.05rem; }

/* ── Schede: linguette da banco ── */
.tabs-bar {
    background: var(--mas-sheet);
    border-bottom: 1px solid var(--mas-line);
    gap: 0;
}
.tab-link {
    font-family: var(--mas-mono);
    font-size: .76rem;
    font-weight: 500;
    letter-spacing: .08em;
    text-transform: uppercase;
    border-bottom: 3px solid transparent;
    padding: .85rem 1.05rem .7rem;
    transition: color .15s, border-color .15s, background .15s;
}
.tab-link:hover { background: var(--mas-accent-wash); color: var(--mas-accent-deep); }
.tab-link.active { color: var(--mas-accent-deep); border-bottom-color: var(--mas-saffron); background: var(--mas-saffron-wash); }

/* ── Titoli di sezione ── */
.sec-title {
    font-family: var(--mas-mono);
    font-weight: 500;
    letter-spacing: .14em;
    border-bottom: 1px solid var(--mas-accent);
    display: flex; align-items: center; gap: .6rem;
}
.sec-title::before { content: ''; width: 8px; height: 8px; background: var(--mas-saffron); flex-shrink: 0; }

/* ── Hero ── */
.mas-eyebrow {
    font-family: var(--mas-mono);
    font-weight: 500;
    letter-spacing: .14em;
    color: var(--mas-accent-deep);
}
.mas-eyebrow::before { content: ''; width: 10px; height: 10px; background: var(--mas-saffron); flex-shrink: 0; }
.mas-eyebrow::after { width: 56px; background: var(--mas-accent); opacity: .45; }
.mas-hero h1 { font-size: clamp(2rem, 1.35rem + 2.2vw, 3rem); line-height: 1.06; letter-spacing: -.015em; }
.mas-hero h1 em { font-style: italic; color: var(--mas-accent-deep); }
.mas-meta { border-top: 1px dashed var(--mas-accent); font-family: var(--mas-mono); }
.mas-meta strong { font-weight: 500; }

/* ── Cartellini ticket: bordo perforato in alto + tacche ai lati ── */
.form-card, .ticket-bar, .stat-card, .info-card, .done-card, .no-ep, .msg-agent .msg-bubble {
    position: relative;
    border-radius: 8px;
    border-color: var(--mas-line);
    box-shadow: 0 1px 0 rgba(11, 42, 46, .05), 0 6px 14px -10px rgba(11, 42, 46, .35);
    background-image: repeating-linear-gradient(90deg, rgba(15, 94, 99, .45) 0 6px, transparent 6px 11px);
    background-size: calc(100% - 32px) 1px;
    background-position: 16px 9px;
    background-repeat: no-repeat;
}
.form-card, .info-card, .done-card, .no-ep { padding-top: calc(1.9rem + 6px); }
.info-grid .info-card { padding-top: calc(1.35rem + 6px); }
.stat-card { padding-top: calc(1.25rem + 6px); }
.msg-agent .msg-bubble { padding-top: calc(1.6rem + 6px); }

.form-card::before, .form-card::after,
.info-card::before, .info-card::after,
.stat-card::before, .stat-card::after,
.done-card::before, .done-card::after,
.ticket-bar::before, .ticket-bar::after {
    content: '';
    position: absolute;
    top: calc(50% - 7px);
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--mas-paper);
    border: 1px solid var(--mas-line);
    pointer-events: none;
}
.form-card::before, .info-card::before, .stat-card::before, .done-card::before, .ticket-bar::before {
    left: -8px; clip-path: inset(0 0 0 50%);
}
.form-card::after, .info-card::after, .stat-card::after, .done-card::after, .ticket-bar::after {
    right: -8px; clip-path: inset(0 50% 0 0);
}
.ticket-bar { padding-top: calc(.9rem + 6px); border-left: 4px solid var(--mas-accent); }

.form-card h2, .done-card h3, .no-ep h3 { font-family: var(--mas-serif); font-size: 1.9rem; line-height: 1.1; letter-spacing: -.005em; }
.done-card h3 { font-size: 1.6rem; }
.info-card h3 { font-family: var(--mas-serif); font-weight: 400; font-size: 1.4rem; line-height: 1.15; }
.card-index {
    display: inline-block;
    background: var(--mas-saffron-wash);
    color: var(--mas-saffron-ink);
    border: 1px solid rgba(138, 90, 0, .35);
    border-radius: 3px;
    padding: 1px 7px;
    font-weight: 500;
}
.info-card code { border-radius: 3px; }

/* ── Campi ── */
.field label { font-family: var(--mas-mono); font-weight: 500; letter-spacing: .1em; }
.field input, .field select, .field textarea {
    border-radius: 6px;
    border-bottom: 2px solid var(--mas-accent);
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--mas-accent);
    border-bottom-color: var(--mas-saffron);
    box-shadow: 0 0 0 3px rgba(233, 168, 32, .28);
}
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible {
    outline: 2px solid var(--mas-accent); outline-offset: 2px;
}
.attachment-drop { border-radius: 6px; border: 1.5px dashed var(--mas-accent); }
.attachment-drop:hover { background: var(--mas-saffron-wash); }

/* ── Pulsanti: timbro con filo zafferano ── */
.btn-go {
    border-radius: 6px;
    font-family: var(--mas-mono);
    font-size: .86rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    box-shadow: inset 0 -4px 0 var(--mas-saffron);
    min-height: 48px;
    transition: background .15s, transform .12s;
}
.btn-go:hover:not(:disabled) { transform: translateY(-1px); }
.btn-go:active:not(:disabled) { transform: translateY(1px); }
.btn-reset { border-radius: 6px; font-family: var(--mas-mono); font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; }
.btn-reset:hover { background: var(--mas-desk); border-color: var(--mas-desk); }
.btn-sync, .dl-btn { border-radius: 4px; font-family: var(--mas-mono); }
.btn-sync:hover:not(:disabled), .dl-btn:hover { background: var(--mas-saffron-wash); }
.res-links > a, .res-links > span { border-radius: 6px; font-family: var(--mas-mono); font-size: .76rem; letter-spacing: .06em; text-transform: uppercase; }
.res-links > a:hover { background: var(--mas-desk); border-color: var(--mas-desk); color: #f2b233; }

/* ── Pratica ── */
.ticket-bar .tb-label, .app-type-badge { font-family: var(--mas-mono); font-weight: 500; }
.ticket-bar .tb-val.mono { font-weight: 500; color: var(--mas-accent-deep); }
.app-type-badge { border-radius: 3px; }
.phase-step.active { box-shadow: inset 0 -2px 0 var(--mas-saffron); }
.phase-step.done::before { color: var(--mas-accent); }

.msg-agent .msg-bubble { border-left: 4px solid var(--mas-accent); }
.msg-user .msg-bubble {
    background: var(--mas-saffron-wash);
    border: 1px dashed rgba(138, 90, 0, .55);
    border-radius: 6px;
    color: var(--mas-ink);
}
#chat-messages .msg-user .msg-bubble::before { font-family: var(--mas-mono); font-weight: 500; color: var(--mas-saffron-ink); }
.msg-phase { font-family: var(--mas-mono); font-weight: 500; }
.msg-meta { font-family: var(--mas-mono); }
.escalation-badge { border-radius: 3px; font-family: var(--mas-mono); }

/* ── Statistiche ── */
.stat-card { text-align: left; padding-left: 1.2rem; padding-right: 1rem; flex-direction: column-reverse; justify-content: flex-end; gap: .1rem; }
.stat-val { font-size: 2.4rem; line-height: 1.05; }
.stat-label { font-family: var(--mas-mono); font-weight: 500; letter-spacing: .1em; margin-top: 0; margin-bottom: .35rem; }
.stat-val--est { color: var(--mas-saffron-ink); }
.chart-box { border-radius: 8px; border-top: 3px solid var(--mas-accent); }
.chart-box h3 { font-family: var(--mas-mono); font-weight: 500; letter-spacing: .12em; }
.stats-table th { font-family: var(--mas-mono); font-weight: 500; letter-spacing: .1em; border-bottom: 2px solid var(--mas-accent); }
.stats-table tbody tr:hover td { background: var(--mas-saffron-wash); }
.stats-table td.num { font-family: var(--mas-mono); font-size: .82rem; }
.st-paid, .st-progress, .st-unpaid { font-family: var(--mas-mono); font-weight: 500; }
.st-unpaid { color: var(--mas-saffron-ink); }
.empty-stats .empty-mark, .no-ep .empty-mark { font-style: normal; font-size: 2.2rem; color: var(--mas-accent); }

/* ── Info / AI ── */
[data-theme="light"] .ai-notice, [data-theme="light"] .ai-info-card { border-radius: 6px; border-left: 4px solid var(--mas-saffron); }
[data-theme="light"] .ai-info-card h3 { font-family: var(--mas-serif); font-weight: 400; font-size: 1.4rem; }
[data-theme="light"] .ai-info-card .ai-field-label { font-family: var(--mas-mono); }

/* ── Testing ── */
#testing-payload { background: var(--mas-field); border-bottom: 2px solid var(--mas-accent); }
.target-k { font-family: var(--mas-mono); font-weight: 500; }

/* ── Loader ── */
.pl-ring-bg { stroke-dasharray: 2 3; }
.pl-status { font-style: normal; font-size: 1.1rem; }
.pl-dots span { border-radius: 1px; background: var(--mas-saffron); }

#scroll-progress { background: var(--mas-saffron); }
#to-top { border-radius: 6px; background: var(--mas-desk); color: #f2b233; border-color: var(--mas-desk); }
#to-top:hover { border-color: #f2b233; }

@media (max-width: 760px) {
    .tab-link { font-size: .72rem; padding: .8rem .8rem .65rem; }
    .mas-hero h1 { font-size: clamp(1.9rem, 8vw, 2.5rem); }
    .stat-val { font-size: 1.8rem; }
    .form-card h2 { font-size: 1.6rem; }
    .stat-card::before, .stat-card::after { display: none; }
    .stats-table tr { border-bottom: 1px dashed var(--mas-accent); }
}
@media (prefers-reduced-motion: reduce) {
    .logo, .logo span, .btn-go { transition: none; }
    .btn-go:hover:not(:disabled), .btn-go:active:not(:disabled) { transform: none; }
}
