/* ============================================================
   IOS · Million Dollar Dashboard — design system
   Cockpit ejecutivo premium dark. Mobile-first (≤600px),
   desktop ≥960px con sidebar fija 232px.
   Sin dependencias externas. Sin @import. Sin url() remotas.
   ============================================================ */

/* ---------- 1. Tokens ---------- */
:root {
  --bg: #0b0d10;
  --surface: #14171c;
  --surface-2: #1b2027;
  --line: #262c35;
  --text: #f2f5f7;
  --muted: #8b96a3;
  --green: #19c37d;
  --green-soft: rgba(25, 195, 125, .12);
  --yellow: #f5b921;
  --yellow-soft: rgba(245, 185, 33, .12);
  --red: #f6465d;
  --red-soft: rgba(246, 70, 93, .12);
  --radius: 14px;
  --nav-h: 64px;
  --ink-on-green: #052e1f;
  --shadow-1: 0 6px 18px rgba(0, 0, 0, .35);
  --shadow-2: 0 18px 48px rgba(0, 0, 0, .5);
  --t-fast: 160ms cubic-bezier(.4, 0, .2, 1);
}

/* ---------- 2. Reset y base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, 'SF Pro Text', 'Segoe UI', Roboto, Inter, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

body.no-scroll { overflow: hidden; }

[hidden] { display: none !important; }

h1, h2, h3, h4 {
  margin: 0 0 10px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
h1 { font-size: 22px; font-weight: 800; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
h4 { font-size: 13.5px; }

p { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }
b, strong { font-weight: 700; }
small { font-size: 12px; color: var(--muted); }
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button { cursor: pointer; }

img, svg { max-width: 100%; }

::selection { background: var(--green); color: var(--ink-on-green); }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Scrollbars discretos */
* { scrollbar-width: thin; scrollbar-color: #2a313b transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a313b; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #39424e; }

/* Checkbox / radio en verde */
input[type="checkbox"], input[type="radio"] { accent-color: var(--green); }

/* Autofill oscuro (login) */
input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--surface-2) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
}

/* ---------- 3. Iconos ---------- */
.icon {
  display: inline-block;
  vertical-align: -0.28em;
  flex: none;
  width: 20px;
  height: 20px;
}

/* ---------- 4. Layout: app-shell / sidebar / bottomnav / main ---------- */
.app-shell { display: block; min-height: 100vh; }

/* Sidebar — oculta en móvil */
.sidebar { display: none; }

.sidebar__logo {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px 8px 0;
}
.sidebar__mark {
  color: var(--green);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}
.sidebar__mark::after { content: '.'; color: var(--text); }
.sidebar__name {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
  line-height: 1.5;
}
.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 22px;
  flex: 1;
  overflow-y: auto;
}
.sidebar__foot {
  margin-top: auto;
  padding: 10px 8px 4px;
}

.env-tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--yellow-soft);
  color: var(--yellow);
  border: 1px solid rgba(245, 185, 33, .35);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

/* Nav items (compartidos sidebar + bottomnav) */
.nav__item {
  background: none;
  border: none;
  color: var(--muted);
  transition: color var(--t-fast), background-color var(--t-fast), transform var(--t-fast);
}
.nav__item:active { transform: scale(.98); }

/* Nav item dentro del sidebar: fila */
.sidebar__nav .nav__item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
}
.sidebar__nav .nav__item--on {
  color: var(--green);
  background: var(--green-soft);
  font-weight: 600;
}

/* Bottom nav — móvil, fija abajo */
.bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  align-items: stretch;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(20, 23, 28, .94);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.bottomnav .nav__item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px 8px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .01em;
  min-width: 0;
}
.bottomnav .nav__item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.bottomnav .nav__item--on { color: var(--green); }

/* Main y screen */
.main {
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 10px);
}
.main:focus { outline: none; }

.screen {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 16px 36px;
}
.screen > * + * { margin-top: 12px; }

.screen__title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 2px 0 0;
}
.screen__sub {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0;
  margin-top: 3px;
  line-height: 1.45;
}

