/* Registro: bound class-register, not a SaaS dashboard.
   Tenant paints --accent --bg --ink. Structure stays. */

@font-face {
  font-family: "Young Serif";
  src: url("/static/fonts/young-serif-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("/static/fonts/atkinson-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("/static/fonts/atkinson-400i.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("/static/fonts/atkinson-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --accent: #0b5cab;
  --bg: #f6f7f9;
  --ink: #1a1a1a;
  --paper: color-mix(in srgb, var(--bg) 35%, #fff);
  --line: color-mix(in srgb, var(--ink) 14%, var(--bg));
  --mute: color-mix(in srgb, var(--ink) 58%, var(--bg));
  --on-accent: #fff;
  --danger: #9b1c1c;
  --warn: #8a5800;
  --ok: #1f6b3a;
  --spine: 7px;
  --font-ui: "Atkinson Hyperlegible", "Segoe UI", sans-serif;
  --font-display: "Young Serif", "Iowan Old Style", Palatino, serif;
  --space: 1.15rem;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font: 16px/1.5 var(--font-ui);
  color: var(--ink);
  background: var(--bg);
  background-image: linear-gradient(90deg, var(--accent) var(--spine), transparent var(--spine));
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
}
.skip:focus {
  left: calc(var(--spine) + 0.75rem);
  top: 0.5rem;
  z-index: 20;
  background: var(--paper);
  padding: 0.35rem 0.6rem;
}

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: baseline;
  padding: 0.85rem 1.5rem 0.85rem calc(var(--spine) + 1.25rem);
  padding-top: max(0.85rem, env(safe-area-inset-top));
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.top a { color: var(--ink); text-decoration: none; }
.top nav,
.nav-scroll {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1.1rem;
}
.top nav a {
  padding: 0.25rem 0 0.12rem;
  border-bottom: 2px solid transparent;
  touch-action: manipulation;
}
.top nav a.is-current,
.top nav a:hover { border-bottom-color: var(--accent); }
.brand {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.who {
  margin-left: auto;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}
.who .muted { color: var(--mute); }

main {
  padding: 1.5rem 1.5rem 3rem calc(var(--spine) + 1.25rem);
  max-width: 1240px;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
h1 { font-size: 2rem; margin: 0 0 0.85rem; }
h2 { font-size: 1.2rem; margin: 0 0 0.7rem; }
h3 { font-size: 1.05rem; margin: 0 0 0.5rem; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  align-items: end;
  margin-bottom: 1.15rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--ink);
}
.page-head h1 { margin: 0; }
.page-head p {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: baseline;
  margin: 0;
}
.page-head .muted { margin: 0; }

.muted { color: var(--mute); font-size: 0.92rem; }
.hint {
  color: var(--mute);
  font-size: 0.92rem;
  max-width: 40rem;
  margin: -0.35rem 0 1rem;
  line-height: 1.45;
}
.field-help {
  font-size: 0.8rem;
  color: var(--mute);
  font-weight: 400;
}
.legend {
  font-size: 0.9rem;
  color: var(--mute);
  margin: 0 0 0.45rem;
}
.error { color: var(--danger); font-weight: 700; }
code { font-size: 0.88em; word-break: break-word; }
.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0 0 1rem;
}
.empty { color: var(--mute); margin: 0.35rem 0 0; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 0.18rem 0; }
.table-wrap {
  overflow-x: auto;
  margin: 0 0 0.5rem;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.perm-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin: 0.4rem 0 0.75rem;
}
.subpanel {
  padding-top: 0.9rem;
  margin-top: 0.9rem;
  border-top: 1px solid var(--line);
}
.aside {
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.form-actions { margin-top: 0.4rem; }
.is-on {
  background: transparent;
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 50%, var(--line));
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 0 0 1.25rem;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}
.kpis article {
  background: transparent;
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--line);
  padding: 0.7rem 0.85rem 0.8rem;
  min-width: 0;
}
.kpis article:last-child { border-right: 0; }
.kpis span {
  display: block;
  color: var(--mute);
  font-size: 0.82rem;
}
.kpis strong {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 400;
  letter-spacing: -0.03em;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}

.roster {
  list-style: none;
  padding: 0;
  margin: 0;
  columns: 2;
  column-gap: 1.5rem;
}
.roster li { break-inside: avoid; padding: 0.12rem 0; }
.roster a { color: inherit; text-decoration: none; }
.roster a:hover { color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; list-style: none; padding: 0; margin: 0; }
.chips a {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  font-variant-numeric: tabular-nums;
}
.chips a:hover { border-color: var(--accent); color: var(--accent); }

label {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-size: 0.9rem;
  color: var(--mute);
}
label:has([type="checkbox"]) {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  color: var(--ink);
}
input, select, textarea, button {
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  max-width: 100%;
  touch-action: manipulation;
}
input, select, textarea {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 0.4rem 0.55rem;
  border-radius: 0;
}
select { min-height: 2.2rem; }
input::placeholder, textarea::placeholder {
  color: color-mix(in srgb, var(--mute) 70%, var(--paper));
  opacity: 1;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 0;
}
input[type="color"] {
  width: 3rem;
  height: 2rem;
  padding: 0.15rem;
}
.stack input:not([type="checkbox"]):not([type="color"]):not([type="hidden"]),
.stack select,
.stack textarea { width: 100%; }

button, .btn {
  background: var(--accent);
  color: var(--on-accent);
  border: 1px solid var(--accent);
  padding: 0.42rem 0.85rem;
  cursor: pointer;
  border-radius: 0;
}
button:hover, .btn:hover { filter: brightness(0.94); }
button:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.stack > button, .stack > .btn { align-self: start; width: auto; }
.btn-ghost, .who button, .week-nav a {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  text-decoration: none;
}
.btn-ghost:hover, .who button:hover, .week-nav a:hover {
  border-color: var(--accent);
  color: var(--accent);
  filter: none;
}
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
}
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 8%, var(--paper)); filter: none; }

