:root{
  --bg:#07111f;
  --panel:#0f2136;
  --panel2:#132942;
  --text:#f8fbff;
  --muted:#9eb9dc;
  --line:#223b5d;
  --blue:#0d7cff;
  --green:#22c55e;
  --red:#ef4444;
  --yellow:#f59e0b;
  --shadow:0 18px 50px rgba(0,0,0,.25);
}

html[data-theme=light]{
  --bg:#eaf3ff;
  --panel:#ffffff;
  --panel2:#f6fbff;
  --text:#061225;
  --muted:#46638a;
  --line:#d8e5f7;
  --shadow:0 18px 50px rgba(26,71,128,.13);
}

*{box-sizing:border-box}

html,body{
  min-height:100%;
}

body{
  margin:0;
  background:radial-gradient(circle at top right,rgba(13,124,255,.18),transparent 30%),var(--bg);
  color:var(--text);
  font-family:Inter,Segoe UI,Arial,sans-serif;
}

.app-shell{display:flex;min-height:100vh}

.sidebar{
  width:280px;
  background:rgba(4,12,24,.82);
  border-right:1px solid var(--line);
  padding:22px;
  position:fixed;
  inset:0 auto 0 0;
  overflow:auto;
}

html[data-theme=light] .sidebar{background:#fff}

.brand{
  display:flex;
  gap:12px;
  align-items:center;
  text-decoration:none;
  color:var(--text);
  margin-bottom:24px;
}

.brand img{
  width:54px;
  height:54px;
  object-fit:cover;
  border-radius:12px;
}

.brand strong{
  font-size:25px;
  display:block;
  letter-spacing:.5px;
}

.brand strong span{color:var(--blue)}

.brand small,.account-card small{
  display:block;
  color:var(--muted);
  font-size:11px;
  letter-spacing:3px;
  text-transform:uppercase;
}

.nav-group{margin:6px 0}

.nav-link{
  display:flex;
  gap:11px;
  align-items:center;
  padding:11px 10px;
  border-radius:12px;
  color:var(--text);
  text-decoration:none;
  font-weight:700;
}

.nav-group.is-active>.nav-link,.nav-link:hover{
  background:linear-gradient(135deg,var(--blue),#075fd6);
  color:#fff;
}

.nav-link em{
  margin-left:auto;
  font-style:normal;
}

.submenu{
  display:none;
  margin:4px 0 8px 34px;
}

.nav-group.is-open .submenu,
.nav-group.is-active > .submenu{
  display:block;
}

.submenu a{
  display:block;
  color:var(--muted);
  text-decoration:none;
  padding:8px;
  border-radius:8px;
}

.submenu a:hover{
  background:rgba(13,124,255,.12);
  color:var(--text);
}

.submenu a.sub-active{
  background:rgba(13,124,255,.18);
  color:var(--text);
  font-weight:800;
}

.account-card{
  margin-top:26px;
  border:1px solid var(--line);
  border-radius:16px;
  padding:14px;
  display:flex;
  gap:12px;
  align-items:center;
  background:var(--panel);
}

.avatar{
  width:42px;
  height:42px;
  border-radius:50%;
  background:var(--blue);
  display:grid;
  place-items:center;
  color:#fff;
  font-weight:900;
}

.content-shell{
  margin-left:280px;
  width:calc(100% - 280px);
}

.topbar{
  position:sticky;
  top:0;
  z-index:5;
  background:rgba(7,17,31,.82);
  backdrop-filter:blur(14px);
  border-bottom:1px solid var(--line);
  display:flex;
  justify-content:space-between;
  gap:20px;
  padding:22px 26px;
}

html[data-theme=light] .topbar{background:rgba(234,243,255,.84)}

h1{margin:0;font-size:30px}
h2{margin:0 0 14px}

.topbar p{
  margin:6px 0 0;
  color:var(--muted);
}

.toolbar{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}

.btn,.toolbar button,.danger{
  border:1px solid var(--line);
  border-radius:11px;
  padding:12px 16px;
  background:var(--panel);
  color:var(--text);
  font-weight:800;
  text-decoration:none;
  cursor:pointer;
}

.btn.primary{
  background:var(--blue);
  border-color:var(--blue);
  color:#fff;
}

.btn.ghost,
.toolbar .btn.ghost{
  background:transparent;
}

.danger{
  background:var(--red);
  border-color:var(--red);
  color:#fff;
}

.dropdown{
  position:relative;
  display:inline-flex;
}

.dropdown button{
  white-space:nowrap;
}

.dropdown-menu{
  display:none;
  position:absolute;
  right:0;
  top:100%;
  margin-top:0;
  background:var(--panel);
  border:1px solid var(--line);
  box-shadow:var(--shadow);
  border-radius:12px;
  min-width:160px;
  padding:6px;
  z-index:50;
}

.dropdown:hover .dropdown-menu,
.dropdown:focus-within .dropdown-menu{
  display:block;
}

.dropdown-menu a{
  display:block;
  color:var(--text);
  padding:10px 12px;
  text-decoration:none;
  border-radius:8px;
}

.dropdown-menu a:hover{
  background:rgba(13,124,255,.14);
}

.main-content{padding:24px 26px}

.emergency,.panel,.feature-card,.kpi{
  background:linear-gradient(180deg,var(--panel),var(--panel2));
  border:1px solid var(--line);
  border-radius:18px;
  box-shadow:var(--shadow);
}

.emergency{
  display:flex;
  justify-content:space-between;
  gap:20px;
  align-items:center;
  padding:18px 20px;
  margin-bottom:16px;
}

.emergency p{
  margin:6px 0 0;
  color:var(--muted);
}

.kpi-grid{
  display:grid;
  grid-template-columns:repeat(6,minmax(140px,1fr));
  gap:14px;
  margin-bottom:16px;
}

.kpi{padding:18px}
.kpi span{font-size:26px}

.kpi small{
  display:block;
  color:var(--muted);
  margin-top:10px;
}

.kpi strong{
  display:block;
  font-size:30px;
  margin:8px 0;
}

.kpi em{
  color:var(--green);
  font-style:normal;
}

.grid.two{
  display:grid;
  grid-template-columns:1.2fr .8fr;
  gap:16px;
  margin-bottom:16px;
}

.panel{
  padding:20px;
  overflow:hidden;
}

.panel.narrow{max-width:760px}

.card-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(240px,1fr));
  gap:16px;
}