/* ---------- 5. Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color var(--t-fast);
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card h2, .card h3 { margin-bottom: 10px; }

.card--alert {
  border-left: 3px solid var(--red);
  background: linear-gradient(90deg, rgba(246, 70, 93, .07), var(--surface) 55%);
}
.card--warn {
  border-left: 3px solid var(--yellow);
  background: linear-gradient(90deg, rgba(245, 185, 33, .07), var(--surface) 55%);
}
.card--green {
  border-left: 3px solid var(--green);
  background: linear-gradient(90deg, rgba(25, 195, 125, .07), var(--surface) 55%);
}

/* ---------- 6. KPIs / stats ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 0;
}
.stat__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat__value {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}
.stat__value--green { color: var(--green); }
.stat__value--yellow { color: var(--yellow); }
.stat__value--red { color: var(--red); }
.stat__hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.35;
}

/* ---------- 7. Level badge ---------- */
.level-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  white-space: nowrap;
}
.level-badge.lv0 { background: var(--red-soft);    color: var(--red);    border-color: rgba(246, 70, 93, .4); }
.level-badge.lv1 { background: var(--yellow-soft); color: var(--yellow); border-color: rgba(245, 185, 33, .4); }
.level-badge.lv2 { background: var(--yellow-soft); color: var(--yellow); border-color: rgba(245, 185, 33, .4); }
.level-badge.lv3 { background: var(--green-soft);  color: var(--green);  border-color: rgba(25, 195, 125, .4); }
.level-badge.lv4 { background: var(--green-soft);  color: var(--green);  border-color: rgba(25, 195, 125, .4); }
.level-badge.lv5 { background: var(--green);       color: var(--ink-on-green); border-color: var(--green); }

/* ---------- 8. Semáforo ---------- */
.semaforo {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
  vertical-align: baseline;
}
.semaforo--green  { background: var(--green);  box-shadow: 0 0 0 3px var(--green-soft); }
.semaforo--yellow { background: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-soft); }
.semaforo--red    { background: var(--red);    box-shadow: 0 0 0 3px var(--red-soft); }

/* ---------- 9. Barras de progreso ---------- */
.bar {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  min-width: 40px;
}
.bar__fill {
  height: 100%;
  max-width: 100%;
  border-radius: 999px;
  background: var(--green);
  transition: width .35s cubic-bezier(.4, 0, .2, 1);
}
.bar__fill--green  { background: var(--green); }
.bar__fill--yellow { background: var(--yellow); }
.bar__fill--red    { background: var(--red); }
.bar__mark {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  border-radius: 1px;
  background: var(--text);
  opacity: .75;
  transform: translateX(-1px);
}

/* ---------- 10. Ranking ---------- */
.rank {
  margin: 0;
  padding: 0;
  list-style: none;
  font-variant-numeric: tabular-nums;
}
.rank__item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.rank__item:last-child { border-bottom: none; }
.rank__pos {
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.rank__item:first-child .rank__pos {
  background: var(--green-soft);
  color: var(--green);
}
.rank__val {
  margin-left: auto;
  font-weight: 700;
  font-size: 14.5px;
  white-space: nowrap;
}

/* ---------- 11. Alert items ---------- */
.alert-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  font-size: 13.5px;
  line-height: 1.4;
}
.alert-item + .alert-item { margin-top: 8px; }
.alert-item p,
.alert-item .alert-item__text { flex: 1; margin: 0; min-width: 0; }
.alert-item .btn { margin-left: auto; flex: none; }

/* ---------- 12. Decision footer ---------- */
.decision-footer {
  margin-top: 22px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-top: 3px solid var(--green);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.decision-footer__title,
.decision-footer h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--green);
  margin: 0 0 9px;
}
.decision-footer p {
  font-size: 14.5px;
  line-height: 1.45;
  margin: 0 0 12px;
}
.decision-footer__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.decision-footer > .btn { margin: 4px 8px 0 0; }

