:root {
  --bar-low: #c0392b; --bar-mid: #d4a017; --bar-high: #2e7d4f; --bar-off: #e3e0da; --bar-none: #8a9099;
  --bg: #fbfaf8; --surface: #ffffff; --text: #1d1f23; --muted: #5f6670; --line: #e3e0da;
  --accent: #1f5f8b; --accent-text: #ffffff; --alarm-bg: #fdecea; --alarm-line: #c0392b;
  --ok: #2e7d4f; --code-bg: #f2f0ec;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bar-low: #e57368; --bar-mid: #e3b93b; --bar-high: #6cc28f; --bar-off: #33373d; --bar-none: #a2a8b0;
    --bg: #15171a; --surface: #1d2024; --text: #e7e5e1; --muted: #a2a8b0; --line: #33373d;
    --accent: #6fb1e0; --accent-text: #0f1418; --alarm-bg: #3a1f1c; --alarm-line: #e57368;
    --ok: #6cc28f; --code-bg: #24282d;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 860px; margin: 0 auto; padding: 24px 16px 48px; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0.4em 0 0.6em; }
h2 { font-size: 1.2rem; }
.top {
  display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: baseline; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--text); }
.top nav { display: flex; gap: 16px; flex-wrap: wrap; }
.top nav a { text-decoration: none; }
.foot { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 16px; border-top: 1px solid var(--line); }
textarea, input[type="text"], input:not([type]) {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
.buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
button, .button {
  font: inherit; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none;
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.hint, .meta { color: var(--muted); font-size: 0.92rem; }
.notice { background: var(--code-bg); padding: 8px 12px; border-radius: 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin: 16px 0; }
.card label { display: block; font-weight: 600; margin-bottom: 4px; }
.pick { display: block; font-weight: 400 !important; margin: 8px 0; }
.kind { color: var(--muted); font-size: 0.85rem; }
.alarm { background: var(--alarm-bg); border-left: 4px solid var(--alarm-line); padding: 12px 16px; border-radius: 6px; margin: 16px 0; }
.alarm h1, .alarm h2 { margin-top: 0; }
.asked { font-size: 1.1rem; font-style: italic; }
.status-line { display: flex; gap: 12px; align-items: baseline; }
.cost { color: var(--muted); font-variant-numeric: tabular-nums; }
#log { padding-left: 0; list-style: none; }
#log li { border-left: 2px solid var(--line); padding: 2px 0 6px 12px; }
.stage { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); }
pre { white-space: pre-wrap; word-break: break-word; margin: 2px 0; font: 0.88rem/1.45 ui-monospace, "SFMono-Regular", Menlo, monospace; }
.log-file pre { background: var(--code-bg); padding: 12px; border-radius: 8px; }
details summary { cursor: pointer; font-weight: 600; margin: 12px 0 4px; }
table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 0.95rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.total { font-size: 1.1rem; }
.meter { width: 100%; height: 12px; }
.report { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 20px 16px; overflow-wrap: anywhere; }
.report blockquote { border-left: 3px solid var(--alarm-line); margin: 12px 0; padding: 4px 12px; background: var(--alarm-bg); }
.report code { background: var(--code-bg); padding: 1px 4px; border-radius: 4px; }
.report table { display: block; overflow-x: auto; }
@media (max-width: 560px) { main { padding: 16px 16px 40px; } h1 { font-size: 1.35rem; } }

/* diary */
.row { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-end; margin: 8px 0; }
.row label, .entry-form > label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; flex: 1 1 200px; }
.row[hidden] { display: none; }
select, input[type="number"], input[type="datetime-local"], input[type="date"] {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px;
}
form.inline { display: inline; }
button.small { padding: 2px 8px; font-size: 0.85rem; }
button.link { border: none; background: none; color: var(--muted); text-decoration: underline; cursor: pointer; }
.plain { list-style: none; padding-left: 0; }
.episodes { padding-left: 18px; }
.timeline { list-style: none; padding-left: 0; }
.timeline li { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); }
.timeline .when { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 9.5em; }
.timeline .kind { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); min-width: 5em; }
.timeline .what { font-weight: 600; }
.timeline .note { color: var(--muted); flex-basis: 100%; padding-left: 0; }
.reminders { background: var(--code-bg); border-bottom: 1px solid var(--line); padding: 4px 16px; }
.reminders p { max-width: 860px; margin: 6px auto; }
.chart { width: 100%; height: auto; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .series { fill: none; stroke-width: 2.5; }
.chart .dose { stroke: var(--muted); stroke-width: 2; }
.s0 { stroke: #1f77b4; fill: #1f77b4; color: #1f77b4; } .s1 { stroke: #d1495b; fill: #d1495b; color: #d1495b; }
.s2 { stroke: #2e9e6b; fill: #2e9e6b; color: #2e9e6b; } .s3 { stroke: #b3721b; fill: #b3721b; color: #b3721b; }
.s4 { stroke: #7a5cc4; fill: #7a5cc4; color: #7a5cc4; } .s5 { stroke: #5f6670; fill: #5f6670; color: #5f6670; }
.chart .series.s0, .chart .series.s1, .chart .series.s2, .chart .series.s3, .chart .series.s4, .chart .series.s5 { fill: none; }
.legend { margin-right: 12px; font-weight: 600; }
.legend::before { content: "● "; }
table.compact { font-size: 0.85rem; }
.summary header p { margin: 4px 0; }
.citation-link { text-decoration: none; }
.citation-link code, .citation-link strong { text-decoration: underline dotted; cursor: pointer; }
.source-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); z-index: 20;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: -4px 0 16px rgba(0,0,0,.15);
  padding: 16px 16px 32px; overflow-y: auto;
}
.source-panel[hidden] { display: none; }
.panel-close { float: right; font-size: 1.3rem; line-height: 1; padding: 2px 10px; }
.panel-head p { margin: 6px 0; }
.panel-text p { margin: 8px 0; font-size: 0.95rem; }
.panel-text mark { background: #fff1a8; color: #1d1f23; padding: 1px 2px; }
.section-label { color: var(--muted); font-size: 0.75rem; letter-spacing: 0.04em; }
.code { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.consult-card .card-title { font-size: 1rem; margin: 0 0 8px; }
.card-row { margin: 10px 0; }
.card-label { color: var(--muted); font-size: 0.9rem; }
.card-label strong { color: var(--text); margin-left: 4px; }
.subq { list-style: none; padding: 0; margin: 6px 0 0; font-size: 0.92rem; }
.subq li { display: flex; gap: 8px; align-items: baseline; margin: 3px 0; }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--bar-high); }
.subq .yes .dot { background: var(--bar-high); }
.subq .no .dot { border-color: var(--bar-none); }
.subq .no { color: var(--muted); }
.sr { position: absolute; left: -9999px; }
.cells { display: flex; flex-wrap: wrap; gap: 3px; margin: 6px 0 4px; }
.cell { display: inline-block; width: 14px; height: 14px; border-radius: 3px; background: var(--bar-off); }
.card-legend { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.85rem; color: var(--muted); }
.card-legend li, .subq li { list-style: none; }
.card-legend .cell { width: 10px; height: 10px; margin-right: 5px; vertical-align: -1px; }
.cell.kind-0 { background: #6b4fa0; } .cell.kind-1 { background: #1f5f8b; } .cell.kind-2 { background: #3f8fc4; }
.cell.kind-3 { background: #7fb7de; } .cell.kind-4 { background: #b9c3cc; }
.cell.kind-5 { background: #9fcfb0; }
.cell.ok { background: var(--bar-high); } .cell.mid { background: var(--bar-mid); } .cell.bad { background: var(--bar-low); }
.card-more p { margin: 4px 0; font-size: 0.9rem; }
.card-more .card-label { display: inline-block; min-width: 9em; }
@media print {
  .top, .foot, .reminders, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  main { max-width: none; padding: 0; }
  a { color: #000; text-decoration: none; }
  table { page-break-inside: auto; } tr { page-break-inside: avoid; }
}

/* test set review */
pre.source { background: var(--code-bg); padding: 12px; border-radius: 8px; font-family: inherit; font-size: 0.95rem; }
a.primary-link { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.view-switch { margin: 8px 0 16px; }
.sections details { border-top: 1px solid var(--line); }
.sections details summary { margin: 10px 0; }
.strength-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; justify-content: space-between; }
.squares { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin: 10px 0 4px; max-width: 360px; }
.sq { aspect-ratio: 1; border-radius: 3px; background: var(--bar-off); }
.sq.on.tone-low { background: var(--bar-low); }
.sq.on.tone-mid { background: var(--bar-mid); }
.sq.on.tone-high { background: var(--bar-high); }
.strength-label { font-weight: 600; }
.strength-label.tone-low { color: var(--bar-low); }
.strength-label.tone-mid { color: var(--bar-mid); }
.strength-label.tone-high { color: var(--bar-high); }
.strength-label.tone-none { color: var(--bar-none); }
.sq.on.tone-none { background: var(--bar-none); }
@media print {
  :root {
    --bg: #ffffff; --surface: #ffffff; --text: #000000; --muted: #444444; --line: #cccccc;
    --accent: #1f5f8b; --code-bg: #f2f2f2;
    --bar-low: #c0392b; --bar-mid: #d4a017; --bar-high: #2e7d4f; --bar-off: #dddddd; --bar-none: #8a9099;
  }
  .top, .reminders, .no-print, button { display: none !important; }
  main { max-width: none; padding: 0; }
  body { font-size: 11pt; }
  .squares, .sq, .strength-label, .cell, .dot { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report li, .card, .alarm, blockquote, table { break-inside: avoid; }
  h1, h2, h3, summary { break-after: avoid; }
  details summary { list-style: none; }
  a[href^="http"]::after { content: ""; }
  .foot { border-top: 1px solid var(--line); }
}
/* seguito-1: the «Aggiungi informazioni» form under the report */
.follow-up h2 { margin-top: 0; }
.follow-item { margin: 12px 0; }
.follow-item input[type="text"] { width: 100%; box-sizing: border-box; }
.follow-up label.inline { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; margin-top: 4px; }
.follow-up textarea { width: 100%; box-sizing: border-box; }
.follow-up button[disabled] { opacity: 0.5; cursor: not-allowed; }

/* accounts (vps-1) */
.inline-form { display: inline; margin: 0; }
button.link { background: none; border: none; padding: 0; color: inherit; font: inherit; cursor: pointer; text-decoration: underline; }
.auth { max-width: 26rem; }
.auth label { display: block; margin-top: 10px; }
.auth input[type="email"], .auth input[type="password"] { width: 100%; box-sizing: border-box; padding: 8px; }
.error { background: #fde8e8; color: #7a1b1b; padding: 8px 12px; border-radius: 8px; }
@media (prefers-color-scheme: dark) { .error { background: #4a1d1d; color: #ffd6d6; } }
.consent-text { max-width: 44rem; }
table.admin { border-collapse: collapse; width: 100%; }
table.admin td, table.admin th { border-bottom: 1px solid var(--code-bg); padding: 6px; text-align: left; vertical-align: top; }
.copy-link { word-break: break-all; font-family: monospace; }

/* ---------------------------------------------------------------------------------------
   Visual refresh (11/2026): calmer identity, cards, header, buttons. Overrides the rules
   above; everything stays local (no web fonts: the CSP allows only 'self').
   ------------------------------------------------------------------------------------- */
:root {
  --bg: #f4f6f8; --surface: #ffffff; --text: #17212b; --muted: #5d6b78; --line: #dfe5ea;
  --accent: #0f6b74; --accent-strong: #0b555c; --accent-soft: #e3f1f1; --accent-text: #ffffff;
  --code-bg: #eef2f5; --shadow: 0 1px 2px rgba(16, 32, 48, .06), 0 4px 16px rgba(16, 32, 48, .06);
  --radius: 14px; --ring: 0 0 0 3px rgba(15, 107, 116, .35);
  --hero: linear-gradient(135deg, #0f6b74 0%, #135e8a 100%);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1418; --surface: #172027; --text: #e6ecf0; --muted: #9aa9b5; --line: #26323b;
    --accent: #4fc1c6; --accent-strong: #7fd6d9; --accent-soft: #15343a; --accent-text: #08262a;
    --code-bg: #1d2930; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    --ring: 0 0 0 3px rgba(79, 193, 198, .4);
    --hero: linear-gradient(135deg, #12474d 0%, #163c57 100%);
  }
}
body { font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
       -webkit-font-smoothing: antialiased; }
main { max-width: 900px; padding: 28px 16px 56px; }
h1 { font-size: 1.75rem; line-height: 1.25; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; letter-spacing: -0.005em; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-strong); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

/* header */
.top {
  position: sticky; top: 0; z-index: 10; align-items: center; padding: 10px 20px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 1.15rem; letter-spacing: -0.01em; }
.brand svg { width: 30px; height: 30px; flex: none; }
.top nav { gap: 4px; align-items: center; }
.top nav a, .top nav button.link {
  padding: 6px 12px; border-radius: 999px; color: var(--muted); text-decoration: none; font-weight: 500;
}
.top nav a:hover, .top nav button.link:hover { background: var(--code-bg); color: var(--text); }
.top nav a.active { background: var(--accent-soft); color: var(--accent-strong); }
.foot { border-top: none; padding: 24px 16px 32px; }

/* forms and buttons */
textarea, input[type="text"], input[type="email"], input[type="password"], input:not([type]), select {
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
button, .button {
  border-radius: 10px; padding: 9px 18px; font-weight: 600; transition: background .15s, transform .05s, box-shadow .15s;
}
button:hover, .button:hover { background: var(--code-bg); }
button:active { transform: translateY(1px); }
button.primary, a.primary-link, .auth button[type="submit"], .follow-up button[type="submit"] {
  background: var(--accent); color: var(--accent-text); border-color: var(--accent);
}
button.primary:hover, a.primary-link:hover, .auth button[type="submit"]:hover, .follow-up button[type="submit"]:hover {
  background: var(--accent-strong); border-color: var(--accent-strong);
}
.top nav button.link { font: inherit; font-weight: 500; text-decoration: none; }

/* cards */
.card, .report { border-radius: var(--radius); box-shadow: var(--shadow); border-color: var(--line); }
.card { padding: 20px; }
.report { padding: 12px 24px 20px; }
.notice { background: var(--accent-soft); color: var(--text); border-radius: 10px; padding: 10px 14px; }
.alarm { border-radius: 12px; }

/* home */
.hero {
  background: var(--hero); color: #fff; border-radius: 20px; padding: 28px 28px 24px; margin: 4px 0 20px;
  box-shadow: var(--shadow);
}
.hero h1 { color: #fff; margin: 0 0 6px; font-size: 1.9rem; }
.hero p { margin: 0; opacity: .92; max-width: 40rem; }
.ask.card textarea { min-height: 7.5rem; font-size: 1.05rem; resize: vertical; }
.ask .buttons button { padding: 11px 20px; }
.steps { list-style: none; padding: 0; margin: 24px 0 8px; display: grid; gap: 12px;
         grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); counter-reset: step; }
.steps li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
            padding: 14px 16px; box-shadow: var(--shadow); counter-increment: step; }
.steps li::before { content: counter(step); display: inline-grid; place-items: center; width: 26px; height: 26px;
                    border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong);
                    font-weight: 700; font-size: .9rem; margin-bottom: 6px; }
.steps strong { display: block; }
.steps span { color: var(--muted); font-size: .92rem; }

/* job page */
.asked { font-size: 1.15rem; font-style: normal; font-weight: 600; background: var(--surface);
         border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 12px; padding: 12px 16px; }
.status-line { align-items: center; margin: 12px 0; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--accent-soft);
           border-top-color: var(--accent); animation: spin .9s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
#log li { border-left: 2px solid var(--accent-soft); }

/* history and tables */
.table-card { padding: 4px 8px; overflow-x: auto; }
table th { color: var(--muted); font-weight: 600; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: var(--code-bg); }

/* report */
.report-head h1 { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; }
.report-head .code { background: var(--accent-soft); color: var(--accent-strong); border-radius: 8px;
                     padding: 2px 10px; font-size: 1rem; }
.view-switch { display: inline-flex; gap: 4px; padding: 4px; background: var(--code-bg); border-radius: 999px; }
.view-switch a, .view-switch strong { padding: 5px 14px; border-radius: 999px; text-decoration: none; }
.view-switch strong { background: var(--surface); box-shadow: var(--shadow); }

/* accounts */
.auth-page { min-height: 60vh; display: grid; place-items: start center; padding-top: 4vh; }
.auth-page .auth { width: 100%; max-width: 27rem; background: var(--surface); border: 1px solid var(--line);
                   border-radius: 18px; box-shadow: var(--shadow); padding: 28px; }
.auth-page .auth h1 { margin-top: 0; }
.auth input[type="email"], .auth input[type="password"], .auth input[type="text"] { padding: 11px 12px; }
.auth button[type="submit"] { width: 100%; padding: 12px; }
.muted { color: var(--muted); }

@media (max-width: 560px) {
  .hero { padding: 22px 18px; border-radius: 16px; } .hero h1 { font-size: 1.5rem; }
  .top { padding: 8px 12px; } .top nav a, .top nav button.link { padding: 6px 9px; }
  .report { padding: 8px 14px 14px; }
}
@media print {
  .card, .report, .steps li { box-shadow: none; }
  .hero { background: none; color: #000; box-shadow: none; padding: 0; }
  .top { position: static; }
}
@media (max-width: 560px) {
  .top { flex-wrap: nowrap; gap: 8px; }
  .brand { font-size: 1rem; } .brand svg { width: 26px; height: 26px; }
  .top nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .top nav::-webkit-scrollbar { display: none; }
  .top nav a, .top nav button.link { white-space: nowrap; font-size: .92rem; }
}
