:root {
  --bg: #f5f5f3;
  --surface: #ffffff;
  --surface-2: #efefec;
  --text: #171a23;
  --muted: #5e6577;
  --border: #e2e0da;
  --accent: #1f2e85;
  --accent-ink: #ffffff;
  --accent-soft: #e6e9f5;
  --gold: #c5a760;
  --gold-ink: #7a6326;
  --gold-soft: #f6f0e1;
  --ok: #1f2e85;
  --ok-soft: #e6e9f5;
  --danger: #c43535;
  --danger-soft: #fbe7e7;
  --warn: #9a6200;
  --warn-soft: #fff2d9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 4px 16px rgba(20, 24, 40, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #181b24;
    --surface-2: #20242f;
    --text: #eceef4;
    --muted: #9aa1b2;
    --border: #2c3140;
    --accent: #8f9de6;
    --accent-ink: #0f1117;
    --accent-soft: #1f2645;
    --gold: #d4ba7a;
    --gold-ink: #d4ba7a;
    --gold-soft: #2e2716;
    --ok: #4a5cc7;
    --ok-soft: #1f2645;
    --danger: #ff7a7a;
    --danger-soft: #3a1d1f;
    --warn: #f0b44c;
    --warn-soft: #3a2d14;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
.form-week { display: block; margin-top: 4px; font-size: 1.05rem; font-weight: 600; color: var(--accent); }
h2 { font-size: 1.15rem; }
p { margin: 0 0 1rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
[hidden] { display: none !important; }

.wrap { max-width: 860px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 460px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

label { display: block; font-weight: 600; font-size: .9rem; margin: 0 0 6px; }
.field { margin-bottom: 14px; }
input[type=text], input[type=email], input[type=password], input[type=date], textarea, select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  min-height: 46px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, .day-option:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button, .btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 16px;
  min-height: 44px;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}
button:disabled { opacity: .55; cursor: not-allowed; }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .875rem; }
.btn-block { width: 100%; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

.alert { border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: .95rem; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }

.badge {
  display: inline-block; font-size: .75rem; font-weight: 600; border-radius: 999px;
  padding: 2px 9px; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

/* Cabecera de marca */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }

/* Formulario público: opciones de día */
.days { display: grid; gap: 8px; margin-bottom: 14px; }
.day-option {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; cursor: pointer; background: var(--surface);
  font-weight: 500; margin: 0;
}
.day-option input { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; }
.day-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.day-option .date { margin-left: auto; color: var(--muted); font-size: .9rem; }

/* App */
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--gold);
}
.topbar .wrap { display: flex; align-items: center; gap: 12px; padding-top: 10px; padding-bottom: 10px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin-bottom: 16px; }
.tabs button { flex: 1; background: transparent; color: var(--muted); min-height: 40px; white-space: nowrap; padding: 8px 10px; }
.user-list { list-style: none; margin: 0; padding: 0; }
.user-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: 0; }
.btn-sm { white-space: nowrap; }
.tabs button[aria-selected=true] { background: var(--surface); color: var(--accent); box-shadow: var(--shadow), inset 0 -2px 0 var(--gold); }

.week-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.week-nav .title { flex: 1; text-align: center; font-weight: 700; }
.week-nav button { min-width: 44px; padding: 0; }

.linkbox {
  display: flex; gap: 8px; align-items: center;
  background: var(--surface-2); border-radius: 10px; padding: 8px 8px 8px 12px;
  font-size: .875rem; word-break: break-all;
}
.linkbox code { flex: 1; font-family: ui-monospace, Menlo, monospace; }

.day-card { padding: 16px; }
.day-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.day-head h3 { margin: 0; font-size: 1.05rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 6px 14px; min-height: 38px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip[aria-pressed=true] { background: var(--ok); border-color: var(--ok); color: #fff; }
.chip .note-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.chip.extra { border-style: dashed; }
.empty { color: var(--muted); font-size: .9rem; }
.notes-list { margin: 10px 0 0; padding: 0; list-style: none; font-size: .875rem; color: var(--muted); }
.notes-list li { margin-top: 4px; }
.notes-list b { color: var(--text); font-weight: 600; }

.add-extra { display: flex; gap: 8px; margin-top: 10px; }
.add-extra input { min-height: 38px; padding: 6px 10px; }

table.list { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.list th, table.list td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.list th { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.table-scroll { overflow-x: auto; }

.preview { width: 100%; border-radius: 10px; border: 1px solid var(--border); display: block; margin-bottom: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-weight: 600; z-index: 50; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.2);
}

dialog {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  padding: 20px; width: min(440px, calc(100% - 32px));
}
dialog::backdrop { background: rgba(10, 12, 20, .45); }

.center-screen { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.center-screen > * { width: 100%; }

@media (min-width: 720px) {
  .days-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .days-grid .card { margin-bottom: 0; }
}

/* Días festivos */
.badge-holiday { background: var(--gold-soft); color: var(--gold-ink); border: 1px solid var(--gold); }
.day-card.is-holiday { border-color: var(--gold); box-shadow: var(--shadow), inset 4px 0 0 var(--gold); }
.holiday-toggle { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); margin: 0 0 10px; cursor: pointer; width: fit-content; }
.holiday-toggle input { width: 18px; height: 18px; margin: 0; accent-color: var(--gold); }
.day-option .holiday-tag { font-size: .75rem; font-weight: 600; color: var(--gold-ink); background: var(--gold-soft); border: 1px solid var(--gold); border-radius: 999px; padding: 1px 8px; }
