/* Portal del cliente.
   Tres paletas (grafito, salvia, ciruela) x claro/oscuro. Todas sobrias: el
   color de marca aparece en el acento y en nada mas; el resto es neutro. */

:root, [data-paleta="grafito"] {
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f8f9fa; --ink: #1c2430; --muted: #5f6b7a;
  --faint: #8a94a1; --line: #e2e6eb; --line-strong: #cfd5dc;
  --accent: #3d5a7a; --accent-strong: #2f4862; --accent-soft: #edf1f6; --accent-ink: #ffffff;
}
[data-paleta="salvia"] {
  --bg: #f4f5f2; --surface: #ffffff; --surface-2: #f8f9f6; --ink: #1e2620; --muted: #5e6a61;
  --faint: #8b958d; --line: #e1e5df; --line-strong: #cdd3ca;
  --accent: #4b6a56; --accent-strong: #3c5645; --accent-soft: #edf2ee; --accent-ink: #ffffff;
}
[data-paleta="ciruela"] {
  --bg: #f6f4f5; --surface: #ffffff; --surface-2: #faf8f9; --ink: #261e24; --muted: #6b6068;
  --faint: #978c94; --line: #e8e2e6; --line-strong: #d6ced3;
  --accent: #6c4d64; --accent-strong: #573e51; --accent-soft: #f3eef1; --accent-ink: #ffffff;
}
[data-theme="dark"], [data-theme="dark"][data-paleta="grafito"] {
  --bg: #111418; --surface: #171b21; --surface-2: #1d2229; --ink: #e6e9ed; --muted: #9aa4b0;
  --faint: #6d7782; --line: #262c34; --line-strong: #343b45;
  --accent: #93acc9; --accent-strong: #aec2da; --accent-soft: #1e2732; --accent-ink: #0f1720;
}
[data-theme="dark"][data-paleta="salvia"] {
  --bg: #111412; --surface: #171b18; --surface-2: #1d221e; --ink: #e5eae6; --muted: #98a49b;
  --faint: #6c776e; --line: #262d28; --line-strong: #333b35;
  --accent: #97b5a0; --accent-strong: #b0c9b7; --accent-soft: #1e2822; --accent-ink: #101611;
}
[data-theme="dark"][data-paleta="ciruela"] {
  --bg: #141113; --surface: #1a1619; --surface-2: #211c20; --ink: #ede7eb; --muted: #a79ba3;
  --faint: #776c74; --line: #2e272c; --line-strong: #3d353b;
  --accent: #c3a3ba; --accent-strong: #d5bccd; --accent-soft: #2a2028; --accent-ink: #1a1218;
}
:root { --go: #2e7a5e; --go-soft: #e8f3ee; --warn: #9a6b17; --warn-soft: #f7f0e1; --stop: #b0463d; --stop-soft: #f8eae8; }
[data-theme="dark"] { --go: #6fc3a1; --go-soft: #17261f; --warn: #e0b45e; --warn-soft: #2a2416; --stop: #e88b81; --stop-soft: #2c1b19; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.5 "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1, "cv11" 1;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
.mono { font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace; font-size: .92em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- layout */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.rail {
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 22px 20px 18px; border-bottom: 1px solid var(--line); }
.brand .logo { height: 36px; max-width: 180px; display: flex; align-items: center; margin-bottom: 10px; }
.brand .logo img { max-height: 36px; max-width: 180px; object-fit: contain; }
.brand .mark {
  width: 36px; height: 36px; border-radius: 9px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 650; font-size: 15px; letter-spacing: .02em;
}
.brand .name { font-weight: 620; font-size: 15px; line-height: 1.25; }
.brand .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 1px; overflow-y: auto; flex: 1; }
.nav .grp { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .07em; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px;
  color: var(--muted); font-weight: 500; text-decoration: none;
}
.nav a svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent-strong); }
[data-theme="dark"] .nav a.on { color: var(--accent); }
.nav a.off { opacity: .4; pointer-events: none; }
.nav a .ext { margin-left: auto; width: 12px; height: 12px; opacity: .6; }
.me { border-top: 1px solid var(--line); padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.me .av {
  width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--muted); flex: none;
}
.me .who { min-width: 0; flex: 1; }
.me .who b { display: block; font-weight: 560; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me .who span { font-size: 12px; color: var(--muted); }

.main { min-width: 0; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 22px 36px 0; max-width: 1180px;
}
.top h1 { font-size: 22px; font-weight: 640; margin: 0; letter-spacing: -.01em; }
.top .lead { color: var(--muted); margin: 4px 0 0; max-width: 680px; }
.tools { display: flex; gap: 8px; align-items: center; flex: none; }
.content { padding: 22px 36px 60px; max-width: 1180px; }

/* -------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font-weight: 540; cursor: pointer; white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.pri:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { color: var(--stop); }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn { width: 34px; padding: 0; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 0 12px; height: 32px; cursor: pointer; color: var(--muted); font-weight: 520; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-soft); color: var(--accent-strong); }
[data-theme="dark"] .seg button.on { color: var(--accent); }

label.f { display: block; font-size: 12.5px; font-weight: 560; color: var(--muted); margin-bottom: 6px; }
.in {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); outline: none;
}
.in:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.in.sm { height: 30px; font-size: 13px; padding: 0 8px; border-radius: 7px; }
.field { margin-bottom: 14px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* ----------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.card > .hd {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.card > .hd h2 { font-size: 14px; font-weight: 620; margin: 0; }
.card > .hd .muted { font-size: 12.5px; }
.card > .bd { padding: 18px; }
.card > .bd.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g-21 { grid-template-columns: 2fr 1fr; }
.stack > * + * { margin-top: 16px; }

.kpi { padding: 16px 18px; }
.kpi .lb { font-size: 12.5px; color: var(--muted); font-weight: 520; }
.kpi .v { font-size: 26px; font-weight: 640; letter-spacing: -.02em; margin-top: 4px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 14px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.kpi .s { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.meter { height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; position: relative; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.meter.wait > i { background: var(--warn); }
.meter.hot > i { background: var(--stop); }
.meter.lg { height: 12px; }
.ticks { position: relative; height: 18px; font-size: 11px; color: var(--faint); }
.ticks span { position: absolute; transform: translateX(-50%); top: 3px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px;
  font-size: 12px; font-weight: 560; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
  white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.go { background: var(--go-soft); color: var(--go); border-color: transparent; }
.pill.wait { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.hot { background: var(--stop-soft); color: var(--stop); border-color: transparent; }
.pill.acc { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
[data-theme="dark"] .pill.acc { color: var(--accent); }
.pill.plain::before { display: none; }

.alert { display: flex; gap: 10px; padding: 11px 14px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; }
.alert + .alert { margin-top: 8px; }
.alert::before { content: ""; width: 3px; border-radius: 3px; background: var(--faint); flex: none; }
.alert.hot { background: var(--stop-soft); border-color: transparent; }
.alert.hot::before { background: var(--stop); }
.alert.wait { background: var(--warn-soft); border-color: transparent; }
.alert.wait::before { background: var(--warn); }
.alert.ok::before { background: var(--go); }

.note { font-size: 13px; color: var(--muted); padding: 12px 14px; border-radius: 9px; background: var(--surface-2); border: 1px dashed var(--line-strong); }
.note b { color: var(--ink); font-weight: 580; }

/* ---------------------------------------------------------------- tables */
table.t { width: 100%; border-collapse: collapse; }
table.t th {
  text-align: left; font-size: 12px; font-weight: 560; color: var(--muted); padding: 10px 18px;
  border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
table.t td { padding: 11px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr:hover td { background: var(--surface-2); }
table.t .sub { font-size: 12.5px; color: var(--muted); }
.empty { padding: 34px 18px; text-align: center; color: var(--muted); }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--accent); opacity: .75; border-radius: 99px; }

/* ----------------------------------------------------------------- chart */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 180px; padding: 6px 0 0; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; }
.chart .col i { display: block; background: var(--accent); opacity: .55; border-radius: 3px 3px 0 0; min-height: 2px; }
.chart .col:hover i { opacity: 1; }
.chart .col.hi i { opacity: .9; }
.chart .col .tip {
  display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--surface); font-size: 12px; padding: 6px 8px; border-radius: 6px; white-space: nowrap; z-index: 3;
}
.chart .col:hover .tip { display: block; }
.axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--faint); padding-top: 8px; border-top: 1px solid var(--line); margin-top: 2px; }

