:root {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --ink: #1d2a24;
  --muted: #6b766f;
  --line: #e4e2da;
  --brand: #1f4d3a;
  --brand-2: #2f6b52;
  --accent: #8cc63f;
  --accent-soft: #eef6e2;
  --warn: #b7791f;
  --warn-soft: #fdf3e1;
  --danger: #b4423a;
  --danger-soft: #fbeceb;
  --info: #2b6cb0;
  --info-soft: #e8f1fb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 4px 16px rgba(20, 30, 25, .05);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-2); }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--brand); color: #e7efe9; padding: 22px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; font-size: 18px; }
.brand b { display: block; font-size: 16px; letter-spacing: .2px; }
.brand small { opacity: .7; font-size: 12px; }
.brand.logo { flex-direction: column; align-items: flex-start; gap: 6px; }
.brand.logo img { max-height: 56px; max-width: 200px; object-fit: contain; display: block; }
.login-logo { background: var(--brand); border-radius: 14px; padding: 14px 18px; display: inline-block; }
.login-logo img { max-height: 54px; max-width: 220px; object-fit: contain; display: block; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: inherit; text-decoration: none; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.07); }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; }
.nav .ico { width: 20px; text-align: center; opacity: .9; }
.nav .badge { margin-left: auto; background: var(--accent); color: var(--brand); font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 99px; }
.sidebar .foot { margin-top: auto; font-size: 12px; opacity: .75; padding: 8px; display: grid; gap: 8px; }
.sidebar .foot button { background: rgba(255,255,255,.1); border: 0; color: #fff; padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: left; }

.main { padding: 28px 32px 80px; max-width: 1180px; width: 100%; }
.topbar { display: none; }
.demo-banner { background: var(--warn-soft); color: #7a5214; border: 1px solid #f3dfb5; padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.demo-banner button { margin-left: auto; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 26px; letter-spacing: -.3px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: 1.2px; font-size: 11px; color: var(--muted); font-weight: 600; }

/* ---------- componentes ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: #cfccc1; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--brand); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h3 { margin: 0 0 12px; font-size: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; }
.card-head h3 { margin: 0; }

.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.kpi .sub { font-size: 12px; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stack { display: grid; gap: 16px; }

.list { display: grid; gap: 10px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.row .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.row .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: #eee; color: #555; white-space: nowrap; }
.pill.confirmada { background: var(--info-soft); color: var(--info); }
.pill.hospedado { background: var(--accent-soft); color: #3f6e17; }
.pill.completada { background: #eceae4; color: #6b6b6b; }
.pill.cancelada { background: var(--danger-soft); color: var(--danger); }
.pill.pendiente { background: var(--warn-soft); color: var(--warn); }
.pill.atendida { background: #eceae4; color: #6b6b6b; }
.pill.online { background: var(--accent-soft); color: #3f6e17; }
.pill.offline { background: #eceae4; color: #777; }

.empty { text-align: center; color: var(--muted); padding: 26px 10px; border: 1px dashed var(--line); border-radius: 12px; }
.group-title { margin: 22px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; }

.toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; background: #ebe9e2; border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.input, select.input, textarea.input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; outline: none; }
.input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(47,107,82,.12); }
.search { max-width: 280px; }

.hero { border-radius: var(--radius); background: linear-gradient(120deg, #1f4d3a, #2f6b52 60%, #5f9a3a); color: #fff; padding: 22px; display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.hero h2 { margin: 4px 0 6px; font-size: 22px; }
.hero p { margin: 0; opacity: .85; }
.hero .eyebrow { color: rgba(255,255,255,.75); }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 28, 24, .45); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 16px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal header { padding: 18px 20px 6px; display: flex; justify-content: space-between; align-items: center; }
.modal header h2 { margin: 0; font-size: 18px; }
.modal .body { padding: 10px 20px; display: grid; gap: 12px; }
.modal footer { padding: 14px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check input { width: 18px; height: 18px; }
@keyframes fade { from { opacity: 0; } }
.modal.wide { width: min(1100px, 100%); }
.tv-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #0b1a15; }
.tv-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; animation: fade .2s; max-width: 340px; }
.toast.error { background: var(--danger); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(140deg, #1f4d3a, #2f6b52 55%, #7fb23a); }
.login .card { width: min(380px, 100%); padding: 28px; }
.login h1 { margin: 10px 0 4px; font-size: 22px; }
.login p { color: var(--muted); margin: 0 0 18px; }
.login form { display: grid; gap: 12px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .app.menu-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; background: var(--brand); color: #fff; padding: 10px 14px; }
  .topbar button { background: transparent; border: 0; color: #fff; font-size: 22px; padding: 2px 6px; cursor: pointer; }
  .topbar b { font-size: 16px; }
  .topbar .badge { margin-left: auto; background: var(--accent); color: var(--brand); font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; text-decoration: none; }
  .main { padding: 16px 14px 90px; }
  .page-head h1 { font-size: 22px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi .value { font-size: 24px; }
  .row { flex-wrap: wrap; }
  .row .actions { width: 100%; justify-content: flex-start; }
  .field-row { grid-template-columns: 1fr; }
  .search { max-width: none; flex: 1 1 100%; }
  .demo-banner { font-size: 12px; padding: 8px 12px; }
  .modal-bg { place-items: end center; padding: 0; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92vh; }
  .toasts { left: 14px; right: 14px; bottom: 14px; }
}

/* ---------- modo TV ---------- */
.tvmode { position: fixed; inset: 0; z-index: 80; background: #000; }
.tvmode iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.tvmode-bar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 2; display: flex; gap: 8px; align-items: center;
  background: rgba(15, 25, 20, .82); padding: 8px; border-radius: 14px; transition: opacity .3s; box-shadow: 0 8px 30px rgba(0,0,0,.4); max-width: calc(100% - 24px); }
.tvmode-bar select { width: auto; max-width: 220px; padding: 7px 10px; }
.tvmode.idle .tvmode-bar { opacity: 0; pointer-events: none; }
.tvmode.idle { cursor: none; }

/* ---------- ajustes ---------- */
.logo-box { background: var(--brand); border-radius: 12px; height: 96px; display: flex; align-items: center; justify-content: center; padding: 12px; color: rgba(255,255,255,.7); font-weight: 600; }
.logo-box img { max-height: 72px; max-width: 100%; object-fit: contain; }
.range { width: 100%; accent-color: var(--brand-2); }
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.swatch { aspect-ratio: 16 / 10; border-radius: 10px; border: 3px solid transparent; cursor: pointer; position: relative; padding: 0; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.swatch span { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 6px; font-size: 11px; font-weight: 700; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.55)); text-align: left; }
.swatch.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--brand); }
.swatch.add { background: #f3f1ea; border: 2px dashed #cfccc1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); }
.swatch.add b { font-size: 22px; }
.swatch.add span { position: static; background: none; color: var(--muted); text-align: center; }
.mini-tv { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; color: #fff; padding: 4% 5%; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.mini-top { display: flex; align-items: center; gap: 8px; }
.mini-top img { height: 26px; max-width: 110px; object-fit: contain; }
.mini-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: grid; place-items: center; font-size: 12px; }
.mini-top b { display: block; font-size: 11px; letter-spacing: .5px; text-transform: uppercase; }
.mini-top small { display: block; font-size: 9px; opacity: .75; font-style: italic; }
.mini-hello { position: absolute; left: 5%; top: 34%; }
.mini-hello small { font-size: 8px; letter-spacing: 2px; opacity: .8; }
.mini-hello div { font-family: Georgia, serif; font-size: clamp(16px, 3.2vw, 30px); line-height: 1.05; margin-top: 4px; }
.mini-card { position: absolute; right: 5%; top: 24%; width: 30%; height: 22%; background: rgba(255,255,255,.92); border-radius: 8px; }
.mini-card.two { top: 50%; background: rgba(31,77,58,.85); }
@media (max-width: 860px) { .swatches { grid-template-columns: repeat(3, 1fr); } .mini-hello div { font-size: 20px; } }
.fav-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fav-box { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; font-size: 22px; overflow: hidden; }
.fav-box img { width: 32px; height: 32px; object-fit: contain; }
