/* Citas · Reusalia — estilo alineado con altas/caja/reposición/precios */
:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1b2430;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #4f46e5;
  --brand-ink: #ffffff;
  --ok: #16a34a;
  --amber: #d97706;
  --err: #dc2626;
  --wallapop: #13c1ac;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216; --panel: #171b21; --ink: #e8eaed; --muted: #9aa3af;
    --line: #262b33; --brand: #6366f1; --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10; gap: 12px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { font-size: 26px; }
.brand h1 { font-size: 17px; margin: 0; }
.brand .sub { margin: 0; font-size: 12px; color: var(--muted); }
.conn { display: flex; align-items: center; gap: 10px; }
.conn-text { font-size: 13px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-on { background: var(--ok); box-shadow: 0 0 0 3px rgba(22,163,74,.18); }
.dot-off { background: #9ca3af; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; cursor: pointer; font-size: 15px; color: var(--ink); }

/* Filtros */
.filters {
  display: flex; gap: 14px; align-items: end; flex-wrap: wrap;
  padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.filters .quick { display: flex; gap: 6px; align-self: end; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; align-self: center; }
.tab {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 999px; padding: 7px 14px; cursor: pointer; font-size: 13.5px;
}
.tab.active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* Layout */
.wrap { padding: 16px 18px 60px; max-width: 980px; margin: 0 auto; }
.lista { display: flex; flex-direction: column; gap: 10px; }

/* Separador de día */
.day-sep {
  display: flex; align-items: baseline; gap: 10px; margin: 14px 2px 2px;
  font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
}
.day-sep .count { font-weight: 600; text-transform: none; letter-spacing: 0; }

/* Tarjeta de cita */
.cita {
  background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px;
  display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: start;
}
@media (max-width: 720px) { .cita { grid-template-columns: 1fr; } }
.cita .foto {
  width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--bg);
  border: 1px solid var(--line);
}
.cita .foto.ph { display: flex; align-items: center; justify-content: center; font-size: 26px; color: var(--muted); }
.cita .info { min-width: 0; }
.cita .when { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.cita .when .hora { font-weight: 800; font-size: 16px; }
.cita .when .dia { font-size: 12.5px; color: var(--muted); }
.cita .cliente { font-weight: 700; }
.cita .producto { margin: 4px 0; font-size: 14px; }
.cita .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.cita .notas { margin: 6px 0 0; font-size: 13px; color: var(--muted); white-space: pre-line; }
.cita code.lpn { font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); background: var(--bg); padding: 2px 8px; border-radius: 6px; }
.cita .precio { font-weight: 800; font-size: 16px; white-space: nowrap; }

.cita .side { display: flex; flex-direction: column; gap: 8px; align-items: stretch; min-width: 150px; }
@media (max-width: 720px) { .cita .side { min-width: 0; } }
.cita .side select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); font-size: 13.5px; }
.cita .acts { display: flex; gap: 6px; flex-wrap: wrap; }

/* Badges / pills */
.badge { font-size: 11.5px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; color: var(--muted); }
.badge.green { background: rgba(22,163,74,.12); color: var(--ok); border-color: transparent; }
.badge.red { background: rgba(220,38,38,.12); color: var(--err); border-color: transparent; }
.badge.amber { background: rgba(217,119,6,.14); color: var(--amber); border-color: transparent; }
.badge.wp { background: rgba(19,193,172,.14); color: #0a8f7f; border-color: transparent; }
.pill { font-size: 11.5px; border-radius: 999px; padding: 2px 10px; font-weight: 700; color: #fff; }

/* Botones */
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 10px; padding: 9px 14px; cursor: pointer; font-size: 13.5px; font-weight: 600; }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-wa { background: #25d366; color: #04210d; border-color: #25d366; }
.btn-wp { background: var(--wallapop); color: #04211d; border-color: var(--wallapop); }

/* Fields */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; color: var(--muted); }
.field input, .field select, .field textarea { padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); color: var(--ink); font-size: 15px; font-family: inherit; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }
.lpn-info { min-height: 16px; margin-top: 2px; }
.lpn-info.ok { color: var(--ok); }
.lpn-info.err { color: var(--err); }

/* Modal */
.modal-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 60; }
.modal {
  position: fixed; z-index: 61; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 28px)); max-height: calc(100vh - 40px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); }

.empty { color: var(--muted); text-align: center; padding: 28px 8px; font-size: 14px; }
.empty.error { color: var(--err); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); padding: 11px 18px; border-radius: 10px; color: #fff; box-shadow: var(--shadow); z-index: 80; font-weight: 600; max-width: 90vw; }
.toast-ok { background: var(--ok); }
.toast-warn { background: var(--amber); }
.toast-error { background: var(--err); }
