:root {
  --bg: #0d0f14; --side: #12151c; --card: #151922; --line: #222837; --line2: #2d3445;
  --text: #e6e8ee; --muted: #a3aab8; --dim: #8b93a3; --accent: #5eead4; --accent-ink: #0d0f14;
  --red-bg: #3b1219; --red: #fca5a5; --amb-bg: #3a2a0a; --amb: #fcd34d; --grn-bg: #0f2e22; --grn: #6ee7b7;
  --radius: 14px;
  --strong: #fff; --btn: #1c2230; --btn-hover: #232a3b; --chip: #1f2636; --input: #0f1219; --link: #7dd3fc;
  --wa-bg: #14532d; --wa-fg: #86efac; --prog-full: #64748b; --bar: #2b3346; --pill-gray: #262b36; --track: #232938;
  --hover: #181d28; --tab: #161a23; --acc-bg: #121620; --info: #10141c; --backdrop: rgba(0, 0, 0, .6); --shadow: rgba(0,0,0,.4);
  --toast-bg: #1f2636; --toast-fg: #fff;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--link); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); }
.dim { color: var(--dim); font-size: 12px; }
.error { color: var(--red); min-height: 1em; margin: 6px 0 0; font-size: 13px; }

/* Layout */
.app { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 1 1 220px; max-width: 250px; min-width: 200px; background: var(--side); border-right: 1px solid var(--line); padding: 22px 14px; display: flex; flex-direction: column; gap: 4px; }
.side a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 14px; }
.side a svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; flex: none; }
.side a:hover { background: var(--hover); color: var(--text); }
.side a.on { background: var(--btn); color: var(--strong); font-weight: 600; }
.side-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; padding: 12px 8px 0; border-top: 1px solid var(--line); gap: 8px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand.big { font-size: 22px; justify-content: center; padding-bottom: 8px; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; }
.main { flex: 999 1 560px; min-width: 0; padding: 26px 30px 48px; display: flex; flex-direction: column; gap: 22px; outline: none; }
@media (max-width: 700px) {
  .side { max-width: none; flex-basis: 100%; flex-direction: row; flex-wrap: wrap; padding: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side .brand { width: 100%; padding-bottom: 8px; }
  .side a { padding: 8px 10px; font-size: 13px; }
  .side-foot { width: 100%; margin-top: 6px; }
  .main { padding: 18px 14px 40px; }
}

/* Header */
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.head h1 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.head p { margin: 4px 0 0; }
.tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card h2 { font-size: 17px; margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi .val { font-size: 30px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.kpi .sub { font-size: 12px; margin-top: 4px; color: var(--muted); }
.cols { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.col-main { flex: 2 1 560px; min-width: 0; }
.col-side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.empty { padding: 30px 10px; text-align: center; color: var(--muted); }

/* Table */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th { text-align: left; color: var(--dim); font-size: 12px; font-weight: 500; padding: 8px 10px; white-space: nowrap; }
td { padding: 11px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
td.r, th.r { text-align: right; white-space: nowrap; }
.strong { font-weight: 600; }
.nw { white-space: nowrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }
tr.off td { opacity: .5; }

/* Pills */
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.amb { background: var(--amb-bg); color: var(--amb); }
.pill.grn { background: var(--grn-bg); color: var(--grn); }
.pill.gray { background: var(--pill-gray); color: var(--muted); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button { background: var(--tab); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 13px; cursor: pointer; }
.tabs button.on { background: var(--btn); color: var(--strong); border-color: var(--line2); font-weight: 600; }

/* Buttons & inputs */
.btn { height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line2); background: var(--btn); color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; justify-content: center; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--btn-hover); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.wa { background: var(--wa-bg); color: var(--wa-fg); border-color: transparent; }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { background: transparent; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; width: 36px; height: 36px; border-radius: 8px; }
.icon-btn:hover { background: var(--btn); color: var(--strong); }
.acts { display: inline-flex; gap: 6px; }
input, select, textarea { width: 100%; height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line2); background: var(--input); color: var(--text); font: inherit; font-size: 14px; }
textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-size: 14px; color: var(--text); }
.search { width: 260px; max-width: 100%; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }

/* Bars & progress */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 160px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.bar .b { width: 100%; max-width: 36px; border-radius: 6px 6px 2px 2px; background: var(--bar); min-height: 3px; }
.bar.cur .b { background: var(--accent); }
.bar span { font-size: 11px; color: var(--muted); }
.bar .v { font-size: 10px; color: var(--dim); }
.prog { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.prog > div { height: 100%; border-radius: 4px; background: var(--accent); }
.prog.full > div { background: var(--prog-full); }
.occ { display: flex; flex-direction: column; gap: 14px; }
.occ-row .top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; gap: 10px; }

/* Platform cards */
.plat { display: flex; flex-direction: column; gap: 14px; }
.plat.off { opacity: .6; }
.plat-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.plat-id { display: flex; gap: 12px; align-items: center; min-width: 0; }
.badge { width: 42px; height: 42px; flex: none; border-radius: 10px; background: var(--chip); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; }
.plat-id h3 { font-size: 16px; }
.plat-id .lnk { font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; display: block; }
.stats { display: flex; flex-wrap: wrap; gap: 12px 20px; }
.stats .k { color: var(--dim); font-size: 11px; }
.stats .n { font-weight: 700; font-size: 16px; margin-top: 2px; }
.stats .n.grn { color: var(--grn); }
.row-btns { display: flex; gap: 8px; }
.row-btns .btn { flex: 1; }

/* Pass */
.passbox { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

/* Auth */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 30px; display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { font-size: 20px; text-align: center; }
.auth-card p.muted { text-align: center; margin: -6px 0 0; font-size: 13px; }

/* Modal */
dialog { background: var(--card); color: var(--text); border: 1px solid var(--line2); border-radius: 16px; padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); }
dialog::backdrop { background: var(--backdrop); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
dialog header { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 6px; }
dialog header h2 { font-size: 18px; }
.modal-body { padding: 10px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
dialog .error { padding: 0 20px; }
dialog footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px 18px; }
.info { background: var(--info); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 13px; line-height: 1.6; }
.info b { color: var(--strong); }

/* Toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--toast-bg); color: var(--toast-fg); border: 1px solid var(--line2); padding: 12px 18px; border-radius: 10px; font-size: 14px; z-index: 50; box-shadow: 0 10px 30px var(--shadow); }
.toast.err { background: var(--red-bg); color: var(--red); }

/* v2 */
.linklike { background: none; border: 0; padding: 0; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.linklike:hover { color: var(--accent); text-decoration: underline; }
h3.sec { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); margin: 8px 0 0; font-weight: 600; }
.acc { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: var(--acc-bg); }
.acc.off { opacity: .55; }
.acc-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.acc-cred { font-size: 13px; }
pre.msg { white-space: pre-wrap; background: var(--input); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font: inherit; font-size: 13px; line-height: 1.6; margin: 0; }
.plat-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.plat-line:last-child { border-bottom: 0; padding-bottom: 0; }
table.ptable { min-width: 0; font-size: 13px; }
table.ptable th, table.ptable td { padding: 6px 4px; }
.pill-btn { border: 0; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; }
.prow { display: grid; grid-template-columns: 90px 1fr 1fr 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
.prow.head { font-size: 12px; color: var(--muted); margin-bottom: 2px; }

/* Tema claro (celeste) - predeterminado */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f1f7fc; --side: #e3f2fd; --card: #ffffff; --line: #dde9f3; --line2: #c8dbea;
  --text: #182031; --muted: #556074; --dim: #637085; --accent: #0284c7; --accent-ink: #ffffff;
  --red-bg: #fde7e7; --red: #b42318; --amb-bg: #fdf1cc; --amb: #8a4b06; --grn-bg: #dcf5e6; --grn: #12663a;
  --strong: #0b1220; --btn: #eef6fc; --btn-hover: #e0eef9; --chip: #e0f2fe; --input: #ffffff; --link: #0369a1;
  --wa-bg: #dcf5e6; --wa-fg: #12663a; --prog-full: #9aa6b8; --bar: #cfe3f3; --pill-gray: #edf0f4; --track: #e3eef7;
  --hover: #e8f4fd; --tab: #ffffff; --acc-bg: #f6fbff; --info: #f3f9fe; --backdrop: rgba(15, 23, 42, .35); --shadow: rgba(15,23,42,.14);
  --toast-bg: #182031; --toast-fg: #ffffff;
}
:root[data-theme="light"] .card, :root[data-theme="light"] .auth-card { box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 1px 8px rgba(15,23,42,.04); }
:root[data-theme="light"] .side { border-right-color: #cfe5f7; }
:root[data-theme="light"] .side a { color: #2f4b63; }
:root[data-theme="light"] .side a:hover { background: #d3eafb; color: #0b1220; }
:root[data-theme="light"] .side a.on { background: #ffffff; color: #0369a1; box-shadow: 0 1px 3px rgba(3,105,161,.15); }
:root[data-theme="light"] .side-foot { border-top-color: #cfe5f7; }
:root[data-theme="light"] .side .muted { color: #3d566c; }
.theme-pick { display: flex; gap: 10px; flex-wrap: wrap; }
.theme-pick button { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line2); background: var(--btn); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.theme-pick button.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.theme-pick .sw { width: 28px; height: 20px; border-radius: 5px; border: 1px solid var(--line2); }

/* Logo de la empresa */
.brand.has-logo .logo { background: none; width: auto; height: auto; border-radius: 0; }
.brand.has-logo .logo img { display: block; height: 40px; max-width: 170px; object-fit: contain; }
.brand.big.has-logo .logo img { height: 64px; max-width: 260px; }
.brand.has-logo.solo-logo { padding-bottom: 14px; }
.logo-prev { display: flex; align-items: center; justify-content: center; min-height: 110px; border: 1px dashed var(--line2); border-radius: 12px; background: var(--info); padding: 16px; }
.logo-prev img { max-height: 90px; max-width: 280px; object-fit: contain; }
