/* Base: fuentes, variables de diseño y componentes compartidos. */

/* Las fuentes (Figtree y Poppins) se declaran en crm.css. */

:root {
  --font-ui: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: var(--font-ui);

  --ink: #0d0a08;
  --text: #f6efe6;
  --text-2: rgba(246, 239, 230, 0.72);
  --text-3: rgba(246, 239, 230, 0.5);

  /* Cristal: oscuro y cálido, deja ver el fondo desenfocado */
  --glass: rgba(30, 22, 16, 0.42);
  --glass-strong: rgba(22, 16, 12, 0.86);
  --fill: rgba(255, 240, 222, 0.06);
  --fill-2: rgba(255, 240, 222, 0.1);
  --fill-3: rgba(255, 240, 222, 0.16);
  --line: rgba(255, 236, 214, 0.11);
  --line-2: rgba(255, 236, 214, 0.2);
  --blur: 26px;

  --ok: #5fd39a;
  --warn: #ffb057;
  --danger: #ff7d6e;

  --r-xl: 26px;
  --r-l: 20px;
  --r-m: 13px;
  --r-s: 9px;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 10px 24px -12px rgba(0, 0, 0, 0.45), 0 30px 70px -30px rgba(0, 0, 0, 0.6);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.2), 0 16px 32px -14px rgba(0, 0, 0, 0.55), 0 40px 80px -30px rgba(0, 0, 0, 0.6);

  /* Movimiento */
  --ease: cubic-bezier(0.22, 0.8, 0.26, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 140ms;
  --t-med: 240ms;
  --t-slow: 420ms;

  /* Acento (ámbar por defecto) */
  --accent: #f5a54a;
  --accent-2: #ffd9a0;
  --accent-3: #c96f1f;
  --accent-ink: #2a1602;
  --accent-soft: rgba(245, 165, 74, 0.16);
  color-scheme: dark;
}
[data-accent='rose'] { --accent: #f2788a; --accent-2: #ffc4cb; --accent-3: #c2475c; --accent-ink: #2c060d; --accent-soft: rgba(242, 120, 138, 0.16); }
[data-accent='teal'] { --accent: #3fc6c0; --accent-2: #b4f0e8; --accent-3: #1f8d8c; --accent-ink: #021f1e; --accent-soft: rgba(63, 198, 192, 0.16); }
[data-accent='violet'] { --accent: #a98bf5; --accent-2: #dccfff; --accent-3: #7355c9; --accent-ink: #150a33; --accent-soft: rgba(169, 139, 245, 0.18); }

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font: 450 14px/1.5 var(--font-ui);
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
h1, h2, h3, p, ul, ol, dl, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: rgba(255, 236, 214, 0.22) transparent; }

/* ---------- Fondo ---------- */
#backdrop {
  position: fixed; inset: 0; z-index: 0;
  background: #17110d center / cover no-repeat;
  transition: opacity 0.5s var(--ease);
}
#backdrop::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(13, 10, 8, 0.16), rgba(13, 10, 8, 0.4)); }
#backdrop[data-bg='none'] { background: var(--ink); }
#backdrop[data-bg='none']::after { display: none; }
#backdrop[data-bg='estudio'], .choice-thumb[data-bg='estudio'] { background-image: url('/img/bg-estudio.svg'); }
#backdrop[data-bg='atardecer'], .choice-thumb[data-bg='atardecer'] {
  background-image:
    radial-gradient(60% 55% at 18% 18%, rgba(255, 170, 110, 0.75), transparent 70%),
    radial-gradient(55% 60% at 85% 30%, rgba(214, 84, 110, 0.7), transparent 70%),
    radial-gradient(70% 60% at 55% 100%, rgba(94, 44, 92, 0.9), transparent 75%),
    linear-gradient(160deg, #3a1d1a, #1a0f18);
}
#backdrop[data-bg='aurora'], .choice-thumb[data-bg='aurora'] {
  background-image:
    radial-gradient(55% 60% at 15% 25%, rgba(46, 196, 170, 0.6), transparent 70%),
    radial-gradient(50% 55% at 80% 15%, rgba(96, 110, 232, 0.6), transparent 70%),
    radial-gradient(70% 60% at 60% 100%, rgba(22, 92, 110, 0.85), transparent 75%),
    linear-gradient(160deg, #0d2026, #0b1020);
}
#backdrop[data-bg='grafito'], .choice-thumb[data-bg='grafito'] {
  background-image:
    radial-gradient(60% 55% at 20% 10%, rgba(255, 255, 255, 0.16), transparent 70%),
    radial-gradient(60% 60% at 90% 90%, rgba(255, 255, 255, 0.08), transparent 70%),
    linear-gradient(160deg, #2b2a2a, #121212);
}

#app { position: relative; z-index: 1; height: 100%; }
.noscript { position: relative; z-index: 2; padding: 2rem; }
#layer { position: relative; z-index: 50; }

/* ---------- Cristal ---------- */
.glass, .glass-solid, .glass-accent {
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 244, 230, 0.07), var(--shadow);
}
.glass {
  background: linear-gradient(180deg, rgba(255, 248, 240, 0.075), rgba(255, 248, 240, 0.015) 42%, rgba(255, 248, 240, 0) 70%), var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(135%);
  backdrop-filter: blur(var(--blur)) saturate(135%);
}
.glass-solid {
  background: linear-gradient(180deg, rgba(255, 248, 240, 0.06), rgba(255, 248, 240, 0) 50%), var(--glass-strong);
  -webkit-backdrop-filter: blur(34px) saturate(140%);
  backdrop-filter: blur(34px) saturate(140%);
  border-color: var(--line-2);
}
.glass-accent {
  background: linear-gradient(150deg, color-mix(in srgb, var(--accent) 62%, transparent), color-mix(in srgb, var(--accent-3) 34%, transparent));
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  backdrop-filter: blur(var(--blur)) saturate(150%);
  border-color: color-mix(in srgb, var(--accent-2) 45%, transparent);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: rgba(26, 19, 14, 0.9); }
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  background: var(--fill-2); border: 1px solid var(--line);
  font-weight: 600; font-size: 13.5px; letter-spacing: -0.01em; white-space: nowrap;
  position: relative; isolation: isolate; overflow: hidden;
  transition: transform 0.5s var(--spring), background var(--t-med), border-color var(--t-med), box-shadow var(--t-med), color var(--t-fast);
}
.btn:hover:not(:disabled) { background: var(--fill-3); border-color: var(--line-2); }
.btn:active:not(:disabled) { transform: scale(0.955); transition-duration: 90ms; }
.btn-primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: var(--accent-ink);
  border-color: transparent; font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 8px 22px -10px var(--accent);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #fff6ea, var(--accent-2) 70%); border-color: transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 12px 30px -10px var(--accent);
}
/* Destello que recorre el botón principal al pasar el cursor */
.btn-primary::after {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.65) 50%, transparent 65%);
  transform: translateX(-110%);
}
.btn-primary:hover:not(:disabled)::after { transform: translateX(110%); transition: transform 0.75s var(--ease-out); }
.btn-danger { background: rgba(255, 125, 110, 0.18); border-color: rgba(255, 125, 110, 0.4); color: #ffc9c1; }
.btn-danger:hover:not(:disabled) { background: rgba(255, 125, 110, 0.3); border-color: rgba(255, 125, 110, 0.6); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { color: var(--text); }
.btn-ghost.is-on { background: var(--accent-soft); color: var(--text); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.btn-block { width: 100%; height: 42px; font-size: 14.5px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: 10px; color: var(--text-2);
  transition: background var(--t-fast), color var(--t-fast), transform 0.45s var(--spring);
}
.icon-btn:active:not(:disabled) { transform: scale(0.86); transition-duration: 80ms; }
.icon-btn:hover:not(:disabled), .icon-btn.is-active { background: var(--fill-2); color: var(--text); }
.icon-btn.is-small { width: 28px; height: 28px; border-radius: 8px; }
.icon { flex: none; display: block; }

/* ---------- Formularios ---------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; min-width: 0; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.field-help { font-size: 12.5px; color: var(--text-3); line-height: 1.5; }
.field-static { padding: 9px 0; color: var(--text-2); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-error, .login-error {
  padding: 9px 12px; border-radius: var(--r-s); font-size: 13px;
  background: rgba(255, 125, 110, 0.14); border: 1px solid rgba(255, 125, 110, 0.35); color: #ffc9c1;
}
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; }

.input {
  width: 100%; height: 40px; padding: 0 12px;
  background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line); border-radius: var(--r-s);
  transition: border-color 0.15s, background 0.15s;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 64px; line-height: 1.5; }
select.input { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px; background-size: 5px 5px; background-repeat: no-repeat; }
select option { background: #1c1510; color: var(--text); }
.input::placeholder, .add-input::placeholder { color: var(--text-3); }
.input:hover { border-color: var(--line-2); }
.input:focus-visible { outline: none; border-color: var(--accent); background: rgba(0, 0, 0, 0.4); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-wrap { position: relative; }
.input-wrap > .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-wrap.has-icon .input { padding-left: 36px; }
.input-wrap.has-action .input { padding-right: 40px; }
.input-action { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: var(--text-3); }
.input-action:hover { color: var(--text); background: var(--fill); }

.check-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.switch {
  appearance: none; width: 34px; height: 20px; flex: none; margin: 0; cursor: pointer;
  border-radius: 999px; background: var(--fill-3); position: relative; transition: background 0.2s;
}
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); transition: transform 0.4s var(--spring), width 0.2s var(--ease-out); }
.switch:active::after { width: 18px; }
.switch:checked:active::after { transform: translateX(10px); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(14px); }
input[type='checkbox']:not(.switch) { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; flex: none; transition: transform 0.35s var(--spring); }
input[type='checkbox']:not(.switch):active { transform: scale(0.82); transition-duration: 80ms; }
input[type='checkbox']:not(.switch):checked { animation: tick 0.42s var(--spring); }
@keyframes tick { 0% { transform: scale(0.7); } 100% { transform: scale(1); } }

/* ---------- Piezas pequeñas ---------- */
.avatar {
  display: inline-grid; place-items: center; flex: none; border-radius: 50%;
  background: color-mix(in srgb, var(--c) 78%, #1a120c); color: #fff; font-weight: 600; letter-spacing: 0.01em;
  box-shadow: 0 0 0 2px rgba(20, 14, 10, 0.75);
}
.avatar.is-off { filter: grayscale(1); opacity: 0.6; }
.avatar.is-more { background: var(--fill-3); color: var(--text); }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar + .avatar { margin-left: -5px; }

.pill {
  display: inline-flex; align-items: center; max-width: 100%; height: 24px; padding: 0 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 26%, transparent); color: color-mix(in srgb, var(--c) 45%, #fff);
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pill.is-small { height: 22px; padding: 0 8px; font-size: 11.5px; }

.chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 7px; border-radius: 7px; background: var(--fill); color: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip.is-quiet { background: transparent; padding: 0 2px; color: var(--text-3); }
.chip.is-ok { color: var(--ok); }
.chip.is-overdue { color: #ffc9c1; background: rgba(255, 125, 110, 0.16); }

.tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; background: var(--fill-2); color: var(--text-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag.is-accent { background: var(--accent-soft); color: var(--accent-2); }
.count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }

.brand-mark {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 11px;
  background: linear-gradient(150deg, var(--accent-2), var(--accent) 55%, var(--accent-3)); color: var(--accent-ink);
  font: 800 17px/1 var(--font-display); letter-spacing: -0.04em; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 6px 18px -8px var(--accent);
}
.board-dot {
  display: inline-grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 8px;
  background: color-mix(in srgb, var(--c) 30%, transparent); color: color-mix(in srgb, var(--c) 55%, #fff);
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
}
.board-dot.is-big { width: 42px; height: 42px; border-radius: 13px; }

.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--fill-3); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { display: grid; justify-items: center; gap: 8px; padding: 44px 20px; text-align: center; }
.empty h3 { font-size: 16px; font-weight: 600; }
.empty p { max-width: 46ch; color: var(--text-2); }
.empty .btn { margin-top: 8px; }
.empty-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: var(--fill-2); color: var(--accent-2); margin-bottom: 4px; }

.swatches { display: grid; grid-template-columns: repeat(5, 28px); gap: 8px; padding: 6px; }
.swatch-btn { width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--c); border: 2px solid rgba(0, 0, 0, 0.25); transition: transform 0.12s; }
.swatch-btn:hover { transform: scale(1.1); }
.swatch-btn.is-active { box-shadow: 0 0 0 2px var(--glass-strong), 0 0 0 4px var(--text); }
.swatch { width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; margin: 0 2px; }

.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); }
.seg-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 13px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--text-2); transition: background var(--t-med) var(--ease-out), color var(--t-fast), transform 0.45s var(--spring); }
.seg-btn:active { transform: scale(0.94); transition-duration: 80ms; }
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active { background: var(--fill-3); color: var(--text); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08); }

