/* Panel del tatuador — "libro de citas": superficies de tinta, papel y una sola tinta de acento. */
:root {
  --bg: #121110;
  --panel: #1b1916;
  --panel-2: #23201c;
  --line: #2f2b25;
  --fg: #ece6d8;
  --muted: #9a9283;
  --accent: #e8e1d3;
  --accent-fg: #14110d;
  --ok: #86b88e;
  --warn: #dcaa4e;
  --bad: #d4695c;
  --info: #8fa9c9;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 12px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f0ec;
    --panel: #ffffff;
    --panel-2: #f6f4ef;
    --line: #dedacf;
    --fg: #1c1a17;
    --muted: #6b655a;
    --ok: #3f7c4a;
    --warn: #96660a;
    --bad: #b03a2e;
    --info: #3d6190;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--sans);
  font-size: 15px; line-height: 1.45; min-height: 100vh;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; line-height: 1.2; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.2rem; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.side { display: none; }
.content { min-width: 0; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.brand-name { font-family: var(--serif); font-weight: 600; font-size: 1.05rem; }
.plan { display: inline-block; font-size: .72rem; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); margin-left: 8px; vertical-align: 2px; }
.plan-pro { border-color: var(--accent); color: var(--accent); }
main { padding: 20px 16px 24px; max-width: 1120px; margin: 0 auto; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 6;
}
.tabbar a {
  display: grid; justify-items: center; gap: 3px; padding: 9px 4px 8px; color: var(--muted); text-decoration: none; font-size: .72rem;
}
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar svg, .side svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

@media (min-width: 900px) {
  .app { grid-template-columns: 248px 1fr; }
  .side {
    display: flex; flex-direction: column; gap: 22px; padding: 26px 18px; border-right: 1px solid var(--line);
    position: sticky; top: 0; height: 100vh; background: var(--bg);
  }
  .side .brand-name { font-size: 1.25rem; display: block; line-height: 1.2; }
  .side .plan { margin: 8px 0 0; }
  .side nav { display: grid; gap: 2px; }
  .side nav a {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--muted); text-decoration: none;
  }
  .side nav a:hover { color: var(--fg); background: var(--panel); }
  .side nav a[aria-current="page"] { color: var(--fg); background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent); }
  .side-foot { margin-top: auto; display: grid; gap: 10px; font-size: .88rem; }
  .side-foot button { text-align: left; background: none; border: 0; padding: 0; color: var(--muted); }
  .side-foot button:hover { color: var(--fg); }
  .topbar, .tabbar { display: none; }
  .content { padding-bottom: 0; }
  main { padding: 36px 40px 56px; }
}

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 20px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 4px; }

