/* Pilot Flight Log — stile ispirato a iOS, chiaro/scuro automatico */
:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --card-2: #f7f7fa;
  --text: #1c1c1e;
  --muted: #6e6e73;
  --line: rgba(60, 60, 67, .14);
  --accent: #0a63d1;
  --accent-ink: #ffffff;
  --accent-soft: rgba(10, 99, 209, .10);
  --ok: #1f8a3d; --ok-soft: rgba(31, 138, 61, .12);
  --warn: #a35c00; --warn-soft: rgba(230, 140, 0, .15);
  --bad: #c62828; --bad-soft: rgba(198, 40, 40, .12);
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 2px 10px rgba(0, 0, 0, .04);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --tabbar-h: 58px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --card: #1c1c1e; --card-2: #2c2c2e; --text: #f2f2f7; --muted: #98989f;
    --line: rgba(235, 235, 245, .14); --accent: #3d8bff; --accent-soft: rgba(61, 139, 255, .16);
    --ok: #4cc96b; --ok-soft: rgba(76, 201, 107, .16); --warn: #ffb340; --warn-soft: rgba(255, 179, 64, .16);
    --bad: #ff6b60; --bad-soft: rgba(255, 107, 96, .16); --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --card: #1c1c1e; --card-2: #2c2c2e; --text: #f2f2f7; --muted: #98989f;
  --line: rgba(235, 235, 245, .14); --accent: #3d8bff; --accent-soft: rgba(61, 139, 255, .16);
  --ok: #4cc96b; --ok-soft: rgba(76, 201, 107, .16); --warn: #ffb340; --warn-soft: rgba(255, 179, 64, .16);
  --bad: #ff6b60; --bad-soft: rgba(255, 107, 96, .16); --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); letter-spacing: .02em; }
.muted { color: var(--muted); font-size: 14px; }
.strong { font-weight: 600; }
.grow { flex: 1; min-width: 0; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 4px 0; }
.hint.center { text-align: center; margin: 28px 0 8px; }
.danger-text { color: var(--bad); }
.ico { display: inline-flex; flex-shrink: 0; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- layout ---------- */
.app { min-height: 100vh; }
main { padding: calc(env(safe-area-inset-top) + 8px) 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px); outline: none; }
.view { max-width: 960px; margin: 0 auto; }
.view.narrow { max-width: 680px; }
.view-head { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 14px 0 12px; }
.view-head h1 { font-size: 30px; font-weight: 700; flex: 1; }
.view-head .btn.ghost + h1 { font-size: 22px; text-align: right; }
.section-title { font-size: 20px; font-weight: 700; margin: 26px 0 10px; }
.group-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 4px 8px; }

.sidebar { display: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around; align-items: stretch;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--card) 86%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}
.tabbar .nav-link { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); font-weight: 500; }
.tabbar .nav-link.active { color: var(--accent); }
.tabbar .nav-new .ico { background: var(--accent); color: var(--accent-ink); border-radius: 50%; padding: 3px; }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 240px 1fr; }
  .tabbar { display: none; }
  .sidebar { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; padding: 20px 12px; border-right: 1px solid var(--line); background: var(--card); }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 6px 12px 20px; }
  .brand .ico { color: var(--accent); }
  .sidebar .nav-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text); font-weight: 500; }
  .sidebar .nav-link:hover { background: var(--card-2); }
  .sidebar .nav-link.active { background: var(--accent-soft); color: var(--accent); }
  main { padding: 16px 40px 48px; }
}

