/* =====================================================================
   TOKENS
   ===================================================================== */
:root{
  --font-ui:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono:ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --nav-w:256px;
  --files-w:300px;
  --top-h:56px;

  --r:8px;
  --r-sm:6px;
  --r-xs:4px;
}
:root[data-theme="light"]{
  color-scheme:light;
  --bg:#f3f5f8;
  --surface:#ffffff;
  --surface-2:#f8f9fb;
  --hover:#f1f3f7;
  --line:#e5e8ee;
  --line-strong:#d3d8e0;
  --text:#1c2430;
  --text-2:#556075;
  --text-3:#6b778a;
  --accent:#2f6fed;
  --accent-hover:#2560d6;
  --accent-bg:rgba(47,111,237,.09);
  --on-accent:#ffffff;
  --ok:#12805c;
  --warn:#946200;
  --danger:#c8342b;
  --ok-bg:rgba(18,128,92,.10);
  --warn-bg:rgba(148,98,0,.11);
  --danger-bg:rgba(200,52,43,.09);
  --scrim:rgba(17,24,36,.45);
  --shadow:0 1px 2px rgba(16,24,40,.05);

  --st-on:#12805c; --st-off:#c8342b; --st-none:#a16207;
  --c-slate:#5a6577; --c-green:#12805c; --c-red:#c8342b; --c-amber:#a16207;
  --c-teal:#0f766e; --c-orange:#c2570c; --c-blue:#2f6fed; --c-sky:#0369a1;
  --shadow-lg:0 20px 50px -12px rgba(16,24,40,.35);

  --sb-bg:#1a2130;
  --sb-line:rgba(255,255,255,.08);
  --sb-text:#a9b3c4;
  --sb-strong:#f1f4f9;
  --sb-label:#8591a5;
  --sb-hover:rgba(255,255,255,.05);
  --sb-active:rgba(255,255,255,.09);
  --sb-accent:#6f9bff;
}
:root[data-theme="dark"]{
  color-scheme:dark;
  --bg:#0e1218;
  --surface:#151a22;
  --surface-2:#1a2029;
  --hover:#1e2530;
  --line:#242c37;
  --line-strong:#323c4a;
  --text:#e2e7ee;
  --text-2:#9aa5b5;
  --text-3:#7c8797;
  --accent:#4d8dff;
  --accent-hover:#6aa0ff;
  --accent-bg:rgba(77,141,255,.15);
  --on-accent:#0b1220;
  --ok:#3ecf8e;
  --warn:#e5b64a;
  --danger:#f2796f;
  --ok-bg:rgba(62,207,142,.12);
  --warn-bg:rgba(229,182,74,.12);
  --danger-bg:rgba(242,121,111,.12);
  --scrim:rgba(2,5,9,.62);
  --shadow:none;

  --st-on:#3ecf8e; --st-off:#f2796f; --st-none:#e5b64a;
  --c-slate:#9aa5b5; --c-green:#3ecf8e; --c-red:#f2796f; --c-amber:#e5b64a;
  --c-teal:#2dd4bf; --c-orange:#fb923c; --c-blue:#4d8dff; --c-sky:#38bdf8;
  --shadow-lg:0 24px 60px -12px rgba(0,0,0,.6);

  --sb-bg:#0a0d12;
  --sb-line:rgba(255,255,255,.06);
  --sb-text:#9aa5b5;
  --sb-strong:#eef2f7;
  --sb-label:#778296;
  --sb-hover:rgba(255,255,255,.04);
  --sb-active:rgba(255,255,255,.08);
  --sb-accent:#4d8dff;
}

/* =====================================================================
   BASE
   ===================================================================== */
