/* VOICE work tool for the group's admin: calm, exact, trustworthy
   IDEA the key cabinet of a dealership: every account is a key tag on a hook, grouped by company
   PICTURE the "cuadro de llaves" on the Panel, rails per company with coloured tags by status
   COLOUR Palausa Eurotax palette: navy ink #14213d, warm paper #f3f1ec, Palausa Claves logo green #00b187; status green/amber/red
   TYPE Fraunces for titles and figures + Source Sans 3 for text
   LAYOUT navy band header; Panel = title + figures, then the key board full width; Claves = rail of companies left, accounts right; phone stacks */
:root {
  color-scheme: light dark;
  --bg: light-dark(#f3f1ec, #0e1524);
  --panel: light-dark(#ffffff, #16203a);
  --panel-2: light-dark(#faf8f3, #1b2745);
  --ink: light-dark(#14213d, #e8ecf5);
  --mute: light-dark(#5b6478, #98a2b8);
  --line: light-dark(#d9d5ca, #2a3657);
  --acc: light-dark(#007a5f, #2fd3a6);
  --acc-ink: light-dark(#ffffff, #04261d);
  --acc-soft: light-dark(#ddf2ea, #11362d);
  --navy: #14213d;
  --navy-2: #1d2f55;
  --rail: light-dark(#c9c2b2, #3a4a72);
  --verde: light-dark(#1e7d45, #5fd08f);
  --naranja: light-dark(#b8660a, #f0a64a);
  --rojo: light-dark(#b42318, #f2827a);
  --amarillo: light-dark(#d9a300, #f2cc4d);
  --radius: 8px;
  --tag-ink: light-dark(#ffffff, #0e1524);
}
:root[data-theme=light] { color-scheme: light; }
:root[data-theme=dark] { color-scheme: dark; }
* { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 "Source Sans 3", "Segoe UI", system-ui, sans-serif; overflow-x: clip; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--acc); }
h1, h2, h3 { font-family: "Fraunces", Georgia, serif; letter-spacing: -.02em; line-height: 1.05; text-wrap: balance; margin: 0; }
.boot { padding: 40px; color: var(--mute); }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); background: var(--bg); }
.login-art { background: var(--navy); color: #fff; padding: clamp(28px, 5vw, 64px); display: flex; flex-direction: column; justify-content: space-between; gap: 28px; position: relative; overflow: hidden; }
.login-art h1 { font-size: clamp(40px, 5vw, 60px); color: #fff; max-width: 13ch; }
.login-art p { color: #c4cde0; max-width: 38ch; margin: 14px 0 0; font-size: 17px; }
.login-board { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; border-top: 6px solid #33476f; padding-top: 2px; }
.login-board .tag { width: 40px; height: 60px; animation: sway 4s ease-in-out infinite; transform-origin: 50% 0; }
.login-board .tag:nth-child(2n) { animation-delay: -1.3s; } .login-board .tag:nth-child(3n) { animation-delay: -2.6s; }
@keyframes sway { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@media (prefers-reduced-motion: reduce) { .login-board .tag { width: 40px; height: 60px; animation: none; } }
.login-side { display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 380px; }
.login h2 { font-size: 32px; margin-bottom: 6px; }
.login .sub { margin-bottom: 22px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 14px; }
.field small { color: var(--mute); font-size: 13px; }
input[type=text], input[type=password], input[type=search], input[type=url], input[type=tel], select, textarea {
  border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; background: var(--panel); width: 100%; font-size: 16px; min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--acc); outline-offset: 0; border-color: var(--acc); }
textarea { min-height: 80px; resize: vertical; }
.error { color: var(--rojo); font-size: 14px; min-height: 20px; margin-bottom: 8px; }
.demo-note { margin-top: 16px; font-size: 14px; color: var(--mute); border-left: 3px solid var(--acc); padding: 6px 10px; background: var(--panel); }
.demo-note button { margin: 6px 6px 0 0; }

/* ---------- Botones ---------- */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 9px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; min-height: 40px; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--rojo); }
.btn.small { padding: 5px 10px; font-size: 13px; min-height: 32px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--acc-soft); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; padding: 12px; min-height: 48px; font-size: 17px; }

/* ---------- Cabecera ---------- */
header.top { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 14px; padding: 0 max(2vw, 16px); min-height: 62px; position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font: 600 20px "Fraunces", Georgia, serif; letter-spacing: -.01em; }
.brand .logo { height: 36px; width: auto; display: block; }
.login-art .brand .logo { height: clamp(44px, 6vw, 64px); }
header.top nav { display: flex; gap: 2px; margin-left: 12px; flex-wrap: wrap; }
header.top nav button { background: transparent; border: 0; color: #b9c4da; padding: 10px 14px; border-radius: 6px; cursor: pointer; font-weight: 600; min-height: 44px; }
header.top nav button.on { color: #fff; box-shadow: inset 0 -3px 0 #00b187; border-radius: 0; }
header.top nav button:hover { color: #fff; }
header.top .who { margin-left: auto; display: flex; align-items: center; gap: 10px; color: #c4cde0; flex-wrap: wrap; }
header.top .who .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
header.top .who .btn:hover { border-color: #fff; }
.badge { display: inline-block; font-size: 13px; font-weight: 600; padding: 1px 9px; border-radius: 20px; background: var(--acc-soft); color: var(--acc); }
header .badge { background: rgba(0,177,135,.2); color: #6fe3c3; }
.demo-band { background: var(--acc-soft); color: var(--ink); font-size: 14px; padding: 8px max(2vw, 16px); border-bottom: 1px solid var(--line); }

/* ---------- Panel ---------- */
.wrap { max-width: 1280px; margin: 0 auto; padding: 26px max(2vw, 16px) 60px; }
.panel-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px 32px; align-items: end; margin-bottom: 22px; }
.panel-head h1 { font-size: clamp(32px, 4vw, 46px); }
.panel-head .sub { margin-top: 8px; }
.figs { display: grid; grid-template-columns: repeat(4, minmax(7.5em, auto)); border-top: 2px solid var(--ink); }
.fig-n { padding: 10px 18px 4px 0; }
.fig-n b { display: block; font: 600 clamp(28px, 3vw, 38px)/1 "Fraunces", Georgia, serif; font-variant-numeric: tabular-nums; }
.fig-n span { font-size: 14px; color: var(--mute); display: flex; align-items: center; gap: 6px; }
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 18px 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px 22px; }
.board-title { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.board-title h2 { font-size: 22px; }
.rail { cursor: default; }
.rail-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.rail-head button { background: none; border: 0; padding: 0; font: 600 16px "Source Sans 3", system-ui, sans-serif; color: var(--ink); cursor: pointer; text-align: left; }
.rail-head button:hover { color: var(--acc); text-decoration: underline; }
.rail-head span { font-size: 13px; color: var(--mute); white-space: nowrap; }
.rail-bar { height: 7px; border-radius: 4px; background: linear-gradient(var(--rail), color-mix(in srgb, var(--rail) 70%, #000)); margin: 6px 0 0; }
.hooks { display: flex; flex-wrap: wrap; gap: 4px 6px; padding: 0 4px; }
.tag { position: relative; width: 30px; height: 42px; border: 0; padding: 0; background: none; cursor: pointer; transform-origin: 50% 0; transition: transform .15s; }
.tag::before { content: ""; position: absolute; left: 50%; top: 0; width: 1.5px; height: 9px; background: var(--mute); transform: translateX(-50%); }
.tag i { position: absolute; left: 2px; right: 2px; top: 8px; bottom: 0; border-radius: 4px 4px 7px 7px; background: var(--c); box-shadow: inset -3px -3px 0 rgba(0,0,0,.14), inset 2px 2px 0 rgba(255,255,255,.25); font: 700 10px/1 "Source Sans 3", sans-serif; color: var(--tag-ink); display: grid; place-items: end center; padding-bottom: 5px; font-style: normal; }
.tag i::after { content: ""; position: absolute; top: 4px; left: 50%; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: var(--panel); }
.tag.has i { outline: 2px solid var(--ink); outline-offset: 1px; }
.tag:hover, .tag:focus-visible { transform: rotate(-8deg) translateY(2px); }
.tag.verde { --c: var(--verde); } .tag.naranja { --c: var(--naranja); } .tag.rojo { --c: var(--rojo); }
.tag.amarillo { --c: var(--amarillo); --tag-ink: #14213d; }
.legend { display: flex; gap: 6px 18px; flex-wrap: wrap; color: var(--mute); font-size: 14px; align-items: center; }
.legend .sw { display: inline-block; width: 11px; height: 15px; border-radius: 2px 2px 4px 4px; vertical-align: -2px; margin-right: 6px; }
.sw.verde { background: var(--verde); } .sw.naranja { background: var(--naranja); } .sw.rojo { background: var(--rojo); } .sw.amarillo { background: var(--amarillo); }
.sw.has { background: transparent; outline: 2px solid var(--ink); outline-offset: -2px; }
.tip { position: fixed; z-index: 40; background: var(--navy); color: #fff; font-size: 14px; padding: 6px 10px; border-radius: 6px; pointer-events: none; max-width: 280px; display: none; }

/* ---------- Claves ---------- */
.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: calc(100vh - 62px); }
aside.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 14px; position: sticky; top: 62px; height: calc(100vh - 62px); overflow: auto; }
aside .group-title { font-size: 13px; color: var(--mute); font-weight: 600; margin: 18px 8px 6px; }
aside .item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; gap: 8px; min-height: 40px; }
aside .item:hover { background: var(--panel-2); }
aside .item.on { background: var(--acc-soft); color: var(--acc); font-weight: 700; }
aside .item .count { color: var(--mute); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
aside .mini { display: flex; height: 4px; border-radius: 2px; overflow: hidden; grid-column: 1 / -1; background: var(--line); }
aside .mini span { display: block; height: 100%; }
main.content { padding: 24px max(2vw, 18px) 60px; }
.page-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h2 { font-size: clamp(28px, 3vw, 36px); }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.sub { color: var(--mute); margin-top: 6px; }
.info { border-left: 3px solid var(--acc); padding: 4px 0 4px 14px; margin-bottom: 18px; color: var(--mute); }
.info div { padding: 1px 0; }
.marca { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.marca > h3 { font-size: 19px; padding: 14px 16px 10px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.marca > h3 .empresa-tag { font: 400 14px "Source Sans 3", sans-serif; color: var(--mute); letter-spacing: 0; }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 13px; color: var(--mute); font-weight: 600; padding: 6px 14px; border-bottom: 1px solid var(--line); }
td { padding: 11px 14px; border-top: 1px solid var(--line); vertical-align: top; }
tbody tr:first-child td { border-top: 0; }
tr.flash td { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--acc-soft); } to { background: transparent; } }
.marca table { table-layout: fixed; min-width: 780px; }
.marca th:nth-child(1) { width: 33%; } .marca th:nth-child(2) { width: 17%; } .marca th:nth-child(3) { width: 21%; }
.marca th:nth-child(4) { width: 11%; } .marca th:nth-child(5) { width: 7%; } .marca th:nth-child(6) { width: 11%; }
td.cuenta { font-weight: 600; }
.acc { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 10px; align-items: start; }
.plat { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; font: 700 12px "Source Sans 3", sans-serif; background: var(--acc-soft); color: var(--acc); position: relative; }
.plat::after { content: ""; position: absolute; right: -3px; bottom: -3px; width: 11px; height: 11px; border-radius: 50%; background: var(--c); border: 2px solid var(--panel); }
.plat.verde { --c: var(--verde); } .plat.naranja { --c: var(--naranja); } .plat.rojo { --c: var(--rojo); } .plat.amarillo { --c: var(--amarillo); }
.sit { display: inline-block; margin-top: 4px; font-size: 13px; font-weight: 600; padding: 1px 9px; border-radius: 12px; background: color-mix(in srgb, var(--c, var(--mute)) 16%, transparent); color: var(--ink); border: 1px solid color-mix(in srgb, var(--c, var(--mute)) 45%, transparent); }
.sit.verde { --c: var(--verde); } .sit.naranja { --c: var(--naranja); } .sit.rojo { --c: var(--rojo); } .sit.amarillo { --c: var(--amarillo); }
td .notas { color: var(--mute); font-size: 14px; font-weight: 400; margin-top: 2px; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 14px; overflow-wrap: anywhere; }
.clave-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.none { color: color-mix(in srgb, var(--mute) 60%, transparent); }
.row-actions { white-space: nowrap; text-align: right; }
.empty { text-align: center; color: var(--mute); padding: 50px 20px; background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }
.noborder { border: 0 !important; }
.search { position: relative; }
.search input { padding-left: 36px; }
.search::before { content: ""; position: absolute; left: 13px; top: 15px; width: 10px; height: 10px; border: 2px solid var(--mute); border-radius: 50%; }
.search::after { content: ""; position: absolute; left: 24px; top: 26px; width: 6px; height: 2px; background: var(--mute); transform: rotate(45deg); }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(14,21,36,.55); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal { background: var(--panel); border-radius: 12px; width: 100%; max-width: 580px; max-height: 92vh; overflow: auto; box-shadow: 0 24px 60px rgba(0,0,0,.3); border-top: 5px solid var(--acc); }
.modal header { padding: 16px 20px 10px; display: flex; justify-content: space-between; align-items: center; font: 600 24px "Fraunces", Georgia, serif; }
.modal .body { padding: 8px 20px 4px; }
.modal footer { padding: 12px 20px 20px; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; }
.inline { display: flex; gap: 6px; }
.inline input { flex: 1; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.check input { width: 18px; height: 18px; }

/* ---------- Usuarios, permisos y registro ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.users { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 14px; }
.ucard { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.ucard.off { opacity: .6; }
.ucard .top { display: flex; gap: 12px; align-items: center; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font: 600 17px "Fraunces", Georgia, serif; flex: none; }
.ucard .name { font-weight: 700; font-size: 17px; }
.ucard .meta { color: var(--mute); font-size: 14px; }
.ucard .bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.ucard .bar span { display: block; height: 100%; background: var(--acc); }
.ucard .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.tree { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.tree .emp { border-bottom: 1px solid var(--line); }
.tree .emp:last-child { border-bottom: 0; }
.tree .row { display: flex; align-items: center; gap: 10px; padding: 9px 14px; min-height: 44px; flex-wrap: wrap; }
.tree .row.emp-row { font-weight: 700; cursor: pointer; }
.tree .row.emp-row:hover { background: var(--panel-2); }
.tree .row.marca-row { padding-left: 42px; font-weight: 600; }
.tree .row.cuenta-row { padding-left: 70px; }
.tree .row .muted { color: var(--mute); font-weight: 400; font-size: 14px; }
.tree .toggle { width: 18px; color: var(--mute); }
.tree input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--acc); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.verde { background: var(--verde); } .dot.naranja { background: var(--naranja); } .dot.rojo { background: var(--rojo); } .dot.amarillo { background: var(--amarillo); }
.sticky-bar { position: sticky; top: 62px; background: var(--bg); padding: 10px 0; z-index: 3; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sticky-bar .search { flex: 1; min-width: 220px; }
.counter { font-weight: 700; color: var(--acc); white-space: nowrap; }
.nowrap { white-space: nowrap; }
.txt-rojo { color: var(--rojo); }
textarea.tall { min-height: 120px; }
.offscreen { position: fixed; opacity: 0; left: -9999px; }
.mt10 { margin-top: 10px; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.err { background: #9a3412; }

@media (max-width: 900px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { min-height: 0; }
  .panel-head { grid-template-columns: 1fr; }
  .figs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout { grid-template-columns: 1fr; }
  aside.side { position: static; height: auto; max-height: 300px; border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 600px) {
  header.top { padding: 8px 14px; gap: 4px; }
  header.top nav { margin-left: 0; width: 100%; }
  header.top .who { margin-left: 0; }
  .sticky-bar { top: 0; position: static; }
  .grid2 { grid-template-columns: 1fr; }
  .marca table { min-width: 640px; }
  .board { padding: 14px; }
}
