/* Business OS — Dashboard 2.0 design system. Tema scuro premium (predefinito) e tema chiaro. Mobile-first. */

/* ---------- Token ---------- */
:root {
  --bg: #0a0c10; --bg-2: #0e1117; --surface: #12161d; --surface-2: #171c25; --surface-3: #1e2430;
  --border: rgba(255, 255, 255, .07); --border-2: rgba(255, 255, 255, .12);
  --text: #e9ecf2; --text-2: #b4bccb; --muted: #8790a1;
  --accent: #8f84ff; --accent-2: #6d62f0; --accent-ink: #0b0a1f; --accent-soft: rgba(143, 132, 255, .14);
  --ok: #3ccf91; --ok-soft: rgba(60, 207, 145, .13); --warn: #f2b84b; --warn-soft: rgba(242, 184, 75, .13);
  --bad: #ff6b6b; --bad-soft: rgba(255, 107, 107, .13); --info: #5cb6ff; --info-soft: rgba(92, 182, 255, .13);
  --openai: #3ccf91; --anthropic: #e8956b; --other: #8790a1;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .5);
  --r-s: 8px; --r: 12px; --r-l: 16px; --r-xl: 22px;
  --side: 248px; --side-c: 72px; --tabbar: 64px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, Consolas, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f5f6f8; --bg-2: #eef0f4; --surface: #ffffff; --surface-2: #f7f8fa; --surface-3: #eef0f4;
  --border: rgba(16, 24, 40, .08); --border-2: rgba(16, 24, 40, .14);
  --text: #10141b; --text-2: #3b4352; --muted: #5f6878;
  --accent: #5b4ff0; --accent-2: #4a3fe0; --accent-ink: #ffffff; --accent-soft: rgba(91, 79, 240, .1);
  --ok: #138a5a; --ok-soft: rgba(19, 138, 90, .1); --warn: #a86a00; --warn-soft: rgba(196, 128, 0, .12);
  --bad: #d23c3c; --bad-soft: rgba(210, 60, 60, .1); --info: #1f6fc4; --info-soft: rgba(31, 111, 196, .1);
  --openai: #16a06a; --anthropic: #d0703f;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .05);
  --shadow-lg: 0 24px 64px rgba(16, 24, 40, .18);
  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
body.no-scroll { overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 650; }
h2 { font-size: 1.12rem; font-weight: 620; }
h3 { font-size: 1rem; font-weight: 600; }
.h3 { font-size: 1rem; font-weight: 620; margin-bottom: .6rem; display: flex; align-items: center; gap: .45rem; }
p { margin: 0 0 .6rem; }
p:last-child { margin-bottom: 0; }
small, .small { font-size: .84rem; }
code, .mono { font-family: var(--mono); font-size: .86em; }
code { background: var(--surface-3); padding: .1em .4em; border-radius: 6px; word-break: break-all; }
pre { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent-soft); }
.i { width: 18px; height: 18px; flex: none; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: .5rem .8rem; border-radius: var(--r-s); }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.ok-text { color: var(--ok); } .warn-text { color: var(--warn); }
.ellipsis { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.grow { flex: 1 1 auto; min-width: 0; }
.spacer { flex: 1 1 auto; }
.row { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.row.wrap, .wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.label { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.eyebrow { font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 650; margin-bottom: .35rem; }
.end-col { display: flex; flex-direction: column; align-items: flex-end; text-align: right; gap: .1rem; flex: none; }

/* ---------- Boot ---------- */
.boot { min-height: 100dvh; display: grid; place-items: center; }
.logo, .logo-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), #48c6ff); position: relative; flex: none; box-shadow: 0 6px 18px rgba(124, 110, 255, .35); }
.logo::after, .logo-mark::after { content: ""; position: absolute; inset: 8px; border-radius: 4px; border: 2px solid rgba(255, 255, 255, .85); border-right-color: transparent; }
.boot .logo-mark { width: 44px; height: 44px; animation: pulse 1.4s var(--ease) infinite; }

/* ---------- Guscio dell'app ---------- */
.app { min-height: 100dvh; }
.sidebar { display: none; }
.main { padding: max(12px, env(safe-area-inset-top)) 16px calc(var(--tabbar) + 24px + env(safe-area-inset-bottom)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
#main { outline: none; max-width: 1180px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: .65rem; font-weight: 680; letter-spacing: -.01em; }
.brand.center { justify-content: center; margin-bottom: 1.4rem; }
.brand-text { font-size: 1.02rem; white-space: nowrap; }

.tabbar { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); background: color-mix(in srgb, var(--bg-2) 88%, transparent); backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px); border-top: 1px solid var(--border); padding: 4px max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left)); }
.tabbar a, .tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 56px; color: var(--muted); font-size: .7rem; font-weight: 560; background: none; border: 0; border-radius: var(--r); text-decoration: none; -webkit-tap-highlight-color: transparent; }
.tabbar .i { width: 22px; height: 22px; }
.tabbar a.active { color: var(--text); }
.tabbar a.active .i { color: var(--accent); }
.tabbar a:active, .tabbar button:active { background: var(--surface-2); }
.badge-count { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn); color: #1b1300; font-size: .68rem; font-weight: 700; display: grid; place-items: center; }