*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{
  background:var(--bg); color:var(--text);
  font-family:var(--font-ui); font-size:14px; line-height:1.5;
  min-height:100vh; -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility;
}
h1,h2,h3,p{ margin:0; }
button{ font:inherit; color:inherit; }
code,.mono{ font-family:var(--font-mono); font-size:.92em; }
::selection{ background:var(--accent-bg); }
:focus-visible{ outline:2px solid var(--accent); outline-offset:1px; }
.icon{ width:18px; height:18px; flex-shrink:0; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.icon.sm{ width:15px; height:15px; }
[hidden]{ display:none !important; }
kbd{
  font-family:var(--font-mono); font-size:11px; color:var(--text-2);
  background:var(--surface-2); border:1px solid var(--line-strong); border-bottom-width:2px;
  border-radius:var(--r-xs); padding:0 5px; line-height:1.55;
}

/* =====================================================================
   SHELL
   Escritorio ancho: [menú] [contenido] [archivos]
   < 1200px: archivos pasa a cajón derecho
   <  900px: menú pasa a cajón izquierdo
   ===================================================================== */
.app{
  display:grid;
  grid-template-columns:var(--nav-w) minmax(0,1fr) var(--files-w);
  min-height:100vh;
  transition:grid-template-columns .2s ease;
}
.app[data-nav="rail"]{ --nav-w:68px; }
.app[data-files="closed"]{ --files-w:0px; }

.content{ grid-column:2; min-width:0; display:flex; flex-direction:column; }

/* ---------- Sidebar (menú) ---------- */
.sidebar{
  grid-column:1; position:sticky; top:0; height:100vh;
  display:flex; flex-direction:column; min-width:0; overflow:hidden;
  background:var(--sb-bg); color:var(--sb-text);
}
.sb-brand{
  display:flex; align-items:center; gap:11px; height:var(--top-h); padding:0 18px; flex-shrink:0;
  border-bottom:1px solid var(--sb-line); color:var(--sb-strong); font-weight:600; font-size:15px; white-space:nowrap;
}
.sb-brand .logo{
  width:30px; height:30px; border-radius:var(--r-sm); flex-shrink:0; display:grid; place-items:center;
  background:var(--accent); color:var(--on-accent);
}
.sb-brand .logo .icon{ width:17px; height:17px; }
.sb-scroll{ flex:1; overflow-y:auto; overflow-x:hidden; padding:8px 12px 16px; }
.sb-scroll::-webkit-scrollbar{ width:6px; }
.sb-scroll::-webkit-scrollbar-thumb{ background:var(--sb-line); border-radius:3px; }
.sb-section{
  display:flex; align-items:center; justify-content:space-between; gap:8px;
  padding:16px 10px 6px; font-size:11px; font-weight:600; letter-spacing:.07em; text-transform:uppercase; color:var(--sb-label);
}
.sb-section .count{ font-family:var(--font-mono); letter-spacing:0; font-weight:500; }

.nav-item{
  display:flex; align-items:center; gap:11px; width:100%; text-align:left;
  border:0; background:transparent; cursor:pointer; position:relative;
  padding:8px 10px; border-radius:var(--r-sm); color:var(--sb-text); white-space:nowrap;
}
.nav-item:hover{ background:var(--sb-hover); color:var(--sb-strong); }
.nav-item.active{ background:var(--sb-active); color:var(--sb-strong); }
.nav-item.active::before{
  content:""; position:absolute; left:-12px; top:7px; bottom:7px; width:3px; border-radius:0 3px 3px 0; background:var(--sb-accent);
}
.nav-item .icon{ color:var(--sb-label); }
.nav-item:hover .icon{ color:var(--sb-strong); }
.nav-item .grow{ flex:1; min-width:0; }
.nav-item kbd{ background:transparent; border-color:var(--sb-line); color:var(--sb-label); }
.nav-item:focus-visible, .sb-brand :focus-visible{ outline-color:var(--sb-accent); }

.avatar{
  --st:var(--st-none);
  position:relative; width:30px; height:30px; border-radius:var(--r-sm); flex-shrink:0; display:grid; place-items:center;
  background:color-mix(in srgb, var(--st) 16%, transparent); color:var(--st);
  box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--st) 45%, transparent);
  font-size:11.5px; font-weight:700; letter-spacing:.02em;
}
.avatar[data-ad="on"]{ --st:var(--st-on); }
.avatar[data-ad="off"]{ --st:var(--st-off); }
.avatar[data-ad="none"]{ --st:var(--st-none); }
.avatar img{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; border-radius:inherit; background:var(--surface-2); }
.avatar.has-icon{ background:transparent; box-shadow:0 0 0 2px var(--sb-bg, var(--bg)), 0 0 0 4px var(--st); margin:2px; width:26px; height:26px; }
.avatar.has-icon .av-txt{ visibility:hidden; }
.avatar.lg{ width:56px; height:56px; border-radius:12px; font-size:18px; }
.avatar.lg.has-icon{ width:52px; height:52px; margin:2px; box-shadow:0 0 0 2px var(--bg), 0 0 0 4px var(--st); }
.sidebar .avatar{ --st-on:#3ecf8e; --st-off:#f2796f; --st-none:#e5b64a; }
.sb-legend{ display:flex; flex-wrap:wrap; gap:4px 11px; padding:0 10px 8px; font-size:11.5px; color:var(--sb-label); }
.sb-legend b{ font-weight:500; }
.sb-legend span{ display:inline-flex; align-items:center; gap:5px; }
.sb-legend i{ width:8px; height:8px; border-radius:50%; background:#e5b64a; }
.sb-legend i[data-ad="on"]{ background:#3ecf8e; }
.sb-legend i[data-ad="off"]{ background:#f2796f; }
.item-main{ min-width:0; display:flex; flex-direction:column; line-height:1.3; }
.item-title{ font-size:13.5px; font-weight:500; color:var(--sb-strong); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.item-sub{ font-size:12px; color:var(--sb-label); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sb-foot{ padding:12px; border-top:1px solid var(--sb-line); display:flex; flex-direction:column; gap:6px; }
.sb-state{ padding:18px 10px; font-size:13px; color:var(--sb-text); line-height:1.6; }
.sb-state code{ background:var(--sb-hover); padding:1px 5px; border-radius:var(--r-xs); color:var(--sb-strong); }
.sb-state .err{ color:#f2a29b; display:block; margin:6px 0 10px; }

/* Menú colapsado a iconos (solo escritorio) */
@media (min-width:900px){
  .app[data-nav="rail"] .sidebar .label{ display:none; }
  .app[data-nav="rail"] .sb-brand{ justify-content:center; padding:0; }
  .app[data-nav="rail"] .sb-scroll{ padding:8px 10px 16px; }
  .app[data-nav="rail"] .nav-item{ justify-content:center; padding:8px 0; }
  .app[data-nav="rail"] .nav-item.active::before{ left:-10px; }
  .app[data-nav="rail"] .sb-section{ height:1px; padding:0; margin:12px 8px; background:var(--sb-line); font-size:0; }
}

/* ---------- Topbar ---------- */
.topbar{
  position:sticky; top:0; z-index:30; flex-shrink:0;
  display:flex; align-items:center; gap:8px; height:var(--top-h); padding:0 20px 0 14px;
  background:var(--surface); border-bottom:1px solid var(--line);
}
.crumb{ display:flex; align-items:center; gap:8px; margin-left:6px; color:var(--text-2); min-width:0; white-space:nowrap; overflow:hidden; font-size:13.5px; }
.crumb b{ color:var(--text); font-weight:600; overflow:hidden; text-overflow:ellipsis; }
.crumb .sep{ color:var(--line-strong); }
.spacer{ flex:1; }

.search-trigger{
  display:flex; align-items:center; gap:9px; height:36px; padding:0 8px 0 11px;
  min-width:240px; border-radius:var(--r-sm); cursor:pointer;
  background:var(--surface-2); border:1px solid var(--line); color:var(--text-3); font-size:13.5px;
}
.search-trigger:hover{ border-color:var(--line-strong); color:var(--text-2); }
.search-trigger span{ flex:1; text-align:left; }

/* ---------- Botones ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:7px;
  height:34px; padding:0 14px; border-radius:var(--r-sm);
  background:var(--surface); border:1px solid var(--line-strong); box-shadow:var(--shadow);
  font-size:13.5px; font-weight:500; cursor:pointer; white-space:nowrap;
  transition:background .12s, border-color .12s, color .12s;
}
.btn:hover{ background:var(--hover); }
a.btn{ text-decoration:none; color:var(--text); }
.btn:active{ transform:translateY(1px); }
.btn:disabled{ opacity:.4; cursor:not-allowed; transform:none; }
.btn.primary{ background:var(--accent); border-color:var(--accent); color:var(--on-accent); box-shadow:none; }
.btn.primary:hover{ background:var(--accent-hover); border-color:var(--accent-hover); }
.btn.ghost{ background:transparent; border-color:transparent; color:var(--text-2); box-shadow:none; }
.btn.ghost:hover{ background:var(--hover); color:var(--text); }
.btn.danger{ color:var(--danger); border-color:color-mix(in srgb, var(--danger) 45%, transparent); background:transparent; box-shadow:none; }
.btn.danger:hover{ background:var(--danger-bg); border-color:var(--danger); }
.btn-icon{ width:36px; padding:0; }
.btn.small{ height:28px; padding:0 10px; font-size:12.5px; }
.btn.small.btn-icon{ width:28px; padding:0; }
.btn.full{ width:100%; }
.sb-foot .btn{ background:var(--sb-hover); border-color:var(--sb-line); color:var(--sb-strong); box-shadow:none; }
.sb-foot .btn.ghost{ background:transparent; color:var(--sb-text); }

/* ---------- Panel de archivos (derecha) ---------- */
.files{
  grid-column:3; position:sticky; top:0; height:100vh; overflow:hidden;
  background:var(--surface); border-left:1px solid var(--line); min-width:0;
}
.app[data-files="closed"] .files{ border-left-color:transparent; visibility:hidden; transition:visibility 0s .2s; }
.files-inner{ width:var(--files-full,300px); height:100%; display:flex; flex-direction:column; }
.files-head{
  display:flex; align-items:center; justify-content:space-between; gap:8px; height:var(--top-h); padding:0 10px 0 16px; flex-shrink:0;
  border-bottom:1px solid var(--line); font-weight:600; font-size:14.5px;
}
.files-head .count{ font-family:var(--font-mono); font-size:12px; font-weight:500; color:var(--text-3); margin-left:8px; }
.files-tools{ padding:12px 12px 4px; display:flex; flex-direction:column; gap:10px; flex-shrink:0; }
.seg{ display:grid; grid-template-columns:1fr 1fr; gap:2px; padding:3px; background:var(--surface-2); border:1px solid var(--line); border-radius:var(--r-sm); }
.seg button{ height:28px; border:0; background:transparent; border-radius:var(--r-xs); font-size:13px; font-weight:500; color:var(--text-2); cursor:pointer; }
.seg button:hover{ color:var(--text); }
.seg button.active{ background:var(--surface); color:var(--text); box-shadow:0 0 0 1px var(--line-strong); }
.pane-note{ padding:4px 16px 8px; font-size:12px; color:var(--text-3); font-family:var(--font-mono); word-break:break-all; flex-shrink:0; }
.pane-body{ padding:0 8px 14px; overflow-y:auto; flex:1; }

.file-item{
  display:flex; align-items:center; gap:9px; width:100%; text-align:left;
  border:0; background:transparent; cursor:pointer; padding:6px 8px; border-radius:var(--r-sm); color:var(--text-2);
}
.file-item:hover{ background:var(--hover); color:var(--text); }
.file-item .icon{ color:var(--text-3); }
.file-name{ font-family:var(--font-mono); font-size:12.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; flex:1; min-width:0; }
.file-name em{ font-style:normal; color:var(--text-3); }
.file-use{ width:7px; height:7px; border-radius:50%; background:var(--accent); flex-shrink:0; }

.field-inline{ position:relative; }
.field-inline .icon{ position:absolute; left:10px; top:50%; transform:translateY(-50%); color:var(--text-3); pointer-events:none; }
.field-inline input[type=text]{ padding-left:33px; }

.state{ padding:28px 14px; text-align:center; color:var(--text-2); font-size:13px; line-height:1.6; }
.state code{ background:var(--surface-2); padding:1px 5px; border-radius:var(--r-xs); }
.state .err{ color:var(--danger); display:block; margin:6px 0; }

/* =====================================================================
   CONTENIDO
   ===================================================================== */
main{ flex:1; min-width:0; padding:24px 28px 64px; }
.page{ max-width:1200px; margin:0 auto; container-type:inline-size; }

.page-head{ display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap; margin-bottom:20px; }
.page-head h1{ font-size:22px; font-weight:600; letter-spacing:-.01em; line-height:1.3; display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.head-main{ display:flex; align-items:center; gap:16px; min-width:0; }
.head-text{ min-width:0; }
.head-actions{ display:flex; gap:8px; flex-wrap:wrap; }
.chips{ display:flex; flex-wrap:wrap; gap:6px; margin-top:10px; }
.chip{ --k:var(--text-3); display:inline-flex; align-items:center; gap:7px; min-height:24px; padding:2px 10px; border-radius:999px; font-size:12.5px; line-height:1.3; color:var(--text); background:var(--surface); border:1px solid var(--line-strong); }
.chip i{ width:7px; height:7px; border-radius:50%; background:var(--k); flex-shrink:0; }
.chip.on{ --k:var(--st-on); } .chip.off{ --k:var(--st-off); } .chip.none{ --k:var(--st-none); }
.chip.plain i{ display:none; }
.page-head .app-id{ margin-top:2px; font-family:var(--font-mono); font-size:12.5px; color:var(--text-3); word-break:break-all; }
.tag{
  display:inline-flex; align-items:center; height:22px; padding:0 8px; border-radius:999px;
  background:var(--accent-bg); color:var(--accent); font-size:12px; font-weight:600;
}

/* Tarjetas de métricas */
.stats{ display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:16px; margin-bottom:20px; }
@container (max-width:760px){ .stats{ grid-template-columns:repeat(2,minmax(0,1fr)); } }
.stat{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:14px 16px; background:var(--surface); border:1px solid var(--line); border-radius:var(--r); box-shadow:var(--shadow); min-width:0;
}
.stat-label{ display:block; font-size:12.5px; line-height:1.3; color:var(--text-2); }
.stat-value{ display:block; margin-top:2px; font-size:24px; font-weight:600; line-height:1.25; letter-spacing:-.01em; font-variant-numeric:tabular-nums; }
.stat{ --c:var(--accent); }
.stat[data-c="slate"]{ --c:var(--c-slate); } .stat[data-c="green"]{ --c:var(--c-green); } .stat[data-c="red"]{ --c:var(--c-red); }
.stat[data-c="amber"]{ --c:var(--c-amber); } .stat[data-c="teal"]{ --c:var(--c-teal); } .stat[data-c="orange"]{ --c:var(--c-orange); }
.stat[data-c="blue"]{ --c:var(--c-blue); } .stat[data-c="sky"]{ --c:var(--c-sky); }
.stat-ico{ width:38px; height:38px; border-radius:var(--r-sm); flex-shrink:0; display:grid; place-items:center; background:color-mix(in srgb, var(--c) 15%, transparent); color:var(--c); }
.stat-ico .icon{ width:20px; height:20px; }

.panel{ background:var(--surface); border:1px solid var(--line); border-radius:var(--r); box-shadow:var(--shadow); margin-bottom:20px; overflow:hidden; }
.panel-head{ display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; padding:14px 20px; border-bottom:1px solid var(--line); }
.panel-head h2{ font-size:15px; font-weight:600; }
.panel-head p{ font-size:12.5px; color:var(--text-2); }
.panel-body{ padding:20px; }

/* Formularios */
.form-grid{ display:grid; grid-template-columns:minmax(0,2fr) minmax(0,.7fr) minmax(0,1fr) minmax(0,1fr); gap:18px 24px; align-items:end; }
@media (max-width:1100px){ .form-grid{ grid-template-columns:1fr 1fr; } }
@media (max-width:520px){ .form-grid{ grid-template-columns:1fr; } }
.field label, .field .lbl{ display:block; font-size:13px; font-weight:500; color:var(--text); margin-bottom:6px; }
input[type=text], input[type=number], textarea{
  width:100%; height:36px; padding:0 11px; border-radius:var(--r-sm);
  background:var(--surface); border:1px solid var(--line-strong); color:var(--text);
  font-family:var(--font-ui); font-size:13.5px;
}
.field input[type=text], .single input[type=text]{ font-family:var(--font-mono); font-size:13px; }
input[type=text]:hover, input[type=number]:hover, textarea:hover{ border-color:var(--text-3); }
input[type=text]:focus, input[type=number]:focus, textarea:focus{ outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-bg); }
input::placeholder{ color:var(--text-3); }

.toggle{ display:flex; align-items:center; gap:10px; height:36px; }
.toggle .txt{ font-size:13.5px; color:var(--text-2); }
.switch{ position:relative; width:38px; height:22px; flex-shrink:0; }
.switch input{ position:absolute; inset:0; width:100%; height:100%; opacity:0; margin:0; cursor:pointer; z-index:1; }
.switch .track{ position:absolute; inset:0; border-radius:999px; background:var(--line-strong); transition:background .15s; }
.switch .track::after{ content:""; position:absolute; top:3px; left:3px; width:16px; height:16px; border-radius:50%; background:#fff; box-shadow:0 1px 2px rgba(0,0,0,.25); transition:transform .15s; }
.switch input:checked + .track{ background:var(--accent); }
.switch input:checked + .track::after{ transform:translateX(16px); }
.switch input:focus-visible + .track{ outline:2px solid var(--accent); outline-offset:2px; }

/* Pestañas */
.tabs{ display:flex; gap:4px; padding:0 14px; border-bottom:1px solid var(--line); overflow-x:auto; }
.tab{
  display:flex; align-items:center; gap:8px; height:48px; padding:0 10px; margin-bottom:-1px;
  background:transparent; border:0; border-bottom:2px solid transparent; cursor:pointer; white-space:nowrap;
  font-size:13.5px; font-weight:500; color:var(--text-2);
}
.tab:hover{ color:var(--text); }
.tab.active{ color:var(--accent); border-bottom-color:var(--accent); }
.count-pill{ font-size:12px; font-weight:500; color:var(--text-2); background:var(--surface-2); border:1px solid var(--line); border-radius:999px; padding:0 8px; line-height:19px; font-variant-numeric:tabular-nums; }
.tab.active .count-pill{ background:var(--accent-bg); border-color:transparent; color:var(--accent); }
.count-pill.warn, .tab.active .count-pill.warn{ color:var(--warn); background:var(--warn-bg); border-color:transparent; }
.tab-panel{ display:none; }
.tab-panel.active{ display:block; }

.toolbar{ display:flex; align-items:center; gap:12px; flex-wrap:wrap; padding:12px 20px; border-bottom:1px solid var(--line); }
.toolbar .field-inline{ flex:0 1 300px; min-width:190px; }
.toolbar .meta{ color:var(--text-2); font-size:13px; font-variant-numeric:tabular-nums; }
.toolbar .meta .bad{ color:var(--warn); font-weight:500; }

/* Tablas */
.table-wrap{ overflow-x:auto; }
table.dt{ width:100%; border-collapse:collapse; font-size:13.5px; }
.dt th{
  text-align:left; font-weight:600; font-size:11.5px; letter-spacing:.05em; text-transform:uppercase; color:var(--text-2);
  padding:10px 12px; background:var(--surface-2); border-bottom:1px solid var(--line); white-space:nowrap;
}
.dt td{ padding:0 12px; height:48px; border-bottom:1px solid var(--line); vertical-align:middle; }
.dt tbody tr:last-child td{ border-bottom:0; }
.dt tbody tr:hover td{ background:var(--surface-2); }
.dt th:first-child, .dt td:first-child{ padding-left:20px; }
.dt th:last-child, .dt td:last-child{ padding-right:20px; }
.dt .num{ text-align:right; font-variant-numeric:tabular-nums; }
.dt .dim{ color:var(--text-2); }
.dt .act{ width:1%; white-space:nowrap; text-align:right; }
.dt tr.row-bad td:first-child{ box-shadow:inset 3px 0 0 var(--warn); }
.dt tr.row-empty td:first-child{ box-shadow:inset 3px 0 0 var(--danger); }

.cell{
  height:32px; padding:0 9px; margin-left:-9px; width:calc(100% + 18px);
  background:transparent; border:1px solid transparent; border-radius:var(--r-sm);
  color:var(--text); font-family:var(--font-ui); font-size:13.5px;
}
.cell.mono{ font-family:var(--font-mono); font-size:13px; }
.cell:hover{ border-color:var(--line-strong); background:var(--surface); }
.cell:focus{ outline:none; background:var(--surface); border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-bg); }

/* Estado como badge */
.status{ display:inline-flex; align-items:center; gap:6px; height:22px; padding:0 9px; border-radius:999px; font-size:12px; font-weight:500; white-space:nowrap; color:var(--text-2); background:var(--surface-2); border:1px solid var(--line); }
.status i{ width:6px; height:6px; border-radius:50%; background:var(--text-3); }
.status.ok{ color:var(--ok); background:var(--ok-bg); border-color:transparent; }
.status.ok i{ background:var(--ok); }
.status.missing, .status.dup{ color:var(--warn); background:var(--warn-bg); border-color:transparent; }
.status.missing i, .status.dup i{ background:var(--warn); }
.status.empty{ color:var(--danger); background:var(--danger-bg); border-color:transparent; }
.status.empty i{ background:var(--danger); }

.table-foot{ display:flex; align-items:center; justify-content:space-between; gap:10px; padding:12px 20px; border-top:1px solid var(--line); background:var(--surface-2); }
.table-foot .hint{ font-size:12.5px; color:var(--text-3); }

.empty{ padding:48px 20px; text-align:center; color:var(--text-2); }
.empty h3{ font-size:15px; font-weight:600; color:var(--text); margin-bottom:4px; }
.empty .btn{ margin-top:16px; }

.single{ padding:20px; display:flex; flex-direction:column; gap:16px; }
.single .hint{ color:var(--text-2); font-size:13.5px; max-width:64ch; }
.single .row{ display:flex; gap:12px; align-items:flex-end; flex-wrap:wrap; }
.single .row .field{ width:min(400px,100%); }

textarea.jsonbox{ height:auto; min-height:420px; padding:14px; line-height:1.6; font-family:var(--font-mono); font-size:13px; resize:vertical; display:block; }
.json-wrap{ padding:20px; }
.json-actions{ display:flex; gap:8px; margin-top:14px; }

/* =====================================================================
   MODALES
   ===================================================================== */
.overlay{ position:fixed; inset:0; z-index:60; background:var(--scrim); display:flex; align-items:flex-start; justify-content:center; padding:7vh 16px 16px; }
.overlay.hidden{ display:none; }
.dialog{
  width:100%; max-width:820px; max-height:84vh; display:flex; flex-direction:column;
  background:var(--surface); border:1px solid var(--line-strong); border-radius:10px;
  box-shadow:var(--shadow-lg); overflow:hidden;
}
.dialog.wide{ max-width:980px; }
.dialog-head{ display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 12px 12px 20px; border-bottom:1px solid var(--line); }
.dialog-head h3{ font-size:13.5px; font-weight:500; font-family:var(--font-mono); word-break:break-all; }
.dialog-body{ padding:20px; overflow-y:auto; }
.dialog-body pre{ margin:0; font-family:var(--font-mono); font-size:12.5px; line-height:1.65; white-space:pre-wrap; word-break:break-word; color:var(--text-2); }
.dtabs{ display:flex; gap:4px; padding:0 14px; border-bottom:1px solid var(--line); }
.dtabs .tab{ height:42px; }
.dpanel{ display:none; }
.dpanel.active{ display:block; }

.stats-row{ display:grid; grid-template-columns:repeat(auto-fit,minmax(120px,1fr)); border:1px solid var(--line); border-radius:var(--r); margin-bottom:18px; overflow:hidden; }
.stats-row > div{ padding:12px 16px; border-left:1px solid var(--line); min-width:0; }
.stats-row > div:first-child{ border-left:0; }
.stats-row b{ display:block; font-size:19px; font-weight:600; font-variant-numeric:tabular-nums; line-height:1.3; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.stats-row span{ font-size:12.5px; color:var(--text-2); }

.sec-title{ font-size:13px; font-weight:600; margin:20px 0 10px; }
.sec-title:first-child{ margin-top:0; }
.dialog .dt-box{ border:1px solid var(--line); border-radius:var(--r); overflow:hidden; }
.dialog .dt td{ height:40px; }
.dialog .dt th:first-child, .dialog .dt td:first-child{ padding-left:14px; }
.badge{ font-size:12px; font-weight:500; color:var(--ok); background:var(--ok-bg); padding:1px 8px; border-radius:999px; }
.emoji-cloud{ display:flex; flex-wrap:wrap; gap:6px; }
.emoji-chip{ display:inline-flex; align-items:center; gap:6px; background:var(--surface-2); border:1px solid var(--line); border-radius:999px; padding:2px 10px; font-size:14px; }
.emoji-chip small{ font-size:11.5px; color:var(--text-2); font-family:var(--font-mono); }
.more{ font-size:12.5px; color:var(--text-3); margin-top:10px; }

/* Buscador */
.search-box{ display:flex; align-items:center; gap:10px; padding:0 14px 0 18px; border-bottom:1px solid var(--line); }
.search-box .icon{ color:var(--text-3); }
.search-box input{ flex:1; height:52px; border:0; background:transparent; box-shadow:none !important; font-family:var(--font-ui); font-size:15px; padding:0; }
.search-box input:focus{ outline:none; }
.search-meta{ padding:9px 20px; font-size:12.5px; color:var(--text-2); border-bottom:1px solid var(--line); background:var(--surface-2); }
.search-layout{ display:grid; grid-template-columns:310px minmax(0,1fr); min-height:0; flex:1; overflow:hidden; }
.search-results-col{ border-right:1px solid var(--line); overflow-y:auto; max-height:58vh; padding:8px; }
.search-preview-col{ padding:20px; overflow-y:auto; max-height:58vh; }
@media (max-width:720px){
  .search-layout{ grid-template-columns:1fr; }
  .search-results-col{ border-right:0; border-bottom:1px solid var(--line); max-height:220px; }
}
.result{ align-items:flex-start; flex-direction:column; gap:5px; padding:9px 10px; }
.result.active{ background:var(--accent-bg); color:var(--text); }
.result .item-title{ font-family:var(--font-mono); font-size:13px; color:var(--text); }
.kw{ display:flex; flex-wrap:wrap; gap:4px; }
.kw span{ font-size:12px; color:var(--text-2); background:var(--surface-2); border:1px solid var(--line); border-radius:999px; padding:0 8px; line-height:19px; }
.preview-head{ display:flex; gap:14px; align-items:center; margin-bottom:18px; }
.preview-head img{ width:56px; height:56px; border-radius:var(--r); object-fit:cover; border:1px solid var(--line-strong); background:var(--surface-2); flex-shrink:0; }
.preview-head h3{ font-size:16px; font-weight:600; margin-bottom:3px; }
.preview-head p{ font-family:var(--font-mono); font-size:12px; color:var(--text-3); word-break:break-all; line-height:1.55; }
.sticker-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(84px,1fr)); gap:8px; }
.sticker-grid img{ width:100%; aspect-ratio:1; object-fit:contain; background:var(--surface-2); border:1px solid var(--line); border-radius:var(--r-sm); }

/* Toast */
#toast{
  position:fixed; bottom:22px; left:50%; transform:translateX(-50%) translateY(12px);
  display:flex; align-items:center; gap:9px; padding:10px 16px; border-radius:var(--r-sm);
  background:var(--surface); color:var(--text); border:1px solid var(--line-strong);
  box-shadow:var(--shadow-lg); font-size:13.5px; font-weight:500; max-width:calc(100vw - 32px);
  opacity:0; pointer-events:none; transition:opacity .18s, transform .18s; z-index:80;
}
#toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }
#toast .icon{ color:var(--ok); }
#toast.warn .icon{ color:var(--warn); }

/* =====================================================================
   RESPONSIVE — cajones deslizables
   ===================================================================== */
.scrim{
  position:fixed; inset:0; z-index:45; background:var(--scrim);
  opacity:0; visibility:hidden; transition:opacity .2s, visibility 0s .2s;
}
.app[data-drawer="nav"] .scrim, .app[data-drawer="files"] .scrim{ opacity:1; visibility:visible; transition-delay:0s; }

/* < 1200px: el panel de archivos se desliza desde la derecha */
@media (max-width:1199.98px){
  .app, .app[data-files="closed"]{ grid-template-columns:var(--nav-w) minmax(0,1fr); }
  .files, .app[data-files="closed"] .files{
    position:fixed; top:0; right:0; bottom:0; height:auto; width:min(340px,88vw); z-index:50;
    border-left:1px solid var(--line-strong); box-shadow:var(--shadow-lg);
    transform:translateX(102%); visibility:hidden;
    transition:transform .22s ease, visibility 0s .22s;
  }
  .files-inner{ width:100%; }
  .app[data-drawer="files"] .files{ transform:none; visibility:visible; transition:transform .22s ease, visibility 0s; }
}

/* < 900px: el menú también se desliza, desde la izquierda */
@media (max-width:899.98px){
  .app, .app[data-files="closed"], .app[data-nav="rail"]{ grid-template-columns:minmax(0,1fr); transition:none; }
  .content{ grid-column:1; }
  .sidebar{
    position:fixed; top:0; left:0; bottom:0; height:auto; width:min(290px,86vw); z-index:50;
    transform:translateX(-102%); visibility:hidden; box-shadow:var(--shadow-lg);
    transition:transform .22s ease, visibility 0s .22s;
  }
  .app[data-drawer="nav"] .sidebar{ transform:none; visibility:visible; transition:transform .22s ease, visibility 0s; }
  .nav-item.active::before{ left:-12px; }
  .topbar{ padding:0 12px 0 8px; }
  .search-trigger{ min-width:0; width:36px; padding:0; justify-content:center; background:transparent; border-color:transparent; }
  .search-trigger span, .search-trigger kbd{ display:none; }
  main{ padding:18px 14px 56px; }
  .toolbar, .panel-head{ padding-left:14px; padding-right:14px; }
  .panel-body, .json-wrap, .single{ padding:16px 14px; }
  .dt th:first-child, .dt td:first-child{ padding-left:14px; }
  .dt th:last-child, .dt td:last-child{ padding-right:14px; }
  .table-foot{ padding:12px 14px; }
  .page-head h1{ font-size:20px; }
  .stat{ padding:14px; }
  .stat-value{ font-size:22px; }
}
@media (max-width:560px){
  .stats{ gap:10px; }
  .head-main{ align-items:flex-start; }
  .avatar.lg{ width:44px; height:44px; font-size:15px; }
  .avatar.lg.has-icon{ width:40px; height:40px; }
  .stat-ico{ display:none; }
  .stat{ border-left:3px solid var(--c); }
  .crumb .crumb-root, .crumb .sep{ display:none; }
}
@media (prefers-reduced-motion: reduce){
  *{ transition:none !important; animation:none !important; }
}
