/* Agenda · estilos del panel y del widget de reservas
   Los temas cambian solo tokens; --primary lo define cada centro. */

:root, [data-theme="lino"] {
  --bg: #f4f5f3; --surface: #ffffff; --surface-2: #eceeea; --line: #dcdfda;
  --ink: #202527; --muted: #676e6d; --on-primary: #ffffff;
  --ok: #3f7457; --warn: #9a6b1f; --bad: #9c4a45; --info: #4d6479;
}
[data-theme="piedra"] { --bg: #f5f4f1; --surface: #fff; --surface-2: #edebe7; --line: #e0ddd7; --ink: #282421; --muted: #736d66; }
[data-theme="niebla"] { --bg: #f2f4f6; --surface: #fff; --surface-2: #e8ecf0; --line: #d9dfe5; --ink: #1d242b; --muted: #636d78; }
[data-theme="malva"]  { --bg: #f6f3f4; --surface: #fff; --surface-2: #eee8ea; --line: #e2dade; --ink: #2a2327; --muted: #766a70; }
[data-theme="grafito"] {
  --bg: #181a1b; --surface: #212426; --surface-2: #2a2e30; --line: #363b3e;
  --ink: #e7eae9; --muted: #9ba3a1; --on-primary: #16191a;
  --ok: #86c09f; --warn: #d9b36b; --bad: #de9690; --info: #9db4c9;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 "Hanken Grotesk", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; margin: 0; }
h2 { font-size: 1.05rem; }
small, .muted { color: var(--muted); }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Estructura del panel ---------- */
.panel { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--surface) 235px, var(--line) 235px 236px, var(--bg) 236px); }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px;
  padding-top: max(18px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.brand img { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; }
.brand .mono {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary); color: var(--on-primary); font-weight: 700;
}
.brand strong { font-size: .95rem; line-height: 1.2; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px;
  text-decoration: none; color: var(--muted); font-weight: 500;
}
.side nav a:hover { background: var(--surface-2); color: var(--ink); }
.side nav a.on { background: var(--surface-2); color: var(--ink); box-shadow: inset 3px 0 0 var(--primary); }
.me { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding: 14px 8px 0; }
.me div { flex: 1; min-width: 0; line-height: 1.25; }
.me strong { display: block; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me small { font-size: .78rem; }
.me a { color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

.main { min-width: 0; }
.top {
  display: flex; align-items: center; gap: 12px; padding: 20px 32px 8px;
  padding-top: max(20px, env(safe-area-inset-top));
}
.top h1 { font-size: 1.55rem; flex: 1; }
.content { padding: 12px 32px 48px; max-width: 1280px; }
.scrim { display: none; }
.only-m { display: none; }

/* ---------- Componentes ---------- */
.btn, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 600; font-size: .9rem; border-radius: 8px; cursor: pointer;
  padding: 9px 15px; text-decoration: none; border: 1px solid transparent; white-space: nowrap;
}
.btn { background: var(--primary); color: var(--on-primary); }
.btn:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-ghost.danger { color: var(--bad); }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.icon-btn { background: none; border: 0; color: var(--ink); padding: 6px; cursor: pointer; border-radius: 8px; }
form.inline { display: inline; }

.panel-box { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.panel-box > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-box > .body { padding: 18px 20px; }
.stack > * + * { margin-top: 20px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.kpi { padding: 16px 20px; border-left: 1px solid var(--line); }
.kpi:first-child { border-left: 0; }
.kpi b { display: block; font-size: 1.7rem; font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; }
.kpi small { font-size: .82rem; }

.badge { display: inline-block; font-size: .76rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.st-pending   { color: var(--warn); background: color-mix(in srgb, var(--warn) 13%, transparent); }
.st-confirmed { color: var(--ok);   background: color-mix(in srgb, var(--ok) 13%, transparent); }
.st-completed { color: var(--info); background: color-mix(in srgb, var(--info) 13%, transparent); }
.st-cancelled { color: var(--bad);  background: color-mix(in srgb, var(--bad) 12%, transparent); }
.st-no_show   { color: var(--muted); }

.flash { margin: 8px 32px 0; padding: 11px 16px; border-radius: 8px; background: color-mix(in srgb, var(--ok) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); }
.flash.err { background: color-mix(in srgb, var(--bad) 10%, var(--surface)); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }

/* Tablas: en móvil cada fila pasa a tarjeta */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .8rem; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions form + form { margin-left: 4px; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }

/* Formularios */
.form { display: grid; gap: 14px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
label { display: grid; gap: 5px; font-size: .85rem; font-weight: 600; }
label small { font-weight: 400; }
input, select, textarea {
  font: inherit; font-size: .95rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
input[type=color] { padding: 3px; height: 40px; }
input[type=checkbox] { width: auto; accent-color: var(--primary); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 16px; }
.filters label { min-width: 150px; }
code.snippet { display: block; background: var(--surface-2); padding: 12px; border-radius: 8px; font-size: .8rem; overflow-x: auto; white-space: pre; }

/* ---------- Hoy: línea de tiempo ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 58px 1fr auto; gap: 14px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .hour { font-size: 1.05rem; font-weight: 600; }
.timeline .who { border-left: 3px solid var(--pro, var(--primary)); padding-left: 12px; min-width: 0; }
.timeline .who strong { display: block; }
.timeline .who small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline li.past { opacity: .55; }
.timeline li.now-line { padding: 0; border: 0; height: 0; position: relative; }
.timeline li.now-line::after { content: ""; position: absolute; left: 20px; right: 20px; top: -1px; height: 2px; background: var(--primary); }

/* ---------- Horarios ---------- */
.week { display: grid; gap: 0; }
.day-row { display: grid; grid-template-columns: 120px 1fr; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: start; }
.day-row:last-child { border-bottom: 0; }
.ranges { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.range { display: flex; align-items: center; gap: 6px; background: var(--surface-2); padding: 4px 6px; border-radius: 8px; }
.range input { width: 128px; padding: 5px 7px; }

/* ---------- Calendario (FullCalendar) ---------- */
.fc { --fc-now-indicator-color: var(--primary); --fc-border-color: var(--line); --fc-today-bg-color: color-mix(in srgb, var(--primary) 7%, transparent); --fc-page-bg-color: var(--surface); --fc-neutral-bg-color: var(--surface-2); --fc-list-event-hover-bg-color: var(--surface-2); font-size: .88rem; }
.fc .fc-button { background: var(--surface); color: var(--ink); border: 1px solid var(--line); font-weight: 600; text-transform: none; box-shadow: none !important; }
.fc .fc-button-primary:not(:disabled).fc-button-active, .fc .fc-button-primary:not(:disabled):active { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.fc .fc-button:disabled { background: var(--surface); color: var(--muted); opacity: .6; }
.fc .fc-toolbar-title { font-size: 1.15rem; }
.fc-event { border-radius: 5px; padding: 1px 3px; cursor: pointer; }
.fc-event.is-pending { background-image: repeating-linear-gradient(45deg, transparent 0 6px, rgba(255,255,255,.22) 6px 12px); }
.fc-event.is-cancelled { opacity: .45; text-decoration: line-through; }

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--surface); color: var(--ink); width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(20, 22, 23, .4); }
dialog .dlg-body { padding: 22px; }
dialog dl { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 16px 0; font-size: .92rem; }
dialog dt { color: var(--muted); }
dialog dd { margin: 0; }
dialog .dlg-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .panel-box { width: min(380px, 100%); }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .grid-2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(3) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .panel { grid-template-columns: 1fr; background: var(--bg); }
  .side { position: fixed; z-index: 30; left: 0; width: 264px; transform: translateX(-100%); transition: transform .22s ease; }
  .side.open { transform: none; }
  .scrim.on { display: block; position: fixed; inset: 0; background: rgba(20, 22, 23, .35); z-index: 20; }
  .only-m { display: inline-flex; }
  .top { padding: 14px 16px 4px; padding-top: max(14px, env(safe-area-inset-top)); }
  .top h1 { font-size: 1.25rem; }
  .top .btn span { display: none; }
  .content { padding: 10px 16px 40px; }
  .filters label { flex: 1 1 140px; min-width: 0; }
  .flash { margin: 8px 16px 0; }
  .table thead { display: none; }
  .table tr { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .table td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: .82rem; flex: none; }
  .table td > div { text-align: right; }
  .table td:not([data-label]) { display: block; }
  .table td:not([data-label]) > div { text-align: left; }
  .table td:not([data-label])::before { display: none; }
  .table td.actions { justify-content: flex-start; flex-wrap: wrap; gap: 6px; padding-top: 8px; }
  .table td.actions::before { display: none; }
  .day-row { grid-template-columns: 1fr; gap: 8px; }
  .timeline li { grid-template-columns: 50px 1fr; padding: 12px 16px; }
  .timeline li > :last-child { grid-column: 2; }
  .panel-box > header, .panel-box > .body { padding: 14px 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