@media (min-width: 1024px) {
  .tabbar { display: none; }
  .sidebar { display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: var(--side); padding: 18px 12px; background: var(--bg-2); border-right: 1px solid var(--border); z-index: 30; transition: width .22s var(--ease); }
  .sidebar .brand { padding: 4px 10px 20px; }
  .nav { display: flex; flex-direction: column; gap: 2px; }
  .nav a, .nav-btn { position: relative; display: flex; align-items: center; gap: .75rem; padding: 0 12px; min-height: 42px; border-radius: 10px; color: var(--text-2); font-weight: 540; text-decoration: none; background: none; border: 0; width: 100%; text-align: left; white-space: nowrap; overflow: hidden; }
  .nav a:hover, .nav-btn:hover { background: var(--surface-2); color: var(--text); }
  .nav a.active { background: var(--accent-soft); color: var(--text); }
  .nav a.active .i { color: var(--accent); }
  .nav .badge-count { position: static; margin-left: auto; }
  .side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--border); padding-top: 10px; }
  .me { display: flex; align-items: center; gap: .6rem; padding: 8px 6px 0 10px; min-width: 0; }
  .me-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-weight: 650; font-size: .85rem; flex: none; }
  .me-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
  .main { margin-left: var(--side); padding: 28px 40px 56px; transition: margin .22s var(--ease); }
  .app.collapsed .sidebar { width: var(--side-c); }
  .app.collapsed .main { margin-left: var(--side-c); }
  .app.collapsed .brand-text, .app.collapsed .nav span, .app.collapsed .nav-btn span, .app.collapsed .me-name, .app.collapsed .me .icon-btn { display: none; }
  .app.collapsed .nav .badge-count { position: absolute; top: 4px; left: 30px; }
  .app.collapsed .me { padding-left: 8px; }
}

/* ---------- Pagina ---------- */
.page.enter { animation: rise .32s var(--ease) both; }
.page > * + * { margin-top: 1.25rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-top: .3rem; }
.page-head .titles { min-width: 0; }
.page-head h1 { overflow-wrap: anywhere; }
.sub { color: var(--muted); margin: .25rem 0 0; overflow-wrap: anywhere; }
.back { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); font-size: .88rem; margin-bottom: .45rem; min-height: 32px; }
.back:hover { color: var(--text); text-decoration: none; }
.block > * + * { margin-top: .75rem; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.block-head h2 { font-size: 1.02rem; }
.link { display: inline-flex; align-items: center; gap: .3rem; font-size: .9rem; font-weight: 560; }
.link .i { width: 15px; height: 15px; }

.cards { display: grid; grid-template-columns: 1fr; gap: .8rem; }
.two-col, .grid-2, .grid-3 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.two-col > *, .grid-2 > *, .grid-3 > * { min-width: 0; }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 768px) { .two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.narrow { max-width: 560px; }

/* ---------- Card ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l); padding: 1.1rem; box-shadow: var(--shadow); min-width: 0; }
.card > * + * { margin-top: .7rem; }
.card h3 { overflow-wrap: anywhere; }
.link-card { display: flex; flex-direction: column; gap: .45rem; color: var(--text); text-decoration: none; transition: border-color .18s, transform .18s var(--ease), background .18s; }
.link-card > * + * { margin-top: 0; }
.link-card:hover { text-decoration: none; border-color: var(--border-2); background: var(--surface-2); }
.link-card:active { transform: scale(.99); }
.card-icon { width: 22px; height: 22px; color: var(--accent); }
.cta-card { background: linear-gradient(160deg, var(--accent-soft), transparent 60%), var(--surface); border-color: color-mix(in srgb, var(--accent) 25%, var(--border)); }
.kv { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .35rem 0; border-bottom: 1px dashed var(--border); }
.kv:last-of-type { border-bottom: 0; }
.kv > span { color: var(--muted); }
.kv > b { text-align: right; overflow-wrap: anywhere; font-weight: 600; }

.list-cards { display: flex; flex-direction: column; gap: .45rem; }
.row-card { display: flex; align-items: center; gap: .75rem; padding: .7rem .85rem; min-height: 56px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); color: var(--text); text-decoration: none; text-align: left; width: 100%; transition: background .15s, border-color .15s; }
.row-card:not(.static):hover { background: var(--surface-2); border-color: var(--border-2); text-decoration: none; }
.row-card > .i:first-child { color: var(--muted); }
.row-card .grow { display: flex; flex-direction: column; min-width: 0; }
.row-card small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-card > .i:last-child { color: var(--muted); width: 16px; }

/* ---------- Bottoni e campi ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 40px; padding: 0 1rem; border-radius: 10px; border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text); font-weight: 580; font-size: .92rem; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s, transform .12s, opacity .15s; -webkit-tap-highlight-color: transparent; }
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.primary { background: linear-gradient(180deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--accent) 70%, transparent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger:not(.ghost) { background: var(--bad); border-color: transparent; color: #fff; }
.btn.ghost.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.lg { min-height: 48px; padding: 0 1.3rem; font-size: 1rem; border-radius: 12px; }
.btn.sm { min-height: 32px; padding: 0 .7rem; font-size: .84rem; }
.btn .i { width: 17px; height: 17px; }
.card .btn.block + .btn.block { margin-top: .5rem; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field > span { font-size: .84rem; font-weight: 560; color: var(--text-2); }
.field.compact > span { font-size: .78rem; }
.input { width: 100%; min-height: 42px; padding: .55rem .8rem; border-radius: 10px; border: 1px solid var(--border-2); background: var(--bg-2); color: var(--text); transition: border-color .15s, box-shadow .15s; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--muted); opacity: .8; }
.input.auto { width: auto; }
textarea.input { resize: vertical; line-height: 1.5; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 2.2rem; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
select.input option { background: var(--surface); color: var(--text); }
.code-input { font-family: var(--mono); font-size: 1.3rem; letter-spacing: .25em; text-align: center; }
.check { display: flex; align-items: flex-start; gap: .6rem; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check small { display: block; color: var(--muted); }
.check.inline { align-items: center; }

/* Interruttore: sia <button class="switch"> sia <input type="checkbox" class="switch"> */
.switch { appearance: none; -webkit-appearance: none; position: relative; width: 46px; height: 28px; border-radius: 14px; border: 1px solid var(--border-2); background: var(--surface-3); flex: none; padding: 0; margin: 0; cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s var(--ease); }
.switch::before { content: ""; position: absolute; inset: -8px -4px; } /* area di tocco più ampia del disegno */
.switch.on, .switch:checked { background: var(--accent); border-color: transparent; }
.switch.on::after, .switch:checked::after { transform: translateX(18px); }
.switch-label { display: inline-flex; align-items: center; min-height: 44px; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border); }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg-opt span { display: inline-flex; align-items: center; min-height: 36px; padding: 0 1rem; border-radius: 9px; color: var(--text-2); font-weight: 560; }
.seg-opt input:checked + span { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--accent); }
.options { display: flex; flex-direction: column; gap: .5rem; }
.option { display: flex; flex-direction: column; align-items: flex-start; gap: .15rem; text-align: left; padding: .75rem .9rem; border-radius: var(--r); border: 1px solid var(--border-2); background: var(--bg-2); }
.option.on { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Chip, pill, avvisi ---------- */
.chip, .pill, .tag { display: inline-flex; align-items: center; gap: .4rem; min-height: 26px; padding: 0 .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.chip.ok, .pill.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn, .pill.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad, .pill.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.muted { color: var(--muted); }
.chip.info .dot { animation: blink 1.6s ease-in-out infinite; }
.pill { background: var(--surface); border: 1px solid var(--border); color: var(--text-2); font-weight: 560; }
.pill .i { width: 14px; height: 14px; }
.tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.tag { border-radius: 8px; font-weight: 540; }
.events > li > .dot.ok { color: var(--ok); } .events > li > .dot.warn { color: var(--warn); } .events > li > .dot.bad { color: var(--bad); }
.notice { padding: .7rem .9rem; border-radius: var(--r); background: var(--info-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--info) 25%, transparent); display: flex; gap: .5rem; align-items: flex-start; overflow-wrap: anywhere; }
.notice.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.notice .i { margin-top: 2px; }
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: linear-gradient(135deg, var(--accent-soft), var(--surface-3)); color: var(--accent); font-size: .7rem; font-weight: 750; letter-spacing: .02em; flex: none; vertical-align: middle; }
.meter svg { display: block; width: 100%; height: 6px; border-radius: 3px; background: var(--surface-3); }
.meter rect { fill: var(--accent); }
.meter.warn rect { fill: var(--warn); } .meter.bad rect { fill: var(--bad); }