/* ---------- 13. Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--t-fast), border-color var(--t-fast),
              color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.btn:active { transform: scale(.98); }
.btn:disabled,
.btn[disabled] {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}

.btn--primary {
  background: var(--green);
  color: var(--ink-on-green);
  border-color: var(--green);
}
.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}
.btn--danger {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(246, 70, 93, .35);
}
.btn--yellow {
  background: var(--yellow-soft);
  color: var(--yellow);
  border-color: rgba(245, 185, 33, .35);
}
.btn--sm {
  padding: 5px 10px;
  font-size: 12.5px;
  border-radius: 8px;
}
.btn--sm .icon { width: 16px; height: 16px; }
.btn--block {
  display: flex;
  width: 100%;
}

/* ---------- 14. Chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
}
.chip--green  { background: var(--green-soft);  color: var(--green);  border-color: rgba(25, 195, 125, .35); }
.chip--yellow { background: var(--yellow-soft); color: var(--yellow); border-color: rgba(245, 185, 33, .35); }
.chip--red    { background: var(--red-soft);    color: var(--red);    border-color: rgba(246, 70, 93, .35); }
.chip--muted  { background: var(--surface-2);   color: var(--muted);  border-color: var(--line); }

/* ---------- 15. Tablas ---------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.table th {
  text-align: left;
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(38, 44, 53, .6);
  white-space: nowrap;
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }

/* ---------- 16. Listas ---------- */
.list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.list__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
  font-size: 14px;
}
.list__item:last-child { border-bottom: none; }
.list__item--btn {
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  text-align: left;
  padding: 13px 4px;
  border-radius: 0;
  cursor: pointer;
  transition: background-color var(--t-fast);
}
.list__item--btn:last-child { border-bottom: none; }
.list__item--btn:active { background: var(--surface-2); }
.list__item--btn span { flex: 1; min-width: 0; }
.list__item--btn .icon:last-child { color: var(--muted); }

/* ---------- 17. Formularios ---------- */
.form-row { margin-bottom: 12px; }
.form-row:last-child { margin-bottom: 0; }
.form-row label,
.form-row > .form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px 10px;
}
.form-grid .form-row { margin-bottom: 0; }

.input, .select, .textarea {
  display: block;
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder, .textarea::placeholder { color: #5c6672; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
  outline: none;
}
.textarea {
  min-height: 84px;
  resize: vertical;
  line-height: 1.45;
}
.select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b96a3' 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 10px center;
  padding-right: 34px;
}
.select option { background: var(--surface-2); color: var(--text); }

.input--login {
  text-align: center;
  letter-spacing: .35em;
  font-size: 17px;
  margin-bottom: 12px;
}
.input--login::placeholder { letter-spacing: .04em; font-size: 14px; }

/* ---------- 18. Segmented control ---------- */
.seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  width: 100%;
  max-width: 480px;
}
.seg__btn {
  flex: 1 1 0;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.seg__btn:active { transform: scale(.98); }
.seg__btn--on {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 5px rgba(0, 0, 0, .4), inset 0 0 0 1px var(--line);
}

/* ---------- 19. Modales ---------- */
@keyframes ios-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes ios-sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes ios-pop-in {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;           /* móvil: bottom sheet */
  justify-content: center;
  background: rgba(4, 6, 8, .68);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: ios-fade-in .18s ease-out;
}

.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 85vh;
  max-height: 85dvh;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 18px 18px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: var(--shadow-2);
  animation: ios-sheet-up .28s cubic-bezier(.32, .72, .28, 1);
}
/* Asa de arrastre (solo estética móvil) */
.modal::before {
  content: '';
  display: block;
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  margin: 8px auto 0;
  flex: none;
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px 8px;
  flex: none;
}
.modal__title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  min-width: 0;
}
.modal__close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  flex: none;
  transition: background-color var(--t-fast), color var(--t-fast);
}
.modal__close:active { transform: scale(.95); }
.modal__body {
  padding: 4px 18px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
}
.modal__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding: 12px 18px 14px;
  border-top: 1px solid var(--line);
  flex: none;
}

