/* Setmana Blanca
   Concepte: senyalística de pistes. Fons de neu freda, tinta blau nit, accent
   taronja de balisa. Els colors de nivell (verd, blau, vermell, negre) són els
   de les pistes i només s'usen per identificar nivells. */
:root {
  --bg: #F2F5F8;
  --surface: #FFFFFF;
  --surface-2: #E9EEF3;
  --ink: #14213A;
  --muted: #586A80;
  --line: #D6DEE7;
  --accent: #C2541A;
  --accent-ink: #FFFFFF;
  --accent-soft: #FBE9DE;
  --ok: #1E8A4C;
  --ok-soft: #DDF2E5;
  --bad: #C9372C;
  --bad-soft: #FBE2DF;
  --warn: #A86A00;
  --warn-soft: #FDF0D2;
  --unmarked: #B9C5D2;
  --lv-verd: #23924F;
  --lv-blau: #2563C9;
  --lv-vermell: #CF3A2F;
  --lv-negre: #151A22;
  --lv-ink: #FFFFFF;
  --on-status: #FFFFFF;
  --shadow: 0 1px 2px rgba(20, 33, 58, .06), 0 4px 14px rgba(20, 33, 58, .06);
  --f-display: 'Barlow Condensed', 'Arial Narrow', 'Roboto Condensed', sans-serif-condensed, system-ui, sans-serif;
  --f-body: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --r: 12px;
  --r-sm: 8px;
  --gutter: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D141E; --surface: #162130; --surface-2: #1D2A3B; --ink: #E7EDF4; --muted: #95A6BA; --line: #2A3A4F;
    --accent: #F0874A; --accent-ink: #1A0E05; --accent-soft: #3A2414;
    --ok: #4CC47E; --ok-soft: #173826; --bad: #F2675C; --bad-soft: #42201E; --warn: #E9B04A; --warn-soft: #3A2D12;
    --unmarked: #3E4F66; --lv-negre: #000000; --on-status: #08110C; --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D141E; --surface: #162130; --surface-2: #1D2A3B; --ink: #E7EDF4; --muted: #95A6BA; --line: #2A3A4F;
  --accent: #F0874A; --accent-ink: #1A0E05; --accent-soft: #3A2414;
  --ok: #4CC47E; --ok-soft: #173826; --bad: #F2675C; --bad-soft: #42201E; --warn: #E9B04A; --warn-soft: #3A2D12;
  --unmarked: #3E4F66; --lv-negre: #000000; --on-status: #08110C; --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.45 var(--f-body);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
body.no-scroll { overflow: hidden; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 700; line-height: 1.1; text-wrap: balance; margin: 0; letter-spacing: .005em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
code, .mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.warn-t { color: var(--warn); }
.selectable { user-select: all; word-break: break-all; }
.ic { width: 20px; height: 20px; flex: none; vertical-align: -4px; }
.ic.big { width: 48px; height: 48px; }
.ic.flip { transform: rotate(180deg); }
.ic.flip-v { transform: rotate(180deg); }
.print-only { display: none; }

/* -------------------------------------------------- botons i camps */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.06); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); border-color: transparent; }
.btn-big { min-height: 54px; font-size: 1.05rem; width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

.input {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
}
textarea.input { resize: vertical; min-height: 80px; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend { font-weight: 600; font-size: .92rem; padding: 0; margin-bottom: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { background: var(--surface-2); padding: 12px 14px; border-radius: var(--r-sm); font-size: .92rem; }
.row-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.row-actions .btn { flex: 1 1 auto; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; }
.chip span {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px;
  border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 500; cursor: pointer;
}
.chip input:checked + span { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.chip-link { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 500; font-size: .92rem; }

.check-list { display: grid; gap: 2px; max-height: 260px; overflow: auto; border: 1.5px solid var(--line); border-radius: var(--r-sm); padding: 4px; }
.check { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 4px 8px; border-radius: 6px; cursor: pointer; }
.check:hover { background: var(--surface-2); }
.check input, .check-only input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.check-only { display: grid; place-items: center; width: 44px; align-self: stretch; cursor: pointer; }

.switch-row { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.switch-row input { position: absolute; opacity: 0; }
.switch { width: 50px; height: 30px; border-radius: 99px; background: var(--unmarked); position: relative; flex: none; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch-row input:checked + .switch { background: var(--bad); }
.switch-row input:checked + .switch::after { transform: translateX(20px); }
.switch-row input:focus-visible + .switch { outline: 3px solid var(--accent); outline-offset: 2px; }

.seg { display: inline-flex; background: var(--surface-2); padding: 4px; border-radius: 10px; gap: 4px; }
.seg button { border: 0; background: transparent; min-height: 40px; padding: 0 16px; border-radius: 7px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.count.urgent { background: var(--bad); color: #fff; }

/* Nivells de pista */
.lvl {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 5px;
  font: 600 .74rem/1 var(--f-body); text-transform: uppercase; letter-spacing: .06em;
  color: var(--lv-ink); vertical-align: 2px;
}
.lvl-verd { background: var(--lv-verd); }
.lvl-blau { background: var(--lv-blau); }
.lvl-vermell { background: var(--lv-vermell); }
.lvl-negre { background: var(--lv-negre); box-shadow: inset 0 0 0 1px var(--line); }

.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); font-size: .8rem; font-weight: 500; border: 0; }
.tag .ic { width: 14px; height: 14px; vertical-align: -2px; }
.tag-dia { background: var(--accent-soft); color: var(--accent); }
.tag-move { background: var(--warn-soft); color: var(--warn); }
.tag-med { background: var(--bad-soft); color: var(--bad); cursor: pointer; }
.tag-abs { background: var(--bad-soft); color: var(--bad); font-variant-numeric: tabular-nums; flex: none; }

/* -------------------------------------------------- barres d'estat */
.demo-bar, .offline-bar {
  padding: 8px var(--gutter); font-size: .85rem; font-weight: 600; text-align: center;
  background: var(--warn-soft); color: var(--warn);
}
.offline-bar { display: flex; gap: 8px; justify-content: center; align-items: center; }
.loading, .center-card { min-height: 70vh; display: grid; place-content: center; justify-items: center; gap: 14px; text-align: center; padding: 24px var(--gutter); color: var(--muted); }
.center-card h1 { color: var(--ink); }
.center-card p { max-width: 36ch; }
.empty { color: var(--muted); padding: 16px 0; }
.empty-state { text-align: center; padding: 40px 16px; display: grid; justify-items: center; gap: 10px; color: var(--muted); }
.empty-state h3 { color: var(--ink); }

/* -------------------------------------------------- inici */
.landing { max-width: 460px; margin: 0 auto; padding: 40px var(--gutter) 48px; display: grid; gap: 18px; }
.landing-mark { color: var(--accent); }
.landing h1 { font-size: 2.6rem; text-transform: uppercase; letter-spacing: .02em; }
.lead { color: var(--muted); font-size: 1.05rem; margin-top: -8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); }
.code-input { font: 700 1.5rem/1 var(--f-display); letter-spacing: .18em; text-transform: uppercase; text-align: center; }
.demo-groups { display: grid; gap: 10px; border-top: 1px dashed var(--line); padding-top: 14px; }

/* -------------------------------------------------- tria de grup */
.picker { max-width: 860px; margin: 0 auto; padding: 24px var(--gutter) 48px; display: grid; gap: 22px; }
.picker-head { display: grid; gap: 10px; }
.picker-head h1 { font-size: 2.2rem; text-transform: uppercase; }
.picker-sec { display: grid; gap: 10px; }
.picker-sec h2 { text-transform: uppercase; letter-spacing: .03em; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.pick {
  display: grid; gap: 6px; text-align: left; padding: 16px; min-height: 76px; border-radius: var(--r);
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
}
.pick:hover, .pick.on { border-color: var(--accent); }
.pick.on { box-shadow: 0 0 0 3px var(--accent-soft); }
.pick-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 1.08rem; }
.t-head-actions { display: flex; gap: 4px; align-items: center; flex: none; }
.share-card { display: grid; gap: 10px; border-color: var(--accent); }
.share-card h2 { display: flex; gap: 8px; align-items: center; }

/* -------------------------------------------------- dies */
.days { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.day {
  flex: 1 0 58px; display: grid; justify-items: center; gap: 0; padding: 6px 4px; min-height: 64px;
  border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--muted);
}
.day span { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.day b { font: 700 1.45rem/1.05 var(--f-display); color: var(--ink); font-variant-numeric: tabular-nums; }
.day small { font-size: .7rem; }
.day.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.day.on b { color: var(--bg); }

/* -------------------------------------------------- professor */
.t-head { background: var(--surface); border-bottom: 1px solid var(--line); padding: 16px var(--gutter) 12px; display: grid; gap: 14px; }
.t-head-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.t-title { min-width: 0; display: grid; gap: 4px; }
.t-title h1 { font-size: 2.1rem; text-transform: uppercase; letter-spacing: .01em; }
.eyebrow { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.t-tabs { margin: 14px var(--gutter) 0; display: flex; }
.t-tabs button { flex: 1; justify-content: center; }
.t-main { padding: 14px var(--gutter) 110px; max-width: 760px; margin: 0 auto; display: grid; gap: 12px; }

.tally { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tally-item { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 6px; text-align: center; display: grid; }
.tally-item b { font: 700 1.8rem/1 var(--f-display); font-variant-numeric: tabular-nums; }
.tally-item span { font-size: .72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tally-item.ok b { color: var(--ok); }
.tally-item.bad b { color: var(--bad); }
.tally-item.warn b { color: var(--warn); }

.progress { display: flex; gap: 2px; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress.sm { height: 6px; }
.progress i { display: block; height: 100%; }
.p-ok { background: var(--ok); }
.p-bad { background: var(--bad); }

.list-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.list-head h2 span { font: 500 1rem var(--f-body); }
.sub { margin-top: 18px; }

.students { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.stu {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; min-height: 68px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r);
  border-left-width: 5px; border-left-color: var(--unmarked);
}
.stu.st-present { border-left-color: var(--ok); }
.stu.st-absent { border-left-color: var(--bad); background: color-mix(in srgb, var(--bad-soft) 45%, var(--surface)); }
.stu-info { flex: 1; min-width: 0; display: grid; gap: 5px; }
.stu-info b { font-size: 1.05rem; font-weight: 600; overflow-wrap: anywhere; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.students.faded .stu { opacity: .6; min-height: 52px; }
.students.compact .stu { min-height: 56px; padding: 6px 8px; }
.students.compact .check { flex: 1; min-width: 0; }
.students.compact .check span { display: grid; }

.mark { display: flex; gap: 8px; flex: none; }
.mark-btn {
  width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center;
  border: 2px solid var(--line); background: var(--surface); color: var(--muted);
  transition: transform .08s ease, background .12s;
}
.mark-btn .ic { width: 28px; height: 28px; stroke-width: 2.6; }
.mark-btn:active { transform: scale(.94); }
.mark-btn.ok.on { background: var(--ok); border-color: var(--ok); color: var(--on-status); }
.mark-btn.bad.on { background: var(--bad); border-color: var(--bad); color: var(--on-status); }
.mark-btn.ok:not(.on):hover { border-color: var(--ok); color: var(--ok); }
.mark-btn.bad:not(.on):hover { border-color: var(--bad); color: var(--bad); }
.mark-btn.sm { width: 44px; height: 44px; border-radius: 10px; }
.mark-btn.sm .ic { width: 22px; height: 22px; }

.pass-toggle {
  justify-self: start; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px;
  border-radius: 99px; border: 1.5px dashed var(--accent); background: transparent; color: var(--accent); font-weight: 600; font-size: .88rem;
}
.pass-toggle.on { border-style: solid; background: var(--accent); color: var(--accent-ink); }
.pass-toggle.subtle { border-color: var(--line); color: var(--muted); font-weight: 500; }
.pass-toggle.subtle.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.fab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.fab-bar .btn { max-width: 728px; margin: 0 auto; display: flex; box-shadow: 0 6px 20px rgba(194, 84, 26, .3); }

.choice-list { display: grid; gap: 10px; margin-top: 12px; }
.choice {
  display: flex; gap: 14px; align-items: center; text-align: left; padding: 16px;
  border: 1.5px solid var(--line); border-radius: var(--r); background: var(--surface); min-height: 76px;
}
.choice:hover { border-color: var(--accent); }
.choice > .ic { width: 28px; height: 28px; color: var(--accent); }
.choice span { display: grid; gap: 2px; }
.choice small { color: var(--muted); }
.note-box { display: flex; gap: 12px; padding: 14px; border-radius: var(--r-sm); background: var(--bad-soft); color: var(--ink); margin-bottom: 12px; }
.note-box .ic { color: var(--bad); }

/* -------------------------------------------------- incidències */
.tickets { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ticket { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 8px; }
.ticket.urgent.tk-obert { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.ticket.tk-resolt, .ticket.tk-rebutjat { opacity: .78; }
.ticket-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge { font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; display: inline-flex; align-items: center; gap: 6px; }
.ticket.urgent .badge { color: var(--bad); }
.status-pill { font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.s-obert { background: var(--warn-soft); color: var(--warn); }
.s-resolt { background: var(--ok-soft); color: var(--ok); }
.s-rebutjat { background: var(--surface-2); color: var(--muted); }
.resolution { color: var(--ok); font-weight: 500; display: flex; gap: 6px; align-items: flex-start; }
.tk-msg { font-size: 1.02rem; }
.tk-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.tk-actions .btn { white-space: normal; text-align: left; }

/* -------------------------------------------------- fulls inferiors */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(8, 14, 24, .45); opacity: 0; transition: opacity .2s; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 92vh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 18px 18px 0 0; transform: translateY(24px); opacity: 0;
  transition: transform .22s ease, opacity .22s ease; padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sheet-wide { max-width: 760px; }
.sheet-wrap.open .sheet { transform: none; opacity: 1; }
.sheet-wrap.open .sheet-backdrop { opacity: 1; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 10px 8px var(--gutter); }
.sheet-head h2 { min-width: 0; }
.sheet-body { overflow-y: auto; padding: 4px var(--gutter) 22px; display: grid; gap: 12px; }
.confirm-text { font-size: 1.05rem; }
.sticky-actions { position: sticky; bottom: -22px; background: var(--bg); padding: 10px 0 4px; }
.link-box { display: flex; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 8px 8px 12px; }
.link-box code { flex: 1; min-width: 0; font-size: .85rem; }
@media (min-width: 700px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 18px; max-height: 86vh; }
}

.toasts { position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 10px; background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); transition: opacity .3s, transform .3s; }
.toast-ok { background: var(--ok); color: #fff; }
.toast-error { background: var(--bad); color: #fff; }
.toast-warn { background: var(--warn); color: #fff; }
.toast.out { opacity: 0; transform: translateY(-8px); }

/* -------------------------------------------------- organització */
.a-head { display: flex; justify-content: space-between; align-items: center; padding: 12px var(--gutter); background: var(--ink); color: var(--bg); }
.a-head .icon-btn { color: var(--bg); }
.a-head .icon-btn:hover { background: rgba(255, 255, 255, .1); }
.a-brand { display: flex; gap: 10px; align-items: center; }
.a-brand > .ic { color: var(--accent); width: 28px; height: 28px; }
.a-brand div { display: grid; }
.a-brand b { font: 700 1.25rem/1.1 var(--f-display); text-transform: uppercase; letter-spacing: .02em; }
.a-brand .muted { color: color-mix(in srgb, var(--bg) 65%, transparent); }
.a-tabs {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; display: flex; gap: 2px; overflow-x: auto;
  background: var(--surface); border-bottom: 1px solid var(--line); padding: 0 8px; scrollbar-width: none;
}
.a-tabs::-webkit-scrollbar { display: none; }
.a-tab {
  display: flex; align-items: center; gap: 6px; padding: 0 12px; min-height: 52px; flex: none;
  border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font-weight: 600;
}
.a-tab.on { color: var(--ink); border-bottom-color: var(--accent); }
.a-main { max-width: 1120px; margin: 0 auto; padding: 16px var(--gutter) 64px; display: grid; gap: 16px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.bulk-bar { position: sticky; top: 60px; z-index: 5; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 14px; background: var(--ink); color: var(--bg); border-radius: var(--r-sm); }
.bulk-bar span { font-weight: 600; margin-right: auto; }
.bulk-bar .btn-ghost { color: var(--bg); }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.kpi {
  display: grid; gap: 2px; text-align: left; padding: 14px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--line); color: var(--ink);
}
.kpi span { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.kpi b { font: 700 2.3rem/1 var(--f-display); font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: .82rem; }
.kpi.ok { border-top-color: var(--ok); }
.kpi.bad { border-top-color: var(--bad); }
.kpi.warn { border-top-color: var(--warn); }
.kpi-link { cursor: pointer; font: inherit; }
.kpi-link:hover { border-color: var(--accent); }

.alert-box { background: var(--warn-soft); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 10px; }
.alert-box h3 { display: flex; gap: 8px; align-items: center; color: var(--warn); }
.alert-box ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.alert-box li { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

.board { display: grid; gap: 10px; }
.board > h2 { text-transform: uppercase; letter-spacing: .03em; }
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.gcard {
  display: grid; gap: 6px; text-align: left; padding: 12px; border-radius: var(--r);
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); min-width: 0;
}
.gcard:hover { border-color: var(--accent); }
.gcard-top { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.gcard-top b { font-weight: 600; }
.gcard-num { font: 600 1rem var(--f-display); color: var(--muted); font-variant-numeric: tabular-nums; }
.gcard-num b { font-size: 1.9rem; color: var(--ink); }

.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.row { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 4px 6px 4px 0; min-height: 60px; }
.row-main { flex: 1; min-width: 0; display: grid; gap: 2px; text-align: left; border: 0; background: transparent; padding: 8px 6px 8px 14px; color: var(--ink); }
.row .check-only + .row-main { padding-left: 0; }
.row-main .muted { overflow-wrap: anywhere; }
.code { font-weight: 700; letter-spacing: .1em; background: var(--surface-2); padding: 4px 8px; border-radius: 6px; font-size: .85rem; }
.mod-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.mod-row .chips { grid-column: 1 / -1; }
.mod-row .icon-btn { grid-row: 1; grid-column: 2; }
.week-dots { display: flex; gap: 6px; }
.dot { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.d-present { background: var(--ok); color: var(--on-status); }
.d-absent { background: var(--bad); color: var(--on-status); }

/* -------------------------------------------------- estadístiques */
.report { display: grid; gap: 16px; }
.report > h2 { margin-top: 12px; text-transform: uppercase; letter-spacing: .03em; }
.report-head { display: grid; gap: 6px; }
.report-head h1 { font-size: 2.4rem; text-transform: uppercase; }
.findings { margin: 0; padding: 14px 16px 14px 34px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); display: grid; gap: 6px; }
.chart { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 8px; }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.bar-present { fill: var(--ok); background: var(--ok); }
.bar-absent { fill: var(--bad); background: var(--bad); }
.bar-unmarked { fill: var(--unmarked); background: var(--unmarked); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ax-l { fill: var(--ink); font: 600 13px var(--f-body); }
.chart .ax-s { fill: var(--muted); font: 500 11px var(--f-body); font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; }
.bar-g:hover .hit, .bar-g:focus .hit { fill: var(--surface-2); }
.bar-g:focus { outline: none; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.tbl .n { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }
.rate { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.rate-track { width: 80px; height: 6px; border-radius: 99px; background: var(--bad-soft); overflow: hidden; }
.rate-track i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.rate b { min-width: 3.2em; text-align: right; }
.day-abs { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 14px; }
.day-abs summary { cursor: pointer; }
.cols { columns: 2 260px; margin: 10px 0 0; padding-left: 18px; }
.cols li { break-inside: avoid; padding: 2px 0; }

@media (max-width: 520px) {
  .tally-item b { font-size: 1.55rem; }
  .tally-item span { font-size: .64rem; }
  .filters { grid-template-columns: 1fr; }
  .a-tab span { display: none; }
  .a-tab.on span { display: inline; }
  .mark-btn { width: 52px; height: 52px; }
  .grid-2 { grid-template-columns: 1fr; }
}

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

/* -------------------------------------------------- impressió de l'informe */
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #F1F3F6; --ink: #000; --muted: #444; --line: #CCC; color-scheme: light; }
  body { font-size: 11pt; }
  .a-head, .a-tabs, .no-print, .demo-bar, .toasts, .fab-bar { display: none !important; }
  .print-only { display: block; }
  .a-main { padding: 0; max-width: none; }
  .table-wrap { overflow: visible; border: 0; }
  .tbl th, .tbl td { white-space: normal; padding: 5px 8px; }
  .report > h2 { break-after: avoid; }
  .table-wrap, .chart, .kpis { break-inside: avoid; }
  .day-abs { break-inside: avoid; }
  .kpi, .lvl, .rate-track i, .bar-present, .bar-absent, .sw { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
