/* Stile di Ice Manager (src/app/globals.css): stessi colori, tabelle dense, niente card. */
.privacy { max-width: 720px; margin: 4vh auto; background: #fff; padding: 20px 24px; border: 1px solid #DADAD4; border-radius: 6px; line-height: 1.5; }
.privacy h2 { font-size: 1.05rem; margin: 18px 0 6px; }
:root {
  --bg: #F4F4F1; --fg: #23252A; --muted: #6E7178; --line: #DADAD4; --head: #F3F3F0;
  --accent: oklch(0.50 0.13 250); --red: oklch(0.50 0.19 25); --blue: #0070FD;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
button, select, input, .button { font: inherit; padding: 5px 10px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--fg); }
button, .button { cursor: pointer; text-decoration: none; display: inline-block; }
button.primary, .button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.button.block { display: block; width: 100%; text-align: center; padding: 8px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-header { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; min-height: 44px; padding: 4px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.app-header .brand { display: flex; gap: 8px; align-items: center; font-weight: 700; color: var(--fg); text-decoration: none; }
.app-header .page-title { color: var(--muted); }
.app-header .spacer { flex: 1; }
.app-header .who { color: var(--muted); font-size: 13px; }
.app-header form { margin: 0; }
main { padding: 10px 16px 80px; }
.intro { margin: 4px 0 10px; color: var(--muted); }

form.search { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 4px; }
form.search label, form.search fieldset { display: flex; flex-direction: column; gap: 3px; margin: 0; padding: 0; border: 0; font-size: 12px; color: var(--muted); }
form.search fieldset legend { padding: 0; margin-bottom: 3px; }
form.search .range { display: flex; gap: 6px; }
form.search input { font-size: 14px; color: var(--fg); }
form.search input[name="nome"] { width: 240px; }
form.search input[name="importo"], form.search input[name="da"], form.search input[name="a"] { width: 110px; }
form.search .actions { display: flex; gap: 10px; align-items: center; }

.notice { padding: 8px 12px; background: #fff8e1; border: 1px solid #f0d58a; border-radius: 4px; margin: 10px 0; }
.error-box { padding: 10px 12px; background: #fdecea; border: 1px solid #f5b5ae; color: var(--red); border-radius: 4px; margin: 10px 0; }
.error-box ul { margin: 0; padding-left: 18px; }
.totals { margin: 10px 0 6px; padding: 8px 12px; background: #e8f1ff; border: 1px solid #b9d3f7; border-radius: 4px; font-size: 15px; }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 4px; margin-top: 10px; }
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
table.data th { background: var(--head); position: sticky; top: 0; font-weight: 600; }
table.data td.num, table.data th.num { text-align: right; }
table.data td.wrap { white-space: normal; min-width: 260px; max-width: 520px; overflow-wrap: anywhere; }
table.data td.check, table.data th.check { width: 34px; text-align: center; }
table.data td.check input { width: 18px; height: 18px; margin: 0; cursor: pointer; }
table.data tbody tr:hover > td { background: #f3f7ff; }
table.data tbody tr.picked > td { background: #e8f1ff; }
table.data tfoot td { font-weight: 700; background: var(--head); }
table.data td.empty { text-align: center; color: var(--muted); padding: 16px 8px; white-space: normal; }

.pick-bar { position: sticky; bottom: 0; display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 10px; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 -4px 14px rgba(0,0,0,.06); }
.pick-bar #pick-count { margin-right: auto; color: var(--muted); }
.js .pick-bar #pick-confirm[disabled] { opacity: .5; cursor: not-allowed; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.toolbar form { margin: 0; }

/* Pagina di accesso: come quella di Ice Manager (blu profondo → ghiaccio, cristalli che salgono piano). */
.login-stage { --ls-a: #123f8c; --ls-b: #2a82e0; --ls-c: #a9d8ff; position: relative; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px 16px; overflow: hidden; color: #fff; background: linear-gradient(160deg, var(--ls-a), var(--ls-b) 55%, var(--ls-c)) 0 0 / 220% 220%; animation: ls-bg 26s ease-in-out infinite alternate; }
.login-stage::before { content: ""; position: absolute; inset: 0; pointer-events: none; background-image: radial-gradient(circle, rgba(255,255,255,.7) 0 1.5px, rgba(190,225,255,.18) 5px, transparent 9px), radial-gradient(circle, rgba(255,255,255,.55) 0 1px, rgba(190,225,255,.14) 4px, transparent 7px), radial-gradient(circle, rgba(255,255,255,.4) 0 2px, rgba(190,225,255,.1) 7px, transparent 12px); background-size: 330px 270px, 470px 410px, 610px 530px; background-position: 40px 60px, 210px 200px, 380px 90px; animation: ls-crystals 120s linear infinite; }
.login-brand { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; }
.login-mark { position: relative; display: block; width: clamp(110px, 22vw, 180px); aspect-ratio: 1; border-radius: 13%; overflow: hidden; box-shadow: 0 0 34px rgba(150,210,255,.45), 0 12px 40px rgba(2,20,60,.45); animation: ls-in 1s cubic-bezier(.2,.8,.2,1) both; }
.login-mark img { display: block; width: 100%; height: 100%; }
.login-brand h1 { margin: 18px 0 2px; font-size: 28px; text-shadow: 0 1px 12px rgba(2,20,60,.5); }
.login-brand p { margin: 0; font-size: 13px; color: #dbeeff; }
.login-panel { position: relative; width: 100%; max-width: 340px; padding: 20px; background: #fff; color: var(--fg); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 34px rgba(2,20,60,.35); }
.login-panel .error-box { margin-top: 0; }
.login-panel p { margin: 12px 0 0; text-align: center; }
@keyframes ls-bg { to { background-position: 100% 100%; } }
@keyframes ls-crystals { to { background-position: 40px 1680px, 210px 1840px, 380px 1680px; } }
@keyframes ls-in { from { opacity: 0; transform: scale(.86) translateY(10px); } }
@media (prefers-reduced-motion: reduce) { .login-stage, .login-stage::before, .login-mark { animation: none; } }

form.search .pair { display: flex; gap: 14px; }
form.search .more { display: contents; }
form.search .more-toggle { display: none; }
.install { border-color: var(--blue); color: var(--blue); }
.install-ios { margin: 0; border-radius: 0; border-width: 0 0 1px; }

/* Smartphone (titolare 23/10/2026): come un'app di banca. Tutto sta nella larghezza dello schermo: niente zoom, niente scorrimento
   laterale. Campi a 16px (l'iPhone non ingrandisce la pagina quando li tocchi), tasti grandi, la tabella diventa un elenco a righe:
   ordinante e importo in grande, causale sotto, data e tipo in piccolo. Stessi colori di Ice Manager. */
@media (max-width: 700px) {
  body { font-size: 15px; -webkit-text-size-adjust: 100%; }
  .app-header { position: sticky; top: 0; z-index: 5; gap: 8px; min-height: 52px; padding: 6px 12px; padding-top: max(6px, env(safe-area-inset-top)); flex-wrap: nowrap; }
  .app-header .brand span { font-size: 17px; }
  .app-header .page-title, .app-header .who { display: none; }
  .app-header button { padding: 7px 12px; }
  .hide-mobile { display: none; }
  main { padding: 10px 12px calc(96px + env(safe-area-inset-bottom)); }

  form.search { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; border-radius: 10px; }
  form.search label, form.search fieldset { width: auto; font-size: 13px; }
  form.search > label:first-child, form.search .more, form.search .more-toggle, form.search .actions { grid-column: 1 / -1; }
  form.search .more { display: grid; grid-template-columns: 1fr; gap: 10px; }
  form.search .more.closed { display: none; }
  form.search .more-toggle { display: block; width: 100%; text-align: left; padding: 10px 12px; font-size: 15px; border-radius: 8px; color: var(--accent); background: var(--head); }
  form.search .more-toggle::after { content: " ▾"; }
  form.search .more-toggle.open::after { content: " ▴"; }
  form.search .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  form.search .range { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  form.search input, form.search input[name] { width: 100%; min-width: 0; font-size: 16px; padding: 10px 12px; border-radius: 8px; }
  form.search .actions { display: grid; grid-template-columns: 1fr auto; align-items: center; }
  form.search .actions button { padding: 12px; font-size: 16px; border-radius: 8px; }
  form.search .actions a { padding: 0 6px; }
  main > p.small { margin: 8px 2px; }

  .totals { border-radius: 10px; font-size: 16px; }
  .notice, .error-box { border-radius: 10px; }

  /* La tabella diventa un elenco: ogni movimento è una riga a più livelli, separata da una linea sottile (non un riquadro). */
  .table-wrap { overflow: visible; border-radius: 10px; }
  table.data, table.data tbody, table.data tfoot { display: block; }
  table.data thead { display: none; }
  table.data tbody tr { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name amount" "desc desc" "date type"; column-gap: 10px; row-gap: 3px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.data.pickable tbody tr { grid-template-columns: 30px 1fr auto; grid-template-areas: "check name amount" "check desc desc" "check date type"; }
  table.data tbody tr:last-child { border-bottom: 0; }
  table.data td { display: block; padding: 0; border: 0; white-space: normal; min-width: 0; }
  table.data td.check { grid-area: check; width: auto; align-self: center; text-align: left; }
  table.data td.check input { width: 22px; height: 22px; }
  table.data td.name { grid-area: name; font-weight: 600; overflow-wrap: anywhere; }
  table.data td.amount { grid-area: amount; font-weight: 700; font-size: 16px; text-align: right; white-space: nowrap; }
  table.data td.desc { grid-area: desc; min-width: 0; max-width: none; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
  table.data td.date { grid-area: date; font-size: 12px; color: var(--muted); }
  table.data td.type { grid-area: type; font-size: 12px; color: var(--muted); text-align: right; }
  table.data td.empty { padding: 18px 12px; }
  table.data tbody tr:hover > td { background: transparent; }
  table.data tbody tr.picked { background: #e8f1ff; }
  table.data tbody tr.picked > td { background: transparent; }
  table.data tfoot tr { display: flex; justify-content: space-between; padding: 12px 14px; background: var(--head); border-top: 1px solid var(--line); }
  table.data tfoot td { display: block; padding: 0; border: 0; background: transparent; }

  .pick-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; margin: 0; border-radius: 14px 14px 0 0; border-width: 1px 0 0; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); }
  .pick-bar button { padding: 12px 16px; font-size: 16px; border-radius: 8px; }
  .pick-bar #pick-count { font-size: 14px; }

  .toolbar { display: grid; grid-template-columns: 1fr; gap: 10px; }
  .toolbar .button, .toolbar button, .toolbar form { width: 100%; text-align: center; padding: 12px; font-size: 16px; border-radius: 8px; }
  .toolbar form { padding: 0; }
  .toolbar form button { width: 100%; }

  .login-panel .button.block { padding: 12px; font-size: 16px; border-radius: 8px; }
  .privacy { margin: 0; border-radius: 0; border-width: 0; padding: 18px 16px; }
}
@media print {
  .no-print, .app-header form, .pick-bar { display: none !important; }
  body { background: #fff; }
}
