:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #101828;
  --muted: #667085;
  --muted-2: #98a2b3;
  --line: #e4e7ec;
  --line-2: #d0d5dd;
  --nav: #0b1b2e;
  --nav-2: #13283f;
  --primary: #0f62fe;
  --primary-2: #1d4ed8;
  --cyan: #06b6d4;
  --teal: #14b8a6;
  --green: #12b76a;
  --orange: #ff8a00;
  --red: #ef4444;
  --purple: #6d5dfc;
  --shadow: 0 16px 50px rgba(16, 24, 40, 0.08);
  --shadow-soft: 0 8px 24px rgba(16, 24, 40, 0.06);
  --radius: 18px;
  --radius-lg: 24px;
  --font: Inter, "Segoe UI", Roboto, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  display: block;
}

.hidden {
  display: none !important;
}

/* -------------------- COMMON -------------------- */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  background: #101828;
  color: white;
  border-radius: 14px;
  padding: 13px 16px;
  box-shadow: var(--shadow);
  font-weight: 700;
  animation: toastIn .25s ease;
}

@keyframes toastIn {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.brand-mark {
  width: 62px;
  height: 62px;
  border-radius: 16px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 5px;
  padding: 12px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 40% 20%, rgba(61, 144, 255, .6), transparent 32%),
    linear-gradient(135deg, #0f62fe, #083b8d);
  box-shadow: 0 18px 40px rgba(15, 98, 254, .35);
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, transparent 0 45%, rgba(255,255,255,.15) 45% 55%, transparent 55%),
    radial-gradient(circle at 72% 72%, rgba(20, 184, 166, .38), transparent 34%);
}

.brand-mark span {
  width: 7px;
  border-radius: 12px 12px 4px 4px;
  background: white;
  z-index: 1;
}

.brand-mark span:nth-child(1) { height: 17px; opacity: .75; }
.brand-mark span:nth-child(2) { height: 28px; opacity: .9; }
.brand-mark span:nth-child(3) { height: 38px; }
.brand-mark span:nth-child(4) { height: 24px; opacity: .8; }

.brand-mark.small {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  padding: 10px;
  gap: 4px;
}

.brand-mark.small span {
  width: 5px;
}

.field {
  display: grid;
  gap: 10px;
}

.field > span {
  font-size: 13px;
  color: #344054;
  font-weight: 800;
}

.input-wrap {
  height: 54px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line-2);
  border-radius: 13px;
  background: white;
  padding: 0 14px;
  transition: .2s ease;
}

.input-wrap:focus-within {
  border-color: rgba(15, 98, 254, .65);
  box-shadow: 0 0 0 4px rgba(15, 98, 254, .1);
}

.input-wrap svg {
  width: 21px;
  height: 21px;
  stroke: #667085;
  fill: none;
  stroke-width: 2;
}

.input-wrap input,
.field.slim input,
.search-input {
  width: 100%;
  border: 0;
  outline: none;
  color: var(--text);
  background: transparent;
}

.field.slim input,
.search-input {
  height: 43px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 0 13px;
  background: white;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  border: 0;
  background: transparent;
}

.primary-button {
  height: 46px;
  padding: 0 18px;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  font-weight: 800;
  box-shadow: 0 12px 26px rgba(15,98,254,.2);
}

.secondary-button {
  height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: white;
  color: #475467;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.secondary-button svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.ghost-button {
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #667085;
  background: white;
  font-weight: 800;
}

.icon-button.mini {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
}

.icon-button.mini svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* -------------------- LOGIN -------------------- */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(520px, 45vw) 1fr;
  background: #f8fbff;
}

.login-left {
  position: relative;
  min-height: 100vh;
  padding: 76px 7vw;
  color: white;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(5, 22, 42, .88), rgba(4, 18, 35, .96)),
    radial-gradient(circle at 26% 0%, rgba(15, 98, 254, .55), transparent 38%),
    linear-gradient(135deg, #081e36, #020b16);
}

.login-left::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .17;
  background:
    linear-gradient(120deg, transparent 0 35%, rgba(255,255,255,.18) 35% 36%, transparent 36% 100%),
    linear-gradient(40deg, transparent 0 48%, rgba(255,255,255,.15) 48% 49%, transparent 49% 100%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.08) 0 1px, transparent 1px 96px);
}

.ambient-grid {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 16%, rgba(18,183,106,.18), transparent 18%),
    radial-gradient(circle at 80% 22%, rgba(15,98,254,.28), transparent 22%),
    linear-gradient(180deg, transparent, rgba(0,0,0,.3));
  opacity: .85;
}

.login-brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 74px;
}

.login-brand h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: -.04em;
}

.login-brand p {
  margin: 5px 0 0;
  color: rgba(255,255,255,.75);
  font-size: 17px;
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(610px, 100%);
  background: rgba(255,255,255,.98);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.75);
  border-radius: 22px;
  box-shadow: 0 28px 80px rgba(0,0,0,.25);
  padding: 36px;
  display: grid;
  gap: 22px;
}

.login-card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.login-card h2 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -.035em;
}

.login-card p {
  margin: 8px 0 0;
  color: var(--muted);
}

.secure-badge {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border-radius: 10px;
  color: #027a48;
  background: #ecfdf3;
  border: 1px solid #abefc6;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.secure-badge svg,
.sso-button svg,
.login-security-note svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  font-size: 14px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #344054;
}

.checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.login-options a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 800;
}

.login-submit {
  height: 62px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  border: 0;
  border-radius: 13px;
  color: white;
  background: linear-gradient(135deg, #0f62fe, #0757e5);
  font-size: 19px;
  font-weight: 900;
  box-shadow: 0 18px 32px rgba(15,98,254,.28);
}

.login-submit svg {
  width: 25px;
  height: 25px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.divider {
  position: relative;
  text-align: center;
  color: var(--muted-2);
  font-size: 13px;
}

.divider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--line);
}

.divider span {
  position: relative;
  background: white;
  padding: 0 15px;
}

.sso-button {
  height: 58px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line-2);
  background: white;
  color: #1e3a8a;
  border-radius: 13px;
  font-weight: 900;
  font-size: 17px;
}

.demo-strip {
  margin: 4px -36px -36px;
  height: 64px;
  border: 0;
  border-radius: 0 0 22px 22px;
  border-top: 1px solid var(--line);
  background: #f8fafc;
  color: #344054;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 36px;
  font-weight: 700;
  text-align: left;
}

.demo-strip span {
  color: white;
  background: var(--primary);
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 13px;
}

