/* ===========================================================================
   Reker Vault — Diseño editorial (claro, cálido, plano · sin glow)
   Tipografía San Francisco (-apple-system). Acento teal Reker.
=========================================================================== */
:root {
  --paper: #eef3fb;          /* lienzo azul-blanco (tech) */
  --surface: #ffffff;
  --surface-2: #f7faff;

  --ink: #0f172a;            /* slate 900 */
  --ink-soft: #1e293b;
  --text-2: #475569;
  --text-3: #94a3b8;

  --hairline: rgba(15, 23, 42, 0.09);
  --hairline-strong: rgba(15, 23, 42, 0.15);

  --accent: #2563eb;         /* azul tech Reker */
  --accent-press: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.10);
  --accent-bright: #3b82f6;
  --accent-grad: linear-gradient(135deg, #2563eb 0%, #3b82f6 55%, #06b6d4 100%);
  --accent-grad-soft: linear-gradient(135deg, rgba(37,99,235,.12), rgba(6,182,212,.10));

  --cyan: #06b6d4;
  --indigo: #6366f1;
  --green: #16a34a;
  --orange: #ea580c;
  --red: #dc2626;
  --amber: #f59e0b;

  --r-lg: 20px;
  --r: 14px;
  --r-sm: 10px;
  --r-pill: 980px;

  --sh: 0 1px 2px rgba(0,0,0,.05), 0 1px 3px rgba(0,0,0,.04);
  --sh-2: 0 8px 26px rgba(0,0,0,.10);
  --sh-pop: 0 18px 50px rgba(0,0,0,.18);

  --ease: cubic-bezier(.22,.61,.36,1);
  --spring: cubic-bezier(.34,1.4,.5,1);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
/* App-like: la página no hace scroll ni rebota; solo scrollan zonas internas. */
html, body { height: 100%; overflow: hidden; overflow-x: hidden; overscroll-behavior: none; }
body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.47;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
::selection { background: rgba(15,107,88,.15); }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.18); border-radius: 20px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.3); background-clip: padding-box; }

.hidden { display: none !important; }
.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, h3 { letter-spacing: -0.022em; font-weight: 600; }

/* ============================ INPUTS / BOTONES ============================ */
.field { text-align: left; margin-bottom: 15px; }
.field label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 7px; font-weight: 500; }
.input, input[type=text], input[type=password], input[type=number], input[type=date], textarea, select {
  width: 100%; background: var(--surface); border: 1px solid var(--hairline-strong);
  color: var(--ink); border-radius: var(--r-sm); padding: 11px 13px; font-size: 15px;
  font-family: inherit; outline: none; transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
.input:focus, input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 74px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239a9aa2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--hairline-strong); background: var(--surface); color: var(--ink);
  padding: 9px 16px; border-radius: var(--r-sm); font-size: 14px; font-weight: 500;
  transition: transform .16s var(--spring), background .16s var(--ease), border-color .16s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--hairline-strong); }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent-grad); color: #fff; border: none; box-shadow: 0 4px 14px rgba(37,99,235,.28); }
