/* ===== App di gestione (pensata per il telefono) ===== */
body.admin { min-height: 100dvh; }
body.admin .toasts { bottom: calc(92px + env(safe-area-inset-bottom)); }

/* ----- Accesso ----- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 28px 22px; box-shadow: var(--shadow); }
.login-card { text-align: center; }
.login-card .field, .login-card .form-err { text-align: left; }
.login-card h1 { font-family: var(--brand); font-size: 24px; letter-spacing: .03em; margin: 8px 0 2px; }
.login-card .muted { margin-bottom: 22px; }
.login-logo { width: 160px; height: auto; margin: 0 auto; }

/* ----- Struttura ----- */
.appbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  max-width: 760px; margin: 0 auto; padding: calc(10px + env(safe-area-inset-top)) 10px 8px 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.appbar-logo { height: 35px; width: auto; flex: none; margin-right: 4px; }
.appbar h1 { font-family: var(--display); font-size: 30px; letter-spacing: -.01em; margin: 0; flex: 1; }
#btn-aggiorna.gira .i { animation: spin .8s linear infinite; }
.demo-banner { max-width: 728px; margin: 0 auto 8px; padding: 10px 14px; border-radius: 12px; background: var(--amber-soft); color: var(--amber); font-size: 14px; }
.demo-banner a { color: inherit; font-weight: 700; }
@media (max-width: 760px) { .demo-banner { margin: 0 16px 8px; } }
.admin-main { max-width: 760px; margin: 0 auto; padding: 0 16px calc(110px + env(safe-area-inset-bottom)); }
.tools { display: grid; gap: 10px; margin: 4px 0 6px; }

