/* ─────────────────────────────────────────────
   CADEC · Backoffice — admin UI
───────────────────────────────────────────── */
:root {
  --c-primary: #2563eb;
  --c-primary-hover: #1d4ed8;
  --c-accent: #f59e0b;
  --bg-body: #f1f5f9;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
  --font-sans: "Inter", system-ui, sans-serif;
  --font-display: "Plus Jakarta Sans", system-ui, sans-serif;
  --radius: 12px; --radius-lg: 18px;
  font-size: 16px; -webkit-font-smoothing: antialiased;
}
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-sans); background: var(--bg-body); color: var(--text-main); min-height: 100dvh; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 10px; font-weight: 600; font-size: .9rem; cursor: pointer; border: 1px solid transparent; transition: .15s; white-space: nowrap; }
.btn-sm { padding: 7px 12px; font-size: .82rem; }
.btn-full { width: 100%; }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-hover); }
.btn-ghost { background: var(--bg-card); border-color: var(--border); color: var(--text-main); }
.btn-ghost:hover { border-color: var(--border-hover); background: #f8fafc; }

/* Inputs */
.inp, .sel, .txa { width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--text-main); }
.inp:focus, .sel:focus, .txa:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.txa { min-height: 90px; resize: vertical; }
.lbl { display: block; font-size: .82rem; font-weight: 600; color: var(--text-muted); margin: 14px 0 6px; }

/* Pills */
.pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.pill-blue { background: #eff6ff; color: #1d4ed8; }
.pill-orange { background: #fff7ed; color: #c2410c; }
.pill-green { background: #ecfdf5; color: #047857; }
.pill-gray { background: #f1f5f9; color: #475569; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

/* Boot / auth */
.boot, .boot-error { min-height: 70vh; display: grid; place-items: center; color: var(--text-muted); font-weight: 600; }
.boot-error { color: #b91c1c; }
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 40px; box-shadow: var(--shadow-lg); }
.auth-logo { font-family: var(--font-display); font-size: 1.4rem; font-weight: 800; color: var(--c-primary); }
.auth-sub { color: var(--text-muted); font-size: .9rem; margin: 6px 0 22px; }
.auth-card label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-muted); margin: 14px 0 6px; }
.auth-error { margin-top: 14px; color: #b91c1c; font-weight: 600; font-size: .88rem; text-align: center; }

/* Nav */
.bo-nav { display: flex; align-items: center; gap: 24px; background: #fff; border-bottom: 1px solid var(--border); padding: 0 clamp(16px,3vw,32px); height: 64px; position: sticky; top: 0; z-index: 50; }
.bo-brand { font-family: var(--font-display); font-weight: 800; color: var(--c-primary); }
.bo-tabs { display: flex; gap: 4px; flex: 1; }
.bo-tab { padding: 8px 14px; border: 0; background: transparent; border-radius: 9px; font-weight: 600; color: var(--text-muted); cursor: pointer; }
.bo-tab:hover { background: #f1f5f9; color: var(--text-main); }
.bo-tab.active { background: #eff6ff; color: var(--c-primary); }
.bo-user { display: flex; align-items: center; gap: 12px; font-size: .85rem; color: var(--text-muted); }

/* Main */
.bo-main { max-width: 1200px; margin: 0 auto; padding: 32px clamp(16px,3vw,32px) 80px; }
.bo-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.bo-head h1 { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; }

/* Tabla */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: #fff; }
.bo-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.bo-table th { text-align: left; padding: 14px 16px; background: #f8fafc; color: var(--text-muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; border-bottom: 1px solid var(--border); }
.bo-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.bo-table tr:last-child td { border-bottom: 0; }
.bo-table tr:hover td { background: #f8fafc; }
.td-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.td-empty { text-align: center; color: var(--text-muted); padding: 40px; }

/* Cards / paneles */
.card-list { display: flex; flex-direction: column; gap: 12px; }
.card-row { display: flex; align-items: center; gap: 16px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.card-row h3 { font-size: 1.05rem; font-weight: 700; }
.card-row p { color: var(--text-muted); font-size: .88rem; margin-top: 4px; }
.panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; }
.panel h3 { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; margin-bottom: 6px; }
.panel > p { color: var(--text-muted); font-size: .9rem; }
.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: start; }

/* Constructor de preguntas */
.q-builder { display: flex; flex-direction: column; gap: 14px; margin: 18px 0; }
.q-row { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: #f8fafc; }
.q-top { display: flex; gap: 8px; align-items: center; }
.q-top .inp { flex: 1; }
.q-top .sel { max-width: 150px; }
.q-row .inp + .inp { margin-top: 8px; }

/* Empty */
.empty { display: flex; flex-direction: column; gap: 6px; padding: 50px 24px; text-align: center; border: 2px dashed var(--border); border-radius: var(--radius-lg); color: var(--text-muted); background: #fff; }
.empty strong { color: var(--text-main); font-size: 1.05rem; }

/* Toast */
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 9999; max-width: min(360px, calc(100vw - 48px)); padding: 15px 22px; border: 1px solid var(--border); border-radius: 12px; background: #fff; color: var(--text-main); font-weight: 600; font-size: .92rem; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 800px) {
  .split { grid-template-columns: 1fr; }
  .bo-nav { flex-wrap: wrap; height: auto; padding: 12px 16px; gap: 12px; }
  .bo-tabs { order: 3; width: 100%; overflow-x: auto; }
  .card-row { flex-direction: column; align-items: flex-start; }
}

/* Modals */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.4); backdrop-filter: blur(2px); z-index: 1000; display: grid; place-items: center; padding: 20px; animation: fade .2s; }
.modal-card { background: var(--bg-card); width: 100%; max-width: 440px; border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow-lg); animation: slide-up .2s; }
.modal-title { font-family: var(--font-display); font-size: 1.25rem; font-weight: 800; margin-bottom: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