/* ---------- Home ---------- */
.hero { padding: .6rem 0 .4rem; }
.hero > * + * { margin-top: 1rem; }
.status-line { display: flex; flex-wrap: wrap; gap: .4rem; }
.status-line .pill.ok .dot { color: var(--ok); }
.display { font-size: clamp(1.75rem, 6vw, 2.75rem); font-weight: 700; letter-spacing: -.025em; line-height: 1.12; background: linear-gradient(180deg, var(--text), color-mix(in srgb, var(--text) 72%, var(--accent))); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { color: var(--text-2); font-size: 1.04rem; max-width: 60ch; }
.command { background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-xl); padding: .4rem; box-shadow: var(--shadow); transition: border-color .2s, box-shadow .2s; }
.command:focus-within { border-color: color-mix(in srgb, var(--accent) 60%, var(--border-2)); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); }
.command textarea { display: block; width: 100%; border: 0; background: transparent; resize: none; padding: .85rem .9rem .4rem; font-size: 1.06rem; line-height: 1.5; min-height: 92px; outline: none; }
.command textarea::placeholder { color: var(--muted); }
.command-bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; padding: .4rem .4rem .4rem .9rem; }
.command-bar .btn { margin-left: auto; }
.quick { display: flex; gap: .5rem; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; scroll-snap-type: x proximity; }
.quick::-webkit-scrollbar { display: none; }
.quick-chip { flex: none; min-height: 40px; padding: 0 1rem; border-radius: 999px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text-2); font-weight: 560; font-size: .9rem; scroll-snap-align: start; transition: all .15s; }
.quick-chip:hover { color: var(--text); border-color: var(--accent); }
.quick-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
@media (min-width: 768px) { .quick { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; } }
.decision-mini { border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); }

/* ---------- Piano ---------- */
.plan > * + * { margin-top: 1.25rem; }
.plan-goal .grid-2 { margin-top: 1rem; }
.goal-quote { font-size: 1.12rem; line-height: 1.45; color: var(--text); font-weight: 520; overflow-wrap: anywhere; }
.phases { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .8rem; }
.phase-head { display: flex; align-items: flex-start; gap: .8rem; }
.phase-n { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 750; flex: none; }
.phase-head h3 { margin-bottom: .25rem; }
.phase-controls { display: grid; grid-template-columns: 1fr; gap: .7rem; padding: .8rem; border-radius: var(--r); background: var(--bg-2); border: 1px solid var(--border); }
@media (min-width: 640px) { .phase-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; } }
.estimate { display: flex; gap: .55rem; align-items: flex-start; padding: .6rem .8rem; border-radius: var(--r); background: var(--accent-soft); font-size: .9rem; overflow-wrap: anywhere; }
.estimate .i { color: var(--accent); margin-top: 2px; }
.estimate.bad { background: var(--bad-soft); } .estimate.bad .i { color: var(--bad); }
details summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; gap: .4rem; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "›"; display: inline-block; transition: transform .15s; font-size: 1.1em; }
details[open] summary::before { transform: rotate(90deg); }
details.card summary { font-weight: 600; }
.limits { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .55rem; }
.limits li { display: flex; gap: .6rem; align-items: flex-start; color: var(--text-2); }
.limits .i { color: var(--muted); margin-top: 3px; }
.plan-footer { position: sticky; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 8px); z-index: 20; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--border-2); border-radius: var(--r-l); padding: .9rem; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: .7rem; }
.totals { display: flex; flex-wrap: wrap; gap: 1.4rem; }
.totals > div { display: flex; flex-direction: column; }
.totals b { font-size: 1.3rem; font-weight: 700; }
@media (max-width: 767px) {
  .plan-footer { padding: .65rem .75rem; gap: .5rem; border-radius: 14px; }
  .totals { gap: 1rem; }
  .totals small { font-size: .72rem; }
  .totals b { font-size: 1.02rem; }
  .plan-footer .row.end { flex-wrap: nowrap; }
  .plan-footer .row.end .btn.lg { flex: 1; min-height: 46px; font-size: .95rem; }
  .plan-footer #upd span, .plan-footer #upd { font-size: .85rem; padding: 0 .7rem; }
}
@media (min-width: 768px) { .plan-footer { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; } .plan-footer .notice { flex-basis: 100%; } }
@media (min-width: 1024px) { .plan-footer { bottom: 16px; } }

