/* =============================================================================
   amoR — Progetto Roma
   Palette e impianto ripresi dall'app originale: fondo sabbia, inchiostro caldo,
   rosso romano. Mobile-first, con adattamento a schermo largo.
   ========================================================================== */

:root {
  --bg: #f6f3ef;
  --surface: #ffffff;
  --surface-2: #fbf9f6;
  --ink: #201d1b;
  --muted: #6f6863;
  --faint: #9a918a;
  --line: #e4ddd4;
  --red: #b3222b;
  --red-dark: #8d1a22;
  --red-soft: #f5e3e2;
  --sand: #efe3ce;
  --green: #3f7d5c;
  --amber: #b07d1e;
  --slate: #2f3a3f;
  --radius: 16px;
  --nav-h: 74px;
  --shadow: 0 2px 10px rgba(60, 45, 35, .05);
  --shadow-lg: 0 12px 34px rgba(60, 45, 35, .12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1817;
    --surface: #232120;
    --surface-2: #2a2725;
    --ink: #f2ede7;
    --muted: #a89f97;
    --faint: #7d746d;
    --line: #3a3532;
    --red: #d2454e;
    --red-dark: #b3222b;
    --red-soft: #3a2020;
    --sand: #3b3227;
    --shadow: 0 2px 10px rgba(0, 0, 0, .25);
    --shadow-lg: 0 12px 34px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Aptos, Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.015em; line-height: 1.2; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--red); }

/* ---------------------------------------------------------------- struttura */
.view {
  padding: calc(18px + env(safe-area-inset-top)) 16px 26px;
  max-width: 780px;
  margin: 0 auto;
  animation: fade .22s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.page-head .brand-mark { width: 46px; height: 46px; border-radius: 13px; background: var(--surface);
  border: 1px solid var(--line); display: grid; place-items: center; flex: 0 0 auto; overflow: hidden; }
.page-head .brand-mark img { width: 82%; height: 82%; object-fit: contain; }
.page-head-txt { flex: 1 1 auto; min-width: 0; }
.eyebrow { font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase; color: var(--red); font-weight: 650; }
.page-head h1 { font-size: 25px; }
.page-head .sub { font-size: 13px; color: var(--muted); }

.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--slate); color: #fff;
  display: grid; place-items: center; font-weight: 650; font-size: 15px; flex: 0 0 auto; }

/* ------------------------------------------------------------------- schede */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.section { margin-top: 24px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.section-heading h2 { font-size: 12px; letter-spacing: .11em; text-transform: uppercase; color: var(--muted); font-weight: 650; }
.section-heading button { background: none; border: none; color: var(--red); font-size: 12.5px; font-weight: 600; padding: 0; }

/* ------------------------------------------------------------ home: avanzam. */
.progress-card {
  background: linear-gradient(135deg, var(--red) 0%, #9d2b2b 55%, #7d3030 100%);
  color: #fff; border-radius: 20px; padding: 20px;
  display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow-lg);
}
.progress-copy { flex: 1 1 auto; min-width: 0; }
.progress-copy .eyebrow { color: rgba(255,255,255,.78); }
.progress-copy h2 { font-size: 23px; margin: 3px 0 4px; }
.progress-copy p { font-size: 12.5px; color: rgba(255,255,255,.8); }
.donut { flex: 0 0 auto; width: 108px; height: 108px; position: relative; }
.donut svg { transform: rotate(-90deg); }
.donut-txt { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.donut-txt b { display: block; font-size: 23px; line-height: 1; }
.donut-txt span { font-size: 10px; color: rgba(255,255,255,.8); }

.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 13px 10px; text-align: center; box-shadow: var(--shadow); }
.metric .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  margin: 0 auto 7px; background: var(--red-soft); font-size: 16px; }
.metric b { display: block; font-size: 21px; }
.metric span { font-size: 11px; color: var(--muted); }

.wide-card { display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 15px; margin-top: 12px;
  background: var(--surface); box-shadow: var(--shadow); }