/* ---------- Botones y campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 10px; padding: 10px 16px;
  border: 1px solid var(--line); background: var(--panel); font-weight: 600; text-decoration: none; color: var(--fg); min-height: 42px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.btn.quiet { background: none; }
.btn.sm { padding: 6px 12px; min-height: 34px; font-size: .88rem; }
.btn:disabled { opacity: .55; cursor: default; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

label.f { display: grid; gap: 6px; margin: 0 0 14px; font-size: .88rem; color: var(--muted); }
label.f > span small { opacity: .8; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=date], input[type=time], select, textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--fg); min-height: 42px;
}
textarea { min-height: 84px; resize: vertical; }
input:disabled, select:disabled, textarea:disabled { opacity: .55; }
input[type=color] { width: 52px; height: 42px; padding: 3px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; }
.chk { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 12px; cursor: pointer; font-size: .92rem; }
.chk input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }
.row2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .row2 { grid-template-columns: 1fr 1fr; } }
.pro-chip { font-size: .68rem; border: 1px solid var(--accent); color: var(--accent); border-radius: 999px; padding: 1px 7px; margin-left: 6px; }

/* ---------- Agenda ---------- */
.agenda { display: grid; gap: 22px; }
@media (min-width: 900px) { .agenda { grid-template-columns: 360px 1fr; align-items: start; gap: 36px; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 10px; }
.cal-head h2 { font-size: 1.1rem; }
.cal-nav { display: flex; gap: 6px; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: none; }
.icon-btn:hover { border-color: var(--accent); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.dow { text-align: center; font-size: .72rem; color: var(--muted); padding: 4px 0; }
.cd {
  aspect-ratio: 1 / 1.05; min-height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: none; border: 1px solid transparent; border-radius: 10px; font-variant-numeric: tabular-nums;
}
.cd:hover { background: var(--panel-2); }
.cd.today { border-color: var(--line); }
.cd.sel { background: var(--accent); color: var(--accent-fg); }
.cd.blank { visibility: hidden; }
.dots { display: flex; gap: 3px; height: 5px; }
.dot { width: 5px; height: 5px; border-radius: 50%; background: var(--ok); }
.dot.warn { background: var(--warn); }
.cd.sel .dot { background: var(--accent-fg); }

.day-title { margin: 0 0 4px; }
.day-meta { color: var(--muted); margin: 0 0 14px; }
.ledger { display: grid; border-top: 1px solid var(--line); }
.ap {
  display: grid; grid-template-columns: 62px 1fr auto; gap: 14px; align-items: center; text-align: left; width: 100%;
  padding: 13px 4px 13px 14px; background: none; border: 0; border-bottom: 1px solid var(--line); position: relative; border-radius: 0;
}
.ap::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--ok); }
.ap.s-pending::before { background: var(--warn); }
.ap.s-cancelled::before, .ap.s-no_show::before { background: var(--bad); }
.ap.s-completed::before { background: var(--info); }
.ap:hover { background: var(--panel); }
.ap-time { font-variant-numeric: tabular-nums; font-weight: 650; }
.ap-time small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.ap-main b { display: block; font-weight: 600; }
.ap-main span { color: var(--muted); font-size: .88rem; }
.ap-tag { font-size: .78rem; color: var(--muted); padding-right: 6px; text-align: right; }
.ap.s-pending .ap-tag { color: var(--warn); }
.ap.s-cancelled .ap-main, .ap.s-cancelled .ap-time, .ap.s-no_show .ap-main { opacity: .55; }
.ap.s-cancelled .ap-main b { text-decoration: line-through; }
.empty { padding: 26px 0; color: var(--muted); }
.empty .btn { margin-top: 12px; }