/* ---------- Profili di costo ---------- */
.profiles { display: grid; grid-template-columns: 1fr; gap: .6rem; }
@media (min-width: 768px) { .profiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.profile-opt { position: relative; display: flex; flex-direction: column; gap: .3rem; padding: .85rem .95rem; min-height: 44px; border-radius: var(--r); border: 1px solid var(--border-2); background: var(--bg-2); cursor: pointer; transition: border-color .15s, background .15s; }
.profile-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.profile-opt.on, .profile-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.profile-opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.profile-opt .caveat { color: var(--warn); }
.profile-why { display: flex; gap: .5rem; align-items: flex-start; color: var(--text-2); }
.profile-why .i { width: 15px; height: 15px; margin-top: 3px; color: var(--accent); }
.compare-card { padding: .8rem .9rem; border-radius: var(--r); background: var(--bg-2); border: 1px solid var(--border); }
.compare-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-top: .55rem; }
.cmp { display: flex; flex-direction: column; gap: .15rem; min-width: 0; padding: .55rem .6rem; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); overflow-wrap: anywhere; }
.cmp.balanced { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.cmp b { font-size: 1.02rem; }
@media (max-width: 480px) { .compare-grid { gap: .35rem; } .cmp { padding: .45rem .5rem; } .cmp b { font-size: .92rem; } .cmp small { font-size: .72rem; } }

/* ---------- Avvisi, Radar, opportunità ---------- */
.block { display: block; }
.pre { white-space: pre-line; }
.notif-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.notif { display: flex; gap: .75rem; align-items: flex-start; padding: .85rem .95rem; border-radius: var(--r); background: var(--surface); border: 1px solid var(--border); }
.notif > .dot { margin-top: .5rem; color: var(--info); }
.notif.warning > .dot { color: var(--warn); } .notif.critical > .dot { color: var(--bad); }
.notif.read { opacity: .72; } .notif.read > .dot { color: var(--muted); }
.notif.unread { border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.notif .grow > * + * { margin-top: .35rem; }
.score { display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 .4rem; border-radius: 12px; font-weight: 750; font-size: .95rem; flex: none; background: var(--surface-3); color: var(--text-2); }
.score.hi { background: var(--ok-soft); color: var(--ok); } .score.mid { background: var(--warn-soft); color: var(--warn); } .score.lo { background: var(--surface-3); color: var(--muted); }
.radar-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); flex: none; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1.2rem; }
.checks { display: flex; flex-wrap: wrap; gap: .4rem 1rem; }
.checks .check { min-height: 36px; }
.card-inner { padding: .85rem; border-radius: var(--r); background: var(--bg-2); border: 1px solid var(--border); }
.card-inner > * + * { margin-top: .6rem; }
.cat-list { display: flex; flex-direction: column; gap: .7rem; }
.sources { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.sources li { overflow-wrap: anywhere; }
.signal { display: flex; align-items: center; gap: .8rem; padding: .6rem 0; border-bottom: 1px dashed var(--border); }
.signal:last-child { border-bottom: 0; }
.signal b { font-size: 1.1rem; }
.spark { width: 120px; height: 28px; flex: none; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.reasons { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: .35rem; color: var(--text-2); }
.btn-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
.btn-grid .btn { width: 100%; }
.decide .btn.block + .btn.block { margin-top: .5rem; }
.opp-row b { font-weight: 600; }

/* ---------- Produzione (pacchetti, importazioni) ---------- */
.phase-progress { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .45rem; }
.pp { display: flex; align-items: center; gap: .55rem; padding: .55rem .7rem; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--border); }
.pp-dot { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-2); flex: none; }
.pp.done .pp-dot { background: var(--ok); border-color: transparent; color: #fff; }
.pp-dot .i { width: 13px; height: 13px; }
.prompts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; counter-reset: p; }
.prompt { padding: .75rem .85rem; border-radius: var(--r); background: var(--bg-2); border: 1px solid var(--border); }
.prompt > * + * { margin-top: .35rem; }
.prompt pre.code { white-space: pre-wrap; max-height: 320px; overflow: auto; }
.btn.done { border-color: var(--ok); color: var(--ok); }