/* Hoja inferior explícita (ui.sheet) — siempre anclada abajo */
.modal-back--sheet { align-items: flex-end; }
.modal--sheet {
  border-radius: 18px 18px 0 0;
  border-bottom: none;
}
.modal--sheet .modal__body { padding-bottom: 10px; }

/* ---------- 20. Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 14px);
  z-index: 130;
  transform: translate(-50%, 14px);
  opacity: 0;
  max-width: min(92vw, 460px);
  padding: 11px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  box-shadow: var(--shadow-1);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s cubic-bezier(.4, 0, .2, 1);
}
.toast--show { opacity: 1; transform: translate(-50%, 0); }
.toast--ok   { border-left-color: var(--green); }
.toast--warn { border-left-color: var(--yellow); }
.toast--err  { border-left-color: var(--red); }

/* ---------- 21. Progress hero ---------- */
.progress-hero {
  background: linear-gradient(160deg, rgba(25, 195, 125, .09), var(--surface) 60%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.progress-hero__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: 6px;
}
.progress-hero__value {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.progress-hero__sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}
.progress-hero .bar { margin-top: 12px; }

/* ---------- 22. Mic FAB ---------- */
@keyframes ios-mic-pulse {
  0%   { box-shadow: 0 8px 24px rgba(25, 195, 125, .4), 0 0 0 0 rgba(25, 195, 125, .55); }
  100% { box-shadow: 0 8px 24px rgba(25, 195, 125, .4), 0 0 0 20px rgba(25, 195, 125, 0); }
}
.mic-fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 20px);
  z-index: 60;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--green);
  color: var(--ink-on-green);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(25, 195, 125, .4);
  transition: transform var(--t-fast), box-shadow var(--t-fast), background-color var(--t-fast);
}
.mic-fab .icon { width: 24px; height: 24px; }
.mic-fab:active { transform: scale(.94); }
.mic-fab--listening { animation: ios-mic-pulse 1.4s ease-out infinite; }

/* ---------- 23. Assistant panel ---------- */
@keyframes ios-panel-up {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.assistant-panel {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  animation: ios-sheet-up .28s cubic-bezier(.32, .72, .28, 1);
}
.assistant__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 10px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.assistant__log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
}
.bubble {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: break-word;
}
.bubble--user {
  align-self: flex-end;
  background: var(--green-soft);
  border: 1px solid rgba(25, 195, 125, .3);
  border-bottom-right-radius: 4px;
}
.bubble--ai {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.assistant__chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 16px;
  flex: none;
  scrollbar-width: none;
}
.assistant__chips::-webkit-scrollbar { display: none; }
.assistant__chips .chip {
  flex: 0 0 auto;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 11px;
  color: var(--text);
  transition: border-color var(--t-fast), background-color var(--t-fast);
}
.assistant__chips .chip:active { transform: scale(.98); }
.assistant__input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px calc(env(safe-area-inset-bottom, 0px) + 12px);
  border-top: 1px solid var(--line);
  background: var(--surface);
  flex: none;
}
.assistant__input .input { flex: 1; min-width: 0; }
.assistant__input .btn { flex: none; }

/* ---------- 24. Gráficos ---------- */
.trajectory-chart {
  width: 100%;
  margin-top: 6px;
  overflow: hidden;
}
.trajectory-chart svg {
  display: block;
  width: 100%;
  height: auto;
}
.sparkline {
  display: inline-block;
  vertical-align: middle;
  line-height: 0;
}
.sparkline svg { display: block; }

/* ---------- 25. Estado vacío ---------- */
.empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}
.empty .btn { margin-top: 14px; }

/* ---------- 26. Login ---------- */
.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 560px at 50% -8%, rgba(25, 195, 125, .09), transparent 60%),
    var(--bg);
}
.login-box {
  width: 100%;
  max-width: 320px;
  text-align: center;
}
.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
}
.login-logo__mark {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
}
.login-logo__mark::after {
  content: '.';
  color: var(--green);
}
.login-logo__sub {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .26em;
  color: var(--muted);
}
.login-tagline {
  color: var(--muted);
  font-style: italic;
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 26px;
}
.login-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