.demo-strip svg {
  margin-left: auto;
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.login-security-note {
  position: relative;
  z-index: 1;
  margin-top: 38px;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  color: rgba(255,255,255,.78);
  font-size: 15px;
}

.login-preview {
  position: relative;
  min-width: 0;
  padding: 60px 6vw 42px;
  background:
    radial-gradient(circle at 76% 3%, rgba(15,98,254,.08), transparent 22%),
    linear-gradient(180deg, #fbfdff, #f5f8fc);
}

.language-pill {
  position: absolute;
  top: 54px;
  right: 6vw;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #344054;
  background: white;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 0 14px;
  font-weight: 800;
  box-shadow: var(--shadow-soft);
}

.language-pill svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.preview-content {
  max-width: 1040px;
  margin: 34px auto 0;
}

.preview-content > h2 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -.035em;
}

.preview-content > p {
  margin: 8px 0 34px;
  color: var(--muted);
  font-size: 18px;
}

.preview-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

.metric-card {
  position: relative;
  overflow: hidden;
  min-height: 142px;
  padding: 24px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.metric-card.compact {
  display: grid;
  grid-template-columns: 56px 1fr 112px;
  gap: 16px;
  align-items: center;
}

.metric-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #eff4ff;
  position: relative;
}

.metric-icon::before {
  content: "";
  width: 26px;
  height: 26px;
  display: block;
  background: currentColor;
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
}

.metric-icon.temp { color: var(--primary); background: #eef4ff; }
.metric-icon.hum { color: var(--teal); background: #e7f8f7; }
.metric-icon.signal { color: var(--primary); background: #eef4ff; }
.metric-icon.alert { color: var(--orange); background: #fff4e5; }

.metric-icon.temp::before {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10 14.5V5a2 2 0 1 1 4 0v9.5a4 4 0 1 1-4 0z' fill='%23000'/%3E%3C/svg%3E");
}
.metric-icon.hum::before {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 2s7 7.1 7 12a7 7 0 0 1-14 0c0-4.9 7-12 7-12z' fill='%23000'/%3E%3C/svg%3E");
}
.metric-icon.signal::before {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 18.5l2.5-2.5a3.5 3.5 0 0 0-5 0l2.5 2.5zM5 11.5a10 10 0 0 1 14 0l-2.2 2.2a7 7 0 0 0-9.6 0L5 11.5zM1.8 8.3a14.5 14.5 0 0 1 20.4 0L20 10.5a11.5 11.5 0 0 0-16 0L1.8 8.3z' fill='%23000'/%3E%3C/svg%3E");
}
.metric-icon.alert::before {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 2l10 18H2L12 2zm-1 6v6h2V8h-2zm0 8v2h2v-2h-2z' fill='%23000'/%3E%3C/svg%3E");
}

.metric-card span {
  color: #667085;
  font-size: 14px;
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin-top: 7px;
  font-size: 29px;
  letter-spacing: -.04em;
}

.metric-card small {
  font-size: 16px;
}

.metric-card em {
  display: block;
  margin-top: 12px;
  color: #667085;
  font-size: 13px;
  font-style: normal;
}

.green-text {
  color: var(--green) !important;
  font-weight: 900;
}

.sparkline {
  width: 100%;
  height: 45px;
}

.sparkline path {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
}

.sparkline.blue path { stroke: var(--primary); }
.sparkline.teal path { stroke: var(--cyan); }
.sparkline.green path { stroke: var(--green); }
.sparkline.orange path { stroke: var(--orange); }

.preview-panel,
.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.preview-panel {
  padding: 24px;
  margin-top: 18px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title h2,
.section-title h3 {
  margin: 0;
}

.info-dot {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid #98a2b3;
  color: #667085;
  font-weight: 900;
  font-size: 12px;
}

.preview-map {
  position: relative;
  height: 275px;
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid #d9e2ec;
  border-radius: 14px;
  background: #f8fafc;
}

.floorplan {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-controls {
  position: absolute;
  z-index: 3;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
}

.map-controls button,
.map-tools button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  background: white;
  color: #475467;
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(16,24,40,.06);
}

.floating-sensor {
  position: absolute;
  z-index: 4;
  width: 136px;
  transform: translate(-50%, -50%);
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255,255,255,.95);
  border: 1px solid #d7dee8;
  box-shadow: 0 12px 24px rgba(16,24,40,.15);
  font-size: 13px;
}

.floating-sensor::before {
  content: "";
  width: 14px;
  height: 14px;
  display: inline-block;
  border-radius: 50%;
  background: var(--green);
  margin-right: 8px;
  vertical-align: -2px;
}

.floating-sensor.caution::before {
  background: var(--orange);
}

.floating-sensor b {
  font-size: 13px;
}

.floating-sensor span {
  display: block;
  margin-top: 9px;
  color: #344054;
  font-weight: 800;
}

.chart-preview canvas,
.chart-card canvas {
  width: 100%;
  border-radius: 14px;
}

.preview-features {
  margin-top: 28px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #475467;
  font-weight: 700;
}

/* -------------------- APP LAYOUT -------------------- */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  position: sticky;
  top: 0;
  align-self: start;
  color: #d7e3f4;
  background:
    radial-gradient(circle at 26% 0%, rgba(15,98,254,.25), transparent 28%),
    linear-gradient(180deg, #0b1b2e, #081522);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  transition: width .2s ease;
  box-shadow: 12px 0 40px rgba(16,24,40,.1);
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 4px 8px 10px;
}

.side-brand h2 {
  margin: 0;
  color: white;
  font-size: 20px;
  letter-spacing: -.02em;
}

.side-brand p {
  margin: 3px 0 0;
  color: #98a2b3;
  font-size: 13px;
}

.side-menu {
  display: grid;
  gap: 8px;
}

.side-link {
  height: 54px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #c9d7ea;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  text-align: left;
  font-weight: 800;
  font-size: 15px;
  position: relative;
  transition: .18s ease;
}

.side-link:hover {
  background: rgba(255,255,255,.08);
  color: white;
}

.side-link.active {
  background: linear-gradient(135deg, #0f62fe, #1d4ed8);
  color: white;
  box-shadow: 0 12px 30px rgba(15,98,254,.3);
}

.side-link svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  flex: 0 0 auto;
}

.side-link strong {
  margin-left: auto;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #0b1b2e;
  background: #fdb022;
  font-size: 12px;
}

.system-card {
  margin-top: auto;
  padding: 20px;
  border-radius: 14px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}

.system-card h3 {
  margin: 0 0 18px;
  color: white;
  font-size: 14px;
}

.system-row,
.system-mini.with-icon {
  display: flex;
  align-items: center;
  gap: 12px;
}

.round-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #dcfae6;
  color: #079455;
  font-weight: 900;
  box-shadow: 0 0 0 5px rgba(18,183,106,.14);
}

.system-row b {
  color: #dffbea;
}

.divider-line {
  height: 1px;
  background: rgba(255,255,255,.1);
  margin: 18px 0;
}

.system-mini span {
  display: block;
  color: #cbd5e1;
  font-size: 13px;
}

.system-mini strong {
  display: block;
  color: white;
  margin-top: 3px;
  font-size: 14px;
}

.wifi-mini {
  width: 24px;
  height: 24px;
  background: var(--green);
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 18.5l2.5-2.5a3.5 3.5 0 0 0-5 0l2.5 2.5zM5 11.5a10 10 0 0 1 14 0l-2.2 2.2a7 7 0 0 0-9.6 0L5 11.5zM1.8 8.3a14.5 14.5 0 0 1 20.4 0L20 10.5a11.5 11.5 0 0 0-16 0L1.8 8.3z' fill='%23000'/%3E%3C/svg%3E") center / contain no-repeat;
}

.collapse-button {
  height: 44px;
  border: 0;
  background: transparent;
  border-top: 1px solid rgba(255,255,255,.08);
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0 0;
  font-weight: 800;
}

.collapse-button svg {
  width: 30px;
  height: 30px;
  padding: 7px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.14);
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.sidebar.collapsed {
  width: 86px;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 86px minmax(0, 1fr);
}

.sidebar.collapsed .side-brand div:not(.brand-mark),
.sidebar.collapsed .side-link span,
.sidebar.collapsed .system-card,
.sidebar.collapsed .collapse-button span {
  display: none;
}

.sidebar.collapsed .side-link {
  justify-content: center;
  padding: 0;
}

.sidebar.collapsed .side-link strong {
  position: absolute;
  right: 8px;
  top: 7px;
}

.main-content {
  min-width: 0;
  padding: 0 28px 28px;
}

.topbar {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: rgba(255,255,255,.86);
  border-bottom: 1px solid var(--line);
  margin: 0 -28px 24px;
  padding: 18px 28px;
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(16px);
}

.topbar h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -.035em;
}

.topbar p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.datetime-block {
  min-width: 155px;
  padding-right: 18px;
  border-right: 1px solid var(--line);
  text-align: right;
}

.datetime-block strong {
  display: block;
  font-size: 14px;
}

.datetime-block span {
  display: block;
  margin-top: 6px;
  font-size: 18px;
  color: #344054;
  font-variant-numeric: tabular-nums;
}

.notification-button {
  position: relative;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #475467;
  background: transparent;
}

.notification-button svg,
.user-menu button svg {
  width: 23px;
  height: 23px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
}

.notification-button span {
  position: absolute;
  right: 4px;
  top: 1px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #fdb022;
  color: #101828;
  font-size: 11px;
  font-weight: 900;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #eef2f6;
  border: 2px solid #cbd5e1;
  color: #667085;
}

.avatar svg {
  width: 31px;
  height: 31px;
  fill: currentColor;
}

.user-menu strong {
  display: block;
  font-size: 14px;
}

.user-menu span {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 3px;
  color: #475467;
  font-size: 13px;
}

.user-menu span i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.user-menu button {
  border: 0;
  background: transparent;
  color: #667085;
}

/* -------------------- DASHBOARD -------------------- */
.app-section {
  display: none;
}

.app-section.active {
  display: block;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.kpi-row .metric-card {
  min-height: 150px;
  display: grid;
  grid-template-columns: 58px 1fr 112px;
  gap: 16px;
  align-items: center;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.card {
  min-width: 0;
  padding: 18px;
}

.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-7 { grid-column: span 7; }
.span-12 { grid-column: span 12; }

.card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.card-head h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -.02em;
}

.card-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.map-tools {
  display: flex;
  gap: 8px;
}

.room-map {
  position: relative;
  height: 325px;
  overflow: hidden;
  border: 1px solid #d9e2ec;
  border-radius: 13px;
  background:
    linear-gradient(rgba(15,98,254,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15,98,254,.035) 1px, transparent 1px),
    #f8fafc;
  background-size: 30px 30px;
}

.room-map.large {
  height: min(68vh, 680px);
}

.room-map svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.sensor-marker {
  position: absolute;
  z-index: 5;
  transform: translate(-50%, -50%);
  width: 142px;
  padding: 12px 13px;
  border-radius: 10px;
  background: rgba(255,255,255,.96);
  border: 1px solid #d7dee8;
  box-shadow: 0 13px 28px rgba(16,24,40,.16);
  transition: transform .2s ease, box-shadow .2s ease;
}

.sensor-marker:hover {
  transform: translate(-50%, -52%) scale(1.03);
  box-shadow: 0 20px 38px rgba(16,24,40,.2);
}

.sensor-marker .sensor-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
  font-size: 13px;
}

.sensor-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(18,183,106,.14);
}

.sensor-marker.warning .sensor-dot {
  background: var(--orange);
  box-shadow: 0 0 0 6px rgba(255,138,0,.16);
}

.sensor-marker.critical .sensor-dot {
  background: var(--red);
  box-shadow: 0 0 0 6px rgba(239,68,68,.16);
}

.sensor-values {
  display: flex;
  justify-content: space-between;
  gap: 9px;
  margin-top: 11px;
  color: #344054;
  font-size: 13px;
  font-weight: 900;
}

.sensor-values small {
  color: var(--muted);
  font-weight: 800;
}

.sensor-summary-table,
.data-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.sensor-summary-table table,
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.sensor-summary-table th,
.sensor-summary-table td,
.data-table th,
.data-table td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.sensor-summary-table th,
.data-table th {
  background: #f8fafc;
  color: #667085;
  font-size: 12px;
  text-transform: none;
  font-weight: 900;
}

.sensor-summary-table td,
.data-table td {
  color: #101828;
  font-size: 14px;
  font-weight: 650;
}

.sensor-summary-table tr:last-child td,
.data-table tr:last-child td {
  border-bottom: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  height: 25px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.status-pill.normal {
  color: #027a48;
  background: #dcfae6;
}

.status-pill.warning {
  color: #b54708;
  background: #fff4e5;
}

.status-pill.critical {
  color: #b42318;
  background: #fee4e2;
}

.signal-bars {
  width: 28px;
  height: 22px;
  display: inline-flex;
  align-items: end;
  gap: 3px;
}

.signal-bars i {
  width: 4px;
  border-radius: 3px;
  background: var(--green);
}

.signal-bars i:nth-child(1) { height: 7px; }
.signal-bars i:nth-child(2) { height: 11px; }
.signal-bars i:nth-child(3) { height: 16px; }
.signal-bars i:nth-child(4) { height: 20px; }

.signal-bars.warning i {
  background: var(--orange);
}

.battery {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.battery-icon {
  width: 24px;
  height: 12px;
  border: 1px solid #98a2b3;
  border-radius: 3px;
  padding: 2px;
  position: relative;
}

.battery-icon::after {
  content: "";
  position: absolute;
  right: -4px;
  top: 3px;
  width: 3px;
  height: 5px;
  border-radius: 0 2px 2px 0;
  background: #98a2b3;
}

.battery-icon span {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: 2px;
}

.battery.warning .battery-icon span {
  background: var(--orange);
}

.card-foot {
  margin-top: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #667085;
  font-size: 13px;
}

.chart-card {
  min-height: 285px;
}

.chart-card.big {
  min-height: 400px;
}

.range-pills {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.range-pills span {
  min-width: 36px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #667085;
  background: white;
  font-size: 12px;
  font-weight: 900;
}

.range-pills span.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 8px 18px rgba(15,98,254,.22);
}

.insights-list {
  display: grid;
  gap: 12px;
}

.insight {
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 13px;
  display: flex;
  align-items: start;
  gap: 12px;
}

.insight.warning {
  background: #fffaf3;
  border-color: #fedf89;
}

.insight.info {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.insight.success {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.insight-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.insight.warning .insight-icon {
  color: var(--orange);
}

.insight.info .insight-icon {
  color: var(--primary);
}

.insight.success .insight-icon {
  color: var(--green);
}

.insight b {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
}

.insight span {
  color: #667085;
  font-size: 12px;
}

.insight time {
  margin-left: auto;
  color: #667085;
  font-size: 12px;
  white-space: nowrap;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.temp-warning {
  color: var(--orange) !important;
}

/* -------------------- OTHER SECTIONS -------------------- */
.wide-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(360px, .8fr);
  gap: 16px;
}

.detail-card-grid {
  display: grid;
  gap: 12px;
}

.sensor-detail {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 15px;
  display: grid;
  gap: 12px;
  background: #fbfdff;
}

.sensor-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sensor-detail h3 {
  margin: 0;
  font-size: 16px;
}

.sensor-detail p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.sensor-detail-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sensor-detail-values div {
  padding: 12px;
  border-radius: 12px;
  background: white;
  border: 1px solid var(--line);
}

.sensor-detail-values span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.sensor-detail-values strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.charts-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.charts-layout .big {
  grid-column: span 1;
}

.quick-indicators {
  display: grid;
  gap: 12px;
}

.quick-indicator {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border-radius: 13px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.quick-indicator span {
  color: var(--muted);
  font-weight: 800;
}

.quick-indicator strong {
  font-size: 18px;
}

.data-table-wrap.tall {
  max-height: calc(100vh - 240px);
}

.alerts-center {
  display: grid;
  gap: 12px;
}

.alert-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.alert-row.warning {
  border-color: #fedf89;
  background: #fffaf3;
}

.alert-row.info {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.alert-row.success {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.alert-row-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 22px;
}

.alert-row.warning .alert-row-icon { color: var(--orange); background: #fff4e5; }
.alert-row.info .alert-row-icon { color: var(--primary); background: #dbeafe; }
.alert-row.success .alert-row-icon { color: var(--green); background: #dcfae6; }

.alert-row h3 {
  margin: 0;
  font-size: 15px;
}

.alert-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.alert-row time {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.config-layout {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 16px;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.integration-list {
  display: grid;
  gap: 12px;
}

.integration-list div {
  padding: 15px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: #fbfdff;
}

.integration-list b {
  display: block;
  margin-bottom: 5px;
}

.integration-list span {
  color: var(--muted);
  font-size: 14px;
}

/* -------------------- RESPONSIVE -------------------- */
@media (max-width: 1350px) {
  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-left {
    min-height: auto;
    padding-bottom: 50px;
  }

  .login-preview {
    display: none;
  }

  .span-7,
  .span-5,
  .span-4 {
    grid-column: span 12;
  }

  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .charts-layout,
  .wide-layout,
  .config-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .app-shell,
  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    min-height: auto;
  }

  .side-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .system-card,
  .collapse-button {
    display: none;
  }

  .topbar {
    position: relative;
    flex-direction: column;
    align-items: stretch;
  }

  .top-actions {
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .datetime-block {
    text-align: left;
    border-right: 0;
  }
}

@media (max-width: 720px) {
  .login-left {
    padding: 38px 18px;
  }

  .login-brand {
    margin-bottom: 32px;
  }

  .login-brand h1 {
    font-size: 26px;
  }

  .login-card {
    padding: 24px;
  }

  .login-card-header,
  .login-options {
    flex-direction: column;
    align-items: flex-start;
  }

  .demo-strip {
    margin: 0 -24px -24px;
    padding: 0 24px;
    height: auto;
    min-height: 72px;
  }

  .main-content {
    padding: 0 14px 20px;
  }

  .topbar {
    margin: 0 -14px 16px;
    padding: 16px 14px;
  }

  .side-menu,
  .kpi-row,
  .config-grid {
    grid-template-columns: 1fr;
  }

  .kpi-row .metric-card,
  .metric-card.compact {
    grid-template-columns: 56px 1fr;
  }

  .sparkline {
    display: none;
  }

  .sensor-marker {
    width: 126px;
  }
}


/* ================================
   LOGIN SIMPLE CENTRADO
================================ */

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  background:
    radial-gradient(circle at 18% 18%, rgba(15, 98, 254, 0.22), transparent 30%),
    radial-gradient(circle at 82% 14%, rgba(18, 183, 106, 0.16), transparent 26%),
    linear-gradient(135deg, #061426 0%, #08213c 48%, #020916 100%);
}

.login-left {
  min-height: 100vh;
  width: 100%;
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.login-left::before {
  opacity: 0.12;
}

.ambient-grid {
  opacity: 0.65;
}

.login-brand {
  width: min(560px, 100%);
  margin-bottom: 34px;
  justify-content: flex-start;
}

.login-card {
  width: min(560px, 100%);
  padding: 34px;
}

.login-security-note {
  width: min(560px, 100%);
  margin-top: 28px;
  text-align: center;
}

.login-preview {
  display: none;
}

/* ================================
   DROPDOWN DE NOTIFICACIONES
================================ */

.notification-wrap {
  position: relative;
}

.notification-dropdown {
  position: absolute;
  top: calc(100% + 14px);
  right: 0;
  width: 390px;
  max-width: calc(100vw - 32px);
  background: #ffffff;
  border: 1px solid #e4e7ec;
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.18);
  z-index: 80;
  overflow: hidden;
  animation: notificationDrop 0.18s ease;
}

.notification-dropdown.hidden {
  display: none;
}

@keyframes notificationDrop {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.notification-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid #eef2f6;
  background:
    radial-gradient(circle at top right, rgba(15, 98, 254, 0.10), transparent 42%),
    #ffffff;
}

.notification-head h3 {
  margin: 0;
  font-size: 18px;
  color: #101828;
}

.notification-head p {
  margin: 4px 0 0;
  color: #667085;
  font-size: 13px;
}

.notification-head button {
  border: 0;
  background: #eff6ff;
  color: #0f62fe;
  font-weight: 800;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.notification-list {
  max-height: 360px;
  overflow-y: auto;
  padding: 8px;
}

.notification-item {
  width: 100%;
  border: 0;
  background: transparent;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 12px;
  border-radius: 16px;
  cursor: pointer;
  text-align: left;
  transition: background 0.18s ease, transform 0.18s ease;
}

.notification-item:hover {
  background: #f8fafc;
  transform: translateY(-1px);
}

.notification-item + .notification-item {
  margin-top: 4px;
}

.notification-icon {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 17px;
}

.notification-item.warning .notification-icon {
  color: #b54708;
  background: #fff4e5;
}

.notification-item.critical .notification-icon {
  color: #b42318;
  background: #fef3f2;
}

.notification-item.info .notification-icon {
  color: #175cd3;
  background: #eff8ff;
}

.notification-item.success .notification-icon {
  color: #027a48;
  background: #ecfdf3;
}

.notification-body b {
  display: block;
  color: #101828;
  font-size: 14px;
  line-height: 1.25;
}

.notification-body span {
  display: block;
  margin-top: 4px;
  color: #667085;
  font-size: 13px;
  line-height: 1.35;
}

.notification-time {
  color: #98a2b3;
  font-size: 12px;
  white-space: nowrap;
  padding-top: 2px;
}

.notification-footer {
  padding: 12px;
  border-top: 1px solid #eef2f6;
  background: #fbfcff;
}

.notification-footer button {
  width: 100%;
  border: 1px solid #dbeafe;
  background: #ffffff;
  color: #0f62fe;
  font-weight: 800;
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.notification-empty {
  padding: 28px 18px;
  text-align: center;
  color: #667085;
}

.notification-empty strong {
  display: block;
  color: #101828;
  margin-bottom: 4px;
}

#notificationBadge.hidden {
  display: none;
}

/* ================================
   AYUDA Y ZOOM DEL MAPA
================================ */

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.map-help {
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: #fef9c3;
  color: #854d0e;
  border: 1px solid #fde68a;
  font-size: 13px;
  font-weight: 900;
  cursor: help;
  line-height: 1;
}

.map-help:hover,
.map-help:focus {
  background: #facc15;
  color: #111827;
}

.map-tooltip {
  position: absolute;
  left: 50%;
  top: calc(100% + 12px);
  width: 310px;
  padding: 13px 14px;
  border-radius: 14px;
  background: #101828;
  color: #ffffff;
  font-size: 13px;
  line-height: 1.45;
  font-weight: 600;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.28);
  transform: translateX(-50%) translateY(-6px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 50;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}

.map-tooltip::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -7px;
  width: 14px;
  height: 14px;
  background: #101828;
  transform: translateX(-50%) rotate(45deg);
}

.map-help:hover .map-tooltip,
.map-help:focus .map-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.map-tools button {
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.map-tools button:hover {
  transform: translateY(-1px);
  background: #0f62fe;
  color: #ffffff;
  border-color: #0f62fe;
}

.room-map {
  overflow: hidden;
}

.room-map-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: inherit;
  transform-origin: center center;
  transition: transform 0.22s ease;
}

.room-map.is-zoomed {
  cursor: grab;
}

.room-map.is-expanded {
  position: fixed;
  inset: 24px;
  z-index: 120;
  height: auto !important;
  min-height: calc(100vh - 48px);
  background: #f8fafc;
  border-radius: 24px;
  border: 1px solid #d0d5dd;
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.35);
  padding: 18px;
}

.room-map.is-expanded .floorplan {
  height: 100%;
}

body.map-expanded {
  overflow: hidden;
}

/* ================================
   BOTÓN CERRAR MAPA EXPANDIDO
================================ */

.map-close-button {
  display: none;
}

.room-map.is-expanded .map-close-button {
  position: fixed;
  top: 38px;
  right: 42px;
  z-index: 140;
  width: 44px;
  height: 44px;
  border: 1px solid #d0d5dd;
  border-radius: 999px;
  background: #ffffff;
  color: #101828;
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.22);
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.room-map.is-expanded .map-close-button:hover {
  transform: scale(1.06);
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

.room-map.is-expanded {
  padding-top: 64px;
}

.room-map.is-expanded .room-map-stage {
  height: calc(100vh - 130px);
}

/* ================================
   AJUSTE DE TARJETAS DE GRÁFICOS
================================ */

.dashboard-grid > .chart-card.span-4 {
  grid-column: span 6;
}

.dashboard-grid > .insights-card.span-4 {
  grid-column: span 12;
}

.chart-card {
  min-height: 390px;
  display: flex;
  flex-direction: column;
}

.chart-card .card-head {
  align-items: flex-start;
  gap: 16px;
  min-height: 54px;
}

.chart-card .card-head h2 {
  max-width: 55%;
  line-height: 1.18;
}

.chart-card canvas {
  width: 100%;
  display: block;
  flex: 1;
  margin-top: 8px;
}

.range-pills {
  flex-wrap: wrap;
  justify-content: flex-end;
  row-gap: 6px;
  max-width: 45%;
}

.range-pills span {
  white-space: nowrap;
}

@media (max-width: 1300px) {
  .dashboard-grid > .chart-card.span-4,
  .dashboard-grid > .insights-card.span-4 {
    grid-column: span 12;
  }

  .chart-card .card-head h2,
  .range-pills {
    max-width: 100%;
  }

  .chart-card .card-head {
    flex-direction: column;
  }

  .range-pills {
    justify-content: flex-start;
  }
}

/* ================================
   TOOLTIP INTERACTIVO DE GRÁFICOS
================================ */

.chart-card {
  position: relative;
}

.chart-tooltip {
  position: fixed;
  min-width: 210px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(16, 24, 40, 0.96);
  color: #ffffff;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.28);
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.chart-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.chart-tooltip strong {
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
  color: #ffffff;
}

.chart-tooltip-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  line-height: 1.4;
  margin-top: 5px;
}

.chart-tooltip-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.chart-tooltip-row span:nth-child(2) {
  color: #d0d5dd;
}

.chart-tooltip-row b {
  color: #ffffff;
  font-weight: 800;
}

.range-pills span {
  cursor: pointer;
  user-select: none;
}

.range-pills span:hover {
  background: #eff6ff;
  color: #0f62fe;
  border-color: #bfdbfe;
}

/* =========================================================
   RESPONSIVE GENERAL - LoRa Room Monitor
========================================================= */

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  min-width: 320px;
}

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

.main-content,
.card,
.dashboard-grid,
.kpi-row,
.topbar,
.data-table-wrap {
  min-width: 0;
}

/* Botón menú móvil oculto en escritorio */
.mobile-menu-button {
  display: none;
}

/* Overlay móvil */
.sidebar-overlay {
  display: none;
}

/* Evita que tablas rompan el layout */
.data-table-wrap,
.sensor-summary-table {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table,
.sensor-summary-table table {
  min-width: 860px;
}

/* Grillas fluidas */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 20px;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 18px;
}

.span-4 {
  grid-column: span 4;
}

.span-5 {
  grid-column: span 5;
}

.span-7 {
  grid-column: span 7;
}

.span-12 {
  grid-column: span 12;
}

/* Gráficos más estables */
.chart-card {
  min-width: 0;
  overflow: hidden;
}

.chart-card canvas {
  width: 100%;
  max-width: 100%;
}

/* Header flexible */
.topbar {
  gap: 18px;
}

.topbar-title {
  min-width: 0;
  flex: 1;
}

.topbar-title h1,
.topbar-title p {
  overflow-wrap: anywhere;
}

.top-actions {
  min-width: 0;
  flex-wrap: wrap;
}

/* Mapa seguro */
.room-map {
  width: 100%;
  overflow: hidden;
}

.room-map-stage {
  width: 100%;
}

/* =========================================================
   LAPTOPS MEDIANOS
========================================================= */

@media (max-width: 1440px) {
  .app-shell {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .main-content {
    padding: 22px;
  }

  .kpi-row {
    grid-template-columns: repeat(2, minmax(240px, 1fr));
  }

  .dashboard-grid {
    gap: 18px;
  }

  .metric-card {
    min-height: 132px;
  }
}

/* =========================================================
   TABLET HORIZONTAL / NOTEBOOK PEQUEÑO
========================================================= */

@media (max-width: 1200px) {
  .dashboard-grid > .span-7,
  .dashboard-grid > .span-5,
  .dashboard-grid > .span-4,
  .dashboard-grid > .chart-card.span-4,
  .dashboard-grid > .insights-card.span-4 {
    grid-column: span 12;
  }

  .charts-layout,
  .wide-layout,
  .config-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .card-head {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .range-pills {
    max-width: 100%;
    justify-content: flex-start;
  }

  .chart-card .card-head h2 {
    max-width: 100%;
  }

  .room-map {
    min-height: 330px;
  }
}

/* =========================================================
   TABLET VERTICAL / MÓVIL GRANDE
========================================================= */

@media (max-width: 920px) {
  .app-shell {
    display: block;
  }

  .main-content {
    width: 100%;
    padding: 18px;
  }

  .mobile-menu-button {
    width: 44px;
    height: 44px;
    border: 1px solid #d0d5dd;
    border-radius: 14px;
    background: #ffffff;
    color: #101828;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    cursor: pointer;
  }

  .mobile-menu-button svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 60;
    margin: -18px -18px 18px;
    padding: 14px 18px;
    border-bottom: 1px solid #e4e7ec;
    background: rgba(248, 250, 252, 0.92);
    backdrop-filter: blur(14px);
    align-items: center;
  }

  .topbar-title h1 {
    font-size: 22px;
    line-height: 1.15;
  }

  .topbar-title p {
    font-size: 13px;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 292px;
    max-width: calc(100vw - 54px);
    z-index: 100;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 24px 0 70px rgba(15, 23, 42, 0.35);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: block;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(2px);
  }

  .sidebar-overlay.hidden {
    display: none;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .collapse-button {
    display: none;
  }

  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-grid > * {
    grid-column: 1 / -1 !important;
  }

  .card {
    border-radius: 20px;
  }

  .room-map {
    min-height: 320px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .room-map-stage {
    min-width: 760px;
  }

  .sensor-marker {
    transform: translate(-50%, -50%) scale(0.92);
  }

  .notification-dropdown {
    right: -8px;
    width: min(390px, calc(100vw - 36px));
  }

  .history-filter-panel {
    right: -8px;
    width: min(430px, calc(100vw - 36px));
  }
}

/* =========================================================
   MÓVIL
========================================================= */

@media (max-width: 680px) {
  .main-content {
    padding: 14px;
  }

  .topbar {
    margin: -14px -14px 16px;
    padding: 12px 14px;
    gap: 12px;
  }

  .topbar-title h1 {
    font-size: 19px;
  }

  .topbar-title p {
    display: none;
  }

  .top-actions {
    gap: 10px;
  }

  .datetime-block {
    padding: 9px 10px;
    min-width: auto;
  }

  .datetime-block strong {
    font-size: 12px;
  }

  .datetime-block span {
    font-size: 12px;
  }

  .user-menu {
    padding: 6px;
  }

  .user-menu > div {
    display: none;
  }

  .user-menu .avatar {
    margin: 0;
  }

  .notification-button {
    width: 42px;
    height: 42px;
  }

  .kpi-row {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .metric-card {
    min-height: auto;
    padding: 18px;
  }

  .metric-card .sparkline {
    display: none;
  }

  .dashboard-grid {
    gap: 14px;
  }

  .card {
    padding: 16px;
    border-radius: 18px;
  }

  .card-head {
    gap: 12px;
  }

  .card-head h2 {
    font-size: 18px;
  }

  .card-head p {
    font-size: 13px;
  }

  .table-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .secondary-button,
  .primary-button {
    min-height: 42px;
  }

  .range-pills {
    width: 100%;
    gap: 6px;
  }

  .range-pills span {
    flex: 1;
    min-width: 48px;
    text-align: center;
  }

  .chart-card {
    min-height: 360px;
  }

  .chart-card canvas {
    min-height: 260px;
  }

  .room-map {
    min-height: 300px;
  }

  .room-map-stage {
    min-width: 720px;
  }

  .map-tools {
    width: 100%;
    justify-content: flex-start;
  }

  .sensor-marker {
    transform: translate(-50%, -50%) scale(0.82);
  }

  .sensor-values {
    gap: 10px;
  }

  .detail-card-grid,
  .quick-indicators,
  .config-grid {
    grid-template-columns: 1fr;
  }

  .alerts-center,
  .insights-list {
    gap: 10px;
  }

  .alert-row,
  .insight {
    grid-template-columns: 38px 1fr;
  }

  .alert-row time,
  .insight time {
    grid-column: 2;
    justify-self: start;
  }

  .notification-dropdown,
  .history-filter-panel {
    position: fixed;
    left: 12px;
    right: 12px;
    top: 78px;
    width: auto;
    max-width: none;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .filter-grid label:first-child,
  .filter-grid label:nth-child(3) {
    grid-column: span 1;
  }

  .filter-panel-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-panel-footer > div {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .data-table,
  .sensor-summary-table table {
    min-width: 780px;
  }
}

/* =========================================================
   MÓVIL PEQUEÑO
========================================================= */

@media (max-width: 460px) {
  .main-content {
    padding: 12px;
  }

  .topbar {
    margin: -12px -12px 14px;
    padding: 10px 12px;
  }

  .mobile-menu-button,
  .notification-button {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .topbar-title h1 {
    font-size: 17px;
  }

  .datetime-block {
    display: none;
  }

  .card {
    padding: 14px;
  }

  .metric-card {
    padding: 16px;
  }

  .metric-card strong {
    font-size: 26px;
  }

  .sidebar {
    width: 280px;
  }

  .side-brand h2 {
    font-size: 18px;
  }

  .side-link {
    min-height: 46px;
  }

  .system-card {
    padding: 16px;
  }

  .room-map {
    min-height: 280px;
  }

  .room-map-stage {
    min-width: 680px;
  }

  .map-help .map-tooltip {
    left: 0;
    transform: translateX(0) translateY(-6px);
    width: 260px;
  }

  .map-help:hover .map-tooltip,
  .map-help:focus .map-tooltip {
    transform: translateX(0) translateY(0);
  }

  .notification-item {
    grid-template-columns: 36px 1fr;
  }

  .notification-time {
    grid-column: 2;
  }

  .filter-panel-head,
  .notification-head {
    padding: 16px;
  }

  .filter-grid,
  .notification-list {
    padding: 12px;
  }

  .data-table,
  .sensor-summary-table table {
    min-width: 720px;
  }
}

/* =========================================================
   MAPA EXPANDIDO RESPONSIVE
========================================================= */

@media (max-width: 920px) {
  .room-map.is-expanded {
    inset: 10px;
    min-height: calc(100vh - 20px);
    padding: 58px 12px 12px;
    overflow: auto;
  }

  .room-map.is-expanded .map-close-button {
    top: 20px;
    right: 20px;
  }

  .room-map.is-expanded .room-map-stage {
    min-width: 900px;
    height: calc(100vh - 92px);
  }
}

/* =========================================================
   LOGIN RESPONSIVE
========================================================= */

@media (max-width: 760px) {
  .login-shell {
    min-height: 100vh;
  }

  .login-left {
    padding: 32px 18px;
  }

  .login-brand {
    width: 100%;
    max-width: 520px;
    margin-bottom: 24px;
  }

  .login-brand h1 {
    font-size: 26px;
  }

  .login-brand p {
    font-size: 15px;
  }

  .login-card {
    width: 100%;
    max-width: 520px;
    padding: 26px;
    border-radius: 24px;
  }

  .login-card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .login-options {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .login-security-note {
    width: 100%;
    max-width: 520px;
    font-size: 13px;
  }
}

@media (max-width: 440px) {
  .login-left {
    padding: 24px 14px;
  }

  .login-brand {
    gap: 12px;
  }

  .brand-mark {
    width: 52px;
    height: 52px;
  }

  .login-brand h1 {
    font-size: 22px;
  }

  .login-card {
    padding: 22px;
    border-radius: 22px;
  }

  .login-card-header h2 {
    font-size: 24px;
  }

  .input-wrap {
    min-height: 48px;
  }

  .login-submit {
    min-height: 54px;
  }
}

/* =========================================================
   FIX SIDEBAR RESPONSIVE TABLET / MOBILE
   Corrige menú en 894px y pantallas similares
========================================================= */

@media (max-width: 920px) {
  .sidebar {
    width: 320px;
    max-width: min(320px, calc(100vw - 56px));
    height: 100dvh;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .side-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
    flex-shrink: 0;
  }

  .side-brand .brand-mark {
    width: 58px;
    height: 58px;
    flex: 0 0 58px;
  }

  .side-brand h2 {
    font-size: 22px;
    line-height: 1.1;
    margin: 0;
  }

  .side-brand p {
    font-size: 14px;
    margin: 4px 0 0;
  }

  .side-menu {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
    gap: 10px;
    width: 100%;
    flex-shrink: 0;
  }

  .side-link {
    width: 100%;
    min-height: 56px;
    padding: 0 16px;
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    border-radius: 14px;
    text-align: left;
  }

  .side-link svg {
    width: 23px;
    height: 23px;
    flex: 0 0 23px;
  }

  .side-link span {
    display: inline-block !important;
    font-size: 15px;
    line-height: 1.2;
    white-space: normal;
  }

  .side-link strong {
    margin-left: auto;
    min-width: 24px;
    height: 24px;
    display: inline-grid;
    place-items: center;
  }

  .system-card {
    margin-top: 28px;
    width: 100%;
    flex-shrink: 0;
  }

  .collapse-button {
    display: none !important;
  }
}

/* Ajuste especial para tablets angostas tipo 894px */
@media (min-width: 681px) and (max-width: 920px) {
  .sidebar {
    width: 340px;
    max-width: 340px;
  }

  .side-menu {
    gap: 12px;
  }

  .side-link {
    min-height: 58px;
  }
}

/* Móvil más pequeño */
@media (max-width: 520px) {
  .sidebar {
    width: 292px;
    max-width: calc(100vw - 48px);
    padding: 22px 16px;
  }

  .side-brand .brand-mark {
    width: 52px;
    height: 52px;
    flex-basis: 52px;
  }

  .side-brand h2 {
    font-size: 19px;
  }

  .side-link {
    min-height: 52px;
    padding: 0 14px;
  }

  .side-link span {
    font-size: 14px;
  }
}

/* =========================================================
   SIDEBAR FIJO EN ESCRITORIO
   El menú queda fijo y solo se mueve el contenido principal
========================================================= */

@media (min-width: 921px) {
  :root {
    --sidebar-desktop-width: 280px;
    --sidebar-collapsed-width: 92px;
  }

  .app-shell {
    display: block !important;
    min-height: 100vh;
  }

  .sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-desktop-width);
    height: 100dvh;
    z-index: 50;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .main-content {
    margin-left: var(--sidebar-desktop-width);
    width: calc(100% - var(--sidebar-desktop-width));
    min-height: 100vh;
  }

  .app-shell.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
  }

  .app-shell.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(248, 250, 252, 0.92);
    backdrop-filter: blur(14px);
  }

  .sidebar-overlay {
    display: none !important;
  }

  body.sidebar-open {
    overflow: auto;
  }
}

/* =========================================================
   FIX FINAL NOTEBOOK / ESCRITORIO NORMAL
   Optimiza pantallas entre 921px y 1700px
========================================================= */

@media (min-width: 921px) {
  :root {
    --sidebar-desktop-width: 260px;
    --sidebar-collapsed-width: 86px;
  }

  .app-shell {
    display: block !important;
    min-height: 100vh;
    background: #f3f6fb;
  }

  .sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-desktop-width) !important;
    height: 100dvh;
    z-index: 50;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .main-content {
    margin-left: var(--sidebar-desktop-width) !important;
    width: calc(100% - var(--sidebar-desktop-width)) !important;
    min-height: 100vh;
    padding: 24px 28px;
  }

  .app-shell.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width) !important;
  }

  .app-shell.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width) !important;
    width: calc(100% - var(--sidebar-collapsed-width)) !important;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    margin: -24px -28px 24px;
    padding: 22px 28px;
    background: rgba(248, 250, 252, 0.94);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid #e4e7ec;
  }
}

/* =========================================================
   NOTEBOOK: KPIS MÁS LIMPIOS
========================================================= */

@media (min-width: 921px) and (max-width: 1700px) {
  .kpi-row {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 16px;
  }

  .metric-card {
    min-height: 150px;
    padding: 22px;
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 16px;
    align-items: center;
  }

  .metric-icon {
    width: 54px;
    height: 54px;
  }

  .metric-card strong {
    font-size: 30px;
    line-height: 1.05;
  }

  .metric-card span {
    font-size: 15px;
    line-height: 1.25;
  }

  .metric-card em {
    font-size: 13px;
    line-height: 1.25;
  }

  .metric-card .sparkline {
    display: none !important;
  }
}

/* En notebooks más angostos, los KPI pasan a 2 columnas */
@media (min-width: 921px) and (max-width: 1360px) {
  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* =========================================================
   NOTEBOOK: GRILLA PRINCIPAL MÁS EQUILIBRADA
========================================================= */

@media (min-width: 921px) and (max-width: 1700px) {
  .dashboard-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
    gap: 18px;
  }

  .dashboard-grid > .map-card.span-7 {
    grid-column: span 7;
  }

  .dashboard-grid > .span-5 {
    grid-column: span 5;
  }

  .dashboard-grid > .chart-card.span-4 {
    grid-column: span 6;
  }

  .dashboard-grid > .insights-card.span-4 {
    grid-column: span 12;
  }

  .dashboard-grid > .span-12 {
    grid-column: span 12;
  }

  .card {
    padding: 22px;
    border-radius: 22px;
  }

  .card-head {
    gap: 14px;
  }

  .card-head h2 {
    font-size: 20px;
    line-height: 1.2;
  }
}

/* Cuando el notebook es angosto, mapa y resumen se apilan */
@media (min-width: 921px) and (max-width: 1380px) {
  .dashboard-grid > .map-card.span-7,
  .dashboard-grid > .span-5 {
    grid-column: span 12;
  }
}

/* =========================================================
   TABLA RESUMEN DE SENSORES: NO CORTAR EN NOTEBOOK
========================================================= */

@media (min-width: 921px) {
  .sensor-summary-table {
    overflow-x: auto;
  }

  .sensor-summary-table table {
    width: 100%;
    min-width: 620px !important;
    table-layout: auto;
  }

  .sensor-summary-table th,
  .sensor-summary-table td {
    padding: 13px 12px;
    font-size: 13px;
    white-space: nowrap;
  }

  .sensor-summary-table th:nth-child(1),
  .sensor-summary-table td:nth-child(1) {
    width: 70px;
  }

  .sensor-summary-table th:nth-child(2),
  .sensor-summary-table td:nth-child(2) {
    width: 110px;
  }

  .sensor-summary-table th:nth-child(3),
  .sensor-summary-table td:nth-child(3),
  .sensor-summary-table th:nth-child(4),
  .sensor-summary-table td:nth-child(4) {
    width: 95px;
  }
}

/* =========================================================
   MAPA EN NOTEBOOK
========================================================= */

@media (min-width: 921px) and (max-width: 1700px) {
  .room-map {
    min-height: 360px;
  }

  .room-map-stage {
    min-width: 0;
  }

  .sensor-marker {
    transform: translate(-50%, -50%) scale(0.92);
  }

  .sensor-title {
    font-size: 13px;
  }

  .sensor-values {
    gap: 12px;
  }

  .sensor-values span {
    font-size: 13px;
  }
}

/* =========================================================
   GRÁFICOS EN NOTEBOOK
========================================================= */

@media (min-width: 921px) and (max-width: 1700px) {
  .chart-card {
    min-height: 390px;
  }

  .chart-card canvas {
    min-height: 280px;
  }

  .chart-card .card-head {
    align-items: flex-start;
  }

  .range-pills {
    flex-wrap: wrap;
    gap: 6px;
  }

  .range-pills span {
    min-width: 42px;
    text-align: center;
  }
}

/* =========================================================
   SIDEBAR MÁS COMPACTO EN NOTEBOOK
========================================================= */

@media (min-width: 921px) and (max-width: 1700px) {
  .sidebar {
    padding: 24px 18px;
  }

  .side-brand {
    gap: 14px;
    margin-bottom: 30px;
  }

  .side-brand .brand-mark {
    width: 58px;
    height: 58px;
  }

  .side-brand h2 {
    font-size: 22px;
  }

  .side-brand p {
    font-size: 14px;
  }

  .side-menu {
    gap: 10px;
  }

  .side-link {
    min-height: 56px;
    padding: 0 16px;
    border-radius: 14px;
  }

  .side-link svg {
    width: 23px;
    height: 23px;
  }

  .side-link span {
    font-size: 15px;
  }

  .system-card {
    margin-top: 28px;
    padding: 18px;
  }

  .collapse-button {
    min-height: 48px;
  }
}

/* =========================================================
   FIX DEFINITIVO NOTEBOOK / PANTALLA NORMAL
   Pensado para notebooks entre 921px y 1800px
========================================================= */

@media (min-width: 921px) and (max-width: 1800px) {
  :root {
    --sidebar-desktop-width: 240px;
    --sidebar-collapsed-width: 82px;
  }

  body {
    background: #f3f6fb;
  }

  .app-shell {
    display: block !important;
    min-height: 100vh;
    background: #f3f6fb;
  }

  .sidebar {
    position: fixed !important;
    inset: 0 auto 0 0;
    width: var(--sidebar-desktop-width) !important;
    height: 100dvh !important;
    padding: 22px 16px !important;
    z-index: 50;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
  }

  .sidebar::-webkit-scrollbar {
    display: none;
  }

  .main-content {
    margin-left: var(--sidebar-desktop-width) !important;
    width: calc(100% - var(--sidebar-desktop-width)) !important;
    min-height: 100vh;
    padding: 20px 24px !important;
  }

  .app-shell.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width) !important;
  }

  .app-shell.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width) !important;
    width: calc(100% - var(--sidebar-collapsed-width)) !important;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    margin: -20px -24px 22px !important;
    padding: 20px 24px !important;
    background: rgba(248, 250, 252, 0.96);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid #e4e7ec;
  }

  .topbar-title h1 {
    font-size: 28px !important;
    line-height: 1.15;
  }

  .topbar-title p {
    font-size: 15px !important;
  }

  .top-actions {
    gap: 14px !important;
  }

  .datetime-block {
    padding: 0 16px !important;
  }

  .datetime-block strong {
    font-size: 14px !important;
  }

  .datetime-block span {
    font-size: 22px !important;
  }

  .side-brand {
    margin-bottom: 30px !important;
    gap: 12px !important;
  }

  .side-brand .brand-mark {
    width: 54px !important;
    height: 54px !important;
    flex: 0 0 54px;
  }

  .side-brand h2 {
    font-size: 21px !important;
  }

  .side-brand p {
    font-size: 14px !important;
  }

  .side-menu {
    gap: 10px !important;
  }

  .side-link {
    min-height: 54px !important;
    padding: 0 14px !important;
    border-radius: 14px !important;
    gap: 12px !important;
  }

  .side-link svg {
    width: 22px !important;
    height: 22px !important;
  }

  .side-link span {
    font-size: 15px !important;
  }

  .system-card {
    margin-top: 28px !important;
    padding: 17px !important;
  }

  .system-card h3 {
    font-size: 15px !important;
  }

  .collapse-button {
    min-height: 46px !important;
  }
}

/* =========================================================
   KPIS EN NOTEBOOK: 2x2 PARA QUE NO SE APRIETEN
========================================================= */

@media (min-width: 921px) and (max-width: 1800px) {
  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 16px !important;
    margin-bottom: 18px !important;
  }

  .metric-card {
    min-height: 118px !important;
    padding: 20px 22px !important;
    display: grid !important;
    grid-template-columns: 56px minmax(0, 1fr) 120px !important;
    align-items: center !important;
    gap: 18px !important;
  }

  .metric-icon {
    width: 56px !important;
    height: 56px !important;
  }

  .metric-card span {
    font-size: 15px !important;
    line-height: 1.2 !important;
  }

  .metric-card strong {
    font-size: 30px !important;
    line-height: 1.05 !important;
    white-space: nowrap !important;
  }

  .metric-card em {
    font-size: 13px !important;
    line-height: 1.25 !important;
  }

  .metric-card .sparkline {
    display: block !important;
    width: 110px !important;
    height: 42px !important;
    justify-self: end !important;
  }
}

/* =========================================================
   CONTENIDO PRINCIPAL: MAPA Y RESUMEN APILADOS
   Evita que la tabla se corte en notebooks
========================================================= */

@media (min-width: 921px) and (max-width: 1800px) {
  .dashboard-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
    gap: 18px !important;
  }

  .dashboard-grid > .map-card.span-7,
  .dashboard-grid > .span-5 {
    grid-column: span 12 !important;
  }

  .dashboard-grid > .chart-card.span-4 {
    grid-column: span 6 !important;
  }

  .dashboard-grid > .insights-card.span-4 {
    grid-column: span 12 !important;
  }

  .dashboard-grid > .span-12 {
    grid-column: span 12 !important;
  }

  .card {
    padding: 20px !important;
    border-radius: 22px !important;
  }

  .card-head {
    gap: 14px !important;
  }

  .card-head h2 {
    font-size: 20px !important;
    line-height: 1.2 !important;
  }

  .card-head p {
    font-size: 14px !important;
  }
}

/* =========================================================
   MAPA MÁS PROPORCIONADO EN NOTEBOOK
========================================================= */

@media (min-width: 921px) and (max-width: 1800px) {
  .room-map {
    min-height: 390px !important;
    max-height: 460px;
    overflow: hidden !important;
  }

  .room-map-stage {
    min-width: 0 !important;
    width: 100% !important;
    height: 100% !important;
  }

  .floorplan {
    height: 100% !important;
  }

  .sensor-marker {
    transform: translate(-50%, -50%) scale(0.9) !important;
  }

  .sensor-title {
    font-size: 13px !important;
  }

  .sensor-values span {
    font-size: 13px !important;
  }
}

/* =========================================================
   RESUMEN DE SENSORES SIN CORTE
========================================================= */

@media (min-width: 921px) and (max-width: 1800px) {
  .sensor-summary-table {
    overflow-x: visible !important;
  }

  .sensor-summary-table table {
    width: 100% !important;
    min-width: 0 !important;
    table-layout: fixed !important;
  }

  .sensor-summary-table th,
  .sensor-summary-table td {
    padding: 14px 12px !important;
    font-size: 14px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .sensor-summary-table th:nth-child(1),
  .sensor-summary-table td:nth-child(1) {
    width: 11%;
  }

  .sensor-summary-table th:nth-child(2),
  .sensor-summary-table td:nth-child(2) {
    width: 18%;
  }

  .sensor-summary-table th:nth-child(3),
  .sensor-summary-table td:nth-child(3) {
    width: 15%;
  }

  .sensor-summary-table th:nth-child(4),
  .sensor-summary-table td:nth-child(4) {
    width: 15%;
  }

  .sensor-summary-table th:nth-child(5),
  .sensor-summary-table td:nth-child(5) {
    width: 20%;
  }

  .sensor-summary-table th:nth-child(6),
  .sensor-summary-table td:nth-child(6) {
    width: 21%;
  }

  .status-pill {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* =========================================================
   GRÁFICOS EN NOTEBOOK
========================================================= */

@media (min-width: 921px) and (max-width: 1800px) {
  .chart-card {
    min-height: 380px !important;
  }

  .chart-card canvas {
    min-height: 280px !important;
  }

  .chart-card .card-head {
    align-items: flex-start !important;
    flex-wrap: wrap !important;
  }

  .chart-card .card-head h2 {
    max-width: 100% !important;
  }

  .range-pills {
    max-width: 100% !important;
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
    gap: 6px !important;
  }

  .range-pills span {
    min-width: 44px !important;
    text-align: center !important;
  }
}

/* =========================================================
   NOTEBOOK ANGOSTO: TODO EN UNA COLUMNA
========================================================= */

@media (min-width: 921px) and (max-width: 1250px) {
  .kpi-row {
    grid-template-columns: 1fr !important;
  }

  .metric-card {
    grid-template-columns: 56px minmax(0, 1fr) !important;
  }

  .metric-card .sparkline {
    display: none !important;
  }

  .dashboard-grid > .chart-card.span-4 {
    grid-column: span 12 !important;
  }

  .topbar {
    flex-wrap: wrap !important;
  }

  .top-actions {
    width: 100% !important;
    justify-content: flex-start !important;
  }
}

/* =========================================================
   FIX DEFINITIVO LOGIN / DASHBOARD
   Nunca mostrar sidebar ni contenido cuando está el login
========================================================= */

.hidden {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

body.login-mode #appView,
body.login-mode #sidebar,
body.login-mode .main-content,
body.login-mode #sidebarOverlay {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

body.login-mode #loginView {
  display: grid !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

body.app-mode #loginView {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

body.app-mode #appView {
  display: block !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

/* =========================================================
   LOGO STEEN-HANSEN
   Se reemplazó la marca demo por el logo entregado.
========================================================= */
.brand-logo {
  display: block;
  height: auto;
  object-fit: contain;
  user-select: none;
}

.brand-logo-login {
  width: min(285px, 100%);
  max-height: 72px;
  filter: drop-shadow(0 18px 34px rgba(0, 0, 0, .26));
}

.login-brand {
  display: grid;
  align-items: start;
  gap: 16px;
}

.login-brand-copy {
  display: grid;
  gap: 3px;
}

.side-brand {
  align-items: flex-start;
  flex-direction: column;
  gap: 10px;
  padding: 4px 8px 14px;
}

.side-brand-logo-wrap {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
}

.side-brand-logo-full {
  width: min(188px, 100%);
  max-height: 52px;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, .18));
}

.side-brand-logo-icon {
  display: none;
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, .18));
}

.side-brand-copy h2 {
  font-size: 18px;
}

.sidebar.collapsed .side-brand {
  align-items: center;
  padding-inline: 0;
}

.sidebar.collapsed .side-brand-copy,
.sidebar.collapsed .side-brand-logo-full {
  display: none !important;
}

.sidebar.collapsed .side-brand-logo-wrap {
  justify-content: center;
}

.sidebar.collapsed .side-brand-logo-icon {
  display: block !important;
}

@media (max-width: 920px) {
  .side-brand {
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }

  .side-brand-logo-wrap {
    width: auto;
    min-height: auto;
    flex: 0 0 auto;
  }

  .side-brand-logo-full {
    width: 168px;
  }

  .side-brand-copy {
    min-width: 0;
  }
}

@media (max-width: 520px) {
  .brand-logo-login {
    width: 235px;
  }

  .login-brand {
    gap: 12px;
  }

  .side-brand-logo-full {
    width: 144px;
  }
}



/* =========================================================
   AJUSTE DEMO STEEN-HANSEN - PLANO SALA SECADO PINTURA DE REDES
========================================================= */
.room-map {
  background:
    linear-gradient(rgba(15, 23, 42, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, .035) 1px, transparent 1px),
    radial-gradient(circle at 72% 26%, rgba(255, 112, 67, .11), transparent 28%),
    #f8fafc;
}

.floorplan text {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  pointer-events: none;
}

.sensor-marker {
  border-color: rgba(226, 232, 240, .95);
}

.sensor-marker .sensor-title {
  line-height: 1.15;
}

@media (max-width: 820px) {
  .sensor-marker {
    width: 122px;
    padding: 10px 11px;
  }
}

/* -------------------- FILTROS DE HISTÓRICO -------------------- */
.history-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 18px 26px;
  padding: 16px 4px 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
.history-filters .filter-group {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}
.history-filters label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.history-filters .filter-check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.history-filters .filter-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}
.filter-input {
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  background: var(--panel);
}
.filter-input.small {
  width: 74px;
}
.filter-range {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted-2);
  font-size: 13px;
}
.filter-range.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}
.filter-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
