/* ============================================================
   Mission Control — stile
   Palette: sfondo caldo chiaro, accento teal profondo (fiducia),
   verde/giallo/rosso per stato. Display: Space Grotesk, corpo: Inter.
   ============================================================ */

:root {
  --bg: #F6F5F1;
  --surface: #FFFFFF;
  --ink: #1B2430;
  --ink-soft: #5B6572;
  --line: #E4E2DA;
  --accent: #0E7C7B;
  --accent-soft: #E3F0EF;
  --green: #2E9E5B;
  --green-soft: #E5F4EB;
  --amber: #D9822B;
  --amber-soft: #FBEEDD;
  --red: #C0392B;
  --red-soft: #F9E6E3;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(27,36,48,.05), 0 6px 18px rgba(27,36,48,.06);
  --font-body: "Inter", system-ui, sans-serif;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 { font-family: var(--font-display); margin: 0 0 .5rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; }
h3 { font-size: .92rem; }
.muted { color: var(--ink-soft); font-size: .85rem; }
code { background: var(--accent-soft); padding: 1px 5px; border-radius: 5px; font-size: .85em; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------------- bottoni ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  font: 600 .88rem var(--font-body);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .5rem .85rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #0A6362; color: #fff; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #24824A; color: #fff; }
.btn-ghost { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.35); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,.22); border-color: #fff; color: #fff; }
.btn-icon { padding: .45rem; }
.btn-small { font-size: .8rem; padding: .35rem .65rem; }
.btn-block { width: 100%; justify-content: center; }
.btn svg, .btn i { width: 16px; height: 16px; }

/* ---------------- login ---------------- */
.login-view {
  min-height: 100vh; display: grid; place-items: center; padding: 1rem;
}
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 2rem; width: min(380px, 100%);
  display: flex; flex-direction: column; gap: .6rem;
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--accent); }
.brand h1 { font-size: 1.3rem; margin: 0; color: var(--ink); }
.brand-mark { width: 30px; height: 30px; }
.login-sub { margin: 0 0 .8rem; color: var(--ink-soft); font-size: .85rem; }
label { font-weight: 600; font-size: .82rem; }
input, select, textarea {
  font: 400 .95rem var(--font-body); color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px;
  padding: .55rem .7rem; background: #FCFCFA; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.field-error { color: var(--red); font-size: .82rem; margin: .2rem 0 0; }

/* ---------------- ponte di comando ---------------- */
.bridge {
  background: linear-gradient(135deg, #123A3F 0%, #0E7C7B 100%);
  color: #fff;
  padding: 1rem 1.2rem .4rem;
  box-shadow: var(--shadow);
}
.bridge-inner {
  display: grid;
  grid-template-columns: auto auto auto 1fr auto auto;
  gap: 1.4rem; align-items: center;
  max-width: 1240px; margin: 0 auto;
}
.bridge-brand { display: flex; align-items: center; gap: .5rem; }
.bridge-title { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
.bridge .brand-mark { color: #fff; }

.bridge-countdown { display: flex; flex-direction: column; line-height: 1.1; }
.count-num { font: 700 2rem var(--font-display); }
.count-label { font-size: .72rem; opacity: .85; text-transform: uppercase; letter-spacing: .04em; }

.bridge-ring { position: relative; width: 84px; height: 84px; }
.ring { width: 84px; height: 84px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,.25); stroke-width: 8; }
.ring-fg {
  fill: none; stroke: #fff; stroke-width: 8; stroke-linecap: round;
  stroke-dasharray: 226.2; stroke-dashoffset: 226.2;
  transition: stroke-dashoffset .8s ease;
}
.ring-pct {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 700 1rem var(--font-display);
}

.bridge-month { display: flex; flex-direction: column; min-width: 0; }
.month-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; opacity: .85; }
.month-title { font-family: var(--font-display); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.month-state { font-size: .78rem; opacity: .9; }

.bridge-light { position: relative; display: flex; align-items: center; gap: .5rem; cursor: help; }
.light-dot { width: 18px; height: 18px; border-radius: 50%; box-shadow: 0 0 0 4px rgba(255,255,255,.2); }
.light-dot.verde { background: #4ADE80; }
.light-dot.giallo { background: #FBBF24; }
.light-dot.rosso { background: #F87171; }
.light-label { font-weight: 600; font-size: .85rem; }

.tooltip {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 30;
  background: var(--ink); color: #fff; font-size: .78rem; line-height: 1.4;
  padding: .6rem .75rem; border-radius: 9px; width: 240px;
  opacity: 0; pointer-events: none; transition: opacity .15s;
  box-shadow: var(--shadow);
}
.tooltip-wide { width: 320px; }
.bridge-ring:hover .tooltip, .bridge-ring:focus .tooltip,
.bridge-light:hover .tooltip, .bridge-light:focus .tooltip { opacity: 1; }

.bridge-actions { display: flex; gap: .5rem; align-items: center; }

.phrase-bar {
  max-width: 1240px; margin: .8rem auto 0; padding: .55rem .2rem .7rem;
  display: flex; gap: .55rem; align-items: flex-start;
  border-top: 1px solid rgba(255,255,255,.25);
  font-size: .9rem; font-style: italic; opacity: .95;
}
.phrase-icon { width: 16px; height: 16px; flex: none; margin-top: 2px; }

/* ---------------- NO-GO banner ---------------- */
.nogo-banner {
  background: var(--red); color: #fff;
  display: flex; gap: .6rem; align-items: flex-start;
  padding: .8rem 1.2rem; font-weight: 600; font-size: .9rem;
}
.nogo-banner svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }

/* ---------------- griglia principale ---------------- */
.grid {
  max-width: 1240px; margin: 1.4rem auto; padding: 0 1.2rem;
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 1.1rem;
}
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem;
  display: flex; flex-direction: column; min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.card-hint { margin: 0 0 .6rem; color: var(--ink-soft); font-size: .8rem; }
.card-foot { margin-top: auto; padding-top: .7rem; }

/* ---------------- KPI ---------------- */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .8rem;
}
.kpi {
  border: 1px solid var(--line); border-left-width: 5px; border-radius: 11px;
  padding: .65rem .8rem; background: #FDFDFB;
  display: flex; flex-direction: column; gap: .15rem;
  text-align: left; cursor: pointer; font: inherit; color: inherit;
  transition: box-shadow .15s, transform .1s;
}
.kpi:hover { box-shadow: var(--shadow); }
.kpi.verde { border-left-color: var(--green); }
.kpi.giallo { border-left-color: var(--amber); }
.kpi.rosso { border-left-color: var(--red); }
.kpi.auto { cursor: default; }
.kpi-label { font-size: .76rem; color: var(--ink-soft); display: flex; gap: .35rem; align-items: center; }
.kpi-label svg { width: 12px; height: 12px; }
.kpi-value { font: 700 1.25rem var(--font-display); }
.kpi-target { font-size: .74rem; color: var(--ink-soft); }
.kpi-trend { display: flex; gap: 2px; align-items: flex-end; height: 16px; margin-top: .2rem; }
.kpi-trend span { width: 6px; background: var(--accent); opacity: .5; border-radius: 2px 2px 0 0; min-height: 2px; }

/* ---------------- grafici ---------------- */
.chart-box { position: relative; height: 210px; }

/* ---------------- timeline ---------------- */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ms {
  display: grid; grid-template-columns: auto 1fr auto; gap: .9rem;
  padding: .75rem .2rem; border-bottom: 1px solid var(--line); align-items: center;
}
.ms:last-child { border-bottom: none; }
.ms-check {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--line); background: #fff; cursor: pointer;
  display: grid; place-items: center; color: #fff; flex: none;
  transition: background .15s, border-color .15s;
}
.ms-check:hover { border-color: var(--green); }
.ms.done .ms-check { background: var(--green); border-color: var(--green); }
.ms-check svg { width: 15px; height: 15px; }
.ms-body { min-width: 0; }
.ms-month { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); font-weight: 700; }
.ms-title { font-weight: 600; }
.ms.done .ms-title { color: var(--ink-soft); text-decoration: line-through; text-decoration-thickness: 1px; }
.ms-crit { font-size: .78rem; color: var(--ink-soft); }
.ms-date { font-size: .74rem; color: var(--green); font-weight: 600; }
.ms-reward {
  font-size: .74rem; padding: .3rem .6rem; border-radius: 999px;
  border: 1px dashed var(--line); color: var(--ink-soft);
  display: inline-flex; gap: .3rem; align-items: center; max-width: 190px;
}
.ms-reward svg { width: 13px; height: 13px; flex: none; }
.ms.done .ms-reward { border-style: solid; border-color: var(--green); background: var(--green-soft); color: var(--green); font-weight: 600; }

/* ---------------- todoist ---------------- */
.td-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: .8rem; }
.td-stat { background: #FDFDFB; border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; }
.td-num { font: 700 1.2rem var(--font-display); }
.td-lbl { font-size: .72rem; color: var(--ink-soft); }
.td-next { background: var(--accent-soft); border-radius: 10px; padding: .6rem .75rem; margin-bottom: .7rem; }
.td-next-lbl { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); font-weight: 700; }
.td-list { list-style: none; margin: .3rem 0 0; padding: 0; font-size: .82rem; color: var(--ink-soft); }
.td-list li { padding: .2rem 0; border-bottom: 1px dotted var(--line); }
.td-list li:last-child { border-bottom: none; }
.td-empty { color: var(--ink-soft); font-size: .85rem; background: #FDFDFB; border: 1px dashed var(--line); border-radius: 10px; padding: .8rem; }
.td-link { color: var(--accent); font-weight: 600; font-size: .82rem; text-decoration: none; }
.td-link:hover { text-decoration: underline; }

/* ---------------- vendita ---------------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .7rem; }
.stat { background: #FDFDFB; border: 1px solid var(--line); border-radius: 10px; padding: .6rem .75rem; }
.stat-num { font: 700 1.35rem var(--font-display); color: var(--accent); }
.stat-lbl { font-size: .72rem; color: var(--ink-soft); }
.reframe { margin-top: .8rem; }

/* ---------------- vittorie ---------------- */
.wins-list { list-style: none; margin: 0 0 .8rem; padding: 0; }
.wins-list li {
  display: flex; gap: .55rem; padding: .45rem 0; border-bottom: 1px dotted var(--line);
  font-size: .88rem; align-items: baseline;
}
.wins-list li:last-child { border-bottom: none; }
.win-date { color: var(--ink-soft); font-size: .74rem; flex: none; width: 78px; }
.wins-empty { color: var(--ink-soft); font-size: .85rem; padding: .5rem 0; }
.rewards-title { margin-top: .4rem; }
.rewards { display: flex; flex-wrap: wrap; gap: .5rem; }
.reward-badge {
  font-size: .76rem; font-weight: 600; color: var(--green);
  background: var(--green-soft); border: 1px solid var(--green);
  border-radius: 999px; padding: .3rem .7rem;
  display: inline-flex; gap: .35rem; align-items: center;
}
.reward-badge svg { width: 13px; height: 13px; }
.rewards .muted { padding: .2rem 0; }

/* ---------------- modali ---------------- */
.modal { border: none; border-radius: var(--radius); box-shadow: 0 20px 60px rgba(27,36,48,.25); padding: 0; width: min(480px, calc(100vw - 2rem)); }
.modal::backdrop { background: rgba(27,36,48,.45); }
.modal-inner { padding: 1.3rem 1.4rem 1.4rem; display: flex; flex-direction: column; gap: .7rem; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { display: flex; gap: .5rem; align-items: center; margin: 0; }
.modal-head svg { width: 19px; height: 19px; color: var(--accent); }
.modal-phrase { font-style: italic; background: var(--accent-soft); border-radius: 10px; padding: .7rem .85rem; margin: 0; }

.next-action { background: #FDFDFB; border: 1px solid var(--line); border-radius: 10px; padding: .7rem .85rem; }
.pomodoro { text-align: center; padding: .4rem 0 .2rem; }
.pomo-time { font: 700 2.6rem var(--font-display); letter-spacing: .02em; display: block; }
.pomo-btns { display: flex; gap: .5rem; justify-content: center; margin-top: .4rem; }

.morale-proof { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.morale-proof .stat { text-align: center; }
.morale-why h3 { margin: .5rem 0 .1rem; color: var(--accent); }
.morale-why p { margin: 0; font-size: .9rem; }
.morale-replan { background: var(--amber-soft); border-radius: 10px; padding: .8rem .9rem; }
.morale-replan h3 { margin: 0 0 .2rem; }
.morale-replan p { margin: 0 0 .6rem; font-size: .85rem; }
.replan-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.replan-row select { width: auto; flex: 1; }
.checkin h3 { margin: .3rem 0 .4rem; }
.mood-row { display: flex; gap: .5rem; }
.mood {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1.5px solid var(--line); background: #fff;
  font: 600 .95rem var(--font-body); cursor: pointer;
}
.mood:hover, .mood.sel { border-color: var(--accent); background: var(--accent-soft); }
.gentle-note { font-size: .82rem; color: var(--ink-soft); border-top: 1px solid var(--line); padding-top: .7rem; margin: .3rem 0 0; }

/* ---------------- toast ---------------- */
.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: .88rem; font-weight: 500;
  padding: .65rem 1.1rem; border-radius: 999px; box-shadow: var(--shadow); z-index: 100;
}
.toast.err { background: var(--red); }

.foot { max-width: 1240px; margin: 0 auto 1.4rem; padding: 0 1.2rem; }

/* ---------------- responsive ---------------- */
@media (max-width: 1020px) {
  .bridge-inner { grid-template-columns: 1fr 1fr; gap: .9rem; }
  .bridge-actions { grid-column: 1 / -1; flex-wrap: wrap; }
  .span-4, .span-6, .span-8 { grid-column: span 12; }
}
@media (max-width: 560px) {
  .bridge-inner { grid-template-columns: 1fr; }
  .tooltip, .tooltip-wide { width: min(300px, 84vw); left: 0; right: auto; }
  .ms { grid-template-columns: auto 1fr; }
  .ms-reward { grid-column: 2; justify-self: start; }
  .morale-proof { grid-template-columns: 1fr; }
}