.feature-card{padding:22px}

.feature-card p{
  color:var(--muted);
  line-height:1.6;
}

.lead{
  color:var(--muted);
  line-height:1.7;
  max-width:900px;
}

.donut{
  width:190px;
  height:190px;
  margin:10px auto;
  border-radius:50%;
  background:conic-gradient(var(--green) 0 62%,var(--blue) 62% 72%,var(--yellow) 72% 86%,var(--red) 86% 100%);
  display:grid;
  place-items:center;
}

.donut span{
  width:100px;
  height:100px;
  background:var(--panel);
  border-radius:50%;
  display:grid;
  place-items:center;
  text-align:center;
  font-weight:900;
}

.legend{
  list-style:none;
  padding:0;
  margin:0;
}

.legend li{
  display:flex;
  justify-content:space-between;
  padding:7px 0;
  color:var(--muted);
}

.map-placeholder{
  font-size:66px;
  text-align:center;
  color:var(--muted);
  padding:25px 0;
}

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

th,td{
  padding:12px;
  border-bottom:1px solid var(--line);
  text-align:left;
}

th{color:var(--text)}
td{color:var(--muted)}

.badge{
  display:inline-block;
  padding:5px 9px;
  border-radius:8px;
  font-weight:800;
}

.badge.ok{
  background:rgba(34,197,94,.2);
  color:var(--green);
}

.badge.bad{
  background:rgba(239,68,68,.22);
  color:#ff8c8c;
}

.badge.warn{
  background:rgba(245,158,11,.22);
  color:#ffd17a;
}

.form-grid{
  display:grid;
  gap:14px;
  max-width:520px;
}

label{
  display:grid;
  gap:6px;
  color:var(--muted);
  font-weight:700;
}

input,select{
  border:1px solid var(--line);
  background:var(--bg);
  color:var(--text);
  border-radius:10px;
  padding:12px;
}

.footer{
  padding:18px 26px;
  color:var(--muted);
  border-top:1px solid var(--line);
}

/* LOGIN */

