:root {
  --detec-950: #0b1a13;
  --detec-900: #10251c;
  --detec-800: #173b2a;
  --detec-600: #168a55;
  --detec-500: #22a768;
  --detec-100: #e7f7ef;
  --ink: #18211d;
  --muted: #6b7470;
  --surface: #f3f6f4;
  --line: #dde5e0;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--surface);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 78% 16%, rgba(45, 189, 115, .25), transparent 28rem),
    linear-gradient(145deg, var(--detec-950), #1b3328);
}

.login-panel {
  width: min(100%, 430px);
  padding: 2.6rem;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 1.4rem;
  color: #fff;
  background: rgba(11, 26, 19, .74);
  box-shadow: 0 2rem 5rem rgba(0, 0, 0, .3);
  backdrop-filter: blur(14px);
}

.login-panel p { color: rgba(255, 255, 255, .68); }
.login-panel .form-control { border-color: rgba(255, 255, 255, .17); background: rgba(255, 255, 255, .08); color: #fff; }
.login-panel .form-control:focus { border-color: #64dd9f; box-shadow: 0 0 0 .25rem rgba(100, 221, 159, .14); }

.login-brand { display: flex; align-items: center; gap: 1rem; margin-bottom: 2rem; }
.login-brand img { width: 180px; height: auto; filter: invert(1) grayscale(1) brightness(1.7); }
.login-brand span { color: #64dd9f; font-size: 1.55rem; font-weight: 800; letter-spacing: .08em; }
.sidebar-logo { width: 118px; height: auto; filter: invert(1) grayscale(1) brightness(1.7); }
.eyebrow { color: var(--detec-500); font-size: .72rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.btn-detec { border-color: #64dd9f; background: #64dd9f; color: var(--detec-950); font-weight: 750; }
.btn-detec:hover { border-color: #7ae7ae; background: #7ae7ae; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar {
  width: 252px;
  min-height: 100vh;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  padding: 1.2rem;
  color: #fff;
  background: var(--detec-950);
}

.sidebar-brand { display: flex; align-items: center; gap: .8rem; padding: .4rem .35rem 1.8rem; }
.sidebar-brand strong { display: block; font-size: 1.02rem; }
.sidebar-brand small { display: block; color: rgba(255,255,255,.46); font-size: .7rem; }
.sidebar nav { display: grid; gap: .35rem; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .78rem .9rem;
  border-radius: .75rem;
  color: rgba(255,255,255,.58);
  text-decoration: none;
  font-weight: 650;
}
.sidebar nav a:hover, .sidebar nav a.active { color: #fff; background: rgba(255,255,255,.09); }
.sidebar-footer { margin-top: auto; padding: 1rem .55rem .35rem; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-footer span, .sidebar-footer small { display: block; }
.sidebar-footer small { color: rgba(255,255,255,.47); text-transform: capitalize; }

.main-content { width: calc(100% - 252px); margin-left: 252px; padding: 1.5rem 2rem 3rem; }
.topbar { min-height: 72px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.4rem; }
.topbar h2 { margin: .1rem 0 0; font-size: 1.6rem; font-weight: 780; letter-spacing: -.03em; }
.controller-status { display: inline-flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .85rem; font-weight: 650; }
.controller-status span { width: .52rem; height: .52rem; border-radius: 50%; background: var(--detec-500); box-shadow: 0 0 0 .25rem rgba(34,167,104,.14); }

.page { display: none; }
.page.active { display: block; }
.hero-card {
  display: flex;
  justify-content: space-between;
  align-items: end;
  min-height: 190px;
  padding: 2rem;
  margin-bottom: 1.2rem;
  border-radius: 1.25rem;
  color: #fff;
  background:
    radial-gradient(circle at 88% 10%, rgba(100,221,159,.25), transparent 16rem),
    linear-gradient(135deg, var(--detec-900), var(--detec-800));
  box-shadow: 0 1.2rem 3rem rgba(16,37,28,.16);
}
.hero-card h3 { margin: .35rem 0; font-size: 1.8rem; font-weight: 780; letter-spacing: -.03em; }
.hero-card p { margin: 0; color: rgba(255,255,255,.62); }
.hero-kicker { color: #64dd9f; font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.hero-time { color: rgba(255,255,255,.52); font-size: .8rem; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.alerts-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 108px;
  padding: 1.15rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 .4rem 1.2rem rgba(30,49,40,.045);
}
.metric-card span { display: block; color: var(--muted); font-size: .78rem; }
.metric-card strong { display: block; font-size: 1.75rem; letter-spacing: -.04em; }
.metric-icon { width: 2.8rem; height: 2.8rem; display: grid; place-items: center; border-radius: .85rem; font-size: 1.15rem; }
.metric-icon.blue { color: #1d63d9; background: #e9f1ff; }
.metric-icon.green { color: #11824d; background: var(--detec-100); }
.metric-icon.red { color: #c63b3b; background: #fcecec; }
.metric-icon.amber { color: #9b6900; background: #fff5d9; }

.panel { overflow: hidden; border: 1px solid var(--line); border-radius: 1rem; background: #fff; box-shadow: 0 .5rem 1.5rem rgba(30,49,40,.04); }
.panel-heading { display: flex; justify-content: space-between; align-items: center; padding: 1.2rem 1.35rem; border-bottom: 1px solid var(--line); }
.panel-heading h4 { margin: 0; font-size: 1.02rem; font-weight: 760; }
.panel-heading p { margin: .2rem 0 0; color: var(--muted); font-size: .78rem; }
.attention-list { display: grid; }
.attention-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.35rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  background: #fff;
}
.attention-item:last-child { border-bottom: 0; }
.attention-item:hover { background: #fafcfb; }
.attention-item strong, .attention-item small { display: block; }
.attention-item small { color: var(--muted); }
.attention-icon { width: 2.4rem; height: 2.4rem; display: grid; place-items: center; border-radius: .7rem; color: #c63b3b; background: #fcecec; }

.status-pill, .variant-pill, .operation-pill, .severity-pill {
  display: inline-flex;
  align-items: center;
  gap: .38rem;
  padding: .33rem .58rem;
  border-radius: 999px;
  white-space: nowrap;
  font-size: .72rem;
  font-weight: 750;
}
.status-pill span { width: .42rem; height: .42rem; border-radius: 50%; }
.status-pill.online { color: #0c7342; background: var(--detec-100); }
.status-pill.online span { background: var(--detec-500); }
.status-pill.offline { color: #af3030; background: #fcecec; }
.status-pill.offline span { background: #dc4c4c; }
.variant-4g { color: #7a5900; background: #fff2c7; }
.variant-5g { color: #1558b8; background: #e7f0ff; }
.variant-unknown { color: #606763; background: #edf0ee; }
.operation-pill span { width: .45rem; height: .45rem; border-radius: 50%; }
.operation-pill.green { color: #0c7342; background: var(--detec-100); }
.operation-pill.green span { background: var(--detec-500); }
.operation-pill.yellow { color: #845900; background: #fff1c5; }
.operation-pill.yellow span { background: #e6a700; }
.operation-pill.red { color: #a62929; background: #fce4e4; }
.operation-pill.red span { background: #dc4c4c; }
.operation-pill.unknown { color: #606763; background: #edf0ee; }
.operation-pill.unknown span { background: #8a928e; }
.device-actions { display: inline-flex; align-items: center; gap: .35rem; }
.action-icon { width: 2rem; height: 2rem; display: inline-grid; place-items: center; padding: 0; }
.device-actions .dropdown-item { font-size: .82rem; }
.role-pill { display: inline-flex; padding: .3rem .58rem; border-radius: 999px; font-size: .72rem; font-weight: 750; }
.role-pill.superadmin { color: #6b32a8; background: #f1e8fb; }
.role-pill.admin { color: #1558b8; background: #e7f0ff; }
.role-pill.reportes { color: #52605a; background: #edf0ee; }
.role-help { margin-top: .85rem; padding: .8rem; border-radius: .7rem; color: var(--muted); background: #f5f7f6; font-size: .76rem; }
.severity-pill { text-transform: capitalize; }
.severity-pill.critical { color: #a62929; background: #fce4e4; }
.severity-pill.warning { color: #845900; background: #fff1c5; }
.severity-pill.info { color: #1558b8; background: #e7f0ff; }

.search-box { min-width: 300px; display: flex; align-items: center; gap: .6rem; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: .7rem; color: var(--muted); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; }
.device-table th, .panel table th { padding: .8rem 1rem; color: var(--muted); background: #f8faf9; font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; }
.device-table td, .panel table td { padding: .85rem 1rem; border-color: var(--line); font-size: .82rem; }
.device-table td strong, .panel table td strong, .panel table td small { display: block; }
.device-table td small { display: block; color: var(--muted); }
.firmware-cell { max-width: 245px; color: var(--muted) !important; }
code { color: #365149; }

.empty-state, .loading-row { padding: 2.8rem !important; color: var(--muted); text-align: center; }
div.empty-state { display: flex; flex-direction: column; align-items: center; gap: .3rem; }
div.empty-state i { font-size: 1.5rem; }
.device-modal-header { color: #fff; background: var(--detec-900); }
.loading-detail, .empty-telemetry { min-height: 280px; display: grid; place-items: center; align-content: center; gap: .6rem; color: var(--muted); text-align: center; }
.empty-telemetry i { font-size: 2rem; }
.empty-telemetry h5, .empty-telemetry p { margin: 0; }
.telemetry-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.telemetry-grid.cellular { grid-template-columns: repeat(8, minmax(0, 1fr)); margin-bottom: 0; }
.telemetry-metric { min-width: 0; display: grid; gap: .25rem; padding: .8rem; border: 1px solid var(--line); border-radius: .8rem; background: #fff; }
.telemetry-metric > i { color: var(--detec-500); }
.telemetry-metric span { color: var(--muted); font-size: .68rem; }
.telemetry-metric strong { overflow-wrap: anywhere; font-size: .9rem; }
.telemetry-metric.success { background: var(--detec-100); border-color: #bde8d1; }
.telemetry-section { padding: 1rem; margin-bottom: 1rem; border: 1px solid var(--line); border-radius: .9rem; }
.telemetry-section h5 { margin: 0 0 .8rem; font-size: 1rem; }
.telemetry-section h5 i { margin-right: .4rem; color: var(--detec-500); }
.telemetry-time { margin-top: .75rem; color: var(--muted); font-size: .72rem; }

@media (max-width: 1100px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .telemetry-grid, .telemetry-grid.cellular { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .sidebar { width: 76px; padding: .8rem; }
  .sidebar-brand > div:last-child, .sidebar nav a:not(.active) span, .sidebar nav a { font-size: 0; }
  .sidebar nav a { justify-content: center; padding: .9rem; }
  .sidebar nav a i { font-size: 1.05rem; }
  .sidebar-footer span, .sidebar-footer small { display: none; }
  .main-content { width: calc(100% - 76px); margin-left: 76px; padding: 1rem; }
  .topbar { align-items: flex-start; }
  .controller-status { display: none; }
  .hero-card { min-height: 210px; align-items: flex-start; flex-direction: column; }
  .metrics-grid, .alerts-metrics { grid-template-columns: 1fr; }
  .search-box { min-width: 100%; }
  .telemetry-grid, .telemetry-grid.cellular { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