/* ---------- 27. Grids auxiliares ---------- */
.qsplit {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.qsplit .btn { width: 100%; }

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.confirm-text {
  font-size: 15px;
  line-height: 1.55;
  margin: 0;
}

/* ---------- 28. ≥560px — form grid a 2 columnas ---------- */
@media (min-width: 560px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- 29. ≥601px — modales centrados (desktop/tablet) ---------- */
@media (min-width: 601px) {
  .modal-back {
    align-items: center;
    padding: 24px;
  }
  .modal {
    max-width: 520px;
    border-radius: var(--radius);
    border-bottom: 1px solid var(--line);
    padding-bottom: 0;
    animation: ios-pop-in .18s ease-out;
  }
  .modal::before { display: none; }
  .modal__head { padding-top: 16px; }
  .modal--wide { max-width: min(94vw, 960px); }

  /* ui.sheet sigue anclada abajo aunque el viewport crezca */
  .modal-back--sheet { align-items: flex-end; padding: 0; }
  .modal--sheet {
    max-width: 480px;
    border-radius: 18px 18px 0 0;
    border-bottom: none;
    animation: ios-sheet-up .28s cubic-bezier(.32, .72, .28, 1);
  }
}

/* ---------- 30. ≥900px — grid-2 a 2 columnas ---------- */
@media (min-width: 900px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* ---------- 31. ≥960px — desktop con sidebar ---------- */
@media (min-width: 960px) {
  .app-shell {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    align-items: start;
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    padding: 22px 14px 18px;
    border-right: 1px solid var(--line);
    background: var(--surface);
    overflow-y: auto;
  }

  .bottomnav { display: none; }

  .main { padding-bottom: 24px; }

  .screen { padding: 26px 28px 44px; }
  .screen__title { font-size: 26px; }
  .screen__sub { font-size: 13.5px; }

  .card { padding: 18px 20px; }
  .stat__value { font-size: 25px; }
  .progress-hero { padding: 22px 24px; }
  .progress-hero__value { font-size: 40px; }

  .mic-fab { right: 24px; bottom: 24px; }
  .toast { bottom: 26px; }

  /* Panel del asistente: flotante abajo-derecha */
  .assistant-panel {
    inset: auto;
    right: 24px;
    bottom: 92px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 560px;
    max-height: calc(100vh - 120px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-2);
    overflow: hidden;
    animation: ios-panel-up .22s ease-out;
  }
  .assistant__head { padding: 13px 16px 10px; }
  .assistant__input { padding: 10px 14px 12px; }
}

/* ---------- 32. Hover — solo dispositivos con puntero ---------- */
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { border-color: #37404c; background: #222933; }
  .btn--primary:hover:not(:disabled) {
    background: #23d68b;
    border-color: #23d68b;
    box-shadow: 0 4px 16px rgba(25, 195, 125, .35);
  }
  .btn--ghost:hover:not(:disabled) { background: var(--surface-2); border-color: #37404c; }
  .btn--danger:hover:not(:disabled) { background: rgba(246, 70, 93, .22); }
  .btn--yellow:hover:not(:disabled) { background: rgba(245, 185, 33, .22); }

  .sidebar__nav .nav__item:hover { background: var(--surface-2); color: var(--text); }
  .sidebar__nav .nav__item--on:hover { background: var(--green-soft); color: var(--green); }

  .list__item--btn:hover { background: var(--surface-2); }
  .table tbody tr:hover td { background: rgba(27, 32, 39, .55); }
  .seg__btn:hover:not(.seg__btn--on) { color: var(--text); }
  .modal__close:hover { background: var(--surface-2); color: var(--text); }
  .rank__item:hover { background: rgba(27, 32, 39, .4); }
  .assistant__chips .chip:hover { border-color: var(--green); background: var(--green-soft); }
  .mic-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(25, 195, 125, .5); }
  .nav__item:hover { color: var(--text); }
  .bottomnav .nav__item--on:hover,
  .sidebar__nav .nav__item--on:hover { color: var(--green); }
}

/* ---------- 33. Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- 33.5. Tooltips de gráficas (canónico, ver core.js) ---------- */
.chart-tooltip {
  position: fixed;
  display: none;
  z-index: 9999;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
  white-space: pre-line;
  max-width: 260px;
}
[data-tip] { cursor: pointer; }

/* ---------- 34. Print ---------- */
@media print {
  body { background: #fff; color: #000; }
  .sidebar, .bottomnav, .mic-fab, .assistant-panel, .toast,
  .modal-back, .decision-footer .btn, .btn { display: none !important; }
  .app-shell { display: block; }
  .main { padding: 0; }
  .screen { max-width: none; padding: 0; }
  .card, .stat, .table-wrap, .decision-footer, .progress-hero, .alert-item {
    background: #fff !important;
    border-color: #ccc !important;
    box-shadow: none !important;
    color: #000;
  }
  .screen__sub, .stat__hint, .stat__label, .empty { color: #555; }
  .stat__value--green, .chip--green { color: #0a7a4d !important; }
  .stat__value--red, .chip--red { color: #b3122c !important; }
  .stat__value--yellow, .chip--yellow { color: #8a6400 !important; }
  a { color: #000; text-decoration: underline; }
}

/* ---- Tablero de instrumentos (cockpit) ---- */
.cluster { padding: 14px 14px 12px; }
.cluster__row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}
.cluster__gauges {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex: 1 1 280px;
  max-width: 320px;
}
.gauge { text-align: center; }
.gauge svg { display: block; max-width: 200px; margin: 0 auto; }
.gauge__value {
  font-size: 19px; font-weight: 800; letter-spacing: -0.02em;
  margin-top: -26px; font-variant-numeric: tabular-nums; position: relative;
}
.gauge__label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin-top: 2px;
}
.gauge__sub { font-size: 11px; color: var(--muted); }
.lights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
  gap: 8px;
  margin-top: 14px;
}
.light {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 4px; background: var(--surface-2);
  text-align: center; cursor: pointer; color: var(--text);
  min-height: 62px; font-family: inherit;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}
.light:active { transform: scale(0.96); }
.light__icon { display: block; opacity: 0.9; }
.light__icon .icon { width: 17px; height: 17px; }
.light__label {
  display: block; font-size: 9.5px; text-transform: uppercase;
  letter-spacing: 0.06em; margin-top: 3px;
}
.light__val {
  display: block; font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums; margin-top: 1px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.light--ok { opacity: 0.42; }
.light--ok .light__val { color: var(--muted); }
.light--warn {
  border-color: var(--yellow); color: var(--yellow);
  background: var(--yellow-soft); box-shadow: 0 0 14px rgba(245, 185, 33, 0.22);
}
.light--crit {
  border-color: var(--red); color: var(--red);
  background: var(--red-soft);
  animation: light-pulse 1.7s ease-in-out infinite;
}
.light--good {
  border-color: var(--green); color: var(--green);
  background: var(--green-soft); box-shadow: 0 0 14px rgba(25, 195, 125, 0.28);
}
@keyframes light-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(246, 70, 93, 0.25); }
  50% { box-shadow: 0 0 20px rgba(246, 70, 93, 0.55); }
}
@media (hover: hover) {
  .light:hover { opacity: 1; box-shadow: 0 0 12px rgba(255, 255, 255, 0.06); }
}
@media (prefers-reduced-motion: reduce) {
  .light--crit { animation: none; box-shadow: 0 0 14px rgba(246, 70, 93, 0.4); }
}

/* ---- Tarjeta del agente de correo (propia, no enterrada en HOY) ---- */
.agent-card { border-left: 3px solid #7c9cff; }
.agent-card__head {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em;
  color: #7c9cff; margin-bottom: 6px;
}
.agent-card__head .icon { width: 16px; height: 16px; }

/* ---- Agrupación de activos por holding (Prevention at Work Group / Fissy Group / Befoqus) ---- */
.asset-group { margin-bottom: 22px; }
.asset-group__head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 8px; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.asset-group__head b { font-size: 15px; letter-spacing: -0.01em; }