.wide-card.dark { background: var(--slate); border-color: transparent; color: #fff; }
.wide-card.dark .eyebrow { color: rgba(255,255,255,.62); }
.wide-card.dark .sub { color: rgba(255,255,255,.66); }
.wide-card .ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: var(--sand); font-size: 19px; flex: 0 0 auto; }
.wide-card.dark .ico { background: rgba(255,255,255,.12); }
.wide-card .body { flex: 1 1 auto; min-width: 0; }
.wide-card .body h3 { font-size: 15.5px; }
.wide-card .sub { font-size: 12.5px; color: var(--muted); }
.wide-card .pct { font-weight: 700; font-size: 15px; flex: 0 0 auto; }

.live-dot { font-size: 9.5px; font-weight: 700; letter-spacing: .1em; color: var(--red);
  background: var(--red-soft); border-radius: 99px; padding: 3px 8px; flex: 0 0 auto; }

/* -------------------------------------------------------------- lista luoghi */
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 13px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters select, .filters input {
  background: var(--surface); border: 1px solid var(--line); border-radius: 99px;
  padding: 8px 13px; font-size: 13px; outline: none; flex: 0 0 auto; max-width: 190px;
}
.filters input { flex: 1 1 150px; min-width: 130px; }
.filters select:focus, .filters input:focus { border-color: var(--red); }