/* ---------- Factory: editor del prodotto ---------- */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
@media (min-width: 1024px) { .editor-layout { grid-template-columns: 280px minmax(0, 1fr); align-items: start; } .sec-list { position: sticky; top: 16px; } }
.secs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; counter-reset: s; }
.secs li { display: flex; align-items: center; gap: .2rem; border-radius: 10px; }
.secs li.on { background: var(--accent-soft); }
.sec-link { display: flex; align-items: center; gap: .5rem; flex: 1; min-width: 0; min-height: 40px; padding: 0 .55rem; color: var(--text); text-decoration: none; }
.sec-link:hover { text-decoration: none; }
.sec-tools { display: flex; flex: none; }
.sec-tools .icon-btn { width: 32px; height: 32px; }
.sec-tools .icon-btn[disabled] { opacity: .3; }
.md-editor { font: 14.5px/1.6 var(--mono); min-height: 340px; }
.qa { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; font-size: .88rem; max-height: 340px; overflow: auto; }
.qa li { padding: .45rem .6rem; border-radius: 8px; background: var(--warn-soft); }
.qa li.blocking { background: var(--bad-soft); }
.doc-preview { width: 100%; height: calc(100dvh - 220px); min-height: 480px; border: 1px solid var(--border-2); border-radius: var(--r-l); background: #fff; }
.gen-items { list-style: none; margin: .4rem 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.gen-items li { display: flex; align-items: baseline; gap: .6rem; padding: .35rem 0; border-bottom: 1px dashed var(--border); }
.bad-text { color: var(--bad); }
@media (pointer: coarse), (max-width: 1023px) { .sec-tools .icon-btn { width: 40px; height: 40px; } .sec-link { min-height: 44px; } }

/* ---------- Creative Studio ---------- */
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .7rem; }
.asset { display: flex; flex-direction: column; text-align: left; padding: 0; border-radius: var(--r); overflow: hidden; background: var(--surface); border: 1px solid var(--border); color: var(--text); transition: border-color .15s, transform .12s; }
.asset:hover { border-color: var(--border-2); } .asset:active { transform: scale(.99); }
.thumb { display: grid; place-items: center; aspect-ratio: 4 / 3; background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface-3) 0 50%) 0 0 / 16px 16px; }
.thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.asset-meta { display: flex; flex-direction: column; gap: .1rem; padding: .55rem .65rem; min-width: 0; }
.asset-detail { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
@media (min-width: 768px) { .asset-detail { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); } }
.asset-big { display: grid; place-items: center; border-radius: var(--r); background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface-3) 0 50%) 0 0 / 18px 18px; padding: .6rem; max-height: 70vh; }
.asset-big img { max-width: 100%; max-height: 64vh; object-fit: contain; }
.tpl-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
@media (min-width: 768px) { .tpl-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .tpl-actions { grid-column: 1 / -1; } }
.tpl-preview { display: flex; flex-direction: column; gap: .4rem; align-items: center; justify-content: center; border-radius: var(--r); background: var(--bg-2); padding: .6rem; min-height: 260px; }
.tpl-preview img { max-width: 100%; max-height: 60vh; object-fit: contain; border-radius: 6px; }
.field.color input { width: 56px; height: 40px; padding: 2px; border-radius: 8px; border: 1px solid var(--border-2); background: var(--bg-2); }

/* ---------- Landing Factory: editor ---------- */
.lp-top { gap: .45rem; }
.lp-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
@media (min-width: 1100px) { .lp-layout { grid-template-columns: minmax(360px, 440px) minmax(0, 1fr); align-items: start; } .lp-preview { position: sticky; top: 12px; } }
.lp-panel { padding: .8rem; }
.lp-panel > * + * { margin-top: .8rem; }
.lp-tabs { margin: -.2rem -.2rem 0 !important; padding: 0 .2rem !important; }
.lp-tabs a { min-height: 40px; padding: 0 .6rem; font-size: .88rem; }
#panel > * + * { margin-top: .8rem; }
.lp-secs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.lp-secs li { display: flex; align-items: center; gap: .2rem; border-radius: 10px; border: 1px solid transparent; }
.lp-secs li.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.lp-secs li.off .lp-sec { opacity: .45; }
.lp-sec { display: flex; flex-direction: column; align-items: flex-start; flex: 1; min-width: 0; padding: .45rem .55rem; background: none; border: 0; color: var(--text); text-align: left; }
.lp-sec small { max-width: 100%; }
.lp-tools { display: flex; flex: none; }
.lp-tools .icon-btn { width: 30px; height: 30px; }
.lp-tools .icon-btn .i { width: 15px; height: 15px; }
.lp-tools .icon-btn[disabled] { opacity: .3; }
.lp-props { border-top: 1px solid var(--border); padding-top: .8rem; }
.lp-props #fields > * + * { margin-top: .7rem; }
.lp-list { display: flex; flex-direction: column; gap: .5rem; }
.lp-item > * + * { margin-top: .5rem; }
.palettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: .45rem; }
.palette { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: .4rem; border-radius: 10px; border: 1px solid var(--border-2); background: var(--bg-2); }
.palette.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.palette i { height: 22px; border-radius: 4px; }
.palette small { grid-column: 1 / -1; font-size: .7rem; color: var(--muted); }
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .5rem; }
.dev-switch { margin-bottom: .5rem; }
.frame-wrap { position: relative; overflow: hidden; border-radius: var(--r-l); border: 1px solid var(--border-2); background: var(--bg-2); }
.frame-wrap iframe { display: block; border: 0; background: #fff; transform-origin: 0 0; }
.table-wrap { overflow-x: auto; }
table.mini { border-collapse: collapse; width: 100%; font-size: .86rem; }
table.mini th, table.mini td { padding: .4rem .55rem; border-bottom: 1px solid var(--border); text-align: left; }
@media (pointer: coarse), (max-width: 1023px) { .lp-tools .icon-btn { width: 40px; height: 40px; } .lp-sec { min-height: 44px; } .lp-tabs a { min-height: 44px; } }

/* ---------- Missione ---------- */
.mission-top > * + * { margin-top: .6rem; }
.live { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--info); }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--info); animation: blink 1.4s infinite; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
@media (min-width: 768px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { display: flex; flex-direction: column; gap: .2rem; padding: .85rem .95rem; border-radius: var(--r-l); background: var(--surface); border: 1px solid var(--border); min-width: 0; }
.stat b { font-size: 1.2rem; font-weight: 680; overflow-wrap: anywhere; }
.stat .meter { margin-top: .35rem; }
.decision { border-radius: var(--r-l); padding: 1.1rem; background: linear-gradient(160deg, var(--warn-soft), transparent 70%), var(--surface); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--border)); box-shadow: var(--shadow); }
.decision > * + * { margin-top: 1rem; }
.decision-head { display: flex; gap: .7rem; align-items: flex-start; }
.decision-head > .i { color: var(--warn); width: 22px; height: 22px; margin-top: 2px; }
.decision-head .eyebrow { color: var(--warn); }
.decision-grid { display: grid; grid-template-columns: 1fr; gap: .9rem; }
@media (min-width: 768px) { .decision-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.decision-grid p { margin-top: .25rem; color: var(--text-2); }
.big { font-size: 1.5rem; font-weight: 720; color: var(--text) !important; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .8rem; }
.tl-item { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: .7rem; position: relative; }
.tl-item:not(:last-child)::before { content: ""; position: absolute; left: 15px; top: 34px; bottom: -14px; width: 2px; background: var(--border-2); }
.tl-dot { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); color: var(--muted); font-weight: 700; font-size: .85rem; position: relative; z-index: 1; }
.tl-item.succeeded .tl-dot { background: var(--ok-soft); color: var(--ok); }
.tl-item.running .tl-dot { background: var(--info-soft); color: var(--info); }
.tl-item.awaiting_approval .tl-dot { background: var(--warn-soft); color: var(--warn); }
.tl-item.dead .tl-dot, .tl-item.blocked .tl-dot { background: var(--bad-soft); color: var(--bad); }
.tl-card > * + * { margin-top: .55rem; }
.facts { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .84rem; color: var(--muted); }
.facts b { color: var(--text-2); font-weight: 600; }
.working { color: var(--info); font-size: .9rem; display: flex; align-items: center; gap: .5rem; }
.working::after { content: ""; flex: 1; max-width: 160px; height: 3px; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--info), transparent); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }

.events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.events > li { display: flex; flex-wrap: wrap; gap: .2rem .8rem; padding: .55rem 0; border-bottom: 1px solid var(--border); align-items: baseline; min-width: 0; }
.events > li:last-child { border-bottom: 0; }
.events > li > span:first-child { flex: none; min-width: 7.5rem; }
.events.big > li { flex-wrap: nowrap; align-items: flex-start; gap: .7rem; }
.events.big > li > .dot { margin-top: .5rem; }
.events.big .grow { display: flex; flex-direction: column; }

/* ---------- Tab, filtri, ricerca ---------- */
.tabs { display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); margin-left: -16px; margin-right: -16px; padding: 0 16px; scroll-snap-type: x proximity; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 .85rem; color: var(--muted); font-weight: 580; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; scroll-snap-align: start; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
@media (min-width: 1024px) { .tabs { margin: 0; padding: 0; } }
.tab-body > * + * { margin-top: 1rem; }
.filters { display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filter { flex: none; display: inline-flex; align-items: center; min-height: 36px; padding: 0 .85rem; border-radius: 999px; border: 1px solid var(--border-2); color: var(--text-2); font-size: .86rem; font-weight: 560; text-decoration: none; }
.filter:hover { text-decoration: none; color: var(--text); }
.filter.on { background: var(--text); color: var(--bg); border-color: transparent; }
.search { display: flex; align-items: center; gap: .5rem; background: var(--surface); border: 1px solid var(--border-2); border-radius: 14px; padding: .3rem .3rem .3rem .8rem; }
.search > .i { color: var(--muted); }
.search .input { border: 0; background: transparent; box-shadow: none; padding-left: 0; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Discover, progetti ---------- */
.recs { display: flex; flex-wrap: wrap; gap: .35rem; }
.rec { font-size: .76rem; font-weight: 650; padding: .15rem .5rem; border-radius: 6px; }
.rec.ok { background: var(--ok-soft); color: var(--ok); } .rec.info { background: var(--info-soft); color: var(--info); } .rec.bad { background: var(--bad-soft); color: var(--bad); }
.opp .i { width: 14px; height: 14px; vertical-align: -2px; }
.compare { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-l); overflow: hidden; background: var(--surface); }
.compare-row { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem .6rem; padding: .7rem .9rem; border-bottom: 1px solid var(--border); }
.compare-row:last-child { border-bottom: 0; }
.compare-row .grow { flex-basis: 100%; font-weight: 560; }
@media (min-width: 768px) { .compare-row .grow { flex-basis: 0; } }
.reader-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
@media (min-width: 1024px) { .reader-layout { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; } .side-panel { position: sticky; top: 24px; } }
.side-panel { display: flex; flex-direction: column; gap: .9rem; min-width: 0; }
.rating { display: flex; gap: .35rem; }
.rate { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--bg-2); font-weight: 650; }
.rate.on { background: var(--accent); color: #fff; border-color: transparent; }
.next-card { background: linear-gradient(160deg, var(--accent-soft), transparent 65%), var(--surface); }
.next-card h3 { font-size: 1.15rem; }
.agent .row:first-child h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: flex; align-items: baseline; gap: .6rem; padding: .4rem 0; border-bottom: 1px dashed var(--border); }
.bars li:last-child { border-bottom: 0; }
.provider { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.provider .grow { display: flex; flex-direction: column; }

/* ---------- Grafico ---------- */
.chart { margin: 0; }
.chart svg { display: block; width: 100%; height: 150px; }
.chart .axis { stroke: var(--border-2); stroke-width: 1; vector-effect: non-scaling-stroke; }
.bar.c-openai, .legend .c-openai { fill: var(--openai); background: var(--openai); }
.bar.c-anthropic, .legend .c-anthropic { fill: var(--anthropic); background: var(--anthropic); }
.bar.c-other, .legend .c-other { fill: var(--other); background: var(--other); }
.chart figcaption { margin-top: .4rem; }
.legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: .5rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }

/* ---------- Documenti (Markdown) ---------- */
.reader { padding: 1.2rem; }
@media (min-width: 768px) { .reader { padding: 2rem 2.4rem; } }
.doc { line-height: 1.7; color: var(--text-2); overflow-wrap: anywhere; max-width: 78ch; }
.doc > :first-child { margin-top: 0; }
.doc h1, .doc h2, .doc h3, .doc h4 { color: var(--text); margin: 1.6em 0 .5em; }
.doc h1 { font-size: 1.45rem; } .doc h2 { font-size: 1.2rem; padding-bottom: .3rem; border-bottom: 1px solid var(--border); } .doc h3 { font-size: 1.04rem; }
.doc p, .doc ul, .doc ol, .doc blockquote, .doc pre, .doc table { margin: 0 0 1em; }
.doc ul, .doc ol { padding-left: 1.3rem; }
.doc li + li { margin-top: .25rem; }
.doc strong { color: var(--text); }
.doc blockquote { border-left: 3px solid var(--accent); padding: .2rem 0 .2rem 1rem; color: var(--text-2); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.doc pre, .code { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r); padding: .8rem; overflow-x: auto; font: .84rem/1.5 var(--mono); max-width: 100%; }
.doc table { display: block; overflow-x: auto; border-collapse: collapse; max-width: 100%; font-size: .9rem; }
.doc th, .doc td { border: 1px solid var(--border-2); padding: .45rem .65rem; text-align: left; vertical-align: top; min-width: 7rem; }
.doc th { background: var(--surface-2); color: var(--text); }
.doc hr { border: 0; border-top: 1px solid var(--border); margin: 1.6em 0; }
.doc a { word-break: break-word; }
.card .doc { max-width: none; }