/* -------------------------------------------------------------- sites */
.site { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.site:last-child { border-bottom: 0; }
.site .ic { width: 34px; height: 34px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-strong); display: grid; place-items: center; flex: none; }
[data-theme="dark"] .site .ic { color: var(--accent); }
.site .ic svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.site .tx { flex: 1; min-width: 0; }
.site .tx b { display: block; font-weight: 580; }
.site .tx span { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --------------------------------------------------------------- toggles */
.opt { display: flex; align-items: flex-start; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.opt:last-child { border-bottom: 0; }
.opt .tx { flex: 1; }
.opt .tx b { font-weight: 580; }
.opt .tx p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }

/* ----------------------------------------------------------------- marca */
.pals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pal {
  border: 1px solid var(--line-strong); border-radius: 11px; padding: 12px; cursor: pointer; background: var(--surface);
  text-align: left; display: block; width: 100%;
}
.pal:hover { border-color: var(--faint); }
.pal.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pal .sw { display: flex; height: 44px; border-radius: 7px; overflow: hidden; border: 1px solid rgba(0,0,0,.06); }
.pal .sw i { flex: 1; }
.pal b { display: block; margin-top: 10px; font-weight: 600; }
.pal span { font-size: 12.5px; color: var(--muted); }
.drop {
  border: 1.5px dashed var(--line-strong); border-radius: 11px; padding: 22px; text-align: center; color: var(--muted);
  background: var(--surface-2); cursor: pointer;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.logo-prev { display: flex; gap: 12px; }
.logo-prev > div { flex: 1; height: 86px; border-radius: 10px; border: 1px solid var(--line); display: grid; place-items: center; padding: 14px; }
.logo-prev .lt { background: #ffffff; }
.logo-prev .dk { background: #15181c; }
.logo-prev img { max-height: 54px; max-width: 100%; object-fit: contain; }

/* ----------------------------------------------------------------- misc */
.msg { font-size: 13px; margin-top: 10px; min-height: 18px; }
.msg.err { color: var(--stop); }
.msg.ok { color: var(--go); }
.banner {
  display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: 10px;
  background: var(--warn-soft); color: var(--ink); margin-bottom: 18px; font-size: 13.5px;
}
.soporte {
  position: sticky; top: 0; z-index: 5; display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  padding: 9px 36px; background: var(--warn-soft); border-bottom: 1px solid var(--warn); font-size: 13px;
}
.soporte b { color: var(--warn); }
.soporte .tx { flex: 1; min-width: 240px; }
.soporte .muted { color: var(--muted); }
.loading { color: var(--faint); padding: 28px 0; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--surface);
  padding: 10px 16px; border-radius: 9px; font-size: 13.5px; z-index: 50; box-shadow: 0 6px 24px rgba(0,0,0,.18);
}
.inline-edit { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.inline-edit .in { width: 96px; text-align: right; }
.copy { display: inline-flex; align-items: center; gap: 6px; }
.dl { display: grid; grid-template-columns: 160px 1fr; gap: 10px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

dialog.modal {
  border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(460px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); box-shadow: 0 24px 64px rgba(0,0,0,.28);
}
dialog.modal::backdrop { background: rgba(10,14,20,.48); }
dialog.modal .bd { padding: 22px 24px 6px; }
dialog.modal h3 { margin: 0 0 8px; font-size: 16px; font-weight: 640; }
dialog.modal p { margin: 0 0 8px; color: var(--muted); }
dialog.modal .ft { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px 20px; }

/* ----------------------------------------------------------------- login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .box { width: 100%; max-width: 380px; }
.auth .card { padding: 28px; }
.auth .brandline { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth .brandline img { max-height: 40px; max-width: 200px; object-fit: contain; }
.auth h1 { font-size: 19px; margin: 0 0 4px; font-weight: 640; }
.auth .lead { color: var(--muted); margin: 0 0 22px; font-size: 13.5px; }
.auth .foot { text-align: center; color: var(--faint); font-size: 12px; margin-top: 18px; }
.auth .btn.pri { width: 100%; height: 40px; }

@media (max-width: 1080px) {
  .g4 { grid-template-columns: 1fr 1fr; }
  .g-21, .g2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav .grp { display: none; }
  .top, .content { padding-left: 18px; padding-right: 18px; }
  .g3, .pals { grid-template-columns: 1fr; }
}