.btn-primary:hover { filter: brightness(1.06); box-shadow: 0 6px 18px rgba(37,99,235,.34); }
.btn-primary:active { filter: brightness(.97); }
.btn-soft { background: rgba(0,0,0,.05); border-color: transparent; color: var(--ink); }
.btn-soft:hover { background: rgba(0,0,0,.09); }
.btn-block { width: 100%; padding: 13px; font-size: 15px; font-weight: 550; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: rgba(0,0,0,.05); color: var(--ink); }
.btn-danger { color: var(--red); background: rgba(209,52,47,.09); border-color: transparent; }
.btn-danger:hover { background: rgba(209,52,47,.16); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.login-error { color: var(--red); font-size: 13.5px; margin-top: 14px; min-height: 18px; font-weight: 500; }

/* ============================ LOGIN (minimalista · Apple) ============================ */
.login-wrap {
  position: fixed; inset: 0; overflow-y: auto; overflow-x: hidden;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background:
    radial-gradient(115% 85% at 50% -12%, #e9f1ff 0%, transparent 62%),
    linear-gradient(180deg, #ffffff 0%, #f3f7fd 100%);
}
/* Efecto sutil: dos halos de color que flotan despacio detrás del panel */
.login-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.login-bg i { position: absolute; border-radius: 50%; filter: blur(64px); opacity: .4; }
.login-bg i:nth-child(1) { width: 42vw; height: 42vw; left: -12vw; top: -14vw; background: radial-gradient(circle, #93c5fd, transparent 70%); animation: blobA 24s ease-in-out infinite alternate; }
.login-bg i:nth-child(2) { width: 36vw; height: 36vw; right: -10vw; bottom: -14vw; background: radial-gradient(circle, #a5f3fc, transparent 70%); animation: blobB 28s ease-in-out infinite alternate; }
@keyframes blobA { from { transform: translate(0,0); } to { transform: translate(5vw, 4vh); } }
@keyframes blobB { from { transform: translate(0,0); } to { transform: translate(-4vw, -4vh); } }

/* Panel central: glass suave, mucho aire, centrado */
.login-box {
  position: relative; z-index: 2; margin: auto; width: 100%; max-width: 372px; text-align: center;
  padding: 42px 36px 30px; border-radius: 28px;
  background: rgba(255,255,255,.78);
  -webkit-backdrop-filter: blur(22px) saturate(1.5); backdrop-filter: blur(22px) saturate(1.5);
  border: 1px solid rgba(255,255,255,.85);
  box-shadow: 0 24px 70px rgba(30,58,138,.13), 0 2px 6px rgba(30,58,138,.05);
}
.login-box .lb-logo { display: inline-flex; margin-bottom: 20px; }
.login-box .lb-logo svg { filter: drop-shadow(0 12px 26px rgba(37,99,235,.34)); animation: logoFloat 6s ease-in-out infinite; will-change: transform; }
@keyframes logoFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.login-box .lb-word { font-size: 27px; font-weight: 680; letter-spacing: -0.035em; color: var(--ink); }
.login-box .lb-sub { font-size: 14.5px; color: var(--text-3); margin-top: 7px; margin-bottom: 30px; }
.login-box .login-form { text-align: left; }
.login-box .field { margin-bottom: 15px; }
.login-box .field label { font-size: 12px; }
.login-box .btn-primary { margin-top: 10px; }
.login-box .login-error { text-align: center; }
.login-box .lb-foot { font-size: 11px; color: var(--text-3); margin-top: 24px; letter-spacing: .02em; }

@media (max-width: 440px) {
  .login-box { padding: 36px 24px 26px; border-radius: 24px; }
  .login-box .lb-word { font-size: 25px; }
}

/* ============================ APP SHELL ============================ */
.app { display: grid; grid-template-columns: 258px 1fr; height: 100vh; height: 100dvh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--hairline); display: flex; flex-direction: column; padding: 18px 14px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 10px 20px; }
.brand-logo { line-height: 0; }
.brand-name { font-weight: 650; font-size: 16px; letter-spacing: -0.02em; }
.brand-sub { font-size: 11.5px; color: var(--text-3); }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); padding: 15px 12px 6px; font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 8px 12px; border-radius: 9px; color: var(--text-2); font-size: 14px; font-weight: 450; border: none; background: none; text-align: left; width: 100%; transition: background .14s var(--ease), color .14s; }
.nav-item .icon { width: 18px; height: 18px; color: var(--text-3); transition: color .14s; }
.nav-item:hover { background: rgba(0,0,0,.04); color: var(--ink); }
.nav-item:hover .icon { color: var(--text-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.nav-item.active .icon { color: var(--accent); }
.nav-count { margin-left: auto; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; font-weight: 500; }
.nav-item.active .nav-count { color: var(--accent); }
.sidebar-footer { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--hairline); display: flex; flex-direction: column; gap: 1px; }
.userbox { display: flex; align-items: center; gap: 10px; padding: 8px 10px 12px; }
.userbox .avatar { width: 34px; height: 34px; }
.userbox .ub-name { font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.userbox .ub-role { font-size: 11.5px; color: var(--text-3); text-transform: capitalize; }
.avatar { border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 12.5px; font-weight: 650; flex: none; }

/* Main */
.main { display: flex; flex-direction: column; overflow: hidden; background: var(--paper); }
.topbar { display: flex; align-items: center; gap: 12px; padding: 15px 28px; border-bottom: 1px solid var(--hairline); background: var(--surface); z-index: 5; }
.topbar h2 { font-size: 21px; font-weight: 650; letter-spacing: -0.03em; }
.topbar .sub { font-size: 12.5px; color: var(--text-3); }
.search { position: relative; margin-left: auto; width: 270px; max-width: 34vw; }
.search .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); }
.search input { padding-left: 39px; background: rgba(0,0,0,.045); border-color: transparent; border-radius: var(--r-pill); font-size: 14px; }
.search input:focus { background: var(--surface); }
.filter-select { width: 185px; border-radius: var(--r-pill); font-size: 14px; }
.content { padding: 26px 28px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; flex: 1; }

/* ============================ DASHBOARD (editorial) ============================ */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r); padding: 17px 19px; transition: transform .25s var(--spring), border-color .2s; }
.kpi:hover { transform: translateY(-2px); border-color: var(--hairline-strong); }
.kpi-top { display: flex; align-items: center; gap: 7px; color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.kpi-top .icon { width: 15px; height: 15px; color: var(--accent); }
.kpi-val { font-size: 29px; font-weight: 650; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; margin-top: 11px; }

.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
@media (max-width: 1050px) { .dash-cols { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r); overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--hairline); }
.card-head h3 { font-size: 14.5px; font-weight: 600; }
.card-head .icon { color: var(--accent); width: 17px; height: 17px; }
.card-head .head-link { margin-left: auto; font-size: 12.5px; color: var(--accent); cursor: pointer; }
.card-body { padding: 7px; }

.alert-row { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 10px; transition: background .13s; cursor: pointer; }
.alert-row:hover { background: var(--paper); }
.alert-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot-vencido { background: var(--red); } .dot-critico { background: var(--orange); } .dot-proximo { background: var(--accent); }
.alert-main { flex: 1; min-width: 0; }
.alert-title { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-meta { font-size: 11.5px; color: var(--text-3); }
.alert-when { font-size: 12.5px; font-weight: 600; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.when-vencido { color: var(--red); } .when-critico { color: var(--orange); } .when-proximo { color: var(--text-3); }
.empty { text-align: center; color: var(--text-3); padding: 32px; font-size: 13.5px; }

/* Actividad reciente */
.act-row { display: flex; align-items: center; gap: 11px; padding: 9px 13px; border-radius: 10px; }
.act-row .avatar { width: 32px; height: 32px; }
.act-main { flex: 1; min-width: 0; }
.act-title { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-title b { font-weight: 600; }
.act-sub { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: var(--r-pill); flex: none; }
.tag-alta { background: rgba(47,158,107,.12); color: var(--green); }
.tag-mod { background: var(--accent-soft); color: var(--accent); }
.tag-baja { background: rgba(209,52,47,.10); color: var(--red); }
.act-when { font-size: 11.5px; color: var(--text-3); white-space: nowrap; flex: none; }

.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: 8px; }
.mini { background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px; padding: 13px 15px; cursor: pointer; transition: transform .22s var(--spring), border-color .14s; }
.mini:hover { border-color: var(--hairline-strong); transform: translateY(-2px); }
.mini-val { font-size: 20px; font-weight: 650; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.mini-label { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.mini-label .icon { width: 13px; height: 13px; color: var(--text-3); }
.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 600; margin: 4px 2px 10px; }

/* ============================ TABLE ============================ */
.table-wrap { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r); overflow-x: auto; overflow-y: hidden; }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-3); font-weight: 600; padding: 13px 14px; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--hairline); font-size: 14px; vertical-align: middle; white-space: nowrap; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--paper); }
tbody tr:last-child td { border-bottom: none; }