/* ---------- Stati vuoti, errori, skeleton ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .55rem; padding: 2rem 1rem; border: 1px dashed var(--border-2); border-radius: var(--r-l); color: var(--muted); }
.empty-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); }
.empty-title { color: var(--text-2); font-weight: 600; max-width: 46ch; }
.empty .btn { margin-top: .4rem; }
.error-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .6rem; padding: 3rem 1rem; }
.error-state > .i { width: 34px; height: 34px; color: var(--bad); }
.sk { background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: 8px; }
.sk-title { height: 30px; width: min(320px, 70%); }
.sk-l { height: 16px; width: 70%; } .sk-m { height: 12px; width: 50%; } .sk-s { height: 12px; width: 30%; }
.skeleton-wrap { display: grid; gap: .8rem; margin-top: 1.25rem; }
@media (min-width: 768px) { .skeleton-wrap { grid-template-columns: repeat(3, 1fr); } }
.sk-card { display: flex; flex-direction: column; gap: .7rem; padding: 1.1rem; border-radius: var(--r-l); border: 1px solid var(--border); background: var(--surface); }
.sheet-body > .sk + .sk { margin-top: .7rem; }

/* ---------- Toast ---------- */
.toasts { position: fixed; z-index: 90; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: .5rem; width: min(92vw, 420px); pointer-events: none; }
@media (min-width: 1024px) { .toasts { bottom: 24px; left: auto; right: 24px; transform: none; } }
.toast { padding: .75rem 1rem; border-radius: var(--r); background: var(--surface-3); color: var(--text); border: 1px solid var(--border-2); box-shadow: var(--shadow-lg); font-weight: 540; animation: rise .25s var(--ease); border-left: 3px solid var(--ok); }
.toast.warn { border-left-color: var(--warn); } .toast.bad { border-left-color: var(--bad); }
.toast.out { opacity: 0; transform: translateY(6px); transition: all .25s; }

/* ---------- Sheet: bottom sheet su mobile, finestra su desktop ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 80; }
.sheet-bg { position: absolute; inset: 0; background: rgba(4, 6, 10, .6); opacity: 0; transition: opacity .22s; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain; background: var(--surface); border-top: 1px solid var(--border-2); border-radius: 22px 22px 0 0; padding: .6rem max(1.1rem, env(safe-area-inset-right)) calc(1.2rem + env(safe-area-inset-bottom)) max(1.1rem, env(safe-area-inset-left)); transform: translateY(100%); transition: transform .3s var(--ease); box-shadow: var(--shadow-lg); }
.sheet-wrap.open .sheet-bg { opacity: 1; }
.sheet-wrap.open .sheet { transform: none; }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--border-2); margin: 0 auto .8rem; }
.sheet-x { position: absolute; top: .55rem; right: .55rem; }
.sheet-body > * + * { margin-top: .9rem; }
.sheet-title { font-size: 1.2rem; padding-right: 2.5rem; }
.sheet-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); }
@media (min-width: 768px) {
  .sheet { left: 50%; right: auto; top: 50%; bottom: auto; width: min(480px, 92vw); max-height: 86vh; border-radius: 20px; border: 1px solid var(--border-2); padding: 1.5rem; transform: translate(-50%, -46%) scale(.97); opacity: 0; transition: transform .25s var(--ease), opacity .2s; }
  .sheet.wide { width: min(760px, 92vw); }
  .sheet-wrap.open .sheet { transform: translate(-50%, -50%); opacity: 1; }
  .sheet-handle { display: none; }
}
.menu-list { display: flex; flex-direction: column; gap: 2px; }
.menu-item { display: flex; align-items: center; gap: .8rem; min-height: 52px; padding: 0 .8rem; border-radius: var(--r); color: var(--text); text-decoration: none; background: none; border: 0; width: 100%; text-align: left; font-weight: 560; }
.menu-item:hover, .menu-item:active { background: var(--surface-2); text-decoration: none; }
.menu-item .end { margin-left: auto; color: var(--muted); }
.menu-item.danger { color: var(--bad); }
.codes { font: 1rem/1.8 var(--mono); padding: 1rem; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r); text-align: center; letter-spacing: .08em; user-select: all; }

/* ---------- Autenticazione ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: radial-gradient(800px 400px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border-2); border-radius: 22px; padding: 1.8rem 1.4rem; box-shadow: var(--shadow-lg); animation: rise .35s var(--ease); }
.auth-card > * + * { margin-top: 1rem; }
.auth-card h1 { font-size: 1.35rem; text-align: center; }
.auth-card > p.muted { text-align: center; }
.qr { display: grid; place-items: center; padding: 1rem; background: #fff; border-radius: var(--r); }
.qr svg { width: 220px; height: 220px; max-width: 100%; }
.key { font: 1rem var(--mono); word-break: break-all; padding: .6rem; background: var(--bg-2); border-radius: var(--r-s); }
.steps { padding-left: 1.2rem; color: var(--text-2); }

/* ---------- Offline ---------- */
body.offline::before { content: ""; position: fixed; z-index: 95; top: 0; left: 0; right: 0; height: 3px; background: var(--warn); }

