:root{
  --bg:#07101d;
  --panel:#0d1828;
  --panel2:#111f32;
  --text:#eef5ff;
  --muted:#8ea2bd;
  --line:#20314a;
  --accent:#2d7df6;
  --accent2:#66a5ff;
  --green:#21c58b;
  --red:#f45d68;
  --shadow:0 18px 55px rgba(0,0,0,.25);
}

*{
  box-sizing:border-box;
}

body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font:14px/1.45 Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,sans-serif;
}

.hidden{
  display:none!important;
}

button,
input,
select{
  font:inherit;
}

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

.login-shell{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:28px 16px;
  background:
    radial-gradient(
      circle at 62% 8%,
      rgba(34,83,139,.72) 0,
      rgba(21,51,88,.35) 24%,
      transparent 44%
    ),
    linear-gradient(
      135deg,
      #08121f 0%,
      #050b13 58%,
      #06101c 100%
    );
}

.login-card{
  width:min(448px,92vw);
  padding:42px 42px 30px;
  border:1px solid #213956;
  border-radius:24px;
  background:
    linear-gradient(
      180deg,
      rgba(14,27,45,.96),
      rgba(10,22,37,.95)
    );
  box-shadow:
    0 30px 80px rgba(0,0,0,.36),
    0 0 0 1px rgba(72,132,205,.04) inset;
  backdrop-filter:blur(16px);
}

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

