/* Protocollo matrimoni - Diocesi di Teramo-Atri
   Rosso del logo diocesano, carta avorio del registro, titoli in serif. */
:root {
  --rosso: #c8161d;
  --rosso-scuro: #8e0f14;
  --rosso-tenue: #fbeceb;
  --carta: #f8f6f1;
  --bianco: #ffffff;
  --ink: #1e2226;
  --ink-2: #5d646c;
  --line: #e4e0d6;
  --line-2: #efece5;
  --oro: #a07a2c;
  --ok: #1d6b3a;
  --ok-soft: #e8f3ec;
  --warn: #7a5a00;
  --warn-soft: #fdf5d9;
  --no: #b3141a;
  --no-soft: #fbeceb;
  --serif: "Palatino Linotype", "Book Antiqua", Palatino, "URW Palladio L", "P052", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .05);
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--carta); color: var(--ink); font-family: var(--sans); line-height: 1.45; }
a { color: var(--rosso); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { font-family: var(--serif); font-weight: 400; margin: 0; }
h1 { font-size: 1.85rem; line-height: 1.15; }
h2 { font-size: 1.22rem; margin: 0 0 .8rem; color: var(--rosso-scuro); }
h2 small { font-family: var(--sans); font-size: .8rem; font-weight: 400; margin-left: .4rem; }
code { background: var(--line-2); padding: .05rem .35rem; border-radius: 4px; font-size: .9em; }
code.big { font-size: 1.15rem; padding: .2rem .5rem; letter-spacing: .04em; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(200, 22, 29, .3); outline-offset: 2px; }

/* ---------- barra superiore */
.topbar {
  display: flex; align-items: center; gap: 1.2rem; padding: .45rem 1.5rem;
  background: var(--bianco); border-bottom: 3px solid var(--rosso); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .7rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-logo { height: 50px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; font-family: var(--serif); }
.brand-text small { font-size: .78rem; font-variant: small-caps; letter-spacing: .1em; color: var(--rosso); }
.brand-text strong { font-size: 1.25rem; font-weight: 400; font-variant: small-caps; letter-spacing: .04em; color: var(--ink); }
.brand-text.big { align-items: center; margin-top: .5rem; }
.brand-text.big small { font-size: .95rem; }
.brand-text.big strong { font-size: 1.7rem; }
.nav { display: flex; gap: .1rem; flex: 1; flex-wrap: wrap; }
.nav a { color: var(--ink-2); padding: .5rem .7rem; border-radius: 6px; font-weight: 550; font-size: .93rem; position: relative; }
.nav a:hover { color: var(--ink); background: var(--line-2); text-decoration: none; }
.nav a.active { color: var(--rosso); }
.nav a.active::after { content: ""; position: absolute; left: .7rem; right: .7rem; bottom: -.5rem; height: 3px; background: var(--rosso); border-radius: 2px 2px 0 0; }
.nav-new { padding: .45rem .8rem; }
.user { display: flex; align-items: center; gap: .6rem; font-size: .88rem; }
.user a { color: var(--ink); font-weight: 600; }
.user .role { color: var(--ink-2); }
.nav-toggle { display: none; background: none; border: 0; color: var(--ink); font-size: 1.4rem; cursor: pointer; }
button.link { background: none; border: 0; color: var(--rosso); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
form.inline { display: inline; margin: 0; }

.container { max-width: 1240px; margin: 0 auto; padding: 1.6rem 1.5rem; }
.footer { text-align: center; color: var(--ink-2); font-size: .8rem; padding: 1rem 0 2rem; }
.footer a { color: var(--ink-2); text-decoration: underline; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.page-head h1 .muted { font-size: .8em; }
.back { display: inline-block; font-size: .88rem; margin-bottom: .3rem; }

/* ---------- card e griglie */
.card { background: var(--bianco); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card.flush { padding: 0; }
.card.flush .table thead th:first-child { border-top-left-radius: var(--radius); }
.card.flush .table thead th:last-child { border-top-right-radius: var(--radius); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.grid2.wide-left { grid-template-columns: 1.6fr 1fr; }
.span2 { grid-column: span 2; }

/* ---------- testata del mese */
.month-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.month-title small { display: block; font-family: var(--serif); font-variant: small-caps; letter-spacing: .08em; color: var(--ink-2); font-size: 1rem; }
.month-title h1 { font-size: 2.5rem; color: var(--rosso); min-width: 9ch; }
.month-title h1 span { color: var(--ink); }
.arrow { display: inline-flex; align-items: center; justify-content: center; width: 2.4rem; height: 2.4rem; border: 1px solid var(--line); border-radius: 50%; background: var(--bianco); color: var(--rosso); font-size: 1.5rem; line-height: 1; padding-bottom: 3px; }
.arrow:hover { border-color: var(--rosso); text-decoration: none; background: var(--rosso-tenue); }
.month-totals { display: flex; gap: 0; margin-left: auto; background: var(--bianco); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.month-totals div { display: flex; flex-direction: column; padding: .55rem 1.1rem; min-width: 8rem; }
.month-totals div + div { border-left: 1px solid var(--line); }
.month-totals strong { font-family: var(--serif); font-weight: 400; font-size: 1.7rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.month-totals div:first-child strong { color: var(--rosso); }
.month-totals span { font-size: .78rem; color: var(--ink-2); }

.months { display: flex; gap: .3rem; flex-wrap: wrap; align-items: stretch; margin-bottom: 1rem; }
.months a { display: flex; flex-direction: column; align-items: center; min-width: 3.7rem; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bianco); color: var(--ink); font-weight: 600; font-size: .9rem; }
.months a span { font-weight: 400; font-size: .75rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.months a:hover { border-color: var(--rosso); text-decoration: none; }
.months a.on { background: var(--rosso); border-color: var(--rosso); color: #fff; }
.months a.on span { color: #ffdcdd; }
.months a.empty { color: var(--ink-2); background: transparent; }
.year-pick select { height: 100%; font-weight: 600; font-size: 1rem; padding: .4rem .6rem; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: .8rem; flex-wrap: wrap; }
.found { margin: 0; color: var(--ink-2); }
.found strong { font-family: var(--serif); font-size: 1.35rem; font-weight: 400; color: var(--rosso); }
.segmented { display: inline-flex; border: 1px solid #d3cec2; border-radius: 7px; overflow: hidden; background: var(--bianco); }
.segmented a { padding: .45rem .9rem; color: var(--ink-2); font-weight: 550; font-size: .9rem; }
.segmented a + a { border-left: 1px solid #d3cec2; }
.segmented a.on { background: var(--ink); color: #fff; }
.segmented a:hover { text-decoration: none; }
.legend { margin-top: -.2rem; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--oro); }

/* ---------- tabelle */
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: .55rem .7rem; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: top; }
.table thead th { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); font-weight: 600; border-bottom: 1px solid var(--line); background: #fcfbf8; position: sticky; top: 63px; z-index: 1; }
.table thead th a { color: var(--ink-2); }
.table tfoot th { border-top: 2px solid var(--line); border-bottom: 0; }
.table.compact th, .table.compact td { padding: .38rem .55rem; }
.table .num { text-align: right; white-space: nowrap; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #fdf8f3; }
.table tr.disattivo td { color: var(--ink-2); }
.table tr.zero td { color: var(--ink-2); }
.registro .col-prot { width: 7.5rem; white-space: nowrap; }
.registro .col-prot a { display: flex; flex-direction: column; color: var(--ink); }
.registro .col-prot a:hover { text-decoration: none; }
.prot-n { font-family: var(--serif); font-size: 1.25rem; line-height: 1.1; color: var(--rosso); }
.prot-d { font-size: .78rem; color: var(--ink-2); }
.registro .cognome { font-weight: 600; }
.registro tr.speciale td:first-child { box-shadow: inset 3px 0 0 var(--oro); }
.registro td.vuoto { padding: 2.5rem; }
.tag { display: inline-block; font-size: .74rem; padding: .08rem .45rem; border-radius: 99px; background: #f5eedf; color: #6b5220; margin: 0 .15rem .2rem 0; white-space: nowrap; }
.actions { text-align: right; }
.bars .bar-cell { width: 60%; vertical-align: middle; }
.hbar { display: block; height: 10px; background: var(--rosso); border-radius: 3px; min-width: 2px; opacity: .85; }
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: 1rem 0; color: var(--ink-2); font-size: .9rem; }

/* ---------- grafico per anno */
.years-chart { display: flex; align-items: flex-end; gap: 2px; height: 180px; padding: 0 0 1.4rem; position: relative; border-bottom: 1px solid var(--line); margin-bottom: .8rem; }
.years-chart a { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; position: relative; }
.years-chart a span { display: block; background: #e3b9ba; border-radius: 2px 2px 0 0; }
.years-chart a:hover span { background: var(--rosso-scuro); }
.years-chart a.on span { background: var(--rosso); }
.years-chart em { position: absolute; bottom: -1.3rem; left: 50%; transform: translateX(-50%); font-style: normal; font-size: .7rem; color: var(--ink-2); }
.years-table { max-width: 260px; }
details summary { cursor: pointer; color: var(--rosso); font-weight: 550; }

/* ---------- indicatori */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.kpi { background: var(--bianco); border: 1px solid var(--line); border-top: 3px solid var(--rosso); border-radius: var(--radius); padding: .9rem 1.1rem; display: flex; flex-direction: column; gap: .15rem; box-shadow: var(--shadow); }
.kpi-label { font-size: .82rem; color: var(--ink-2); }
.kpi-value { font-family: var(--serif); font-size: 1.9rem; line-height: 1.15; }
.kpi-sub { font-size: .8rem; color: var(--ink-2); }

/* ---------- moduli */
.form label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--ink-2); font-weight: 550; margin-bottom: .75rem; }
.form label small { font-weight: 400; }
.form label.check { flex-direction: row; align-items: center; gap: .45rem; color: var(--ink); }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid #cfcabd; border-radius: 6px; padding: .5rem .6rem; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(200, 22, 29, .18); border-color: var(--rosso); }
textarea { width: 100%; resize: vertical; }
input[type=checkbox] { width: auto; accent-color: var(--rosso); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-family: var(--serif); font-size: 1.05rem; padding: 0; margin-bottom: .5rem; color: var(--ink); }
.row-btn { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.scheda .card { padding: 1.1rem 1.3rem .5rem; }
.prot-grid { display: grid; grid-template-columns: 9rem 8rem 12rem 7rem; gap: .8rem; align-items: end; }
.big-input { font-family: var(--serif); font-size: 1.5rem; padding: .3rem .6rem; color: var(--rosso); }
.scheda .sposo, .scheda .sposa { padding: .9rem 1rem .2rem; border-radius: 6px; background: #fcfbf8; border: 1px solid var(--line-2); }
.casi { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: .5rem; margin-bottom: .8rem; }
.caso { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border: 1px solid var(--line-2); border-radius: 6px; margin: 0 !important; background: #fff; color: var(--ink) !important; font-weight: 550 !important; font-size: .9rem !important; }
.caso span { flex: 1; display: flex; flex-direction: column; }
.caso small { font-weight: 400; color: var(--ink-2); font-size: .76rem; line-height: 1.3; }
.caso.check { flex-direction: row !important; cursor: pointer; }
.caso.check input { width: 18px; height: 18px; flex: none; }
.caso.check:has(input:checked), .caso.parte.on { border-color: #d9c38f; background: #fbf6ea; }
.caso select { flex: none; width: 9.5rem; }
.form-foot { display: flex; gap: .6rem; flex-wrap: wrap; padding: .8rem 0; position: sticky; bottom: 0; background: var(--carta); border-top: 1px solid var(--line); z-index: 2; }
.danger-zone { margin: 1.5rem 0 0; padding-top: 1rem; border-top: 1px dashed var(--line); }

.scheda-view .sposi { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; padding: .4rem 0 1.2rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line-2); }
.scheda-view .sposi div { display: flex; flex-direction: column; }
.scheda-view .sposi div:last-child { text-align: right; }
.scheda-view .sposi small { font-variant: small-caps; letter-spacing: .08em; color: var(--ink-2); font-family: var(--serif); font-size: .95rem; }
.scheda-view .sposi strong { font-family: var(--serif); font-weight: 400; font-size: 1.9rem; line-height: 1.15; }
.scheda-view .sposi span { color: var(--ink-2); }
.rings { color: var(--oro); width: 64px; }
.rings svg { width: 64px; height: 40px; display: block; }
.dl { display: grid; grid-template-columns: 8rem 1fr; gap: .5rem .9rem; margin: 0; }
.dl dt { color: var(--ink-2); font-size: .88rem; }
.dl dd { margin: 0; }
.tip-list { margin: 0 0 1rem; padding-left: 1.1rem; }
.tip-list li { margin-bottom: .3rem; }
.meta { border-top: 1px solid var(--line-2); padding-top: .7rem; margin-bottom: 0; }

.filters-card { padding: 1rem 1.2rem; }
.search-main { display: flex; gap: .5rem; }
.search-main input { flex: 1; font-size: 1.05rem; padding: .6rem .8rem; }
.filters-card details { margin-top: .8rem; }
.filters-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 .8rem; margin: .8rem 0 .2rem; }
.filters-grid label { display: flex; flex-direction: column; gap: .25rem; font-size: .82rem; color: var(--ink-2); font-weight: 550; margin-bottom: .7rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .5rem .95rem; border-radius: 6px; border: 1px solid #cfcabd;
  background: #fff; color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: #f6f3ec; text-decoration: none; }
.btn.primary { background: var(--rosso); border-color: var(--rosso); color: #fff; }
.btn.primary:hover { background: var(--rosso-scuro); }
.btn.danger { color: var(--no); border-color: #ecb8b3; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--rosso); }
.btn.block { width: 100%; }
.btn.icon { padding: .35rem .7rem; font-size: 1.2rem; line-height: 1; }

.alert { padding: .75rem 1rem; border-radius: 7px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert ul { margin: .4rem 0 .6rem; padding-left: 1.2rem; }
.alert-ok { background: var(--ok-soft); border-color: #b9dcc6; }
.alert-error { background: var(--no-soft); border-color: #f0bfbc; }
.alert-warn { background: var(--warn-soft); border-color: #e8d48a; }
.badge { display: inline-block; font-size: .72rem; padding: .1rem .45rem; border-radius: 99px; background: var(--line-2); color: var(--ink-2); font-weight: 600; }

/* ---------- accesso */
body.auth { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 1rem; border-top: 6px solid var(--rosso); }
.auth-box { background: #fff; border-radius: 12px; padding: 2rem 2.2rem; width: 100%; max-width: 400px; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(60, 40, 20, .08); }
.auth-box.wide { max-width: 560px; }
.auth-box h1 { font-size: 1.25rem; margin: 1.2rem 0 1rem; text-align: center; font-weight: 700; }
.brand-big { display: flex; justify-content: center; }
.brand-big img { height: 110px; width: auto; }

/* ---------- stampa */
.print-head { display: none; }
@media print {
  @page { margin: 14mm 12mm; }
  :root { font-size: 10.5pt; }
  body { background: #fff; }
  .topbar, .nav, .footer, .btn, .row-btn, .legend, .months, .segmented, .arrow, .filters-card, .pager, .no-print, .form-foot, .danger-zone, .back, details summary { display: none !important; }
  .container { padding: 0; max-width: none; }
  .print-head { display: flex; align-items: center; gap: 12px; border-bottom: 2px solid var(--rosso); padding-bottom: 8px; margin-bottom: 12px; }
  .print-head img { height: 52px; }
  .print-head div { display: flex; flex-direction: column; font-family: var(--serif); }
  .print-head small { font-variant: small-caps; color: var(--rosso); letter-spacing: .08em; }
  .print-head strong { font-size: 15pt; font-weight: 400; }
  .print-head .print-date { margin-left: auto; font-size: 8.5pt; color: var(--ink-2); }
  .month-head .month-totals { margin-left: 0; }
  .card { border: 0; box-shadow: none; padding: 0; break-inside: avoid; }
  .card.flush { overflow: visible; }
  .table thead th { position: static; background: #fff; }
  .table thead { display: table-header-group; }
  .table tr { break-inside: avoid; }
  .registro tr.speciale td:first-child { box-shadow: none; }
  a { color: inherit; }
  details { display: block; }
  details > *:not(summary) { display: block; }
  .years-chart a span, .hbar { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- schermi stretti */
@media (max-width: 1100px) {
  .brand-text small { display: none; }
  .user .role { display: none; }
  .filters-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; padding: .4rem 1rem; gap: .6rem; }
  .brand-logo { height: 40px; }
  .nav a.active::after { display: none; }
  .nav a.active { background: var(--rosso-tenue); }
  .nav-toggle { display: block; margin-left: auto; }
  .nav, .user, .nav-new { display: none; width: 100%; }
  body.nav-open .nav { display: flex; flex-direction: column; }
  body.nav-open .user, body.nav-open .nav-new { display: flex; padding: .4rem .75rem; }
  .container { padding: 1rem; }
  .grid2, .grid2.wide-left { grid-template-columns: 1fr; }
  .month-totals { margin-left: 0; width: 100%; }
  .month-totals div { flex: 1; min-width: 0; }
  .table thead th { position: static; }
  .card.flush { overflow-x: auto; }
  .card.flush .table thead th { position: static; }
  .prot-grid { grid-template-columns: 1fr 1fr; }
  .casi { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .month-title h1 { font-size: 2rem; }
  .filters-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .search-main { flex-wrap: wrap; }
  .scheda-view .sposi { grid-template-columns: 1fr; }
  .scheda-view .sposi div:last-child { text-align: left; }
  .rings { display: none; }
}