.title-cell { display: inline-flex; align-items: center; gap: 6px; max-width: 360px; vertical-align: middle; }
.title-cell .icon { flex: none; }
.cell-title { font-weight: 550; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-muted { color: var(--text-3); }
.cell-ellipsis { display: inline-block; max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }

.row-actions { display: flex; gap: 2px; justify-content: flex-end; opacity: 0; transition: opacity .13s; }
tr:hover .row-actions { opacity: 1; }
.icon-btn { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: transparent; border: none; color: var(--text-3); transition: background .12s, color .12s, transform .16s var(--spring); }
.icon-btn:hover { background: rgba(0,0,0,.06); color: var(--ink); }
.icon-btn:active { transform: scale(.9); }
.icon-btn.danger:hover { color: var(--red); background: rgba(209,52,47,.1); }
.icon-btn .icon { width: 16px; height: 16px; }

/* estrella favorito (toggle directo) */
.star-btn { width: 28px; height: 28px; color: var(--text-3); }
.star-btn .icon { width: 15px; height: 15px; }
.star-btn:hover { color: var(--amber); background: rgba(242,165,43,.12); }
.star-btn.on { color: var(--amber); }
.star-btn.on .icon { fill: currentColor; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: var(--r-pill); font-size: 12px; font-weight: 500; background: var(--paper); color: var(--text-2); white-space: nowrap; max-width: 240px; }
.chip-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-type { background: var(--accent-soft); color: var(--accent); }
.chip-role { text-transform: capitalize; }

.secret-cell { display: inline-flex; align-items: center; gap: 8px; font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 13px; color: var(--text-3); }
.secret-dots { letter-spacing: 1px; }
.pill-state { font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: var(--r-pill); }
.state-on { background: rgba(47,158,107,.12); color: var(--green); }
.state-off { background: rgba(0,0,0,.06); color: var(--text-3); }

/* ============================ MODAL ============================ */
.overlay { position: fixed; inset: 0; background: rgba(20,20,22,.35); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); z-index: 70; display: grid; place-items: center; padding: 24px; }
.modal { width: 100%; max-width: 640px; max-height: 88vh; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain; background: var(--surface); border-radius: 22px; box-shadow: var(--sh-pop); }
.modal-head { display: flex; align-items: center; gap: 13px; padding: 20px 24px; border-bottom: 1px solid var(--hairline); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h3 { font-size: 17px; font-weight: 600; flex: 1; letter-spacing: -0.03em; }
.modal-head .ic { width: 38px; height: 38px; border-radius: 11px; background: var(--accent-soft); display: grid; place-items: center; color: var(--accent); }
.modal-body { padding: 20px 24px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 24px; border-top: 1px solid var(--hairline); position: sticky; bottom: 0; background: var(--surface); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

.detail-list { display: flex; flex-direction: column; gap: 1px; }
.detail-row { display: grid; grid-template-columns: 185px 1fr; gap: 14px; padding: 11px 12px; border-radius: 10px; align-items: center; }
.detail-row:hover { background: var(--paper); }
.detail-key { font-size: 13px; color: var(--text-3); font-weight: 500; }
.detail-val { font-size: 14px; word-break: break-word; display: flex; align-items: center; gap: 8px; }
.detail-val.mono { font-family: "SF Mono", ui-monospace, Menlo, monospace; }
.detail-val a { word-break: break-all; }

.secret-input-wrap { position: relative; display: flex; gap: 8px; }
.secret-input-wrap input { flex: 1; font-family: "SF Mono", ui-monospace, Menlo, monospace; }
.strength { height: 5px; border-radius: 3px; background: var(--paper); margin-top: 8px; overflow: hidden; }
.strength-bar { height: 100%; width: 0; border-radius: 3px; transition: width .3s var(--ease), background .3s; }
.hint-note { font-size: 12.5px; color: var(--text-2); background: var(--accent-soft); border-radius: 10px; padding: 11px 13px; margin-bottom: 16px; }

/* toast */
.toast-wrap { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: #fff; padding: 11px 18px; border-radius: var(--r-pill); font-size: 14px; font-weight: 500; box-shadow: var(--sh-2); display: flex; align-items: center; gap: 9px; }
.toast .icon { width: 17px; height: 17px; color: var(--accent-bright); }
.toast.err .icon { color: #ff6b6b; }

.menu-toggle { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; width: 262px; height: 100vh; height: 100dvh; transform: translateX(-100%); transition: transform .28s var(--ease); overscroll-behavior: contain; }
  .sidebar.open { transform: none; box-shadow: var(--sh-pop); }
  .menu-toggle { display: grid; }
  .topbar { gap: 8px; padding: 12px 15px; }
  .topbar h2 { font-size: 18px; }
  .search { width: auto; flex: 1; min-width: 0; }
  .filter-select { display: none; }
  /* botones solo con icono para que quepan */
  #btnExport span, #btnFav span, #btnNewLabel { display: none; }
  .btn { padding: 9px 11px; }
  .content { padding: 16px; }
  .kpi-grid { gap: 10px; }
}
/* móvil estrecho: donut apilado sobre su leyenda */
@media (max-width: 480px) {
  .donut-wrap { flex-direction: column; align-items: center; text-align: left; }
  .donut-wrap .legend { width: 100%; }
  .modal { border-radius: 18px; }
  .detail-row { grid-template-columns: 130px 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ==================== NAVEGACIÓN INFERIOR TIPO APP (móvil) ==================== */
.tabbar, .sheet, .sheet-scrim { display: none; }

@media (max-width: 860px) {
  /* En móvil no hay barra lateral ni hamburguesa: la navegación es inferior. */
  .sidebar { display: none !important; }
  .menu-toggle { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .content { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }

  /* Barra de pestañas inferior (fija, estilo iOS) */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    background: rgba(255,255,255,.88);
    -webkit-backdrop-filter: blur(18px) saturate(1.6); backdrop-filter: blur(18px) saturate(1.6);
    border-top: 1px solid var(--hairline);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: none; border: none; color: var(--text-3); padding: 6px 2px; border-radius: 12px;
    font-size: 10.5px; font-weight: 550; transition: color .15s, transform .16s var(--spring);
  }
  .tab .icon { width: 23px; height: 23px; }
  .tab.active { color: var(--accent); }
  .tab:active { transform: scale(.9); }

  /* Hoja/menú que sube desde abajo */
  .sheet-scrim {
    display: block; position: fixed; inset: 0; z-index: 55; background: rgba(15,23,42,.38);
    opacity: 0; pointer-events: none; transition: opacity .3s var(--ease);
  }
  .sheet-scrim.show { opacity: 1; pointer-events: auto; }
  .sheet {
    display: flex; flex-direction: column; position: fixed; left: 0; right: 0; bottom: 0; z-index: 56;
    max-height: 88dvh; transform: translateY(101%); transition: transform .42s var(--ease);
    background: var(--surface); border-radius: 26px 26px 0 0;
    box-shadow: 0 -22px 60px rgba(15,23,42,.26);
  }
  .sheet.open { transform: translateY(0); }
  .sheet-grab { width: 42px; height: 5px; border-radius: 3px; background: var(--hairline-strong); margin: 10px auto 2px; flex: none; }
  .sheet-user { display: flex; align-items: center; gap: 12px; padding: 8px 20px 14px; border-bottom: 1px solid var(--hairline); }
  .sheet-user .avatar { width: 42px; height: 42px; font-size: 14px; }
  .su-name { font-weight: 650; font-size: 15px; }
  .su-role { font-size: 12px; color: var(--text-3); text-transform: capitalize; }
  .sheet-close { margin-left: auto; width: 34px; height: 34px; border-radius: 50%; border: none; background: rgba(0,0,0,.05); color: var(--text-2); display: grid; place-items: center; }
  .sheet-close .icon { width: 17px; height: 17px; }
  .sheet-body { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 6px 16px 4px; flex: 1; }
  .sheet-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 600; padding: 14px 6px 9px; }
  .tile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .tile {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 9px;
    background: var(--surface-2); border: 1px solid var(--hairline); border-radius: 17px;
    padding: 16px 8px; color: var(--ink); font-size: 12.5px; font-weight: 550; text-align: center;
    transition: transform .16s var(--spring), background .15s;
  }
  .tile:active { transform: scale(.93); background: var(--paper); }
  .tile-ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; }
  .tile-ic .icon { width: 22px; height: 22px; }
  .tile-label { line-height: 1.15; }
  .tile-count { position: absolute; top: 8px; right: 8px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 650; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
  .sheet-foot { display: flex; gap: 10px; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--hairline); }
  .sheet-act { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 13px; border-radius: 14px; border: 1px solid var(--hairline); background: var(--surface); color: var(--ink); font-size: 13.5px; font-weight: 550; }
  .sheet-act.danger { color: var(--red); background: rgba(220,38,38,.06); border-color: transparent; }
  .sheet-act .icon { width: 17px; height: 17px; }

  /* Dashboard compacto (móvil): tarjetas más pequeñas, 2 columnas */
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
  .kpi { padding: 13px 14px; border-radius: 15px; }
  .kpi-ic { width: 32px; height: 32px; margin-bottom: 9px; border-radius: 9px; }
  .kpi-ic .icon { width: 16px; height: 16px; }
  .kpi-top { font-size: 11.5px; }
  .kpi-val { font-size: 22px; margin-top: 5px; }
  .charts-row, .dash-cols { gap: 12px; margin-bottom: 12px; }
  .card-head { padding: 13px 15px; }
  .donut-wrap { gap: 14px; padding: 12px 14px 14px; }

  /* ---- Listas como tarjetas (no tabla de escritorio) ---- */
  .table-wrap { background: transparent; border: none; border-radius: 0; overflow: visible; }
  table, thead, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr {
    background: var(--surface); border: 1px solid var(--hairline); border-radius: 16px;
    padding: 4px 15px 8px; margin-bottom: 11px; box-shadow: var(--sh);
  }
  tbody tr:hover { background: var(--surface); }
  tbody tr:last-child td { border-bottom: 1px solid var(--hairline); }
  tbody td {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    min-width: 0; padding: 9px 0; border-bottom: 1px solid var(--hairline);
    white-space: normal; font-size: 14px;
  }
  tbody td:last-child { border-bottom: none; }
  tbody td::before {
    content: attr(data-label); flex: none; color: var(--text-3);
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  }
  tbody td > * { min-width: 0; max-width: 100%; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cell-ellipsis, .chip { max-width: 62vw; }
  tbody td.td-secret > *, tbody td.td-actions > * { overflow: visible; }
  /* Ocultar filas vacías para que la tarjeta quede limpia */
  tbody td.td-empty { display: none; }

  /* Título: fila destacada arriba, a lo ancho, sin etiqueta */
  tbody td.td-title { justify-content: flex-start; padding: 11px 0; }
  tbody td.td-title::before { display: none; }
  tbody td.td-title > * { text-align: left; width: 100%; overflow: visible; text-overflow: clip; white-space: normal; }
  .td-title .title-cell { max-width: none; align-items: flex-start; }
  .td-title .cell-title { font-size: 15.5px; font-weight: 650; white-space: normal; overflow: visible; text-overflow: clip; }
  .td-title .star-btn { flex: none; }

  /* Secreto */
  .secret-cell { font-size: 13px; }

  /* Acciones visibles y grandes al pie de la tarjeta */
  tbody td.td-actions { justify-content: flex-end; padding-top: 10px; }
  tbody td.td-actions::before { display: none; }
  .row-actions { opacity: 1 !important; gap: 7px; }
  tbody td.td-actions .icon-btn { width: 40px; height: 40px; border-radius: 11px; background: rgba(0,0,0,.045); }
  tbody td.td-actions .icon-btn .icon { width: 18px; height: 18px; }
  tbody td.td-actions .icon-btn.danger { background: rgba(220,38,38,.08); }
}

/* ============================ EXPORT / IMPRESIÓN ============================ */
#printArea { display: none; }
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  html, body { background: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; overflow: visible !important; height: auto !important; }
  .app, #login, #modalRoot, .toast-wrap { display: none !important; }
  #printArea { display: block !important; }
  .report-head { display: flex; align-items: center; gap: 14px; border-bottom: 3px solid #2563eb; padding-bottom: 12px; margin-bottom: 4px; }
  .report-head svg { width: 40px; height: 40px; }
  .report-title { font-size: 19px; font-weight: 700; color: #0f172a; }
  .report-sub { font-size: 11.5px; color: #475569; }
  .report-meta { margin-left: auto; text-align: right; font-size: 11px; color: #475569; }
  .report table { width: 100%; border-collapse: collapse; margin-top: 10px; table-layout: fixed; }
  .report th { text-align: left; font-size: 8.5px; text-transform: uppercase; letter-spacing: .02em; color: #2563eb; border-bottom: 1.5px solid #cbd5e1; padding: 6px 6px; }
  .report td { font-size: 9px; padding: 5px 6px; border-bottom: 1px solid #eef2f7; color: #1e293b;
    word-break: break-word; overflow-wrap: anywhere; white-space: normal; vertical-align: top; }
  .report tr:nth-child(even) td { background: #f8fafc; }
  .report-foot { margin-top: 14px; font-size: 9px; color: #94a3b8; border-top: 1px solid #e2e8f0; padding-top: 8px; }
}

/* ============================ GRÁFICAS + COLOR ============================ */
.kpi-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 12px; }
.kpi-ic .icon { width: 18px; height: 18px; }

.charts-row { display: grid; grid-template-columns: 1fr 1.25fr; gap: 18px; margin-bottom: 18px; }
@media (max-width: 1050px) { .charts-row { grid-template-columns: 1fr; } }

.donut-wrap { display: flex; align-items: center; gap: 20px; padding: 14px 18px 18px; }
.donut { flex: none; }
.donut-total { font-size: 26px; font-weight: 700; fill: var(--ink); letter-spacing: -.03em; }
.donut-sub { font-size: 10px; fill: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.donut-seg { transition: opacity .2s; cursor: default; }
.legend { display: flex; flex-direction: column; gap: 7px; flex: 1; min-width: 0; }
.legend-row { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.legend-val { font-weight: 650; font-variant-numeric: tabular-nums; }

.bars { padding: 12px 18px 16px; display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 34px; align-items: center; gap: 12px; }
.bar-label { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 10px; background: var(--paper); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--accent-grad); }
.bar-val { font-size: 12.5px; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }

/* botón de favoritos (filtro) */
#btnFav.on { background: rgba(245,158,11,.14); color: var(--amber); }
#btnFav.on .icon { fill: currentColor; }
