:root {
  --ink: #1b2533;
  --ink-2: #4a5668;
  --paper: #f3f5f8;
  --card: #ffffff;
  --rule: #d6dce4;
  --rule-2: #e8ecf1;
  --blue: #1f4e8c;
  --blue-soft: #e5edf8;
  --ko: #b8410e;
  --ko-soft: #fbe9df;
  --ok: #2d7a4b;
  --ok-soft: #dff0e5;
  --na: #c9a227;
  --nc: #e3e7ec;
  --head: "Barlow Semi Condensed", "Arial Narrow", Arial, sans-serif;
  --body: "Source Sans 3", "Segoe UI", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e7ecf2; --ink-2: #a9b4c2; --paper: #12171e; --card: #1a212b; --rule: #2e3846; --rule-2: #252e3a;
    --blue: #7fa9e6; --blue-soft: #1f2d42; --ko: #ff8a57; --ko-soft: #3a2219; --ok: #6cc28f; --ok-soft: #18301f;
    --na: #d9b445; --nc: #2a333f; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.45 var(--body); }
h1, h2, h3, h4 { font-family: var(--head); font-weight: 600; margin: 0; letter-spacing: .01em; }
a { color: var(--blue); }
small { color: var(--ink-2); font-weight: 400; }
.muted { color: var(--ink-2); }
button { font: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.btn { border: 1px solid var(--rule); background: var(--card); color: var(--ink); padding: .5rem .95rem; border-radius: 6px; cursor: pointer; font-weight: 600; }
.btn:hover { border-color: var(--blue); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0e1520; } }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-box { background: var(--card); border: 1px solid var(--rule); border-radius: 10px; padding: 2rem; width: min(360px, 100%); display: grid; gap: .6rem; }
.login-box h1 { font-size: 2rem; }
.login-box p { margin: 0 0 .6rem; color: var(--ink-2); }
.login-box input { padding: .6rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--paper); color: var(--ink); font: inherit; }
.err { color: var(--ko); min-height: 1.2em; }

/* testata */
.top { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; padding: .9rem clamp(1rem, 3vw, 2.5rem); background: var(--card); border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 5; }
.brand h1 { font-size: 1.7rem; line-height: 1; }
.brand .sub { color: var(--ink-2); font-size: .9rem; }
.period { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.period label { color: var(--ink-2); font-size: .9rem; }
select, input[type=number] { font: inherit; padding: .4rem .5rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--card); color: var(--ink); }

.wrap { max-width: 1320px; margin: 0 auto; padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 4rem; display: grid; gap: 1.25rem; }
.step, .results { background: var(--card); border: 1px solid var(--rule); border-radius: 10px; padding: 1.25rem 1.4rem; }
.step-head { display: grid; gap: .25rem; margin-bottom: 1rem; max-width: 75ch; }
.step-head h2, .res-head h2 { font-size: 1.45rem; }
.step-head p { margin: 0; color: var(--ink-2); }
.row { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.chk { display: inline-flex; gap: .4rem; align-items: center; color: var(--ink-2); }

.drop { display: block; border: 2px dashed var(--rule); border-radius: 10px; padding: 1.6rem; text-align: center; cursor: pointer; color: var(--ink-2); transition: border-color .15s, background .15s; }
.drop.over, .drop:hover { border-color: var(--blue); background: var(--blue-soft); color: var(--ink); }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop:focus-within { outline: 3px solid var(--blue); outline-offset: 2px; }

.filelist, .cassalist { list-style: none; margin: .8rem 0 0; padding: 0; display: grid; gap: 2px; }
.filelist li { display: grid; grid-template-columns: 13rem 1fr auto 2rem; gap: .8rem; align-items: center; padding: .45rem .6rem; background: var(--paper); border-radius: 4px; }
.filelist li.bad { background: var(--ko-soft); }
.filelist .tipo { font-family: var(--head); font-weight: 600; color: var(--blue); }
.filelist .nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist .stato { color: var(--ink-2); font-size: .9rem; white-space: nowrap; }
.filelist .x { border: 0; background: none; color: var(--ink-2); font-size: 1.3rem; cursor: pointer; line-height: 1; }
.filelist .warn { grid-column: 1 / -1; color: var(--ko); font-size: .88rem; }
.opts { display: flex; gap: 1.5rem; margin-top: 1rem; flex-wrap: wrap; color: var(--ink-2); }
.opts label { display: inline-flex; gap: .5rem; align-items: center; }
.opts input { width: 6rem; }

.cassalist { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 4px 1rem; }
.cassalist li { display: grid; grid-template-columns: 9.5rem 1fr; gap: .5rem; font-size: .9rem; padding: .3rem 0; border-bottom: 1px solid var(--rule-2); }
.cassalist li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.cassalist li.bad span { color: var(--ko); white-space: normal; }

.progress[hidden] { display: none; }
.progress { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; color: var(--ink-2); font-size: .9rem; }
.progress .bar { flex: 0 0 220px; height: 6px; background: var(--rule-2); border-radius: 3px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: var(--blue); transition: width .25s; }

/* risultati */
.res-head { display: flex; justify-content: space-between; align-items: end; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.res-head h2 { font-size: 2rem; line-height: 1; }
.res-head h2 small { font-family: var(--body); font-size: 1rem; margin-left: .6rem; }
.legend { display: flex; gap: 1.2rem; font-size: .85rem; color: var(--ink-2); margin-bottom: .8rem; }
.legend span { display: inline-flex; gap: .35rem; align-items: center; }

.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th { font-family: var(--head); font-weight: 600; text-align: left; color: var(--ink-2); font-size: .95rem; padding: .4rem .5rem; border-bottom: 2px solid var(--rule); white-space: nowrap; }
td { padding: .45rem .5rem; border-bottom: 1px solid var(--rule-2); vertical-align: middle; }
.n { text-align: right; white-space: nowrap; }
td.ko, .chip.ko { color: var(--ko); font-weight: 700; }
td.ok { color: var(--ok); font-weight: 600; }

.overview tbody tr { cursor: pointer; }
.overview tbody tr:hover, .overview tbody tr.open { background: var(--blue-soft); }
.overview .loc { font-family: var(--head); font-weight: 600; font-size: 1.1rem; white-space: nowrap; }
.overview .miss { font-family: var(--body); font-weight: 400; font-size: .82rem; color: var(--ko); white-space: normal; max-width: 16rem; }
.overview td.n { font-family: var(--head); font-size: 1.15rem; }
.overview td.n .sub { font-family: var(--body); font-size: .78rem; font-weight: 400; color: var(--ink-2); }

/* la striscia dei giorni: una tacca per giorno, come la perforazione di un blocchetto ticket */
.strip { display: grid; grid-template-columns: repeat(31, 11px); gap: 3px; }
.d { display: inline-block; width: 11px; height: 22px; border-radius: 2px; background: var(--nc); }
.d.ok { background: var(--ok); }
.d.ko { background: var(--ko); }
.d.tx { background: var(--blue); opacity: .45; }
.d.na { background: transparent; box-shadow: inset 0 0 0 2px var(--na); }
.legend .d { width: 10px; height: 14px; }
.strip-h { min-width: 440px; }

.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: .82rem; padding: .1rem .5rem; border-radius: 999px; background: var(--paper); border: 1px solid var(--rule); white-space: nowrap; }
.chip.ko { background: var(--ko-soft); border-color: transparent; }

.warnbox, .infobox { margin: 1rem 0 0; padding: .7rem 1rem; border-radius: 6px; }
.warnbox { background: var(--ko-soft); }
.infobox { background: var(--blue-soft); }
.aibox { background: var(--blue-soft); border-radius: 8px; padding: 1rem 1.2rem; margin-bottom: 1rem; max-width: 95ch; }
.aibox h4 { margin-bottom: .4rem; }

/* dettaglio locale */
.det { margin-top: 1.5rem; border-top: 3px solid var(--ink); padding-top: 1rem; }
.det > header { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.det > header h3 { font-size: 1.8rem; }
.det > header p { margin: 0; color: var(--ink-2); flex: 1; }
.sugg, .note { margin-bottom: 1rem; }
.sugg h4, .note h4 { font-size: 1.05rem; margin-bottom: .3rem; }
.sugg ul, .note ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 3px; }
.sugg li { padding: .4rem .7rem; background: var(--ko-soft); border-radius: 4px; }
.note li { display: grid; grid-template-columns: 3.5rem 1fr auto; gap: .6rem; align-items: center; }
.note code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; background: var(--paper); padding: .25rem .5rem; border-radius: 4px; overflow-x: auto; white-space: nowrap; }
.copy { border: 1px solid var(--rule); background: var(--card); color: var(--ink); border-radius: 4px; cursor: pointer; padding: .15rem .6rem; font-size: .85rem; }