/* ---------- componenti ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.group { padding: 4px 16px 12px; }
.card.list { overflow: hidden; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 0; cursor: pointer;
  font: 600 16px var(--font); background: var(--card-2); color: var(--accent); white-space: nowrap;
}
.btn.small { min-height: 36px; padding: 0 12px; font-size: 15px; border-radius: 10px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger.ghost { background: var(--bad-soft); color: var(--bad); }
.btn.block { width: 100%; }
.btn:active { opacity: .7; }
.btn:focus-visible, a:focus-visible, input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.row-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }

.hero { padding: 22px 20px; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #001a40)); color: #fff; }
.hero-label { font-size: 14px; opacity: .85; font-weight: 500; }
.hero-value { font-size: 48px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; margin: 4px 0; }
.hero-sub { font-size: 14px; opacity: .85; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
@media (min-width: 600px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--card); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; }
.tiles.compact .tile { background: var(--card-2); box-shadow: none; }
.tile-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.tile-value { font-size: 24px; font-weight: 700; margin-top: 2px; }
.tile-value.small { font-size: 17px; }
.tile-sub { font-size: 12px; color: var(--muted); }

.status { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; margin-top: 12px; }
.status.ok .ico { color: var(--ok); }
.status.warn .ico { color: var(--warn); }
.pill { font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }

.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card.group .list-row { padding: 12px 0; }
.list-row:last-child { border-bottom: 0; }
.warn-row .ico { color: var(--warn); align-self: flex-start; margin-top: 2px; }
.warn-fix .muted { white-space: nowrap; }
.warn-fix { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.warn-fix input { width: auto; flex: 0 1 200px; min-height: 38px; padding: 6px 10px; font-size: 16px; }

.entry { display: flex; align-items: center; gap: 12px; padding: 10px 16px; color: var(--text); border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; }
.entry:hover { background: var(--card-2); }
.entry-date { display: flex; flex-direction: column; align-items: center; width: 34px; flex-shrink: 0; line-height: 1.1; }
.entry-date .d { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.entry-date .m { font-size: 11px; color: var(--muted); font-weight: 600; }
.entry-main { flex: 1; min-width: 0; }
.entry-route { font-family: var(--mono); font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.entry-route .arrow { color: var(--muted); font-family: var(--font); }
.entry-route .ico { color: var(--muted); }
.entry-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-time { font-weight: 600; font-size: 16px; }
.tag { font-family: var(--font); font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 1px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); margin-left: 4px; }

.month { margin-bottom: 18px; }
.month-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px 6px; font-weight: 600; font-size: 15px; }
.link-more { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 14px; font-weight: 500; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar-sub { padding: 8px 4px 12px; }
.search { flex: 1 1 260px; display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 12px; padding: 0 12px; box-shadow: var(--shadow); }
.search .ico { color: var(--muted); }
.search input { border: 0; background: transparent; padding: 11px 0; }
.search input:focus-visible { outline: none; }

.segmented { display: inline-flex; background: var(--card-2); border-radius: 10px; padding: 2px; gap: 2px; }
.card .segmented { background: var(--bg); }
.segmented > * { border: 0; background: transparent; color: var(--text); font: 500 14px var(--font); padding: 7px 10px; white-space: nowrap; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.segmented > .on { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); font-weight: 600; }
.segmented.wide { display: flex; margin: 12px 0 4px; }
.segmented.wide > * { flex: 1; }
.view > .segmented { margin-bottom: 8px; }

/* ---------- form ---------- */
.field { display: flex; flex-direction: column; gap: 4px; padding-top: 12px; min-width: 0; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field-hint { font-size: 12px; color: var(--muted); min-height: 16px; }
.field-hint.unknown { color: var(--warn); }
input, textarea, select {
  width: 100%; font: 17px var(--font); color: var(--text); background: var(--card-2);
  border: 1px solid transparent; border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
input:focus, textarea:focus { border-color: var(--accent); outline: none; background: var(--card); }
input.big { font-size: 24px; font-weight: 700; }
input[type="time"], input[type="date"] { -webkit-appearance: none; appearance: none; }
textarea { resize: vertical; margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid4 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (min-width: 600px) { .grid4 { grid-template-columns: repeat(4, 1fr); } }
.with-chips { display: flex; gap: 6px; align-items: center; }
.with-chips input { flex: 1; min-width: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 0; background: var(--accent-soft); color: var(--accent); font: 600 13px var(--font); padding: 6px 10px; border-radius: 8px; cursor: pointer; min-height: 32px; }
.chip.mono { font-family: var(--mono); }
.ap-wrap { position: relative; }
.suggest { position: absolute; left: 0; right: -60%; top: calc(100% + 4px); z-index: 10; background: var(--card); border-radius: 12px; box-shadow: 0 8px 30px rgba(0, 0, 0, .18); border: 1px solid var(--line); overflow: hidden; max-width: 92vw; }
.suggest button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 10px 12px; font: 15px var(--font); color: var(--text); border-bottom: 1px solid var(--line); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest button:hover, .suggest button:focus { background: var(--accent-soft); }
.grid2 > .field:last-child .suggest { left: -60%; right: 0; }
.route-info { text-align: center; font-size: 13px; min-height: 4px; }
.stepper { display: flex; align-items: center; justify-content: space-between; background: var(--card-2); border-radius: 10px; min-height: 44px; }
.stepper button { border: 0; background: transparent; color: var(--accent); font-size: 22px; width: 44px; height: 44px; cursor: pointer; }
.step-val { font-weight: 700; font-size: 18px; }
.details { margin-top: 14px; }
.details summary { cursor: pointer; color: var(--accent); font-weight: 500; font-size: 15px; padding: 4px 0; }
.form-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }

.empty { padding: 36px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty .ico { color: var(--accent); }
.empty h2 { font-size: 20px; }
.empty p { color: var(--muted); margin: 0; }

.import-preview { padding: 16px; margin-top: 12px; border: 2px solid var(--accent); }
.import-preview h3 { font-size: 18px; }
.import-preview h4 { margin-top: 18px; font-size: 15px; }
.note { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 12px 0 0; }

/* ---------- toast e finestre ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); transform: translate(-50%, 20px); opacity: 0; transition: .25s; z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 500; font-size: 15px; max-width: 90vw; }
.toast.err { background: var(--bad); color: #fff; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.sheet-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); display: flex; align-items: flex-end; justify-content: center; z-index: 40; opacity: 0; transition: opacity .2s; }
.sheet-back.show { opacity: 1; }
.sheet { background: var(--card); width: 100%; max-width: 480px; border-radius: 18px 18px 0 0; padding: 22px 20px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 600px) { .sheet-back { align-items: center; } .sheet { border-radius: 18px; } }
.sheet h3 { font-size: 18px; }
.sheet p { color: var(--muted); margin: 8px 0 18px; }
.sheet-actions { display: flex; gap: 10px; }
.sheet-actions .btn { flex: 1; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---------- fase 2: scadenze ---------- */
.small { font-size: 13px; }
.pad { margin: 0 4px 12px; }
.pad-top { padding-top: 12px; }
.ok-text { color: var(--ok); font-weight: 600; }
.ico { position: relative; }
.badge { position: absolute; top: -6px; right: -10px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font: 700 11px/18px var(--font); text-align: center; }
.link-row { color: var(--text); }
.link-row:hover { background: var(--card-2); }
.link-row > .ico, .alert-banner > .ico:last-child, .link-card > .ico:last-child { color: var(--muted); }

.alert-banner { display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin-bottom: 12px; color: var(--text); }
.alert-banner.bad { background: var(--bad-soft); }
.alert-banner.bad > .ico:first-child { color: var(--bad); }
.alert-banner.warn { background: var(--warn-soft); }
.alert-banner.warn > .ico:first-child { color: var(--warn); }
.alert-banner .grow div { font-size: 14px; color: var(--muted); margin-top: 2px; }
.link-card { color: var(--text); align-items: center; }

.exp-list { display: flex; flex-direction: column; gap: 12px; }
.exp-card { display: block; padding: 14px 16px; color: var(--text); }
.exp-card:hover { box-shadow: 0 2px 14px rgba(0, 0, 0, .08); }
.exp-top { display: flex; gap: 12px; align-items: flex-start; }
.exp-cat { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.exp-title { font-size: 18px; font-weight: 700; margin: 1px 0 2px; }
.exp-note { font-size: 13px; color: var(--muted); margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--card-2); }
.exp-note.open { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

.meter { height: 8px; border-radius: 4px; background: var(--card-2); overflow: hidden; margin-top: 4px; }
.card.group .meter, .exp-card .meter { background: var(--bg); }
.meter.thin { height: 4px; margin-top: 12px; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.meter > span.ok { background: var(--ok); }
.meter > span.warn { background: var(--warn); }
.meter > span.bad { background: var(--bad); }

.sep-req { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.card.group > .sep-req { border-top: 0; padding-top: 4px; }
.req-title { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 15px; }
.req-title .ico { color: var(--accent); }
.req-head { display: flex; justify-content: space-between; font-size: 14px; }

.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 600px) { .tpl-grid { grid-template-columns: repeat(3, 1fr); } }
.tpl { display: flex; flex-direction: column; gap: 4px; padding: 14px; color: var(--text); min-height: 76px; }
.tpl:hover { box-shadow: 0 2px 14px rgba(0, 0, 0, .08); }

.chip.toggle { background: var(--card-2); color: var(--text); font-weight: 500; }
.chip.toggle.on { background: var(--accent); color: var(--accent-ink); }
.check { display: flex; align-items: center; gap: 10px; padding: 12px 0 4px; font-size: 15px; }
.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }
input:disabled { opacity: .45; }
select { -webkit-appearance: none; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.renew { margin-bottom: 4px; border: 1px solid var(--accent-soft); }
.renew .muted { margin: 4px 0 0; }
.renew-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.renew-row input { flex: 0 1 200px; }
.renew .btn { margin-bottom: 4px; }
.notify .list-row > .ico { color: var(--accent); align-self: flex-start; margin-top: 2px; }
.notify .list-row { align-items: flex-start; }
.notify .list-row .btn { align-self: center; }
.tabbar .nav-link span:not(.ico):not(.badge) { white-space: nowrap; }

.form > .note:first-child { margin: 0 0 12px; }

/* ---------- fase 3: esporta ---------- */
.grid2.gap { gap: 10px; }
.view-head .btn.small + .btn.small { margin-left: -4px; }
.export-summary .list-row { padding: 10px 0; }

/* ---------- fase 4: mappa ---------- */
.icon-only { padding: 0 10px; }
@media (min-width: 900px) { .only-phone { display: none; } }
.map-tools { margin-bottom: 12px; }
.map-tools select { width: auto; min-height: 36px; padding: 6px 34px 6px 12px; font-size: 15px; background-color: var(--card); box-shadow: var(--shadow); }
.check.inline { padding: 0; font-size: 14px; }
.map-card { overflow: hidden; }
.map { height: min(62vh, 560px); min-height: 320px; background: var(--card-2); }
@media (max-width: 599px) { .map { height: 56vh; } }
.map .empty { height: 100%; justify-content: center; }
.route-row { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; font: inherit; text-align: left; cursor: pointer; }
.route-row:last-child { border-bottom: 0; }
.right { text-align: right; }
.map + .tiles, .map-card + div + .tiles { margin-top: 12px; }
/* Leaflet nei colori dell'app */
.leaflet-container { font: 13px var(--font); background: var(--card-2); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--card); color: var(--text); box-shadow: 0 6px 24px rgba(0,0,0,.2); }
.leaflet-popup-content { margin: 10px 14px; line-height: 1.45; }
.leaflet-popup-content strong { font-family: var(--mono); }
.pop-muted { color: var(--muted); font-size: 12px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-bar a { background: var(--card); color: var(--text); border-color: var(--line); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--card) 80%, transparent) !important; color: var(--muted); font-size: 10px; }
.leaflet-control-attribution a { color: var(--accent); }
.leaflet-tooltip.ap-label { background: transparent; border: 0; box-shadow: none; padding: 0 2px; font: 700 11px var(--mono); color: #1c1c1e; text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 2px #fff; }
.leaflet-tooltip.ap-label::before { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .leaflet-tooltip.ap-label { color: #f2f2f7; text-shadow: 0 0 3px #000, 0 0 3px #000, 0 0 2px #000; } }
.map.zoom-low .leaflet-tooltip.ap-label.minor { display: none; }

/* ---------- fase 5: statistiche ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head .section-title { margin-bottom: 10px; }
.widgets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: start; }
@media (min-width: 600px) { .widgets { grid-template-columns: repeat(4, minmax(0, 1fr)); } .widgets .wide { grid-column: span 2; } }
@media (max-width: 599px) { .widgets .wide { grid-column: 1 / -1; } }
.widgets.preview { grid-template-columns: 1fr; margin-bottom: 4px; }
.widgets.preview .wide { grid-column: auto; }
.widget { position: relative; min-width: 0; }
.widget .tile-value { font-variant-numeric: normal; }
.chart-card { padding: 14px 16px 10px; }
.w-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.w-title { font-weight: 600; font-size: 15px; }
.w-total { font-size: 20px; font-weight: 700; white-space: nowrap; }
.chart { position: relative; height: 180px; touch-action: pan-y; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: color-mix(in srgb, var(--muted) 60%, transparent); stroke-width: 1; }
.chart .tick { fill: var(--muted); font: 10.5px var(--font); font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--accent); }
.chart .hit { fill: transparent; cursor: pointer; outline: none; }
.chart .hit:focus-visible { stroke: var(--accent); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); opacity: .1; }
.chart .dot { fill: var(--accent); stroke: var(--card); stroke-width: 2; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart-tip { position: absolute; transform: translateX(-50%); background: var(--text); color: var(--bg); font-size: 12.5px; font-weight: 600; padding: 4px 9px; border-radius: 8px; white-space: nowrap; pointer-events: none; z-index: 2; font-variant-numeric: tabular-nums; }
.w-table { margin-top: 6px; font-size: 13px; }
.w-table summary { color: var(--muted); cursor: pointer; font-size: 12.5px; }
.w-table table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.w-table th, .w-table td { text-align: left; padding: 4px 2px; border-bottom: 1px solid var(--line); }
.w-table td.num, .w-table th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.hbars { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 4px; }
.hbar { display: grid; grid-template-columns: minmax(56px, 26%) 1fr auto; align-items: center; gap: 10px; font-size: 14px; }
.hbar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.hbar-track { height: 12px; }
.hbar-fill { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.hbar-fill.other { background: color-mix(in srgb, var(--accent) 40%, var(--card-2)); }
.hbar-value { white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
.goal-meter { height: 12px; margin: 6px 0 8px; border-radius: 6px; background: color-mix(in srgb, var(--accent) 16%, transparent) !important; }
.goal-row { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; flex-wrap: wrap; }
.widgets.editing .widget { outline: 1.5px dashed color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: -1px; padding-bottom: 46px; }
.w-tools { position: absolute; left: 8px; right: 8px; bottom: 8px; display: flex; gap: 4px; justify-content: flex-end; }
.w-tools > * { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 30px; border-radius: 8px; border: 0; background: var(--card-2); color: var(--accent); cursor: pointer; }
.w-tools > *:disabled { opacity: .35; cursor: default; }
.w-tools .danger { color: var(--bad); }
.add-widget { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 64px; color: var(--accent); font-weight: 600; border: 1.5px dashed color-mix(in srgb, var(--accent) 50%, transparent); background: transparent; box-shadow: none; }
.widgets.editing .add-widget { outline: 0; padding-bottom: 0; }
.reset-widgets { grid-column: 1 / -1; justify-self: center; color: var(--muted); }
.kind-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 600px) { .kind-grid { grid-template-columns: repeat(3, 1fr); } }
.kind { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; text-align: left; padding: 12px; border-radius: 12px; border: 1.5px solid transparent; background: var(--card); color: var(--text); font: inherit; cursor: pointer; box-shadow: var(--shadow); }
.kind.on { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- fase 6: calendario e import ---------- */
.view-switch { display: flex; margin: 0 0 12px; }
.view-switch > * { flex: 1; }
.cal { padding: 10px 10px 8px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.cal-title-wrap { text-align: center; }
.cal-title { font-size: 18px; font-weight: 700; }
.cal-sum { font-size: 13px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; touch-action: pan-y; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; padding: 4px 0; }
.cal-cell { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 58px; padding: 6px 2px 4px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.cal-cell.empty { cursor: default; }
.cal-cell:not(.empty):hover { background: var(--card-2); }
.cal-cell.has { background: var(--accent-soft); }
.cal-num { font-size: 15px; font-weight: 500; width: 26px; height: 26px; line-height: 26px; border-radius: 13px; text-align: center; font-variant-numeric: tabular-nums; }
.cal-cell.today .cal-num { background: var(--bad); color: #fff; font-weight: 700; }
.cal-cell.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-marks { display: flex; gap: 3px; height: 6px; }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 3px; background: var(--accent); }
.dot.sim { background: transparent; box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal-hours { font-size: 10.5px; font-weight: 600; color: var(--text); }
.cal-foot { display: flex; align-items: center; gap: 14px; padding: 8px 6px 2px; font-size: 13px; color: var(--muted); }
.cal-foot .btn { margin-left: auto; }
.legend { display: inline-flex; align-items: center; gap: 6px; }
.cal-day { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.cal-day-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 4px; }
.cap::first-letter { text-transform: uppercase; }
.row-gap { display: flex; gap: 8px; }
.map-rows { display: flex; flex-direction: column; gap: 6px; padding: 8px 0 4px; }
.map-row { display: grid; grid-template-columns: 42% 1fr; gap: 10px; align-items: center; font-size: 14px; }
.map-row.set > span { font-weight: 600; }
.map-row select { min-height: 38px; padding: 6px 30px 6px 10px; font-size: 14px; }
.mapping summary { cursor: pointer; font-weight: 600; padding: 12px 0 4px; color: var(--accent); }
.warnbox { background: var(--warn-soft); }
.warnbox summary { cursor: pointer; font-weight: 600; }
.warnbox ul { margin: 8px 0 0; padding-left: 18px; font-size: 13px; }
.preview-list { margin-top: 12px; }
.list-row.off { opacity: .55; }
.ics-row { align-items: flex-start; }
.ics-row > input[type=checkbox] { width: 22px; height: 22px; min-height: 0; margin-top: 4px; accent-color: var(--accent); flex-shrink: 0; }
.ics-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ics-code { width: 64px; min-height: 32px; padding: 4px 6px; font-size: 14px; text-transform: uppercase; }
.right-auto { margin-left: auto; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.warn-text { color: var(--warn); font-weight: 500; }

/* mappa di base: selettore e versione scura della mappa OpenStreetMap */
.map-base-switch { display: flex; background: var(--card); overflow: hidden; }
.map-base-switch button { border: 0; background: var(--card); color: var(--text); font: 600 12px var(--font); padding: 7px 10px; cursor: pointer; border-right: 1px solid var(--line); }
.map-base-switch button:last-child { border-right: 0; }
.map-base-switch button.on { background: var(--accent); color: var(--accent-ink); }
.map.map-invert .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.9) saturate(.7); }

/* barra in basso con 6 voci (Dati incluso) */
.tabbar .nav-link { font-size: 10.5px; min-width: 0; padding: 0 1px; }
.tabbar .nav-link span:not(.ico):not(.badge) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 359px) { .tabbar .nav-link { font-size: 9.5px; } }