/* ---------- Touch: bersagli di almeno 44px, niente zoom iOS sui campi ---------- */
@media (pointer: coarse), (max-width: 1023px) {
  .btn, .btn.sm { min-height: 44px; }
  .link { min-height: 44px; }
  .compare-row a.grow { min-height: 44px; display: flex; align-items: center; }
  .input, select.input { min-height: 46px; font-size: 16px; }
  .command textarea { font-size: 16px; }
  .icon-btn { width: 44px; height: 44px; }
  .rate { width: 44px; height: 44px; }
  .back { min-height: 44px; }
  .filter { min-height: 44px; }
  .switch { width: 52px; height: 32px; border-radius: 16px; }
  .switch::after { width: 24px; height: 24px; }
  .switch.on::after, .switch:checked::after { transform: translateX(20px); }
  .seg-opt span { min-height: 42px; }
  details summary { min-height: 44px; }
  .row-card { min-height: 60px; }
  a, button { -webkit-tap-highlight-color: transparent; }
}

/* ---------- Animazioni ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: .35; } }
@keyframes pulse { 50% { transform: scale(.92); opacity: .7; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ---------- Workflow ibrido: tre percorsi e passi del pacchetto ---------- */
.paths { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: .75rem; margin-top: .6rem; }
.path { display: flex; flex-direction: column; align-items: flex-start; gap: .45rem; padding: 1rem; min-height: 150px; text-align: left; color: var(--text); font: inherit; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-l); cursor: pointer; transition: border-color .15s, background .15s; -webkit-tap-highlight-color: transparent; }
.path b { display: inline-flex; align-items: center; gap: .4rem; font-size: 1.02rem; }
.path:hover, .path:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.path:active { transform: scale(.99); }
.path-cta { margin-top: auto; display: inline-flex; align-items: center; gap: .3rem; color: var(--accent); font-weight: 600; font-size: .9rem; }
.wf-progress { display: flex; align-items: center; gap: .7rem; margin: .4rem 0 .7rem; }
.wf-progress .bar { flex: 1; height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.wf-progress .bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.steps { list-style: none; padding: 0; margin: .8rem 0 0; display: flex; flex-direction: column; gap: .6rem; }
.step { padding: .8rem; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); display: flex; flex-direction: column; gap: .45rem; min-width: 0; }
.step.done { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.step-head { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.step-head b { overflow-wrap: anywhere; }
.step-n { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-size: .8rem; font-weight: 650; }
.step.done .step-n { background: var(--accent); color: var(--accent-ink); }
.step-actions .btn { min-height: 40px; }
.step-actions label.btn { cursor: pointer; }
.step pre.code { max-height: 260px; overflow: auto; white-space: pre-wrap; }
.step small { overflow-wrap: anywhere; }
.wf-thumb { max-height: 220px; width: auto; max-width: 100%; border-radius: var(--r); border: 1px solid var(--border); align-self: center; }
.versions { list-style: none; padding: 0; margin: .6rem 0 0; display: flex; flex-direction: column; gap: .6rem; }
.versions > li { display: flex; flex-direction: column; gap: .35rem; padding: .7rem; border: 1px solid var(--border); border-radius: var(--r); }
select.input.sm { width: auto; max-width: 100%; min-height: 36px; padding-block: .3rem; }
details > summary.h3 { cursor: pointer; display: flex; align-items: center; gap: .4rem; list-style: none; }
details > summary.h3::-webkit-details-marker { display: none; }
details[open] > summary.h3 { margin-bottom: .8rem; }
@media (max-width: 560px) { .step-actions .btn { flex: 1 1 calc(50% - .4rem); justify-content: center; } }
/* Evidenze A-E dell'opportunità */
.ev-list { list-style: none; margin: 0 0 .75rem; padding: 0; display: grid; gap: .5rem; }
.ev { display: flex; gap: .65rem; align-items: flex-start; padding: .55rem .65rem; border-radius: 10px; background: var(--surface-2); }
.ev.off { opacity: .75; }
.ev-k { flex: none; width: 1.75rem; height: 1.75rem; border-radius: 8px; display: grid; place-items: center; font-weight: 700; background: var(--surface-3); }
.ev.on .ev-k { background: var(--accent); color: #fff; }
.ev .reasons { margin: .35rem 0 0; }
.h4 { font-size: .95rem; margin: .75rem 0 .25rem; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; }

/* Selettori con nomi di file lunghi (es. file importati dai pacchetti): mai più larghi del contenitore */
select.input.auto { max-width: 100%; min-width: 0; text-overflow: ellipsis; }
#impf { flex: 1 1 12rem; width: 0; }

/* AI Usage Center */
.usage-top { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.usage-top .utile { display: flex; flex-direction: column; gap: .3rem; text-decoration: none; color: inherit; min-width: 0; }
.usage-top .utile b { font-size: 1.35rem; }
.usage-top .utile.on { outline: 2px solid var(--accent); }
@media (max-width: 720px) { .usage-top { grid-template-columns: 1fr; } .usage-top .utile b { font-size: 1.15rem; } }
.bill { align-self: flex-start; font-size: .72rem; font-weight: 650; letter-spacing: .02em; padding: .15rem .55rem; border-radius: 999px; }
.bill.payg { background: var(--accent-soft); color: var(--accent); }
.bill.sub { background: rgba(52, 199, 140, .14); color: #2fb985; }
.dk { display: inline-block; font-size: .68rem; font-weight: 650; padding: .08rem .45rem; border-radius: 6px; vertical-align: middle; margin-left: .25rem; border: 1px solid currentColor; }
.dk.ok { color: #2fb985; } .dk.warn { color: #e0a43a; } .dk.info { color: var(--accent); } .dk.muted { color: var(--text-2); }
.legend-dk { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0 1rem; }
.thr { display: flex; gap: .3rem; margin-top: .35rem; flex-wrap: wrap; }
.quota-na { font-size: 1.25rem; font-weight: 700; margin: .25rem 0; }
.prov.off { opacity: .8; }
.pill.link { text-decoration: none; color: inherit; }