.inline, .stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: end;
  margin-bottom: 1rem;
}
.inline h2 { flex: 1 0 100%; margin-bottom: 0; }
.stack { flex-direction: column; align-items: stretch; }
.snapshot-bar label { max-width: 36rem; }
.snapshot-bar select { width: 100%; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: end;
  margin: 0 0 1rem;
}
.actions { flex-wrap: nowrap; }

table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
}
table.data th, table.data td {
  border-bottom: 1px solid var(--line);
  padding: 0.5rem 0.55rem;
  text-align: left;
  vertical-align: top;
}
table.data th {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--mute);
}
table.data tr:hover td { background: color-mix(in srgb, var(--accent) 5%, var(--paper)); }
table.data .inline { margin: 0; gap: 0.35rem; align-items: center; }
table.data input, table.data select { padding: 0.28rem 0.4rem; }
table.data button { padding: 0.28rem 0.55rem; }

.scroll-hint { display: none; }
.grid-wrap {
  overflow: auto;
  margin: 0 0 1.25rem;
  border: 1px solid var(--line);
  background: var(--paper);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
table.grid {
  width: 100%;
  min-width: 44rem;
  border-collapse: collapse;
  background: var(--paper);
}
table.grid th, table.grid td {
  border: 1px solid var(--line);
  vertical-align: top;
  padding: 0.35rem;
  min-width: 7.2rem;
}
table.grid thead th {
  background: color-mix(in srgb, var(--bg) 70%, var(--paper));
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.95rem;
  position: sticky;
  top: 0;
  z-index: 2;
}
table.grid tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--paper);
  font-variant-numeric: tabular-nums;
  min-width: 4.2rem;
  width: 4.2rem;
  text-align: right;
  padding-right: 0.55rem;
  color: var(--mute);
  font-weight: 400;
  box-shadow: 6px 0 8px -6px color-mix(in srgb, var(--ink) 28%, transparent);
}
.cell {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  padding: 0.35rem 0.45rem 0.4rem;
  margin-bottom: 0.3rem;
  background: var(--paper);
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--accent) 70%, var(--line));
}
.cell[data-campus] { background: color-mix(in srgb, var(--accent) 9%, var(--paper)); }
.stamp {
  font-size: 0.75rem;
  color: var(--mute);
  font-variant-numeric: tabular-nums;
}
.role-tag {
  font-size: 0.78rem;
  font-style: italic;
  color: var(--warn);
  width: fit-content;
}
.cell[data-role="supplenza"],
.cell[data-role="prova_supplenza"] { background: #fff4d6; }
.cell[data-role="assente"] { background: #fde8e8; }
.cell[data-role="codocenza"] { background: #e8f0fe; }
.cell[data-role="occupato"],
.cell[data-role="sorveglianza"] { background: color-mix(in srgb, var(--ink) 6%, var(--paper)); }
.cell[data-role="project_work"],
.cell[data-role="colloqui"] { background: #efe8fa; }
.conflict, .conflict-slot { outline: 2px solid var(--danger); outline-offset: -2px; }
.conflict { background: #fdecea; }

.week-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1rem;
}
.week-nav a {
  padding: 0.5rem 0.7rem;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.week-nav strong {
  font-family: var(--font-display);
  font-weight: 400;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.week-nav-short { display: none; }

details {
  margin-top: 0.25rem;
  font-size: 0.88rem;
}
details summary { cursor: pointer; color: var(--mute); }
td > details > summary {
  font-size: 0.78rem;
}
td details[open] > summary { opacity: 1; }
@media (hover: hover) and (pointer: fine) {
  td > details > summary { opacity: 0.38; }
  td:hover > details > summary { opacity: 1; }
}
.cell details summary { font-size: 0.78rem; }
details[open] {
  background: var(--bg);
  padding: 0.45rem;
  margin-top: 0.35rem;
}

.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: 0 0 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}
.steps li { counter-increment: step; }
.steps a {
  color: var(--mute);
  text-decoration: none;
}
.steps a::before {
  content: counter(step) "  ";
  font-variant-numeric: tabular-nums;
  color: var(--mute);
}
.steps .current a {
  color: var(--ink);
  border-bottom: 2px solid var(--accent);
}

.snapshot-bar { margin: 0 0 1rem; }
.findings { list-style: none; padding: 0; margin: 0; }
.findings li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--line);
}
.sev {
  display: inline-block;
  min-width: 4.6rem;
  font-size: 0.82rem;
  font-weight: 700;
}
.sev-error { color: var(--danger); }
.sev-warning { color: var(--warn); }
.sev-info { color: var(--accent); }

.auth {
  background:
    linear-gradient(90deg, var(--accent) var(--spine), transparent var(--spine)),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 1.7rem,
      color-mix(in srgb, var(--ink) 8%, transparent) 1.7rem,
      color-mix(in srgb, var(--ink) 8%, transparent) calc(1.7rem + 1px)
    ),
    var(--bg);
}
.auth .top { background: transparent; border-bottom: 0; }
.auth main {
  max-width: 26rem;
  margin-left: auto;
  margin-right: auto;
  padding-top: 14vh;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}
.auth-sheet {
  background: var(--paper);
  border: 1px solid var(--ink);
  padding: 1.6rem 1.5rem 1.4rem;
}
.auth-sheet h1 { font-size: 2.1rem; }
.auth-sheet .stack > button { align-self: stretch; width: 100%; }

pre {
  background: var(--ink);
  color: #eee;
  padding: 0.75rem;
  overflow: auto;
}

@media (pointer: coarse) {
  button, .btn {
    min-height: 2.75rem;
    padding: 0.55rem 0.95rem;
  }
  .chips a, .roster a {
    min-height: 2.5rem;
    display: inline-flex;
    align-items: center;
  }
  td > details > summary {
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    opacity: 0.9;
  }
  .perm-grid label { min-height: 2.5rem; }
}

@media (max-width: 800px) {
  :root { --spine: 5px; }
  h1 { font-size: 1.65rem; }
  .top {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.45rem 0.75rem;
    padding: 0.55rem 0.75rem 0.55rem calc(var(--spine) + 0.7rem);
    padding-top: max(0.55rem, env(safe-area-inset-top));
  }
  .brand { grid-column: 1; grid-row: 1; font-size: 1.2rem; }
  .who {
    grid-column: 2;
    grid-row: 1;
    margin-left: 0;
    width: auto;
    max-width: 55%;
    justify-self: end;
  }
  .who .muted {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 9rem;
  }
  .top nav,
  .nav-scroll {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    gap: 0;
    scrollbar-width: none;
  }
  .top nav::-webkit-scrollbar,
  .nav-scroll::-webkit-scrollbar { display: none; }
  .top nav a,
  .nav-scroll a {
    flex: 0 0 auto;
    padding: 0.55rem 0.7rem;
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
  }
  main {
    padding: 1rem 0.75rem calc(2.5rem + env(safe-area-inset-bottom)) calc(var(--spine) + 0.7rem);
  }
  .split { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis article:nth-child(2n) { border-right: 0; }
  .kpis article:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .kpis article:last-child { grid-column: 1 / -1; }
  .roster { columns: 1; }
  .inline {
    flex-direction: column;
    align-items: stretch;
  }
  .inline label,
  .inline input:not([type="checkbox"]):not([type="hidden"]),
  .inline select,
  .inline button { width: 100%; }
  .inline h2, .inline .hint { flex: none; width: 100%; }
  table.data .inline {
    flex-direction: row;
    flex-wrap: wrap;
    width: auto;
  }
  table.data .inline input,
  table.data .inline select,
  table.data .inline button { width: auto; }
  .snapshot-bar label { max-width: none; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar label { width: 100%; }
  .actions { flex-wrap: wrap; }
  .page-head { align-items: start; }
  .page-head h1 { font-size: 1.55rem; word-break: break-word; }
  .scroll-hint {
    display: block;
    color: var(--mute);
    font-size: 0.82rem;
    margin: 0 0 0.4rem;
  }
  .grid-wrap { max-height: calc(100dvh - 11rem); }
  table.grid { font-size: 0.85rem; min-width: 40rem; }
  table.grid th, table.grid td { min-width: 6.4rem; }
  .week-nav { gap: 0.4rem; }
  .week-nav a { flex: 1 1 0; }
  .week-nav-long { display: none; }
  .week-nav-short { display: inline; }
  .week-nav strong { font-size: 0.85rem; min-width: 0; }
  .auth main {
    padding-top: 2.5rem;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  }
  .auth-sheet { padding: 1.25rem 1rem 1.1rem; }
  .steps {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.75rem;
  }
  .steps li { flex: 0 0 auto; white-space: nowrap; }
  .form-actions button { width: 100%; min-height: 2.75rem; }
  .stack > button, .stack > .btn { align-self: stretch; width: 100%; }
  .table-wrap {
    background:
      linear-gradient(var(--paper) 30%, transparent) 0 0 / 1.25rem 100% no-repeat,
      linear-gradient(to left, var(--paper) 30%, transparent) 100% 0 / 1.25rem 100% no-repeat;
    background-attachment: local, local;
  }
}

@media (max-width: 520px) {
  .kpis strong { font-size: 1.45rem; }
  table.data { min-width: 36rem; }
  .who .muted { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media print {
  body { background: #fff; background-image: none; }
  .top, .who, button, details, .skip { display: none !important; }
  main { max-width: none; padding: 0; }
  .grid-wrap { overflow: visible; border: 0; }
  table.grid { min-width: 0; }
}