/* ----- Barra in basso ----- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
@media (min-width: 780px) {
  .tabbar { left: 50%; right: auto; transform: translateX(-50%); width: 760px; border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; box-shadow: var(--shadow); }
}
.tabbar button {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: none; color: var(--ink-2); font-size: 12px; font-weight: 600; min-height: 56px; border-radius: 12px; padding: 4px 0;
}
.tabbar button .i { width: 24px; height: 24px; }
.tabbar button > .i { margin: 4px 0; }
.tabbar button[aria-current=page] { color: var(--accent-text); }
.tabbar button[aria-current=page] .i { stroke-width: 2.4; }
.tab-add .plus { width: 48px; height: 32px; border-radius: 999px; background: var(--gold); color: var(--accent-ink); display: grid; place-items: center; }
.tab-add .plus .i { stroke-width: 2.6; }
.tab-badge {
  position: absolute; top: 3px; left: calc(50% + 5px); min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--red); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--surface);
}

/* ----- Lista richieste ----- */
.day { font-size: 12px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .07em; margin: 18px 4px 8px; }
.req {
  width: 100%; text-align: left; display: grid; gap: 6px; margin-bottom: 10px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); position: relative;
}
.req:active { background: var(--surface-2); }
.req.is-new { border-left: 4px solid var(--accent); padding-left: 13px; }
.req-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.req-name { font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req time { font-size: 13px; color: var(--ink-2); flex: none; }
.req-sub { font-size: 14px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.req-bot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.req-code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--ink-2); }
.thumbs { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.thumbs img { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; background: var(--surface-2); }
.thumbs .more { font-size: 12px; font-weight: 700; color: var(--ink-2); padding-left: 2px; }

/* ----- Lista articoli ----- */
.prod {
  width: 100%; display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px 10px 10px; margin-bottom: 8px;
}
.prod:active { background: var(--surface-2); }
.prod img { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--surface-2); }
.prod-t { min-width: 0; }
.prod-t strong { font-size: 15px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prod-t small { color: var(--ink-2); font-size: 13px; display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.prod-t small .i { width: 14px; height: 14px; }
.prod-s { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.prod.nascosto img { opacity: .5; }
.conta { font-size: 13px; color: var(--ink-2); margin: 8px 4px; }

/* ----- Finestre a tutto schermo ----- */
dialog.full { width: 100%; max-width: 760px; height: 100dvh; max-height: 100dvh; margin: 0 auto; border-radius: 0; }
dialog.full[open] { animation: sale .22s ease; }
@keyframes sale { from { transform: translateY(24px); opacity: 0; } }
@media (min-width: 780px) { dialog.full { height: calc(100dvh - 32px); max-height: calc(100dvh - 32px); margin: 16px auto; border-radius: var(--r-lg); } }
.full-in { display: flex; flex-direction: column; height: 100%; }
.dlg-bar { display: flex; align-items: center; gap: 6px; padding: calc(6px + env(safe-area-inset-top)) 8px 6px; border-bottom: 1px solid var(--line); min-height: 60px; flex: none; }
.dlg-bar h2 { flex: 1; font-size: 18px; margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-body { flex: 1; overflow: auto; padding: 8px 16px 32px; overscroll-behavior: contain; }
.dlg-foot { display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); flex: none; }
.dlg-foot .btn { flex: 1; }

/* ----- Dettaglio richiesta ----- */
.blk { padding: 18px 0; border-bottom: 1px solid var(--line); }
.blk:last-of-type { border-bottom: 0; }
.blk h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2); margin: 0 0 10px; }
.cli-nome { font-family: var(--display); font-size: 30px; letter-spacing: -.01em; margin: 4px 0 2px; }
.cli-riga { margin: 0; color: var(--ink-2); overflow-wrap: anywhere; }
.cli-riga a { color: var(--ink); font-weight: 600; text-decoration: none; }
.azioni { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin-top: 14px; }
.azioni .btn { padding-inline: 10px; }
.pref { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-top: 8px; }
.messaggio { margin: 0; background: var(--surface-2); border-radius: 12px; padding: 12px 14px; white-space: pre-line; overflow-wrap: anywhere; }
.arts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.art { width: 100%; display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; text-align: left; background: var(--surface-2); border: 0; border-radius: 12px; padding: 8px 10px 8px 8px; }
.art:disabled { cursor: default; opacity: .75; }
.art img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; }
.art-t strong { display: block; font-size: 15px; line-height: 1.3; }
.art-t span { font-size: 14px; color: var(--ink-2); }
.tot { display: flex; justify-content: space-between; margin: 10px 2px 0; font-weight: 600; }
.stati { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stati .stato-btn:last-child:nth-child(odd) { grid-column: 1 / -1; }
.stato-btn { min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 15px; color: var(--ink-2); display: flex; align-items: center; justify-content: center; gap: 6px; }
.stato-btn[aria-pressed=true] { color: var(--ink); border-width: 2px; }
.stato-btn[aria-pressed=true] .i { display: inline; }
.stato-btn .i { display: none; width: 18px; height: 18px; stroke-width: 2.6; }
.tono-accent[aria-pressed=true] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.tono-amber[aria-pressed=true]  { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); }
.tono-blue[aria-pressed=true]   { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }
.tono-green[aria-pressed=true]  { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.tono-gray[aria-pressed=true]   { background: var(--gray-soft); border-color: var(--gray); color: var(--gray); }
.hint { font-size: 13px; color: var(--ink-2); margin: 8px 2px 0; }
.rapidi { display: grid; gap: 8px; }
.rapido { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; text-decoration: none; color: var(--ink); background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.rapido strong { font-size: 15px; }
.rapido span { grid-column: 1; color: var(--ink-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rapido .i { grid-row: 1 / span 2; grid-column: 2; color: var(--green); }
.note-int { width: 100%; min-height: 84px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); font-size: 16px; resize: vertical; }
.note-int:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.meta { font-size: 13px; color: var(--ink-2); text-align: center; margin: 16px 0 12px; }

/* ----- Modifica articolo ----- */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 18px; }
@media (min-width: 560px) { .photos { grid-template-columns: repeat(4, 1fr); } }
.ph { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.ph img { width: 100%; height: 100%; object-fit: cover; }
.ph-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 2px dashed var(--line); background: transparent; color: var(--ink-2); font-size: 13px; font-weight: 600; cursor: pointer; text-align: center; padding: 6px; }
.ph-add .i { width: 28px; height: 28px; color: var(--accent); }
.ph-add:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.ph-btn { position: absolute; top: 6px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .6); color: #fff; display: grid; place-items: center; }
.ph-btn .i { width: 18px; height: 18px; }
.ph-x { right: 6px; }
.ph-star { left: 6px; }
.ph-cover { position: absolute; left: 6px; bottom: 6px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; }
.ph-carico { display: grid; place-items: center; }
.seg.stati-prod span { font-size: 14px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); font-weight: 600; cursor: pointer; }
.switch small { display: block; font-weight: 400; color: var(--ink-2); font-size: 13px; }
.switch input { appearance: none; -webkit-appearance: none; width: 52px; height: 32px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; flex: none; cursor: pointer; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(20px); }

/* ----- Negozio ----- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 8px 0 16px; }
@media (min-width: 560px) { .stats { grid-template-columns: repeat(3, 1fr); } }
.stat { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.stat:active { background: var(--surface-2); }
.stat b { display: block; font-family: var(--display); font-size: 34px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.stat.evid b { color: var(--accent-text); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 12px; }
.panel h3 { display: flex; align-items: center; gap: 8px; font-size: 16px; margin: 0 0 6px; }
.panel h3 .i { color: var(--accent); }
.panel p { margin: 0 0 12px; color: var(--ink-2); font-size: 14px; }
.panel p:last-child { margin-bottom: 0; }
.versione { text-align: center; font-size: 12px; color: var(--ink-3); margin: 20px 0; }