body:has(.login-shell){
  overflow-x:hidden;
}

.login-shell{
  min-height:100vh;
  width:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:32px 18px;
  position:relative;
  background:
    radial-gradient(circle at 50% 20%,rgba(13,124,255,.28),transparent 34%),
    radial-gradient(circle at 15% 80%,rgba(13,124,255,.12),transparent 28%),
    var(--bg);
}

.login-toolbar{
  position:fixed;
  top:24px;
  right:24px;
  display:flex;
  gap:10px;
  align-items:center;
  z-index:100;
}

.login-toolbar .dropdown button{
  border:1px solid var(--line);
  border-radius:11px;
  padding:10px 13px;
  background:var(--panel);
  color:var(--text);
  font-weight:800;
  cursor:pointer;
  box-shadow:var(--shadow);
}

.login-card{
  width:100%;
  max-width:430px;
  background:linear-gradient(180deg,var(--panel),var(--panel2));
  border:1px solid var(--line);
  border-radius:24px;
  padding:34px;
  box-shadow:0 30px 90px rgba(0,0,0,.38);
}

.login-card img{
  display:block;
  width:118px;
  max-width:118px;
  height:118px;
  object-fit:cover;
  border-radius:16px;
  margin:0 auto 22px;
}

.login-card h1{
  margin:0 0 8px;
  color:var(--text);
  font-size:30px;
  text-align:left;
}

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

.login-card label{
  display:block;
  margin:15px 0 7px;
  color:var(--text);
  font-weight:800;
}

.login-card input{
  width:100%;
  padding:14px 15px;
  border-radius:13px;
  border:1px solid var(--line);
  background:var(--bg);
  color:var(--text);
  outline:none;
}

.login-card input:focus{
  border-color:var(--blue);
  box-shadow:0 0 0 4px rgba(13,124,255,.16);
}

.login-card .btn{
  width:100%;
  margin-top:22px;
  display:block;
  text-align:center;
}

.alert.bad{
  background:rgba(239,68,68,.13);
  color:#fecaca;
  border:1px solid rgba(239,68,68,.35);
  padding:12px;
  border-radius:12px;
  margin-bottom:16px;
}

html[data-theme=light] .alert.bad{
  color:#991b1b;
  background:#fee2e2;
  border-color:#fecaca;
}

@media(max-width:1100px){
  .kpi-grid,.card-grid{grid-template-columns:repeat(2,1fr)}
  .grid.two{grid-template-columns:1fr}
  .topbar{flex-direction:column}
}

@media(max-width:760px){
  .sidebar{
    position:static;
    width:100%;
    height:auto;
  }

  .content-shell{
    margin-left:0;
    width:100%;
  }

  .app-shell{display:block}
  .kpi-grid,.card-grid{grid-template-columns:1fr}

  .emergency{
    flex-direction:column;
    align-items:stretch;
  }

  .login-toolbar{
    position:absolute;
    top:14px;
    right:14px;
    left:14px;
    justify-content:center;
    flex-wrap:wrap;
  }

  .login-card{
    margin-top:82px;
    padding:26px;
  }
}
.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.filter-input {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 12px;
  padding: 13px 14px;
}

.pager-info {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin: 10px 0;
}

.pagination-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-link {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.btn-link:hover {
  text-decoration: underline;
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.modal-overlay{
  display:none;
  position:fixed;
  inset:0;
  z-index:200;
  background:rgba(0,0,0,.55);
  padding:28px;
  overflow:auto;
}

.modal-overlay.is-visible{
  display:flex;
  align-items:center;
  justify-content:center;
}

.modal-card{
  width:min(760px,100%);
  background:linear-gradient(180deg,var(--panel),var(--panel2));
  border:1px solid var(--line);
  border-radius:22px;
  box-shadow:var(--shadow);
  padding:24px;
}

.action-row{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
}

.btn-small{
  padding:8px 10px;
  font-size:13px;
}

.alert.ok{
  background:rgba(34,197,94,.14);
  color:#86efac;
  border:1px solid rgba(34,197,94,.35);
  padding:12px;
  border-radius:12px;
  margin:12px 0;
}

html[data-theme=light] .alert.ok{
  color:#166534;
  background:#dcfce7;
  border-color:#bbf7d0;
}
