/* Panel de administración */
body { font-size: 15px; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 1.6rem; text-align: center; }

.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 1.2rem .8rem; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.sidebar .brand { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; padding: .2rem .7rem 1.1rem; display: flex; gap: .5rem; align-items: center; }
.sidebar .brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: .7rem; padding: .62rem .75rem; border-radius: 10px; color: var(--text);
  text-decoration: none; font-weight: 550; font-size: .94rem;
}
.nav a svg { width: 19px; height: 19px; color: var(--muted); flex: none; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent-strong); }
.nav a.active svg { color: var(--accent-strong); }
.nav .count { margin-left: auto; background: var(--danger); color: #fff; font-size: .72rem; font-weight: 700; padding: .05rem .45rem; border-radius: 999px; }
.sidebar-foot { margin-top: auto; display: grid; gap: .4rem; }
.main { padding: 1.6rem clamp(16px, 3vw, 2.2rem) 4rem; min-width: 0; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav { min-width: 0; }
  .page-head h1 { font-size: 1.35rem; }
  .sidebar { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; padding: .5rem 16px; border-right: 0; border-bottom: 1px solid var(--border); gap: .5rem; }
  .sidebar .brand { display: none; }
  .nav { flex-direction: row; overflow-x: auto; flex: 1; scrollbar-width: none; }
  .nav a { white-space: nowrap; padding: .5rem .7rem; font-size: .88rem; }
  .nav a svg { display: none; }
  .sidebar-foot { margin: 0; }
  .sidebar-foot .btn span { display: none; }
  .main { padding-top: 1.1rem; }
}

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: 1.2rem; }
.page-head h1 { font-size: 1.6rem; margin: 0; }
.page-head h1::first-letter { text-transform: uppercase; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.toolbar input[type=date] { width: auto; min-height: 40px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; display: grid; place-items: center; font-size: 1.2rem; line-height: 1; }
.icon-btn:hover { border-color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.chip { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .3rem .8rem; font-size: .85rem; color: var(--muted); }
.chip b { color: var(--text); }

/* ---------- Línea de tiempo ---------- */
.tl { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); max-height: calc(100vh - 230px); min-height: 360px; }
.tl-inner { display: grid; grid-template-columns: 56px 1fr; min-width: fit-content; }
.tl-head { display: contents; }
.tl-head .corner, .tl-head .staff-heads { position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--border); }
.tl-head .corner { left: 0; z-index: 4; }
.staff-heads, .tl-cols { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(170px, 1fr); }
.staff-h { padding: .7rem .8rem; font-weight: 650; display: flex; align-items: center; gap: .5rem; border-left: 1px solid var(--border); }
.staff-h i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.tl-hours { position: sticky; left: 0; z-index: 2; background: var(--surface); border-right: 1px solid var(--border); }
.tl-hours div { position: absolute; right: 8px; font-size: .75rem; color: var(--muted); transform: translateY(-50%); }
.tl-col { position: relative; border-left: 1px solid var(--border); cursor: copy; }
.tl-col .line { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); pointer-events: none; }
.tl-col .line.half { border-top-style: dashed; opacity: .55; }
.tl-col .off { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(-45deg, var(--surface-2), var(--surface-2) 6px, transparent 6px, transparent 12px); pointer-events: none; }
.tl-col .blk { position: absolute; left: 4px; right: 4px; background: var(--surface-2); border: 1px dashed var(--muted); border-radius: 8px; font-size: .75rem; color: var(--muted); padding: .2rem .45rem; overflow: hidden; pointer-events: none; }
.appt {
  position: absolute; left: 4px; right: 4px; border-radius: 9px; padding: .3rem .5rem; overflow: hidden; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--c, var(--accent)); text-align: left;
  font: inherit; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); display: block;
}
.appt::before { content: ''; position: absolute; inset: 0; background: var(--c, var(--accent)); opacity: .1; pointer-events: none; }
.appt:hover { z-index: 2; box-shadow: var(--shadow); }
.appt .t { font-size: .74rem; color: var(--muted); font-weight: 600; display: flex; gap: .3rem; align-items: center; }
.appt .n { font-weight: 650; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt .s { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt.st-pending { border-style: dashed; border-left-style: solid; }
.appt.st-no_show { opacity: .55; }
.appt.st-completed .n::after { content: ' ✓'; color: var(--ok); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot-pending { background: var(--warn); }
.dot-confirmed { background: var(--ok); }
.dot-completed { background: var(--info); }
.dot-no_show { background: var(--muted); }
.now-line { position: absolute; left: 0; right: 0; border-top: 2px solid var(--danger); z-index: 1; pointer-events: none; }
.now-line::before { content: ''; position: absolute; left: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .8rem; color: var(--muted); margin-top: .7rem; }
.legend span { display: inline-flex; gap: .35rem; align-items: center; }

/* ---------- Tablas / listas ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td .sub { font-size: .82rem; color: var(--muted); }
.actions-cell { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }

.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tab { border: 1px solid var(--border); background: var(--surface); padding: .45rem .9rem; border-radius: 999px; cursor: pointer; font: 600 .88rem var(--font); color: var(--muted); }
.tab.active { background: var(--text); border-color: var(--text); color: var(--bg); }
.tab .n { margin-left: .3rem; opacity: .8; }

/* ---------- Modal ---------- */
dialog.modal {
  border: 0; border-radius: var(--radius); padding: 0; width: min(560px, calc(100% - 24px)); max-height: calc(100vh - 40px);
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog.modal.wide { width: min(760px, calc(100% - 24px)); }
dialog.modal::backdrop { background: rgba(20, 16, 12, .5); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h3 { margin: 0; font-size: 1.2rem; }
.modal-body { padding: 1.2rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; padding-top: .6rem; }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: .45rem 1rem; font-size: .93rem; margin-bottom: 1rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 550; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; margin: 1.3rem 0 .6rem; }
.rem-list { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.rem-list li { display: flex; justify-content: space-between; gap: .8rem; padding: .45rem 0; border-bottom: 1px solid var(--border); }
.rem-list li:last-child { border-bottom: 0; }

.suggest { position: relative; }
.suggest-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 5; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); margin-top: 4px; max-height: 220px; overflow: auto; }
.suggest-list button { display: block; width: 100%; text-align: left; padding: .55rem .8rem; border: 0; background: none; color: var(--text); font: inherit; cursor: pointer; }
.suggest-list button:hover { background: var(--surface-2); }

/* ---------- Ajustes ---------- */
.settings-grid { display: grid; gap: 1.2rem; max-width: 860px; }
.settings-grid .card h2 { font-size: 1.2rem; margin-bottom: .3rem; }
.settings-grid .card > p { color: var(--muted); font-size: .9rem; }
.mode-cards { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: 1rem; }
.mode-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; cursor: pointer; display: block; font-weight: 400; }
.mode-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.mode-card input { accent-color: var(--accent); margin-right: .4rem; }
.mode-card strong { font-size: 1rem; }
.mode-card p { font-size: .85rem; color: var(--muted); margin: .4rem 0 0; }
.var-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .3rem 0 .8rem; }
.var-chips code { background: var(--surface-2); border-radius: 6px; padding: .1rem .45rem; font-size: .8rem; cursor: pointer; }
.preview { white-space: pre-wrap; background: #e7f6dc; color: #1b2a12; border-radius: 12px 12px 12px 2px; padding: .8rem 1rem; font-size: .9rem; max-width: 420px; margin-bottom: .6rem; }
.copy-field { display: flex; gap: .4rem; }
.copy-field input { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.steps-list { padding-left: 1.2rem; font-size: .9rem; }
.steps-list li { margin-bottom: .4rem; }

.hours-table td { padding: .5rem .6rem; }
.hours-table input[type=time] { min-height: 38px; padding: .3rem .5rem; width: 118px; }

.stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 1.2rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.stat .lbl { font-size: .82rem; color: var(--muted); }
.stat .val { font-size: 1.8rem; font-weight: 700; font-family: var(--font-display); line-height: 1.2; margin-top: .2rem; }
.bars { display: grid; gap: .6rem; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 40px; gap: .7rem; align-items: center; font-size: .9rem; }
.bar-row .track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--accent); border-radius: 999px; }
.bar-row .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---------- Mejoras de usabilidad ---------- */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 3px; background: var(--surface); }
.seg button { border: 0; background: none; color: var(--muted); font: 600 .85rem var(--font); padding: .35rem .8rem; border-radius: 999px; cursor: pointer; }
.seg button.on { background: var(--text); color: var(--bg); }
.alert-link { display: flex; gap: .6rem; align-items: center; text-decoration: none; }
.alert-link svg { width: 20px; height: 20px; flex: none; }
.day-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.day-summary > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .8rem; }
.day-summary .lbl { display: block; font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.day-summary .val { display: block; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .day-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.appt-list { display: grid; gap: .6rem; }
.appt-row {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: .3rem 1rem; align-items: start; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--ok); border-radius: var(--radius);
  padding: .9rem 1rem; cursor: pointer; color: var(--text); font: inherit; width: 100%; box-shadow: var(--shadow);
}
.appt-row:hover { border-color: var(--accent); }
.appt-row.st-pending { border-left-color: var(--warn); }
.appt-row.st-completed { border-left-color: var(--info); opacity: .85; }
.appt-row.st-no_show { border-left-color: var(--muted); opacity: .6; }
.appt-row.cancelled { border-left-color: var(--danger); opacity: .6; box-shadow: none; grid-template-columns: 64px 1fr; }
.appt-row.overdue { background: var(--warn-soft); }
.ar-time { font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.ar-time small { display: block; font-size: .78rem; color: var(--muted); font-weight: 500; }
.ar-name { font-weight: 700; font-size: 1.02rem; }
.ar-task { color: var(--muted); }
.ar-note { font-size: .85rem; color: var(--muted); margin-top: .2rem; }
.ar-side { text-align: right; display: grid; gap: .3rem; justify-items: end; }
.ar-price { font-weight: 700; font-size: 1.1rem; color: var(--accent-strong); white-space: nowrap; }
.ar-actions { grid-column: 2 / -1; display: flex; gap: .4rem; flex-wrap: wrap; }
.ar-actions:empty { display: none; }
.ar-actions .btn svg { width: 16px; height: 16px; }
@media (max-width: 480px) {
  .appt-row { grid-template-columns: 54px minmax(0, 1fr); }
  .ar-side { grid-column: 2; justify-items: start; text-align: left; grid-auto-flow: column; justify-content: start; align-items: center; gap: .6rem; }
  .ar-actions { grid-column: 1 / -1; }
}

.empty-day { text-align: center; padding: 2.5rem 1rem; }
.empty-icon { font-size: 2.2rem; margin-bottom: .4rem; }
.fab {
  display: none; position: fixed; right: 18px; bottom: 22px; z-index: 30; width: 60px; height: 60px; border-radius: 50%;
  border: 0; background: var(--accent); color: var(--on-accent); font-size: 2rem; line-height: 1; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
@media (max-width: 760px) { .fab { display: block; } .hide-mobile { display: none !important; } .main { padding-bottom: 6rem; } }

.appt-hero { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: flex-start; margin-bottom: 1rem; }
.appt-hero .contact { display: flex; gap: .4rem; }
.task-box { background: var(--surface-2); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.task-box .field:last-of-type { margin-bottom: .8rem; }
.money-input { display: flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.money-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.money-input input { border: 0 !important; box-shadow: none !important; font-size: 1.15rem; font-weight: 700; background: transparent; }
.money-input span { padding: 0 .9rem; color: var(--muted); font-weight: 700; }
.big-actions .btn { flex: 1 1 160px; }
details.more { border-top: 1px solid var(--border); padding-top: .8rem; }
details.more summary { cursor: pointer; font-weight: 600; color: var(--muted); }

.new-form fieldset { border: 0; padding: 0; margin: 0 0 1.1rem; }
.new-form legend { font-weight: 700; font-size: 1rem; margin-bottom: .6rem; display: flex; align-items: center; gap: .5rem; padding: 0; }
.new-form legend .num { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: inline-grid; place-items: center; font-size: .8rem; }
#n-title { font-size: 1.08rem; }
.quick-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: -.4rem 0 1rem; }
.qchip { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: .35rem .75rem; font: 500 .85rem var(--font); cursor: pointer; }
.qchip span { color: var(--muted); margin-left: .2rem; }
.qchip:hover { border-color: var(--accent); }
.qchip.on { background: var(--accent-soft); border-color: var(--accent); }

.pair-code { font: 700 2rem/1.2 ui-monospace, Consolas, monospace; letter-spacing: .15em; text-align: center; background: var(--surface-2); border-radius: var(--radius); padding: .9rem; margin: .4rem 0 1rem; }
.wa-qr { display: block; margin: .4rem auto 1rem; background: #fff; padding: 8px; border-radius: 12px; max-width: 100%; height: auto; }
