:root {
  color-scheme: dark;
  --ink: #f2effa;
  --violet: #ab94ff;
  --accent: #c3b1ff;
  --primary: #6945e5;
  --primary-hover: #7652f0;
  --paper: #10101a;
  --surface: #191926;
  --field: #13131f;
  --border: #323146;
  --field-border: #4b4963;
  --muted: #b5b2c9;
  --soft: #292240;
  --danger: #ffabbc;
  --good: #9fe3bf;
  --good-bg: #1b352d;
  --waiting: #ffda99;
  --waiting-bg: #3a2e21;
  --shadow: 0 24px 85px #06050e6b;
  font: 16px/1.55 "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

:root[data-theme="light"] {
  color-scheme: light;
  --ink: #1c1930;
  --violet: #7350ff;
  --accent: #5735c9;
  --primary: #613bd4;
  --primary-hover: #512bbf;
  --paper: #f5f3fb;
  --surface: #fff;
  --field: #fcfbff;
  --border: #e3dff0;
  --field-border: #a7a0b8;
  --muted: #625c75;
  --soft: #f0eaff;
  --danger: #a52342;
  --good: #246449;
  --good-bg: #e7f5eb;
  --waiting: #825112;
  --waiting-bg: #fff0d5;
  --shadow: 0 24px 85px #27204022;
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.75rem, 4.8vw, 2.65rem); line-height: 1.13; letter-spacing: -.035em; }
h2 { font-size: 1.12rem; }
h3 { font-size: .96rem; margin-top: 1rem; }
p + p { margin-top: .65rem; }
small, .muted { color: var(--muted); font-size: .875rem; }