.pending { margin: 0 0 26px; border: 1px solid color-mix(in srgb, var(--warn) 50%, var(--line)); border-radius: 14px; padding: 14px 16px; background: color-mix(in srgb, var(--warn) 7%, var(--panel)); }
.pending h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; font-size: 1.05rem; }
.count { font-family: var(--sans); font-size: .8rem; background: var(--warn); color: #1b1408; padding: 1px 9px; border-radius: 999px; font-weight: 700; }
.pend { display: grid; gap: 10px; padding: 12px 0; border-top: 1px solid color-mix(in srgb, var(--warn) 25%, var(--line)); }
.pend b { display: block; }
.pend .when { color: var(--muted); font-size: .9rem; }
.pend .note { margin-top: 4px; font-size: .88rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pend-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (min-width: 700px) { .pend { grid-template-columns: 1fr auto; align-items: center; } }

/* ---------- Secciones de formularios ---------- */
.section { padding: 22px 0; border-top: 1px solid var(--line); display: grid; gap: 4px; }
.section:first-of-type { border-top: 0; padding-top: 0; }
.section > h2 { margin-bottom: 4px; }
.section > p.muted { margin-bottom: 12px; max-width: 62ch; }
.form-narrow { max-width: 640px; }
.sticky-save {
  position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); display: flex; gap: 10px; align-items: center; padding: 12px 0; background: linear-gradient(to top, var(--bg) 70%, transparent);
}
@media (min-width: 900px) { .sticky-save { bottom: 0; } }

/* Horario semanal */
.week { display: grid; border-top: 1px solid var(--line); max-width: 760px; }
.wd { display: grid; grid-template-columns: 1fr; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
@media (min-width: 640px) { .wd { grid-template-columns: 150px 1fr; align-items: start; } }
.wd-name { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; width: 100%; height: 100%; }
.switch i { position: absolute; inset: 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; transition: background .15s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: var(--muted); border-radius: 50%; transition: transform .15s, background .15s; }
.switch input:checked + i { background: var(--accent); border-color: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); background: var(--accent-fg); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.ranges { display: grid; gap: 8px; }
.range { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.range input[type=time] { width: 128px; padding-inline: 10px; }
.range input[type=time]::-webkit-calendar-picker-indicator { margin: 0; padding: 0; width: 16px; }
.range .sep { color: var(--muted); }
.closed-label { color: var(--muted); padding-top: 2px; }

.exc-list { display: grid; margin-top: 12px; border-top: 1px solid var(--line); max-width: 760px; }
.exc { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.exc small { color: var(--muted); display: block; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 0 0 14px; }
.seg label { padding: 9px 14px; cursor: pointer; font-size: .9rem; color: var(--muted); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Servicios */
.svc-list { display: grid; border-top: 1px solid var(--line); max-width: 760px; }
.svc-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.svc-row b { display: block; }
.svc-row .meta { color: var(--muted); font-size: .88rem; }
.svc-row.off .meta, .svc-row.off b { opacity: .55; }
.tag { display: inline-block; font-size: .72rem; border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 1px 8px; margin-left: 6px; vertical-align: 1px; }

/* Ajustes */
.code {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem; overflow-x: auto; white-space: pre; margin: 8px 0 10px;
}
.copy-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.plan-box { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: var(--panel); max-width: 640px; display: grid; gap: 8px; }
.plan-box ul { margin: 0; padding-left: 18px; color: var(--muted); }
.notif { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .88rem; align-items: baseline; }
.notif .st-sent { color: var(--ok); } .notif .st-pending { color: var(--warn); } .notif .st-failed { color: var(--bad); }
.notif .err { grid-column: 2 / -1; color: var(--bad); font-size: .8rem; }

/* ---------- Diálogo ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 16px; padding: 0; background: var(--panel); color: var(--fg); width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px); overflow: auto;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dlg { padding: 20px 20px 22px; }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.dlg-head h2 { font-size: 1.35rem; }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 14px 0 18px; }
dl.facts dt { color: var(--muted); font-size: .88rem; }
dl.facts dd { margin: 0; word-break: break-word; }
.status-pill { display: inline-block; font-size: .78rem; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); margin-right: 8px; }
.status-pill.s-confirmed { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.status-pill.s-pending { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); }
.status-pill.s-cancelled, .status-pill.s-no_show { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, var(--line)); }
.status-pill.s-completed { color: var(--info); border-color: color-mix(in srgb, var(--info) 50%, var(--line)); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.cancel-box { border: 1px solid color-mix(in srgb, var(--bad) 40%, var(--line)); border-radius: 12px; padding: 14px; margin-top: 12px; }
.form-error { color: var(--bad); margin: 0 0 12px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px 16px; }
.login-card { width: 100%; max-width: 400px; }
.login-card h1 { margin-bottom: 6px; }
.login-card .muted { margin-bottom: 22px; }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 50;
  background: var(--fg); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-weight: 600; max-width: calc(100vw - 32px); transition: opacity .2s, transform .2s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--bad); color: #fff; }
@media (min-width: 900px) { #toast { bottom: 28px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Demo (§15): aviso siempre visible */
.demo-note {
  margin: 12px 16px 0;
  padding: 10px 14px;
  border: 1px solid #d9a441;
  border-radius: 10px;
  background: #fbf3df;
  color: #4a3a12;
  font-size: 14px;
  line-height: 1.45;
}
@media (min-width: 900px) {
  .demo-note { margin: 20px 32px 0; }
}
