:root {
  --bg: #f4f6fa; --card: #fff; --ink: #0f172a; --muted: #5b6678; --line: #e2e7ef;
  --accent: #0369a1; --accent-soft: #e0f2fe; --navy: #0b1220;
  --good: #15803d; --bad: #b91c1c; --warn-bg: #fff7e6; --warn-line: #f5d28a;
  --band: rgba(3, 105, 161, .14); --band2: rgba(3, 105, 161, .26);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0f1a; --card: #121a2a; --ink: #e8edf6; --muted: #93a0b5; --line: #243049;
    --accent: #38bdf8; --accent-soft: #0c2a3d; --navy: #060a12;
    --good: #4ade80; --bad: #f87171; --warn-bg: #2a2110; --warn-line: #6b5420;
    --band: rgba(56, 189, 248, .14); --band2: rgba(56, 189, 248, .28);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.wrap { max-width: 1060px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 1.55rem; margin: 22px 0 4px; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: .95rem; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.lead { color: var(--muted); margin-bottom: 18px; max-width: 70ch; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* header */
.top { background: var(--navy); color: #e8edf6; position: sticky; top: 0; z-index: 10; }
.top-in { display: flex; align-items: center; gap: 18px; min-height: 54px; }
.brand { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; font-weight: 700; white-space: nowrap; }
.logo { width: 26px; height: 26px; border-radius: 8px; background: #38bdf8; color: #06202e; display: grid; place-items: center; font-weight: 800; }
.badge { font-style: normal; font-size: .65rem; text-transform: uppercase; letter-spacing: .06em; background: #f59e0b; color: #1c1300; border-radius: 99px; padding: 1px 7px; }
nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
nav a { color: #b6c2d6; text-decoration: none; padding: 7px 12px; border-radius: 99px; white-space: nowrap; font-size: .9rem; }
nav a:hover { color: #fff; }
nav a.on { background: #1b2740; color: #fff; }

/* cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g2 > .card, .g3 > .card, .g4 > .card { margin: 0; }
@media (max-width: 820px) { .g2, .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: 1fr 1fr; } }

.kpi .l { color: var(--muted); font-size: .8rem; }
.kpi .v { font-size: 1.45rem; font-weight: 700; letter-spacing: -.01em; }
.kpi .s { font-size: .8rem; color: var(--muted); }

/* segmented / chips */
.seg { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }
.seg button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; padding: 8px 14px; text-align: left;
}
.seg button small { display: block; color: var(--muted); font-size: .75rem; }
.seg button.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.btn { text-align: center; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #04202e; } }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: wait; }
.profiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 18px; }
@media (max-width: 700px) { .profiles { grid-template-columns: 1fr; } }
.prof { text-align: left; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 12px; padding: 12px 14px; cursor: pointer; font: inherit; }
.prof.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.prof b { display: block; }
.prof span { font-size: .8rem; color: var(--muted); }
.prof .tag { float: right; font-size: .75rem; font-weight: 700; color: var(--accent); }

/* forms */
label.f { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); }
input[type=number], input[type=email], input[type=password], input[type=text], select {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; width: 100%;
}
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
details { margin: 8px 0 14px; }
summary { cursor: pointer; color: var(--accent); font-weight: 600; }

/* tables */
.tw { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
.tk { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
code.isin { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }
.copy { border: 1px solid var(--line); background: transparent; color: var(--accent); border-radius: 7px; padding: 2px 8px; font: inherit; font-size: .75rem; cursor: pointer; margin-left: 6px; }
.pos { color: var(--good); } .neg { color: var(--bad); }

/* donut */
.donut-row { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut { width: 170px; height: 170px; flex: none; }
.donut text { fill: var(--ink); }
.legend { flex: 1; min-width: 200px; display: grid; gap: 8px; }
.legend div { display: flex; align-items: center; gap: 8px; }
.legend .w { margin-left: auto; font-weight: 700; }

/* range bars */
.rb { position: relative; height: 10px; background: var(--line); border-radius: 99px; min-width: 120px; }
.rb i { position: absolute; top: 0; bottom: 0; background: var(--band2); border-radius: 99px; }
.rb b { position: absolute; top: -3px; width: 3px; height: 16px; background: var(--accent); border-radius: 2px; }
.rb u { position: absolute; top: -3px; width: 2px; height: 16px; background: var(--muted); }

/* chart */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .ax { stroke: var(--line); } .chart .tx { fill: var(--muted); font-size: 11px; }
.tip { position: absolute; pointer-events: none; background: var(--navy); color: #fff; font-size: .78rem; padding: 8px 10px; border-radius: 8px; display: none; white-space: nowrap; transform: translate(-50%, 0); }
.legend-inline { display: flex; gap: 16px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: 6px; }
.legend-inline span::before { content: ""; display: inline-block; width: 12px; height: 8px; border-radius: 2px; margin-right: 6px; background: var(--c); }

/* checklist */
.chk { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.chk:last-child { border-bottom: 0; }
.chk input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.chk.done .t { text-decoration: line-through; color: var(--muted); }
.chk .t { flex: 1; }
.chk .amt { font-weight: 700; }
.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.mo { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: .85rem; }
.mo.done { background: var(--accent-soft); }
.mo.next { border-color: var(--accent); }
.mo input { accent-color: var(--accent); }
.progress { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; margin: 6px 0 14px; }
.progress i { display: block; height: 100%; background: var(--accent); }

.note { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 12px; padding: 12px 14px; font-size: .88rem; margin-bottom: 16px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .75rem; font-weight: 700; }
.pill.ok { background: rgba(21, 128, 61, .15); color: var(--good); }
.pill.warn { background: rgba(185, 28, 28, .15); color: var(--bad); }
.ul { margin: 0; padding-left: 18px; } .ul li { margin-bottom: 8px; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); background: var(--navy); color: #fff; padding: 9px 16px; border-radius: 99px; font-size: .85rem; opacity: 0; transition: .25s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.foot { color: var(--muted); font-size: .78rem; padding: 18px 16px 40px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.sub { font-size: .75rem; color: var(--muted); font-weight: 400; max-width: 34ch; }
tr.dim td { opacity: .6; }
th.sort { cursor: pointer; user-select: none; } th.sort.on { color: var(--accent); }
.pill.r-Basso { background: rgba(16,185,129,.16); color: var(--good); }
.pill.r-Moderato { background: rgba(245,158,11,.18); color: #b45309; }
.pill.r-Alto { background: rgba(185,28,28,.14); color: var(--bad); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill.r-Moderato { color: #fbbf24; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 99px; padding: 4px 11px; font-size: .82rem; font-weight: 600; cursor: pointer; }
.chip::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--c); }
.chip input { display: none; } .chip.on { background: var(--accent-soft); border-color: var(--accent); }
.wrow { display: grid; grid-template-columns: 88px 1fr 42px; gap: 8px; align-items: center; padding: 3px 0; font-size: .88rem; }
.wrow i { height: 8px; border-radius: 99px; background: linear-gradient(90deg, var(--c) var(--w), var(--line) var(--w)); }
.wrow b { text-align: right; }
input[type=range] { width: 100%; accent-color: var(--accent); }
@media (max-width: 700px) { .hide-s { display: none; } }

.acct { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: .82rem; color: #b6c2d6; white-space: nowrap; }
.acct .who { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.acct .sync { color: #4ade80; font-weight: 700; min-width: 1ch; }
.lnk { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 2px 4px; text-decoration: underline; }
.acct .lnk { color: #7dd3fc; }
.auth { max-width: 440px; margin: 40px auto; }
@media (max-width: 760px) { .acct .who { display: none; } .top-in { flex-wrap: wrap; padding-bottom: 6px; } nav { order: 3; width: 100%; } }
