/* Paleta inspirada en Voice Monkey: verde #18d26b, azul marino #263a5b, fondo #f2f5fa */
:root {
  --brand: #18d26b;
  --brand-hover: #15b45c;
  --brand-soft: #e3f9ed;
  --brand-ink: #0b7a3d;
  --navy: #263a5b;
  --bg: #f2f5fa;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --text: #263a5b;
  --muted: #8a98ac;
  --border: #e3e8ef;
  --cyan: #00b8d4;
  --amber: #ffa800;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --warn-soft: #fff4dc;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(38, 58, 91, .06), 0 4px 16px rgba(38, 58, 91, .06);
  --sidebar-w: 248px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand-soft: #123824;
    --brand-ink: #4be38f;
    --bg: #0f1623;
    --surface: #172133;
    --surface-2: #1d2a40;
    --text: #e5ecf6;
    --muted: #8a98ac;
    --border: #26344d;
    --danger-soft: #3a1d22;
    --warn-soft: #3a2f14;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Figtree, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--brand-ink); }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 700; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }
code { background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; }
pre {
  background: var(--navy); color: #e5ecf6; padding: 14px; border-radius: var(--radius-sm);
  overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 0; font-size: 12.5px; line-height: 1.55;
}
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack > p { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid.cols-2 { grid-template-columns: 1fr; } }

/* ---------- Layout ---------- */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px;
  transition: transform .2s ease;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.25rem; color: var(--text); text-decoration: none; padding: 4px 10px 18px; }
.brand-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--brand); font-size: 18px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-weight: 600;
}
.nav a span { width: 22px; text-align: center; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--brand-soft); color: var(--brand-ink); }
.nav-sep { height: 1px; background: var(--border); margin: 10px 8px; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 0 6px; font-weight: 600; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 14px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
}
.topbar h1 { font-size: 1.45rem; flex: 1; }
.icon-btn { display: none; border: 0; background: var(--surface); color: var(--text); border-radius: 10px; width: 40px; height: 40px; font-size: 20px; cursor: pointer; box-shadow: var(--shadow); }
.page { padding: 8px 28px 48px; max-width: 1180px; width: 100%; display: flex; flex-direction: column; gap: 20px; }
.backdrop { display: none; }

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .backdrop.open { display: block; position: fixed; inset: 0; background: rgba(15, 22, 35, .45); z-index: 30; }
  .main { margin-left: 0; }
  .icon-btn { display: grid; place-items: center; }
  .topbar { padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
  .topbar h1 { font-size: 1.2rem; }
  .page { padding: 4px 16px 40px; }
}

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head p { margin: 4px 0 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head p { margin: 4px 0 0; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat b { font-size: 1.9rem; font-weight: 800; }
.stat a { text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 2px; }
.list { display: flex; flex-direction: column; gap: 12px; }
.item { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; }
.item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.item-title { font-weight: 700; font-size: 1.02rem; }
.item-sub { color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; }
.empty .big { font-size: 38px; display: block; margin-bottom: 6px; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .88rem; }
.field .hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px;
}
@media (max-width: 640px) { input, select, textarea { font-size: 16px; } }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--brand); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { cursor: pointer; }
.days input { display: none; }
.days span { display: inline-grid; place-items: center; width: 38px; height: 34px; border-radius: 8px; border: 1px solid var(--border); font-weight: 600; font-size: .85rem; }
.days input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }

.tabs { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px; gap: 2px; }
.tabs button { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 700; padding: 8px 14px; border-radius: 9px; cursor: pointer; }
.tabs button.active { background: var(--brand-soft); color: var(--brand-ink); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; text-decoration: none;
  border-radius: var(--radius-sm); padding: 9px 16px; border: 1px solid transparent; transition: background .15s;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); }
.btn.navy { background: var(--navy); color: #fff; }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; }
.btn.amazon { background: #ff9900; color: #111; }
.btn.amazon:hover { background: #e88b00; }
.btn.sm { padding: 6px 11px; font-size: .85rem; }
.btn.lg { padding: 13px 20px; font-size: 1rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: wait; }

/* ---------- Etiquetas y estado ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .74rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge:empty { display: none; }
.badge.green { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.badge.red { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.amber { background: var(--warn-soft); color: #9a6400; border-color: transparent; }
.badge.cyan { background: color-mix(in srgb, var(--cyan) 14%, transparent); color: var(--cyan); border-color: transparent; }
.pill { display: inline-flex; align-items: center; gap: 7px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: .82rem; color: var(--text); text-decoration: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ready { background: var(--brand); }
.dot.waiting_login, .dot.initializing, .dot.login_queued { background: var(--amber); }
.dot.error { background: var(--danger); }
.alert { margin: 0; padding: 11px 14px; border-radius: var(--radius-sm); background: var(--brand-soft); color: var(--text); font-size: .9rem; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.warn { background: var(--warn-soft); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; color: var(--muted); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }

/* ---------- Copiar ---------- */
.copy-box { display: flex; gap: 6px; }
.copy-box input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--surface-2); }

/* ---------- Pasos de flow ---------- */
.step { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.step-head { display: flex; align-items: center; gap: 8px; }
.step-num { width: 26px; height: 26px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex: none; }
.step-cond { border-top: 1px dashed var(--border); padding-top: 10px; }

/* ---------- Sonidos ---------- */
.sound-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.sound { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.sound-name { font-weight: 600; }
.sound .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 22, 35, .5); z-index: 80; display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; }
.modal h2 { margin-bottom: 16px; }

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 12px; z-index: 100;
  font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: calc(100% - 32px);
}

/* ---------- Acceso ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 500px at 50% -10%, var(--brand-soft), var(--bg)); }
.auth-card { width: min(400px, 100%); padding: 32px 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { font-size: 1.5rem; text-align: center; }
.auth-card > p { text-align: center; margin: 0; }
.auth-logo { width: 60px; height: 60px; margin: 0 auto; border-radius: 16px; background: var(--brand); display: grid; place-items: center; font-size: 30px; }
.auth-card a { font-weight: 600; text-decoration: none; }
.captcha { display: flex; justify-content: center; min-height: 78px; }