.select-chip { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 6px 0 12px; border-radius: 999px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); font-size: 13px; color: var(--text-3); }
.select-chip select, .select-plain { background: transparent; border: 0; height: 28px; padding: 0 6px; border-radius: 8px; color: var(--text); font-weight: 500; cursor: pointer; max-width: 190px; }
.select-chip select:hover, .select-plain:hover { background: var(--fill); }

/* ---------- Popover y menú ---------- */
.popover { position: fixed; z-index: 80; min-width: 180px; max-width: calc(100vw - 16px); max-height: min(420px, calc(100vh - 16px)); overflow: auto; padding: 6px; border-radius: var(--r-m); animation: pop 0.26s var(--ease-out); box-shadow: inset 0 1px 0 rgba(255, 244, 230, 0.07), var(--shadow-lift); }
.popover.is-closing { animation: pop-out 0.13s ease-in forwards; }
@keyframes pop { from { opacity: 0; transform: scale(0.94); filter: blur(2px); } }
@keyframes pop-out { to { opacity: 0; transform: scale(0.97); } }
.menu { display: grid; gap: 1px; }
.menu-title { padding: 7px 10px 5px; font-size: 12px; color: var(--text-3); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 6px 10px; border-radius: 8px; text-align: left; font-size: 13.5px; font-weight: 500; color: var(--text); transition: background var(--t-fast); }
.menu-item:active:not(:disabled) { background: var(--fill-3); }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--fill-2); outline: none; }
.menu-item.is-active { color: var(--accent-2); }
.menu-item.is-danger { color: #ffb3a8; }
.menu-item.is-danger:hover:not(:disabled) { background: rgba(255, 125, 110, 0.16); }
.menu-item .icon { color: var(--text-3); }
.menu-item.is-danger .icon { color: inherit; }
.menu-item.is-rich { align-items: flex-start; padding: 8px 10px; }
.menu-item.is-rich .icon { margin-top: 2px; }
.menu-item.is-rich span { display: grid; gap: 1px; }
.menu-item.is-rich strong { font-weight: 500; }
.menu-item.is-rich small { font-size: 12px; color: var(--text-3); }
.menu-sep { height: 1px; margin: 5px 6px; background: var(--line); }

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; overflow: auto;
  background: rgba(8, 6, 4, 0.5); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: fade 0.22s var(--ease-out);
}
.overlay.is-closing { animation: fade-out 0.17s ease-in forwards; }
.overlay.is-closing .modal { animation: sink 0.17s ease-in forwards; }
@keyframes fade { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes sink { to { opacity: 0; transform: scale(0.97) translateY(4px); } }
.modal { width: min(440px, 100%); border-radius: var(--r-l); animation: modal-in 0.38s var(--ease-out); box-shadow: inset 0 1px 0 rgba(255, 244, 230, 0.08), var(--shadow-lift); }
@keyframes modal-in { from { opacity: 0; transform: scale(0.94) translateY(10px); } }
.modal.is-wide { width: min(660px, 100%); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.modal-head h2 { letter-spacing: -0.02em; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 6px 22px; }
.modal-head h2 { font-size: 17px; font-weight: 600; }
.modal-body { padding: 10px 22px 22px; }
.modal-text { color: var(--text-2); line-height: 1.55; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 22px 20px; }

/* ---------- Avisos ---------- */
#toasts { position: fixed; z-index: 90; left: 50%; bottom: 22px; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 9px; padding: 10px 16px; border-radius: 999px; background: rgba(22, 16, 12, 0.9); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border: 1px solid var(--line-2); box-shadow: var(--shadow-lift); font-size: 13.5px; font-weight: 500; animation: toast-in 0.55s var(--spring); transition: opacity 0.25s, transform 0.3s var(--ease-out); }
@keyframes toast-in { from { opacity: 0; transform: translateY(18px) scale(0.9); } }
.toast .icon { color: var(--ok); }
.toast.is-error { border-color: rgba(255, 125, 110, 0.5); }
.toast.is-error .icon { color: var(--danger); }
.toast.is-leaving { opacity: 0; transform: translateY(8px) scale(0.96); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
