:root {
  --bg: #f7f4ee; --surface: #ffffff; --ink: #2a2723; --muted: #5f584f; --line: #e2dccf;
  --primary: #2d6a64; --primary-dark: #1f4f4a; --primary-soft: #e3efed;
  --warn: #7a4b00; --warn-soft: #fbefd5;
  --block: #4b4753; --block-soft: #ebe8ee;
  --danger: #9c2f27; --danger-soft: #fbe9e7;
  --radius: 14px; --tap: 48px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 18px; line-height: 1.45; color: var(--ink); background: var(--bg);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
h1 { font-size: 1.5rem; line-height: 1.2; margin: 0 0 .75rem; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primary-dark); }
:focus-visible { outline: 3px solid #1a5fd0; outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: .75rem 1rem; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
[hidden] { display: none !important; }

/* botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: var(--tap); padding: .6rem 1.1rem;
  font: inherit; font-weight: 600; border-radius: 12px; border: 2px solid transparent; cursor: pointer; text-decoration: none; text-align: center; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn--soft { background: var(--primary-soft); color: var(--primary-dark); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); background: var(--surface); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--outline-danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn--block { width: 100%; }
.btn--sm { min-height: 44px; padding: .35rem .7rem; font-size: .9rem; }

/* formularios */
label { display: block; font-weight: 600; margin-bottom: .35rem; }
input, select, textarea { font: inherit; width: 100%; min-height: var(--tap); padding: .55rem .8rem; border: 2px solid #b9b1a2; border-radius: 12px; background: #fff; color: var(--ink); }
input[type=checkbox] { width: 1.4rem; min-height: 1.4rem; height: 1.4rem; }
.hint { color: var(--muted); font-size: .9rem; margin-top: .4rem; }
.msg { padding: .7rem .9rem; border-radius: 10px; margin: .75rem 0; }
.msg--error { background: var(--danger-soft); color: var(--danger); border: 1px solid #e3b4af; font-weight: 600; }
.msg--info { background: var(--primary-soft); color: var(--primary-dark); }
.lead { color: var(--muted); }
.loading, .empty { color: var(--muted); padding: 1rem 0; }
.notice { padding: 1rem; }

.center { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 1.5rem; width: 100%; max-width: 26rem; box-shadow: 0 2px 10px rgba(60,50,30,.06); }
.card--flat { max-width: none; margin-bottom: 1rem; box-shadow: none; }
.card form > * + * { margin-top: .75rem; }
.card form .hint { margin-top: .4rem; }

/* cabecera */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top__in { max-width: 72rem; margin: 0 auto; padding: .4rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { font-weight: 800; color: var(--primary-dark); font-size: 1.2rem; }
.tabs { list-style: none; display: flex; gap: .25rem; margin: 0; padding: 0; flex-wrap: wrap; }
.tabs a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 .9rem; border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 600; }
.tabs a[aria-current=page] { background: var(--primary); color: #fff; }
.wrap { max-width: 72rem; margin: 0 auto; padding: 1rem 1rem 3rem; }
main:focus { outline: none; }

.datebar { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: 1rem; align-items: stretch; }
.datebar__title { grid-column: 1 / -1; order: -1; margin: 0; }
.datebar__pick { grid-column: 1 / -1; }
.datebar__pick label { font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
.datebar .btn--soft { grid-column: 1 / -1; }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.pagehead h1 { margin: 0; }

/* turnos */
.slots, .res, .mini, .names { list-style: none; margin: 0; padding: 0; }
.slots { display: grid; gap: .75rem; }
.slot { background: var(--surface); border: 1px solid var(--line); border-left-width: 8px; border-radius: var(--radius); padding: .9rem 1rem;
  display: grid; gap: .5rem; grid-template-columns: 1fr; }
.slot--open { border-left-color: var(--primary); }
.slot--full { border-left-color: #b9770e; background: #fffaf0; }
.slot--blocked { border-left-color: var(--block); background: repeating-linear-gradient(135deg, #f3f1f5, #f3f1f5 10px, #ebe8ee 10px, #ebe8ee 20px); }
.slot--past { border-left-color: #b7b0a4; background: #f2efe9; color: var(--muted); }
.slot--mine { box-shadow: 0 0 0 2px var(--primary) inset; }
.slot__time { font-size: 1.15rem; }
.slot__side { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.slot__reason { color: var(--muted); font-size: .9rem; margin: .25rem 0 0; }
.nobody { color: var(--muted); }
.names { display: flex; flex-wrap: wrap; gap: .4rem; }
.name { background: #efebe2; border-radius: 999px; padding: .15rem .75rem; font-weight: 600; }
.name--mine { background: var(--primary); color: #fff; }
.badge { display: inline-block; padding: .2rem .65rem; border-radius: 999px; font-size: .9rem; font-weight: 700; white-space: nowrap; }
.badge--open { background: var(--primary-soft); color: var(--primary-dark); }
.badge--full { background: var(--warn-soft); color: var(--warn); }
.badge--blocked { background: var(--block-soft); color: var(--block); }
.badge--past { background: #e8e4db; color: var(--muted); }

/* semana */
.gridwrap { overflow-x: auto; }
.grid { width: 100%; border-collapse: separate; border-spacing: 4px; table-layout: fixed; min-width: 60rem; }
.grid th { font-weight: 700; text-align: center; padding: .4rem; background: var(--surface); border-radius: 10px; }
.grid thead th a { color: var(--ink); text-decoration: none; }
.grid thead th.is-today { background: var(--primary); }
.grid thead th.is-today a, .grid thead th.is-today .num { color: #fff; }
.grid tbody th { width: 4.5rem; background: transparent; }
.grid td { vertical-align: top; padding: 0; }
.num { font-weight: 400; font-size: .85rem; color: var(--muted); }
.cell { border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: .4rem; min-height: 5.5rem; display: grid; gap: .3rem; align-content: start; font-size: .9rem; }
.cell--full { background: #fffaf0; border-color: #e6c88f; }
.cell--blocked { background: var(--block-soft); }
.cell--past { background: #f2efe9; color: var(--muted); }
.cell--mine { box-shadow: 0 0 0 2px var(--primary) inset; }
.cell .badge { font-size: .78rem; padding: .1rem .5rem; }
.names--tight { gap: .25rem; }
.names--tight .name { font-size: .85rem; padding: .05rem .5rem; }
.weeklist { display: grid; gap: 1rem; }
.daysec h2 { margin: 0 0 .4rem; }
.daysec h2.is-today { color: var(--primary-dark); }
.mini { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.mini__row { display: grid; grid-template-columns: 3.4rem 1fr auto; gap: .2rem .6rem; align-items: center; padding: .55rem .75rem; border-bottom: 1px solid var(--line); }
.mini__row:last-child { border-bottom: 0; }
.mini__time { font-weight: 700; }
.mini__state { grid-column: 2; }
.mini__act { grid-column: 3; grid-row: 1 / span 2; }
.mini--past { color: var(--muted); background: #f6f3ed; }
.mini--blocked { background: #f3f1f5; }
.mini--mine { box-shadow: 4px 0 0 var(--primary) inset; }

/* mis reservas */
.res { display: grid; gap: .75rem; }
.res__item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

/* diálogo y avisos */
.dlg { border: 0; border-radius: 20px; padding: 1.5rem; max-width: min(30rem, 92vw); width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,.25); color: var(--ink); }
.dlg::backdrop { background: rgba(40,35,25,.5); }
.dlg__actions { display: flex; gap: .75rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1rem; }
.dlg ul { padding-left: 1.2rem; max-height: 40vh; overflow: auto; }
.toast { position: fixed; left: 50%; width: max-content; bottom: 1rem; transform: translateX(-50%); max-width: min(32rem, 92vw); padding: .85rem 1.1rem; border-radius: 12px;
  background: var(--ink); color: #fff; font-weight: 600; z-index: 200; opacity: 0; pointer-events: none; transition: opacity .2s; }
.toast.show { opacity: 1; pointer-events: auto; }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary-dark); }

@media (max-width: 639px) {
  .top__in { gap: .25rem 1rem; }
  .tabs a { padding: 0 .55rem; font-size: .95rem; }
}
@media (min-width: 640px) {
  .slot { grid-template-columns: 9rem 1fr auto; align-items: center; }
  .slot__side { justify-content: flex-end; }
  .datebar { grid-template-columns: auto 1fr auto auto auto; align-items: center; }
  .datebar__title { grid-column: auto; order: 0; text-align: center; }
  .datebar__pick { grid-column: auto; }
  .datebar .btn--soft { grid-column: auto; }
}
@media (min-width: 900px) { .datebar { grid-template-columns: auto 1fr auto auto auto; } }

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

/* administración */
.admin .wrap { max-width: 80rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.tablewrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: .95rem; }
table.data th, table.data td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-weight: 700; background: #f3efe6; position: sticky; top: 0; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: end; margin-bottom: .75rem; }
.row > * { flex: 1 1 10rem; }
.row > .btn { flex: 0 0 auto; }
.inline { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.admin-slot { background: var(--surface); border: 1px solid var(--line); border-left: 8px solid var(--primary); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: .6rem; }
.admin-slot--full { border-left-color: #b9770e; }
.admin-slot--blocked { border-left-color: var(--block); background: #f3f1f5; }
.admin-slot--past { border-left-color: #b7b0a4; background: #f2efe9; }
.admin-slot__head { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; justify-content: space-between; margin-bottom: .4rem; }
.who { display: inline-flex; align-items: center; gap: .3rem; background: #efebe2; border-radius: 999px; padding: .1rem .2rem .1rem .75rem; margin: .15rem .3rem .15rem 0; font-weight: 600; }
.who button { min-height: 36px; min-width: 36px; border: 0; border-radius: 999px; background: var(--danger-soft); color: var(--danger); font-weight: 800; cursor: pointer; }
.muted { color: var(--muted); }
.tabs--wrap { margin-bottom: 1rem; }

.info { background: var(--primary-soft); border-bottom: 1px solid var(--line); }
.info__in { max-width: 72rem; margin: 0 auto; padding: .6rem 1rem; color: var(--primary-dark); }
.info__in summary { font-weight: 700; cursor: pointer; min-height: 32px; }
.info__in p { margin: .4rem 0 0; color: var(--ink); }
textarea { resize: vertical; }