.brand-mark{
  display:grid;
  place-items:center;
  width:38px;
  height:38px;
  border-radius:12px;
  background:linear-gradient(135deg,var(--accent),#59a2ff);
  font-weight:900;
  font-size:21px;
}

.brand div{
  display:flex;
  flex-direction:column;
}

.brand strong{
  font-size:18px;
}

.brand small{
  color:var(--muted);
}

.login-brand{
  min-height:64px;
  width:100%;
  display:flex;
  justify-content:center;
  align-items:center;
}

.brand-logo{
  display:block;
  width:auto;
  max-width:100%;
}

.login-logo{
  height:64px;
  max-width:230px;
  width:auto;
  display:block;
  margin:0 auto;
}

.sidebar-logo{
  height:34px;
  max-width:180px;
}

.login-copy{
  margin-top:28px;
}

.login-card h1{
  margin:0 0 8px;
  font-size:30px;
  line-height:1.15;
  letter-spacing:-.025em;
}

.login-card>p,
.login-copy p{
  color:#95a9c4;
  margin:0 0 28px;
  font-size:13px;
  line-height:1.55;
  max-width:330px;
}

.login-card form{
  display:grid;
  gap:17px;
}

.login-card label{
  display:grid;
  gap:8px;
  color:#c4d0df;
  font-size:12px;
  font-weight:650;
}

.input-shell{
  position:relative;
  display:flex;
  align-items:center;
}

.input-shell input{
  width:100%;
  height:48px;
  padding:11px 46px 11px 43px;
  background:#081522;
  color:var(--text);
  border:1px solid #233751;
  border-radius:12px;
  outline:none;
  transition:
    border-color .18s ease,
    box-shadow .18s ease,
    background .18s ease;
}

.input-shell input::placeholder{
  color:#60758f;
}

.input-shell:focus-within input{
  border-color:#3b86f4;
  background:#091827;
  box-shadow:0 0 0 3px rgba(45,125,246,.12);
}

.field-icon{
  position:absolute;
  left:14px;
  top:50%;
  transform:translateY(-50%);
  width:17px;
  height:17px;
  color:#7087a3;
  z-index:2;
  pointer-events:none;
}

.field-icon svg,
.password-toggle svg{
  width:100%;
  height:100%;
  fill:none;
  stroke:currentColor;
  stroke-width:1.8;
  stroke-linecap:round;
  stroke-linejoin:round;
}

.password-toggle{
  position:absolute;
  right:7px;
  top:50%;
  transform:translateY(-50%);
  display:grid;
  place-items:center;
  width:35px;
  height:35px;
  padding:9px;
  background:transparent;
  color:#7188a3;
  border-radius:9px;
  border:0;
  cursor:pointer;
}

.password-toggle:hover{
  background:#12233a;
  color:#b9cbe2;
}

.login-submit{
  height:49px;
  margin-top:2px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  border:0;
  border-radius:12px;
  background:linear-gradient(135deg,#2d7df6,#388cfb);
  color:white;
  cursor:pointer;
  font-weight:750;
  box-shadow:0 9px 25px rgba(45,125,246,.22);
  transition:
    transform .16s ease,
    box-shadow .16s ease,
    filter .16s ease;
}

.login-submit:hover{
  transform:translateY(-1px);
  box-shadow:0 13px 30px rgba(45,125,246,.3);
  filter:brightness(1.04);
}

.login-submit:active{
  transform:translateY(0);
}

.login-submit:disabled{
  opacity:.65;
  cursor:not-allowed;
  transform:none;
}

.login-arrow{
  font-size:18px;
  line-height:1;
  transition:transform .16s ease;
}

.login-submit:hover .login-arrow{
  transform:translateX(2px);
}

.login-error{
  padding:10px 12px;
  border:1px solid rgba(244,93,104,.42);
  border-radius:10px;
  background:rgba(244,93,104,.08);
  color:#ffb9bf;
  font-size:12px;
}

.login-footer{
  margin-top:22px;
  padding-top:18px;
  border-top:1px solid rgba(40,61,88,.66);
  color:#637995;
  text-align:center;
  font-size:11px;
}

.login-help{
  display:none;
}

/* =========================================
   CAMPOS GENERALES
========================================= */

label{
  display:grid;
  gap:7px;
  color:#b5c4d8;
  font-size:12px;
  font-weight:650;
}

input,
select{
  background:#081321;
  color:var(--text);
  border:1px solid var(--line);
  border-radius:11px;
  padding:11px 12px;
  outline:none;
}

input:focus,
select:focus{
  border-color:var(--accent);
}

button{
  border:0;
  border-radius:11px;
  padding:11px 15px;
  cursor:pointer;
  font-weight:750;
}

.primary{
  background:var(--accent);
  color:white;
}

.secondary{
  background:#172841;
  color:#ddebff;
  border:1px solid #2b4161;
}

.danger{
  background:#3b1920;
  color:#ffb9bf;
  border:1px solid #682a34;
}

/* =========================================
   APLICACIÓN
========================================= */

.app{
  min-height:100vh;
}

.sidebar{
  position:fixed;
  inset:0 auto 0 0;
  width:238px;
  background:#091423;
  border-right:1px solid #18283d;
  padding:22px 16px;
  display:flex;
  flex-direction:column;
  z-index:4;
}

.brand-side{
  padding:2px 8px 24px;
}

.sidebar nav{
  display:grid;
  gap:6px;
}

.nav{
  display:flex;
  align-items:center;
  gap:13px;
  width:100%;
  text-align:left;
  background:transparent;
  color:#9fb1c9;
  padding:12px 13px;
}

.nav.active,
.nav:hover{
  color:white;
  background:#12223a;
}

.sidebar-bottom{
  margin-top:auto;
}

.badges{
  display:grid;
  gap:7px;
  padding:12px;
}

.badge{
  display:flex;
  justify-content:space-between;
  color:var(--muted);
  font-size:11px;
}

.dot{
  width:8px;
  height:8px;
  border-radius:50%;
  display:inline-block;
  background:#4c5b70;
}

.dot.on{
  background:var(--green);
}

.main{
  margin-left:238px;
  min-height:100vh;
  background:linear-gradient(180deg,#081322,#07101d 300px);
}

.topbar{
  height:90px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:0 32px;
  border-bottom:1px solid #15253a;
  background:rgba(7,16,29,.76);
  position:sticky;
  top:0;
  z-index:3;
  backdrop-filter:blur(12px);
}

.topbar h2{
  margin:0;
  font-size:21px;
}

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

.user-chip{
  display:flex;
  gap:10px;
  align-items:center;
}

.user-chip>span{
  width:36px;
  height:36px;
  display:grid;
  place-items:center;
  border-radius:50%;
  background:#19365e;
}

.user-chip div{
  display:flex;
  flex-direction:column;
}

.user-chip small{
  color:var(--muted);
}

.page{
  padding:28px 32px 45px;
  max-width:1500px;
  margin:auto;
}

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

.stat,
.card{
  background:linear-gradient(180deg,#0e1b2c,#0b1726);
  border:1px solid #1c2d45;
  border-radius:17px;
  box-shadow:0 12px 30px rgba(0,0,0,.12);
}

.stat{
  padding:20px;
}

.stat span,
.stat small{
  color:var(--muted);
}

.stat strong{
  display:block;
  font-size:30px;
  margin:4px 0;
}

.grid-2{
  display:grid;
  grid-template-columns:1.1fr .9fr;
  gap:18px;
  margin-bottom:18px;
}

.card{
  padding:20px;
}

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

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

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

.vehicle-list{
  display:grid;
  gap:9px;
}

.vehicle-row{
  display:grid;
  grid-template-columns:1fr auto;
  gap:10px;
  align-items:center;
  padding:13px;
  border:1px solid #1b2b41;
  border-radius:12px;
  background:#0a1625;
  cursor:pointer;
}

.vehicle-row:hover{
  border-color:#315079;
}

.vehicle-row small{
  color:var(--muted);
}

.vehicle-meta{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.pill{
  padding:5px 8px;
  border-radius:999px;
  background:#172a43;
  color:#aec9ee;
  font-size:11px;
}

.empty-state{
  display:grid;
  place-items:center;
  min-height:170px;
  color:var(--muted);
  text-align:center;
  border:1px dashed #2b3e59;
  border-radius:12px;
  padding:20px;
}

.telemetry{
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:10px;
}

.telemetry div{
  background:#091523;
  border:1px solid #1b2d45;
  border-radius:11px;
  padding:12px;
}

.telemetry span{
  display:block;
  color:var(--muted);
  font-size:11px;
}

.telemetry strong{
  font-size:15px;
}

table{
  width:100%;
  border-collapse:collapse;
}

th,
td{
  text-align:left;
  padding:12px 10px;
  border-bottom:1px solid #1b2a3e;
}

th{
  color:#7f96b4;
  font-size:11px;
  text-transform:uppercase;
}

td small{
  color:var(--muted);
}

/* =========================================
   VIDEO
========================================= */

.video-toolbar{
  display:flex;
  gap:14px;
  align-items:end;
  flex-wrap:wrap;
  margin-bottom:18px;
}

.video-toolbar label,
.history-filters label{
  min-width:165px;
}

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

.video-card{
  padding:14px;
}

.video-stage{
  position:relative;
  background:#020509;
  border-radius:13px;
  overflow:hidden;
  aspect-ratio:16/9;
  display:grid;
  place-items:center;
}

.video-stage video{
  width:100%;
  height:100%;
  object-fit:contain;
  background:#000;
}

.video-overlay{
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
  align-content:center;
  pointer-events:none;
  background:
    radial-gradient(
      circle,
      rgba(25,52,84,.25),
      rgba(0,0,0,.8)
    );
  color:#c9d7e9;
}

.video-overlay span{
  font-weight:850;
  letter-spacing:.12em;
}

.video-overlay p{
  color:#7489a4;
}

.stream-info{
  display:flex;
  align-items:center;
  gap:10px;
  padding:14px 5px 2px;
}

.stream-info code{
  color:#7f96b4;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

/* =========================================
   HISTÓRICOS
========================================= */

.history-filters{
  display:flex;
  gap:12px;
  align-items:end;
  flex-wrap:wrap;
}

.files-box{
  margin-top:18px;
}

.file-row{
  display:grid;
  grid-template-columns:auto 1fr auto;
  gap:12px;
  align-items:center;
  padding:11px;
  border-bottom:1px solid #192b42;
}

.file-row small{
  color:var(--muted);
}

.stack{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.console{
  min-height:150px;
  max-height:300px;
  overflow:auto;
  background:#050b13;
  border:1px solid #192a40;
  border-radius:12px;
  padding:13px;
  color:#9fd1ad;
  white-space:pre-wrap;
}

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

.form-grid button{
  align-self:end;
}

.mini-list{
  display:flex;
  gap:7px;
  flex-wrap:wrap;
  margin-top:15px;
}

.mini-list span{
  background:#102139;
  border:1px solid #263a56;
  padding:7px 10px;
  border-radius:999px;
  color:#b9c9dc;
}

/* =========================================
   NOTIFICACIONES
========================================= */

#toast{
  position:fixed;
  right:22px;
  bottom:22px;
  z-index:20;
  display:grid;
  gap:8px;
}

.toast{
  background:#10233a;
  border:1px solid #2a4669;
  border-radius:12px;
  padding:12px 15px;
  box-shadow:var(--shadow);
}

.toast.bad{
  border-color:#6f2d38;
  color:#ffc0c5;
}

/* =========================================
   TABLET
========================================= */

@media(max-width:980px){

  .sidebar{
    width:76px;
  }

  .sidebar .brand div,
  .sidebar .nav span,
  .sidebar .badges{
    display:none;
  }

  .main{
    margin-left:76px;
  }

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

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

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

@media(max-width:640px){

  .login-shell{
    place-items:center;
    padding:18px;
  }

  .login-card{
    width:100%;
    max-width:430px;
    padding:34px 24px 24px;
    border-radius:21px;
  }

  .login-logo{
    height:54px;
    max-width:210px;
  }

  .login-copy{
    margin-top:25px;
  }

  .login-card h1{
    font-size:27px;
  }

  .login-footer{
    font-size:10px;
  }

  .sidebar{
    position:fixed;
    inset:auto 0 0 0;
    width:auto;
    height:66px;
    flex-direction:row;
    align-items:center;
    padding:7px 10px;
    border-right:0;
    border-top:1px solid #1d2e45;
  }

  .brand-side,
  .sidebar-bottom{
    display:none;
  }

  .sidebar nav{
    display:grid;
    grid-template-columns:repeat(5,1fr);
    width:100%;
  }

  .sidebar .nav{
    justify-content:center;
    padding:11px;
  }

  .main{
    margin-left:0;
    padding-bottom:68px;
  }

  .topbar{
    height:75px;
    padding:0 16px;
  }

  .topbar p,
  .user-chip div{
    display:none;
  }

  .page{
    padding:18px 14px;
  }

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

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

  .card{
    padding:15px;
  }

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

  .video-toolbar,
  .history-filters{
    display:grid;
  }

  .video-toolbar label,
  .history-filters label{
    min-width:0;
  }

  .vehicle-meta{
    display:none;
  }
}