/* Reservas TIC — hoja de estilos única, sin dependencias */
:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --ink: #1d2a2f;
  --ink-2: #4b5a60;
  --muted: #7a868b;
  --line: #e2ddd3;
  --brand: #0f5c63;
  --brand-ink: #ffffff;
  --brand-soft: #e3f0f0;
  --free: #1f7a4a;
  --free-bg: #e5f4ea;
  --partial: #9a5b00;
  --partial-bg: #fdf0d9;
  --full: #a3302b;
  --full-bg: #fbe5e2;
  --focus: #f0a32a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 35, .06), 0 4px 16px rgba(20, 30, 35, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--font);
}
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- estructura */
.topbar {
  background: var(--brand); color: var(--brand-ink);
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: .8rem 16px;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; margin-right: auto; }
.brand-title { font-weight: 700; font-size: 1.1rem; letter-spacing: .01em; }
.brand-sub { font-size: .8rem; opacity: .85; }
.topnav { display: flex; gap: .25rem; flex-wrap: wrap; }
.topnav a, .topnav button {
  color: var(--brand-ink); text-decoration: none; padding: .45rem .75rem; border-radius: 8px;
  font: inherit; background: transparent; border: 0; cursor: pointer;
}
.topnav a:hover, .topnav button:hover { background: rgba(255,255,255,.12); }
.topnav a[aria-current="page"] { background: rgba(255,255,255,.18); font-weight: 600; }