.days th { text-align: center; }
.days thead tr:first-child th { border-bottom: 1px solid var(--rule); }
.days td { padding: .3rem .45rem; font-size: .93rem; }
.days td.g { white-space: nowrap; font-weight: 600; }
.days tr.bad td.g { color: var(--ko); }
.days tr.bad { background: color-mix(in srgb, var(--ko-soft) 45%, transparent); }
.days td.nt { font-size: .8rem; color: var(--ink-2); min-width: 14rem; }
.days tfoot td { font-weight: 700; border-top: 2px solid var(--rule); }
.days small, .tx small { display: inline-block; min-width: 1.6rem; margin-left: .3rem; color: var(--ink-2); font-size: .75rem; }
.tx { border: 0; background: none; color: var(--blue); cursor: pointer; padding: 0; font: inherit; text-decoration: underline dotted; text-underline-offset: 3px; }
.txlist { margin-top: 1rem; background: var(--paper); border-radius: 8px; padding: 1rem; }
.txlist h4 { margin-bottom: .5rem; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; }

@media (max-width: 760px) {
  .filelist li { grid-template-columns: 1fr 2rem; }
  .filelist .stato { white-space: normal; }
  .period { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---- ticket.befedpub.com ---- */
.tabs { display: flex; gap: 2px; margin-left: auto; background: var(--paper); padding: 3px; border-radius: 8px; }
.tabs button { border: 0; background: transparent; color: var(--ink-2); font: 600 1rem var(--head); padding: .45rem 1rem; border-radius: 6px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--rule); }
.pane { display: grid; gap: 1.25rem; }
.pane[hidden] { display: none; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.small { font-size: .85rem; }
.filelist li { grid-template-columns: 15rem 1fr auto; }
.filelist li.warn-row { background: #fff4d6; }
.filelist .info { grid-column: 1 / -1; color: var(--blue); font-size: .88rem; }
.filelist .stato { white-space: normal; text-align: right; }
.docs td { vertical-align: top; }
.docs .warn { color: var(--ko); }
.x { border: 0; background: none; color: var(--ink-2); font-size: 1.3rem; cursor: pointer; line-height: 1; padding: 0 .3rem; }
.x.confirm { font-size: .8rem; color: var(--ko); font-weight: 700; }
.chip.nc { opacity: .55; border-style: dashed; }
td.ok { color: var(--ok); }
p.small { margin: .6rem 0 0; }
.results[hidden] { display: none; }
#avviso[hidden] { display: none; }
@media (prefers-color-scheme: dark) { .filelist li.warn-row { background: #3a3119; } }
@media (max-width: 760px) { .filelist li { grid-template-columns: 1fr; } .tabs { margin-left: 0; } }