.place-list { display: flex; flex-direction: column; gap: 9px; }
.place {
  display: block; width: 100%; text-align: left; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; box-shadow: var(--shadow);
}
.place:active { transform: scale(.995); }
.place .top { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.place .zona { font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 650;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place h3 { font-size: 15.5px; margin: 1px 0 2px; }
.place .meta { font-size: 12px; color: var(--muted); }
.place .foot { display: flex; align-items: center; gap: 9px; margin-top: 9px; }
.bar { flex: 1 1 auto; height: 5px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--red); border-radius: 99px; transition: width .3s; }
.pct-sm { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 auto; }

.pill { font-size: 10px; font-weight: 650; letter-spacing: .04em; border-radius: 99px; padding: 3px 8px; flex: 0 0 auto; }
.pill-a { background: var(--red); color: #fff; }
.pill-b { background: var(--sand); color: #6b5533; }
.pill-c { background: var(--line); color: var(--muted); }
.pill-stato { background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-weight: 600; }
.pill-ok { background: #e3f0e8; color: var(--green); }
.pill-warn { background: #fbeed3; color: var(--amber); }
.pill-stop { background: var(--red-soft); color: var(--red-dark); }
@media (prefers-color-scheme: dark) {
  .pill-ok { background: #22392e; } .pill-warn { background: #3a2f18; }
  .pill-b { color: var(--sand); }
}

.empty { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 14px; }

/* ------------------------------------------------------------ dettaglio luogo */
.detail-head { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 16px; }
.back-btn { width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; flex: 0 0 auto; font-size: 17px; }
.field { border-top: 1px solid var(--line); padding: 11px 0; }
.field:first-child { border-top: none; padding-top: 0; }
.field dt { font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); font-weight: 650; margin-bottom: 3px; }
.field dd { margin: 0; font-size: 14px; }

.steps { display: flex; flex-direction: column; gap: 7px; }
.step { display: flex; align-items: flex-start; gap: 11px; padding: 10px 12px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line); text-align: left; width: 100%; }
.step.done { background: var(--red-soft); border-color: transparent; }
.step .box { width: 21px; height: 21px; border-radius: 6px; border: 1.8px solid var(--line);
  display: grid; place-items: center; flex: 0 0 auto; margin-top: 1px; font-size: 12px; color: #fff; }
.step.done .box { background: var(--red); border-color: var(--red); }
.step .txt { flex: 1 1 auto; min-width: 0; }
.step .txt b { display: block; font-size: 14px; font-weight: 620; }
.step .txt span { font-size: 12px; color: var(--muted); }

textarea.note {
  width: 100%; min-height: 88px; resize: vertical; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); outline: none;
}
textarea.note:focus { border-color: var(--red); }

.btn { border: none; border-radius: 12px; padding: 11px 17px; font-weight: 620; font-size: 14px; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-ghost { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.btn-row { display: flex; gap: 9px; margin-top: 13px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ riprese */
.step-num { width: 30px; height: 30px; border-radius: 9px; background: var(--sand); color: #6b5533;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: 0 0 auto; }

/* --------------------------------------------------------------- calendario */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.cal-head h2 { font-size: 17px; }
.cal-nav { display: flex; gap: 7px; }
.cal-nav button { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 10.5px; color: var(--faint); font-weight: 650; padding-bottom: 5px; }
.cal-day { aspect-ratio: 1; border-radius: 10px; border: 1px solid transparent; background: var(--surface);
  display: grid; place-items: center; position: relative; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.cal-day.other { color: var(--faint); background: transparent; }
.cal-day.today { border-color: var(--red); font-weight: 700; color: var(--red); }
.cal-day.sel { background: var(--red); color: #fff; font-weight: 700; }
.cal-day .dot { position: absolute; bottom: 5px; width: 4px; height: 4px; border-radius: 50%; background: var(--red); }
.cal-day.sel .dot { background: #fff; }

.appt { display: flex; gap: 11px; align-items: flex-start; padding: 12px 13px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 13px; margin-bottom: 8px; box-shadow: var(--shadow); }
.appt .when { font-size: 12px; font-weight: 700; color: var(--red); flex: 0 0 auto; min-width: 42px; font-variant-numeric: tabular-nums; }
.appt .body { flex: 1 1 auto; min-width: 0; }
.appt .body b { font-size: 14.5px; font-weight: 620; }
.appt .body span { display: block; font-size: 12px; color: var(--muted); }
.appt .del { border: none; background: none; color: var(--faint); font-size: 16px; padding: 0 3px; flex: 0 0 auto; }
.appt .del:hover { color: var(--red); }

/* ------------------------------------------------------------------- modale */
.modal-bg { position: fixed; inset: 0; background: rgba(25, 20, 17, .5); backdrop-filter: blur(3px);
  z-index: 900; display: grid; place-items: center; padding: 20px; animation: fade .16s ease; }
.modal { background: var(--bg); border-radius: 18px; padding: 20px; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg); max-height: 88vh; overflow-y: auto; }
.modal h2 { font-size: 18px; margin-bottom: 14px; }
.modal label { display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); font-weight: 650; margin: 12px 0 5px; }
.modal input, .modal select, .modal textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface); outline: none;
}
.modal input:focus, .modal select:focus, .modal textarea:focus { border-color: var(--red); }

/* --------------------------------------------------------------------- nav */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  display: flex; align-items: stretch;
}
.nav-item { flex: 1 1 0; border: none; background: none; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 10.5px; font-weight: 600; }
.nav-item .nav-ico { font-size: 19px; line-height: 1; }
.nav-item-active { color: var(--red); }
.nav-item-active .nav-ico { transform: translateY(-1px); }

/* ------------------------------------------------------------------- accesso */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.gate .card { max-width: 340px; text-align: center; padding: 28px 24px; }
.gate img { width: 78px; margin-bottom: 14px; }
.gate h1 { font-size: 22px; margin-bottom: 5px; }
.gate p { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.gate input { width: 100%; text-align: center; letter-spacing: .3em; font-size: 18px;
  padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); outline: none; }
.gate input:focus { border-color: var(--red); }
.gate .err { color: var(--red); font-size: 12.5px; margin-top: 10px; min-height: 18px; }

.sync { position: fixed; top: calc(10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  background: var(--slate); color: #fff; font-size: 12px; padding: 6px 14px; border-radius: 99px;
  z-index: 800; opacity: 0; pointer-events: none; transition: opacity .25s; box-shadow: var(--shadow-lg); }
.sync.on { opacity: 1; }

@media (min-width: 720px) {
  .metric-grid { gap: 13px; }
  .view { padding-top: 26px; }
}