main { max-width: 1200px; margin: 0 auto; padding: 1.25rem 16px 3rem; }
.footer { max-width: 1200px; margin: 0 auto; padding: 1rem 16px 2rem; color: var(--muted); font-size: .85rem;
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.footer a { color: var(--muted); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem;
}
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: end; }
.grow { flex: 1 1 auto; }
main.narrow { max-width: 760px; }
.mt { margin-top: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- formularios */
label { display: block; font-weight: 600; font-size: .85rem; color: var(--ink-2); margin-bottom: .25rem; }
.field { display: flex; flex-direction: column; min-width: 0; }
.field .hint { font-weight: 400; color: var(--muted); font-size: .8rem; margin-top: .2rem; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid #cfc8bb; border-radius: 8px; padding: .55rem .65rem; min-height: 2.5rem; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 2px solid var(--brand-soft); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--brand); }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; color: var(--ink); }
.form-grid { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.form-grid .span-all { grid-column: 1 / -1; }
.person-row { display: flex; gap: .85rem; align-items: end; flex-wrap: wrap; }
.person-row .field { flex: 1 1 170px; }
input:disabled { background: #ece8e0; color: var(--ink-2); cursor: not-allowed; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem 1rem; margin: 0; }
legend { font-weight: 700; padding: 0 .35rem; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  border-radius: 8px; padding: .55rem 1rem; min-height: 2.5rem;
  border: 1px solid #cfc8bb; background: var(--surface); color: var(--ink);
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: #0b4a50; }
.btn-danger { color: var(--full); border-color: #e5b9b4; }
.btn-danger:hover { background: var(--full-bg); }
.btn-sm { padding: .3rem .6rem; min-height: 2rem; font-size: .85rem; }
.btn-link { border: 0; background: none; color: var(--brand); padding: .2rem; min-height: 0; font-weight: 600; }

.segmented { display: inline-flex; border: 1px solid #cfc8bb; border-radius: 8px; overflow: hidden; background: var(--surface); }
.segmented button { font: inherit; border: 0; background: transparent; padding: .5rem .9rem; cursor: pointer; color: var(--ink-2); min-height: 2.5rem; }
.segmented button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); font-weight: 600; }

/* ---------- avisos */
.alert { border-radius: 8px; padding: .65rem .85rem; border: 1px solid; font-size: .92rem; }
.alert-error { background: var(--full-bg); border-color: #efc2bd; color: #7c1f1a; }
.alert-ok { background: var(--free-bg); border-color: #bfe2cb; color: #155a35; }
.alert-warn { background: var(--partial-bg); border-color: #f1d8a8; color: #6e4100; }
.alert-info { background: var(--brand-soft); border-color: #c4dfe0; color: #0b4a50; }
.alert ul { margin: .35rem 0 0; padding-left: 1.2rem; }

.toast-region { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: .5rem; width: min(92vw, 420px); }
.toast { background: var(--ink); color: #fff; border-radius: 8px; padding: .7rem 1rem; box-shadow: var(--shadow); }

/* ---------- calendario */
.toolbar { display: flex; gap: .75rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.weeknav { display: flex; align-items: center; gap: .35rem; }
.weeknav .week-label { font-weight: 700; min-width: 11rem; text-align: center; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; color: var(--ink-2); margin: .5rem 0 1rem; }
.legend span::before { content: ""; display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.legend .l-free::before { background: var(--free-bg); border: 1px solid var(--free); }
.legend .l-partial::before { background: var(--partial-bg); border: 1px solid var(--partial); }
.legend .l-full::before { background: var(--full-bg); border: 1px solid var(--full); }

.daytabs { display: none; gap: .35rem; overflow-x: auto; margin-bottom: .75rem; padding-bottom: .25rem; }
.daytabs button { font: inherit; border: 1px solid #cfc8bb; background: var(--surface); border-radius: 8px; padding: .4rem .7rem; cursor: pointer; white-space: nowrap; }
.daytabs button[aria-pressed="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }

.cal {
  display: grid; grid-template-columns: 4.5rem repeat(5, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.cal-head, .cal-slot, .cal-cell { padding: .5rem; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
.cal-head { background: var(--surface-2); font-weight: 700; font-size: .88rem; text-align: center; }
.cal-head.is-today { color: var(--brand); box-shadow: inset 0 -3px 0 var(--brand); }
.cal-head .date { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.cal-slot { background: var(--surface-2); font-weight: 700; color: var(--ink-2); display: flex; align-items: center; justify-content: center; font-size: .9rem; }
.cal-cell { display: flex; flex-direction: column; gap: .3rem; min-height: 3.5rem; }
.cal-cell.is-past { background: repeating-linear-gradient(-45deg, #faf8f4, #faf8f4 6px, #f3f0ea 6px, #f3f0ea 12px); }

.chip {
  display: flex; justify-content: space-between; align-items: center; gap: .4rem;
  font: inherit; font-size: .8rem; text-align: left; width: 100%;
  border-radius: 6px; padding: .3rem .45rem; border: 1px solid; cursor: pointer; line-height: 1.2;
}
.chip .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .chip-val { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip.free { background: var(--free-bg); border-color: #a9d8b9; color: var(--free); }
.chip.partial { background: var(--partial-bg); border-color: #efcf93; color: var(--partial); }
.chip.full { background: var(--full-bg); border-color: #ebb7b1; color: var(--full); cursor: default; }
.chip:disabled { cursor: default; }
.chip:not(:disabled):hover { filter: brightness(.97); box-shadow: 0 0 0 2px rgba(15,92,99,.15); }
.chip .chip-dept { display: block; font-size: .72rem; font-weight: 400; opacity: .85; white-space: normal; }

@media (max-width: 760px) {
  .daytabs { display: flex; }
  .cal { grid-template-columns: 3.5rem minmax(0, 1fr); }
  .cal [data-day]:not(.day-visible) { display: none; }
  .weeknav .week-label { min-width: 0; }
  .toolbar > * { flex: 1 1 100%; }
  .toolbar .weeknav { justify-content: space-between; }
}

/* ---------- diálogo */
dialog {
  border: 0; border-radius: 14px; padding: 0; width: min(680px, calc(100vw - 24px));
  max-height: calc(100vh - 24px); box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--ink);
}
dialog::backdrop { background: rgba(20, 30, 35, .45); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.1rem .5rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dlg-head h2 { margin: 0; }
.dlg-body { padding: 1rem 1.1rem; }
.dlg-foot { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; padding: .75rem 1.1rem 1rem; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }
.close-x { font-size: 1.4rem; line-height: 1; border: 0; background: none; cursor: pointer; color: var(--ink-2); padding: .2rem .4rem; border-radius: 6px; }

.avail { border-radius: 8px; padding: .65rem .85rem; font-size: .92rem; border: 1px dashed var(--line); background: var(--surface-2); }
.avail.ok { border-style: solid; border-color: #bfe2cb; background: var(--free-bg); color: #155a35; }
.avail.bad { border-style: solid; border-color: #efc2bd; background: var(--full-bg); color: #7c1f1a; }
.occ-list { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .3rem; }
.occ-list li { font-size: .82rem; padding: .25rem .45rem; border-radius: 6px; background: rgba(255,255,255,.7); }
.occ-list li.bad { background: #fff; color: var(--full); font-weight: 700; }

.code-box {
  text-align: center; border: 2px dashed var(--brand); border-radius: 12px; padding: 1rem; background: var(--brand-soft);
}
.code-box .code { font: 700 2rem/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .12em; color: var(--brand); user-select: all; }

dl.summary { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.summary dt { color: var(--muted); }
dl.summary dd { margin: 0; font-weight: 600; }

/* ---------- tablas (admin) */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { background: var(--surface-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-2); white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.actions { white-space: nowrap; text-align: right; }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: .1rem .45rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.badge.ok { background: var(--free-bg); color: var(--free); border-color: #bfe2cb; }
.badge.off { background: var(--full-bg); color: var(--full); border-color: #efc2bd; }
.badge.rec { background: var(--brand-soft); color: var(--brand); border-color: #c4dfe0; }
code.kode { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; letter-spacing: .05em; white-space: nowrap; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs button { font: inherit; border: 0; background: none; padding: .65rem 1rem; cursor: pointer; color: var(--ink-2); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700; }
.pager { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; margin-top: .75rem; }

.login-wrap { max-width: 380px; margin: 8vh auto; }

@media (max-width: 600px) {
  table.data.responsive thead { display: none; }
  table.data.responsive tr { display: block; border-bottom: 1px solid var(--line); padding: .4rem 0; }
  table.data.responsive td { display: flex; gap: .75rem; border: 0; padding: .2rem .6rem; }
  table.data.responsive td::before { content: attr(data-label); flex: 0 0 7.5rem; color: var(--muted); font-size: .8rem; }
  table.data.responsive td.actions { justify-content: flex-start; }
  table.data.responsive td.actions::before { content: ""; }
}

@media print {
  .topbar, .toolbar, .footer, .daytabs, .btn { display: none !important; }
  body { background: #fff; }
}
