:root {
  --red: #b3261e;
  --red-dark: #8c1d17;
  --green: #1e6b3a;
  --green-bg: #e7f4ea;
  --grid: #d6d9de;
  --head: #f1f3f4;
  --text: #1f2328;
  --muted: #5f6368;
  --sel: #e8f0fe;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: #fafafa; }

.hero {
  background: linear-gradient(135deg, var(--red-dark), var(--red) 60%, #c94a2a);
  color: #fff;
  padding: 28px 20px 24px;
}
.hero-inner { max-width: 1200px; margin: 0 auto; }
.hero h1 { margin: 0 0 8px; font-size: clamp(1.5rem, 3vw, 2.2rem); }
.hero p { margin: 0 0 16px; max-width: 760px; line-height: 1.5; opacity: .95; }
.progress { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.bar { flex: 0 1 380px; height: 12px; background: rgba(255,255,255,.25); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: #ffd54f; transition: width .6s; }
#progress-text { font-weight: 600; }

main { max-width: 1400px; margin: 0 auto; padding: 16px 12px 40px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.toolbar input, .toolbar select {
  font: inherit; padding: 8px 10px; border: 1px solid var(--grid); border-radius: 6px; background: #fff;
}
.toolbar input { flex: 1 1 260px; min-width: 200px; }
.count { color: var(--muted); font-size: .9rem; margin-left: auto; }

/* ── Aspect de foaie de calcul (doar citire) ── */
.sheet {
  background: #fff; border: 1px solid var(--grid); border-radius: 6px;
  overflow: auto; max-height: calc(100vh - 150px); min-height: 300px;
}
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
th, td { border-right: 1px solid var(--grid); border-bottom: 1px solid var(--grid); padding: 6px 8px; white-space: nowrap; text-align: left; }
thead th { position: sticky; background: var(--head); z-index: 2; font-weight: 600; user-select: none; }
thead tr.letters th { top: 0; height: 22px; padding: 2px 8px; font-weight: 400; color: var(--muted); text-align: center; font-size: 12px; }
thead tr.heads th { top: 22px; cursor: pointer; }
table.plain thead tr.heads th { top: 0; cursor: default; }
thead tr.heads th:hover { background: #e3e6e8; }
thead th.sorted-asc::after { content: " ▲"; font-size: 10px; }
thead th.sorted-desc::after { content: " ▼"; font-size: 10px; }
.rownum, td.rownum { position: sticky; left: 0; background: var(--head); color: var(--muted); text-align: center; width: 44px; font-size: 12px; z-index: 1; }
thead .rownum, thead tr.letters th:first-child { left: 0; z-index: 3; }
td.num, th.num { text-align: right; }
td.wide { white-space: normal; min-width: 280px; max-width: 460px; }
td.wish-empty { color: var(--muted); font-style: italic; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--sel); }
tbody tr:hover td.rownum { background: #d2e3fc; }
tbody tr.taken td { color: #6b7076; }
tbody tr.mine td { background: #fff8e1; }
td.santa { min-width: 170px; }
.pill-free {
  display: inline-block; padding: 3px 10px; border-radius: 99px; background: var(--red); color: #fff;
  font-size: 12px; font-weight: 600; border: 0; cursor: pointer; font-family: inherit;
}
.pill-free:hover { background: var(--red-dark); }
.santa-name { color: var(--green); font-weight: 600; }
.empty { text-align: center; padding: 40px; color: var(--muted); }
.hint { color: var(--muted); font-size: .85rem; }

/* ── Modal ── */
dialog {
  border: 0; border-radius: 14px; padding: 26px 26px 22px; width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(20, 20, 30, .55); }
dialog h2 { margin: 0 0 14px; font-size: 1.35rem; padding-right: 30px; }
.close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 28px; cursor: pointer; color: var(--muted); line-height: 1; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin: 0 0 16px; }
.facts div { background: var(--head); border-radius: 8px; padding: 8px 10px; }
.facts dt { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; }
.letter {
  margin: 0 0 16px; padding: 18px 20px; border-radius: 10px; line-height: 1.6;
  background: #fffbf0; border: 1px dashed #e0c58a; font-family: Georgia, "Times New Roman", serif; font-size: 1.05rem;
}
.taken-note { background: var(--green-bg); color: var(--green); padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.btn { font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; }
.btn.primary { background: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.primary:disabled { opacity: .55; cursor: wait; }
.btn.ghost { background: #fff; border-color: var(--grid); color: var(--text); }
.btn.ghost:hover { background: var(--head); }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 600; margin-bottom: 4px; }
.field input { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid #c4c7cc; border-radius: 8px; }
.field input:focus { outline: 2px solid #8ab4f8; border-color: transparent; }
.field input.invalid { border-color: var(--red); background: #fff5f5; }
.field small { display: block; color: var(--muted); margin-top: 4px; font-size: .82rem; line-height: 1.4; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 14px; line-height: 1.45; cursor: pointer; }
.check input { margin-top: 3px; width: 18px; height: 18px; flex: none; accent-color: var(--red); }
.check.invalid span { color: var(--red); }
.error { background: #fdecea; color: var(--red-dark); padding: 10px 12px; border-radius: 8px; margin: 0; }
.demo-note { background: #fff3cd; padding: 8px 12px; border-radius: 8px; font-size: .9rem; }
.done-icon { font-size: 56px; text-align: center; }
[data-step="done"] h2 { text-align: center; padding: 0; }
.box { background: var(--green-bg); border-radius: 10px; padding: 12px 16px; line-height: 1.55; }
.box ol { margin: 6px 0 0; padding-left: 20px; }

/* Exemplu de etichetă pentru cadou */
.tag-wrap { display: flex; gap: 16px; align-items: center; margin: 0 0 16px; }
.tag-help { margin: 0; font-size: .9rem; line-height: 1.45; color: var(--text); }
[data-step="done"] .tag-wrap { margin-top: 4px; }
.tag-link { flex: none; display: block; width: 230px; line-height: 0; border-radius: 8px; }
.tag-link img { width: 100%; height: auto; filter: drop-shadow(0 3px 6px rgba(0,0,0,.18)); }
.tag-print-link { display: inline-block; margin-top: 6px; color: var(--red-dark); font-weight: 600; }

/* Pagina de print a etichetei */
body.tag-page main { max-width: 760px; margin: 0 auto; padding: 24px 16px; }
body.tag-page h1 { margin: 0 0 8px; }
.tag-print { display: block; width: 100%; max-width: 700px; height: auto; margin: 18px 0; }
a.btn { text-decoration: none; display: inline-block; }
@media print {
  @page { margin: 12mm; }
  .no-print, .hint, .site-footer { display: none !important; }
  body { background: #fff; }
  body.tag-page main { padding: 0; }
  .tag-print { width: 110mm; margin: 0; }
}

@media (max-width: 900px) {
  .hero { padding: 18px 14px 16px; }
  .hero p { font-size: .95rem; margin-bottom: 12px; }
  main { padding: 12px 10px 30px; }
  .toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .toolbar input { grid-column: 1 / -1; min-width: 0; font-size: 16px; } /* 16px: iOS nu mai face zoom */
  .toolbar select { min-width: 0; width: 100%; font-size: 15px; }
  .count { grid-column: 1 / -1; margin: 0; }

  /* Pe telefon: fiecare copil = un card (tabelul rămâne pe desktop) */
  .sheet:has(#grid) { background: none; border: 0; overflow: visible; max-height: none; min-height: 0; }
  #grid thead { display: none; }
  #grid, #grid tbody { display: block; }
  #grid tr {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px;
    background: #fff; border: 1px solid var(--grid); border-radius: 12px;
    padding: 12px 14px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
  }
  #grid td { border: 0; padding: 0; white-space: normal; background: none !important; text-align: left; }
  #grid td.rownum { display: none; }
  #grid td.c-code { font-weight: 700; font-size: 1.05rem; }
  #grid td.c-init { font-weight: 600; }
  #grid td.c-init::before { content: "Inițiale: "; font-weight: 400; color: var(--muted); }
  #grid td.wide::before { content: "Dorință: "; color: var(--muted); font-style: normal; }
  #grid td.c-gen::before { content: "Gen: "; color: var(--muted); }
  #grid td.c-age::before { content: "Vârstă: "; color: var(--muted); }
  #grid td.c-cloth::before { content: "Haine: "; color: var(--muted); }
  #grid td.c-shoe::before { content: "Încălț.: "; color: var(--muted); }
  #grid td.c-gen, #grid td.c-age, #grid td.c-cloth, #grid td.c-shoe { font-size: .9rem; }
  #grid td.wide { flex-basis: 100%; min-width: 0; max-width: none; margin-top: 4px; line-height: 1.4; }
  #grid td.santa { flex-basis: 100%; min-width: 0; margin-top: 8px; }
  #grid td.santa .pill-free { display: block; width: 100%; padding: 10px; font-size: 14px; border-radius: 8px; }
  #grid tr.mine { background: #fff8e1; }
  #grid tr:hover td { background: none; }
  .hint { display: none; }

  dialog { padding: 22px 16px 16px; width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  dialog h2 { font-size: 1.15rem; }
  .facts { grid-template-columns: repeat(3, 1fr); }
  .letter { padding: 14px; font-size: 1rem; }
  .tag-wrap { flex-direction: column; gap: 10px; }
  .tag-link { width: min(300px, 100%); }
  .field input { font-size: 16px; }
  .actions { flex-direction: column-reverse; }
  .actions .btn { width: 100%; }
}

/* ── Admin ── */
body.admin main { max-width: 1100px; }
.card { background: #fff; border: 1px solid var(--grid); border-radius: 10px; padding: 18px 20px; margin-bottom: 18px; }
.card h2 { margin: 0 0 6px; font-size: 1.2rem; }
.muted { color: var(--muted); }
.import-row { display: grid; gap: 10px; margin-top: 10px; }
.radio { display: flex; gap: 10px; align-items: flex-start; line-height: 1.45; cursor: pointer; }
.radio input { margin-top: 4px; accent-color: var(--red); }
.check.danger span { color: var(--red-dark); }
.actions.left { justify-content: flex-start; margin-top: 4px; }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.sheet.short { max-height: 420px; min-height: 0; margin-top: 10px; }
table.list td { border-right: 0; }
.summary { margin-top: 14px; padding: 12px 16px; border-radius: 10px; background: #fff8e1; border: 1px solid #f0d58a; }
.summary.done { background: var(--green-bg); border-color: #a8d5b5; }
.summary h3 { margin: 0 0 6px; font-size: 1rem; }
.summary ul { margin: 6px 0; }
.summary details { margin: 4px 0; }
.summary details p { margin: 4px 0 4px 16px; font-size: .88rem; word-break: break-word; }
.summary details.warn summary { color: #8a6100; }
.summary details.danger summary { color: var(--red); font-weight: 700; }
.site-footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 0 12px 30px; }
.site-footer a, .field small a, .check a { color: inherit; }
.legal { max-width: 800px; line-height: 1.6; background: #fff; border: 1px solid var(--grid); border-radius: 10px; margin: 20px auto; padding: 10px 28px 24px; }
.legal h2 { font-size: 1.15rem; margin: 22px 0 6px; }
.legal li { margin-bottom: 6px; }
a.btn { text-decoration: none; display: inline-block; }
.small-print { font-size: .82rem; margin: 0 0 10px; }
.small-print a { color: inherit; }
[data-f="code"] { white-space: nowrap; }

/* Admin: cadouri sosite, SMS, confirmare */
.toolbar.compact { margin: 8px 0; }
table.gifts td { padding: 4px 8px; }
table.gifts td.c-code { font-weight: 700; white-space: nowrap; }
table.gifts td.g-act { text-align: right; white-space: nowrap; }
table.gifts tr.arrived td { background: var(--green-bg); }
.btn.danger { background: var(--red-dark); color: #fff; }
dialog.confirm { width: min(440px, calc(100vw - 24px)); }
.cf-big { font-size: 1.9rem; font-weight: 800; text-align: center; padding: 14px; margin: 6px 0 10px;
  background: #fff8e1; border: 2px dashed #e0c58a; border-radius: 10px; letter-spacing: .02em; }
#cf-text { line-height: 1.5; word-break: break-word; }
.sms-top { display: grid; gap: 6px; margin: 10px 0 4px; }
.field.inline { max-width: 280px; margin: 0; }
.sms-block { border-top: 1px solid var(--grid); padding-top: 14px; margin-top: 14px; }
.sms-block h3 { margin: 0 0 4px; font-size: 1.02rem; }
.sms-block textarea { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid #c4c7cc; border-radius: 8px; resize: vertical; }
.sms-meta { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.warn-text { color: #8a6100 !important; font-weight: 600; }
.ok-text { color: var(--green); margin: 8px 0 0; word-break: break-word; }
.sms-msg:empty { display: none; }
.sms-msg.error { margin-top: 8px; }
.small { font-size: .88rem; }
.nowrap { white-space: nowrap; }
code { background: var(--head); padding: 1px 5px; border-radius: 4px; font-size: .9em; }

/* Meniu de sus */
.topnav { background: #6e1410; position: sticky; top: 0; z-index: 20; }
.topnav-inner { max-width: 1200px; margin: 0 auto; display: flex; gap: 4px; overflow-x: auto; padding: 0 8px;
  scrollbar-width: none; }
.topnav a { color: #fbe9e7; text-decoration: none; padding: 11px 12px; white-space: nowrap; font-weight: 600; font-size: .95rem;
  border-bottom: 3px solid transparent; }
.topnav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.topnav a[aria-current="page"] { color: #fff; border-bottom-color: #f6d77a; }
.hero p.hero-lead { font-size: 1.15rem; font-weight: 700; margin-bottom: 8px; }
.hero p + p { margin-top: -6px; }
.hero.small { padding-top: 22px; padding-bottom: 22px; }

/* Recomandări (pagina principală) */
.recs { background: #fff; border: 1px solid #f0d58a; border-left: 5px solid #e0b84a; border-radius: 12px;
  padding: 12px 18px; margin-bottom: 14px; line-height: 1.55; }
.recs summary { font-weight: 700; font-size: 1.08rem; cursor: pointer; padding: 2px 0; }
.recs ul { margin: 10px 0; padding-left: 20px; }
.recs li { margin-bottom: 6px; }
.recs p { margin: 8px 0; }
.deadline { background: var(--green-bg); color: var(--green); padding: 10px 14px; border-radius: 8px; font-weight: 600; }
.contact-box { background: var(--head); border-radius: 10px; padding: 10px 16px; margin: 10px 0; }
.contact-box p { margin: 6px 0; }
.contact-box a { color: var(--red-dark); font-weight: 700; }

/* Pagini de conținut */
.prose { max-width: 780px; margin: 0 auto; background: #fff; border: 1px solid var(--grid); border-radius: 14px;
  padding: 26px 30px; line-height: 1.7; font-size: 1.04rem; }
.prose h2 { font-size: 1.25rem; margin: 28px 0 8px; color: var(--red-dark); }
.prose p { margin: 0 0 14px; }
.prose .lead { font-size: 1.18rem; font-weight: 700; color: var(--red-dark); }
.prose a { color: var(--red-dark); }
.prose .steps { list-style: none; padding: 0; margin: 0 0 16px; }
.prose .steps li { padding: 8px 12px; margin-bottom: 6px; background: #fff8e1; border-radius: 8px; }
.important-box { background: #fdecea; border: 2px solid #f3b8b3; border-radius: 12px; padding: 4px 18px 6px; margin: 22px 0; }
.important-box h2 { margin-top: 14px; }
.prose .cta { text-align: center; margin: 28px 0 4px; }
.prose .cta .btn { text-decoration: none; display: inline-block; }
@media (max-width: 900px) {
  .prose { padding: 18px 16px; font-size: 1rem; border-radius: 10px; }
  .recs { padding: 10px 14px; }
  .topnav { position: static; }
  .topnav-inner { flex-wrap: wrap; justify-content: center; gap: 0 2px; padding: 2px 4px; }
  .topnav a { padding: 7px 9px; font-size: .88rem; }
}

/* Admin pe pagini: ecranul nu se derulează; se derulează doar conținutul paginii active */
body.admin { height: 100vh; height: 100dvh; overflow: hidden; }
body.admin main { height: 100%; display: flex; flex-direction: column; padding-bottom: 12px; }
body.admin main > h1 { margin: 0 0 8px; font-size: 1.4rem; }
body.admin #panel:not([hidden]) { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.admin-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 10px; border-bottom: 2px solid var(--grid); }
.admin-tabs a { padding: 9px 14px; text-decoration: none; color: var(--text); font-weight: 600; border-radius: 8px 8px 0 0;
  border: 1px solid transparent; border-bottom: 0; margin-bottom: -2px; white-space: nowrap; }
.admin-tabs a:hover { background: var(--head); }
.admin-tabs a[aria-current] { background: #fff; border-color: var(--grid); border-bottom: 2px solid #fff; color: var(--red-dark); }
body.admin .tab-panel:not([hidden]) { flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 0; }
body.admin .tab-panel.scroll-panel { overflow-y: auto; display: block; }
body.admin .sheet.fill { flex: 1; min-height: 120px; max-height: none; margin-top: 10px; }
@media (max-width: 900px) {
  body.admin main { padding: 8px 8px 8px; }
  .admin-tabs { gap: 2px; }
  .admin-tabs a { padding: 6px 8px; font-size: .85rem; }
  body.admin.logged-in main > .toolbar { display: flex; gap: 8px; }
  body.admin.logged-in main > .toolbar .count { grid-column: auto; flex: 1; }
  body.admin .card { padding: 12px; }
}
body.admin.logged-in #token, body.admin.logged-in #btn-load { display: none; }
body.admin.logged-in main > .toolbar { margin-bottom: 0; align-items: center; }
body.admin #btn-logout { margin-left: auto; }
.list-title { margin: 22px 0 2px; font-size: 1.4rem; color: var(--red-dark); }
.list-sub { margin: 0 0 10px; color: var(--muted); }
@media (max-width: 900px) { .list-title { font-size: 1.2rem; margin-top: 16px; } .list-sub { font-size: .92rem; } }
/* Acasă */
.btn.big { font-size: 1.35rem; padding: 18px 34px; border-radius: 12px; text-decoration: none; display: inline-block; font-weight: 800; }
.hero-cta { margin: 20px 0 22px !important; }
.hero-cta .btn { background: #fff; color: var(--red-dark); box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.hero-cta .btn:hover { background: #fff8e1; }
main.home { max-width: 900px; }
.recs h2 { margin: 4px 0 6px; font-size: 1.2rem; }
.cta.center { text-align: center; margin: 22px 0 6px; }
@media (max-width: 900px) { .btn.big { display: block; text-align: center; font-size: 1.15rem; padding: 16px 14px; } }

/* Banda DGASPC deasupra meniului */
.org-band { background: #fff; border-bottom: 1px solid var(--grid); }
.org-inner { max-width: 1200px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 16px;
  color: var(--text); text-decoration: none; flex-wrap: wrap; }
.org-logo { height: 52px; width: auto; flex: none; }
@media (max-width: 700px) {
  .org-inner { padding: 6px 10px; gap: 4px 10px; justify-content: center; }
  .org-logo { height: 40px; }
}