.top { background: #151323; color: white; border-bottom: 1px solid #302941; }
.top-inner, .shell { width: min(70rem, calc(100% - 2rem)); margin: 0 auto; }
.top-inner { min-height: 4.25rem; display: flex; align-items: center; gap: 1rem 2.5rem; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: white; text-decoration: none; font-weight: 750; }
.brand img { display: block; width: 138px; height: auto; }
.brand small { color: #e3d9ff; border: 1px solid #77708d; padding: 0 .35rem; border-radius: 4px; font-size: .7rem; }
.top nav, .account, .top-controls { display: flex; align-items: center; gap: .85rem; }
.top nav { flex-wrap: wrap; }
.top nav a { color: #e3e1ec; text-decoration: none; padding: .5rem .15rem; }
.top nav a[aria-current] { color: white; border-bottom: 2px solid #ad96ff; }
.top-controls { margin-left: auto; }
.account { font-size: .85rem; }
.account .quiet { color: white; border-color: #77708d; }
.shell { padding: 2rem 0 3rem; }
.heading { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.heading p, .login p { margin-top: .55rem; color: var(--muted); }
.eyebrow { color: var(--accent); text-transform: uppercase; font-size: .72rem; letter-spacing: .13em; font-weight: 800; margin-bottom: .45rem; }
.panel, .stats a { background: var(--surface); border: 1px solid var(--border); border-radius: 1rem; padding: 1.2rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .55rem 1rem; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-bottom: 1rem; }
.stats a { text-decoration: none; color: var(--ink); display: grid; align-content: space-between; gap: .25rem; }
.stats a:hover { border-color: var(--violet); }
.stats i { display: grid; place-items: center; width: 2.35rem; height: 2.35rem; background: var(--soft); color: var(--accent); border-radius: .65rem; margin-bottom: .4rem; }
.stats span { font-size: .85rem; color: var(--muted); }
.stats strong { font-size: 1.65rem; }
.sales-filter { margin-bottom: 1rem; }
.sales-stats strong { font-size: clamp(1.1rem, 3vw, 1.65rem); }
.stack { display: grid; align-content: start; gap: .85rem; }
.grid, .detail { display: grid; gap: .85rem; }
.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.detail { grid-template-columns: minmax(0, 1.75fr) minmax(15rem, 1fr); }
.capture { max-width: 52rem; }
.contact-selected { background: var(--soft); padding: .7rem; border-radius: .4rem; }
.case-fields { display: grid; gap: .75rem; margin: 0; min-width: 0; padding: .85rem; border: 1px solid var(--border); border-radius: .55rem; }
legend { padding: 0 .4rem; font-weight: 700; }
.remove-case { justify-self: start; }
.actions, .search { display: flex; align-items: end; flex-wrap: wrap; gap: .65rem; }
.search label { flex: 1 1 15rem; }
.inline-label { display: inline-flex; align-items: center; }
label { display: grid; gap: .35rem; min-width: 0; font-size: .91rem; font-weight: 650; }
label small { font-weight: 400; }
input, textarea, select, button, .button { font: inherit; }
input, textarea, select { width: 100%; min-width: 0; color: var(--ink); border: 1px solid var(--field-border); border-radius: .55rem; padding: .6rem .75rem; background: var(--field); font-size: 1rem; font-weight: 400; }
input::placeholder { color: var(--muted); opacity: .8; }
textarea { resize: vertical; }
button, .button { display: inline-flex; justify-content: center; align-items: center; border: 1px solid transparent; border-radius: .55rem; min-height: 2.65rem; padding: .5rem .85rem; cursor: pointer; background: var(--primary); color: white; text-decoration: none; font-size: .92rem; font-weight: 700; }
button:hover, .button:hover { background: var(--primary-hover); }
.secondary, .secondary:hover { color: var(--accent); background: var(--soft); border-color: var(--border); }
.quiet { color: var(--accent); background: transparent; border-color: var(--border); }
.quiet:hover { background: var(--soft); }
.secondary:hover, .quiet:hover { border-color: var(--violet); }
.top .quiet:hover { background: #292240; }
button:disabled { opacity: .6; cursor: default; }
[hidden] { display: none; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 3px; }
.rows { padding: 0; margin: .55rem 0 0; list-style: none; }
.rows li { display: flex; align-items: center; justify-content: space-between; gap: .7rem; border-top: 1px solid var(--border); padding: .8rem 0; }
.rows li > div { min-width: 0; overflow-wrap: anywhere; }
.rows li:last-child { padding-bottom: .15rem; }
.row-title { font-weight: 700; }
.badge { background: var(--soft); color: var(--accent); border-radius: 999px; padding: .2rem .65rem; font-size: .8rem; display: inline-flex; align-items: center; gap: .35rem; }
.badge::before { content: ""; width: .36rem; height: .36rem; border-radius: 50%; background: currentColor; }
.badge[data-status="Ganada"], .badge[data-status="Resuelta"] { background: var(--good-bg); color: var(--good); }
.badge[data-status="Faltan datos"], .badge[data-status="Esperando al cliente"] { background: var(--waiting-bg); color: var(--waiting); }
.empty { color: var(--muted); margin-top: .8rem; }
.preserve { white-space: pre-wrap; overflow-wrap: anywhere; }
.panel-head + .preserve { margin-top: .7rem; }
.theme-toggle { width: 2.7rem; min-height: 2.7rem; padding: 0; background: var(--field); color: var(--ink); border-color: var(--border); }
.theme-toggle:hover { background: var(--soft); border-color: var(--violet); }
.theme-toggle span { display: flex; }
[data-theme="dark"] .theme-moon, [data-theme="light"] .theme-sun { display: none; }
.top .theme-toggle { background: #211d33; border-color: #49405d; color: #e9e1ff; }
.top .theme-toggle:hover { border-color: #ab94ff; }

.login-shell { min-height: 100svh; display: grid; place-items: center; padding: clamp(1rem, 4vw, 3rem); background: radial-gradient(ellipse at 30% 0%, var(--soft), transparent 65%); }
.access-frame { width: min(100%, 61rem); display: grid; grid-template-columns: 1fr 1.04fr; min-height: 35.25rem; overflow: hidden; border: 1px solid var(--border); border-radius: 1.45rem; background: var(--surface); box-shadow: var(--shadow); }
.access-brand { position: relative; isolation: isolate; overflow: hidden; display: grid; grid-template-rows: auto 1fr auto; padding: clamp(1.4rem, 4vw, 2.3rem); color: #f4efff; background: radial-gradient(ellipse at 52% 42%, #3d276a, transparent 63%), linear-gradient(145deg,#221838,#171226 76%); }
.access-brand::before { content: ""; position: absolute; inset: 0; z-index: -1; background-image: radial-gradient(#d8caff35 1px, transparent 1px); background-size: 17px 17px; mask-image: radial-gradient(ellipse, #000 0%, transparent 73%); }
.access-logo { display: block; width: 10rem; height: auto; }
.access-art { position: relative; min-height: 12.75rem; align-self: stretch; }
.art-ring { position: absolute; top: 50%; left: 50%; width: 9rem; aspect-ratio: 1; transform: translate(-50%, -50%); border: 1px solid #c0a2ff35; border-radius: 50%; }
.art-ring:nth-child(2) { width: 12.8rem; border-color: #c0a2ff28; }
.art-ring:nth-child(3) { width: 16rem; border-color: #c0a2ff18; }
.art-tile { position: absolute; top: 50%; left: 50%; display: grid; place-items: center; border: 1px solid #7657a9; border-radius: 1rem; background: #322050; color: #dacbff; box-shadow: 0 10px 32px #10081888; }
.art-tile-main { transform: translate(-50%, -50%) rotate(-7deg); width: 6rem; height: 6rem; border-radius: 1.6rem; background: #25193f; }
.art-tile-main img { width: 3.7rem; height: auto; }
.art-tile-chat { transform: translate(-8rem,-3.4rem) rotate(-13deg); width: 3.1rem; height: 3.1rem; }
.art-tile-calendar { transform: translate(4.5rem,.8rem) rotate(12deg); width: 3.25rem; height: 3.25rem; }
.access-kicker { display: inline-flex; align-items: center; gap: .48rem; color: #d3c0ff; font-size: .7rem; letter-spacing: .14em; font-weight: 750; }
.access-kicker i { width: .44rem; height: .44rem; border-radius: 50%; background: #bd9cff; box-shadow: 0 0 10px #a374ff; }
.access-copy p { margin: .65rem 0 .5rem; font-size: clamp(1.65rem, 3.4vw, 2.3rem); font-weight: 700; line-height: 1.13; letter-spacing: -.035em; }
.access-copy small { color: #c6bbda; }
.login { position: relative; display: grid; align-items: center; padding: 4.65rem clamp(1.5rem, 5vw, 3.3rem) 2.6rem; }
.login-tools { position: absolute; top: 1.35rem; right: 1.35rem; }
.login form { gap: 1.05rem; margin-top: 1.6rem; }
.login input { min-height: 3.1rem; }
.login .error { color: var(--danger); }
.form-error { color: var(--danger); }
.login-submit { min-height: 3.1rem; gap: .6rem; margin-top: .2rem; }
.access-note { display: flex; gap: .4rem; align-items: center; color: var(--muted); font-size: .8rem; margin-top: 1.35rem; border-top: 1px solid var(--border); padding-top: 1.15rem; }
.access-note svg { width: 1rem; height: 1rem; }

@media (max-width: 46rem) {
  .access-frame { width: min(100%, 32rem); min-height: auto; grid-template-columns: 1fr; border-radius: 1.1rem; }
  .access-brand { min-height: 5.2rem; display: flex; align-items: center; padding: 1rem 1.4rem; }
  .access-copy, .access-art { display: none; }
  .login { padding: 1.65rem 1.4rem 1.45rem; }
  .login-tools { top: -3.95rem; right: 1.4rem; }
  .login-tools .theme-toggle { background: #271d40; color: #eee5ff; border-color: #5d4d7a; }
}

@media (max-width: 42rem) {
  .top-inner { gap: .45rem 1rem; padding: .55rem 0; }
  .top nav { order: 3; flex-basis: 100%; }
  .shell { padding-top: 1.25rem; }
  .detail, .grid { grid-template-columns: minmax(0, 1fr); }
  .stats { gap: .4rem; }
  .stats a { padding: .65rem; }
  .account span { display: none; }
}
