:root{
  --bg:#f6f8fb;
  --panel:#ffffff;
  --ink:#1f2a37;
  --muted:#6b7280;
  --line:#e5e7eb;
  --accent:#2563eb;
  --accent2:#1d4ed8;
  --accent-weak:#e0e7ff;
  --success:#0f766e;
  --warn:#b45309;
  --danger:#b91c1c;
  --ok:#16a34a;
  --radius:14px;
  --shadow:0 1px 2px rgba(0,0,0,.05), 0 12px 24px -12px rgba(31,41,55,.18);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:var(--bg);
  color:var(--ink);
  font:14px/1.5 system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Arial,sans-serif;
}

/* LOGIN */
.login-screen{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  background:linear-gradient(135deg,#08162b,#163565);
  padding:24px;
}

.login-card{
  width:min(980px, 100%);
  display:grid;
  grid-template-columns: 1fr 1.2fr;
  gap:24px;
  align-items:stretch;
}

.login-brand{
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.08);
  border-radius:20px;
  padding:28px;
  color:#fff;
  display:flex;
  align-items:flex-start;
  gap:16px;
  flex-direction:column;
  justify-content:center;
  min-height:520px;
}

.login-logo{
  width:72px;
  height:72px;
  border-radius:18px;
  background:linear-gradient(135deg,#1e3a8a,#3b82f6);
  box-shadow:inset 0 0 0 2px rgba(255,255,255,.12);
}

.login-brand h1{
  margin:0;
  font-size:34px;
  line-height:1.1;
}
.login-brand p{
  margin:0;
  color:#cbd5e1;
  font-size:18px;
}

.login-card-box{
  background:#fff;
  border-radius:20px;
  padding:24px;
  box-shadow:0 20px 60px rgba(0,0,0,.2);
}

.login-card-box h2{
  margin:0 0 14px;
  font-size:24px;
}

.login-card-box label{
  display:block;
  font-size:12px;
  color:var(--muted);
  margin:10px 0 6px;
}

.login-card-box input,
.login-card-box textarea,
.login-card-box select{
  width:100%;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:10px;
  background:#fff;
  color:#111827;
  outline:none;
}

.login-card-box textarea{
  min-height:100px;
  resize:vertical;
}

.login-actions{
  display:flex;
  gap:8px;
  margin-top:14px;
}

.login-meta{
  margin-top:14px;
  font-size:12px;
  color:var(--muted);
  display:grid;
  gap:6px;
}

.login-meta code{
  word-break:break-all;
}

.login-debug-box{
  margin-top:14px;
}
.login-debug-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:8px;
}

/* APP */
.app-shell{
  display:grid;
  grid-template-columns:280px 1fr;
  min-height:100vh;
}

.side{
  background:#0b1e3a;
  color:#cbd5e1;
  padding:18px 14px;
  display:flex;
  flex-direction:column;
  gap:14px;
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 10px;
  border-radius:10px;
  background:rgba(255,255,255,.04);
}
.brand .logo{
  width:36px;
  height:36px;
  border-radius:8px;
  background:linear-gradient(135deg,#1e3a8a,#3b82f6);
  box-shadow:inset 0 0 0 2px rgba(255,255,255,.12);
}
.brand h1{
  font-size:15px;
  margin:0;
  letter-spacing:.4px;
  color:#e5e7eb;
  line-height:1.2;
}
.brand h1 span{
  font-weight:400;
  opacity:.8;
}

.side-userbox{
  background:rgba(255,255,255,.05);
  border:1px solid rgba(255,255,255,.08);
  border-radius:12px;
  padding:12px;
  display:grid;
  gap:10px;
}
.side-userrow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
}
.muted-light{
  color:#cbd5e1;
  font-size:12px;
}
.side-logout{
  width:100%;
}

.nav{
  margin-top:4px;
  display:flex;
  flex-direction:column;
  gap:4px;
}
.nav a{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-radius:10px;
  color:#cbd5e1;
  text-decoration:none;
}
.nav a.active,
.nav a:hover{
  background:rgba(255,255,255,.06);
  color:#fff;
}
.nav .icon{
  width:18px;
  height:18px;
  background:#3b82f6;
  border-radius:4px;
  opacity:.9;
}

.footnote{
  margin-top:auto;
  font-size:12px;
  color:#94a3b8;
  opacity:.9;
}

.main{
  padding:24px 28px;
}

.topbar{
  display:flex;
  align-items:center;
  gap:14px;
  margin-bottom:18px;
}
.topbar h2{
  font-size:18px;
  font-weight:700;
  margin:0;
}
.crumbs{
  color:var(--muted);
  font-size:13px;
}

.grid{display:grid; gap:16px}
@media (min-width:1100px){
  .grid.cols-4{grid-template-columns: repeat(4, 1fr)}
  .grid.cols-2{grid-template-columns: 1.25fr 1fr}
}

.card{
  background:var(--panel);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  border:1px solid var(--line);
}
.card h3{
  margin:0 0 8px;
  font-size:15px;
}
.card .head{
  padding:14px 16px;
  border-bottom:1px solid var(--line);
  display:flex;
  align-items:center;
  justify-content:space-between;
}
.card .body{
  padding:16px;
}

.kpi{
  display:flex;
  align-items:center;
  gap:12px;
}
.kpi .dot{
  width:12px;
  height:12px;
  border-radius:50%;
  background:var(--accent);
}
.kpi .val{
  font-size:22px;
  font-weight:800;
}
.kpi .lbl{
  font-size:12px;
  color:var(--muted);
}

.filters{
  display:grid;
  gap:10px;
}
@media (min-width:800px){
  .filters{grid-template-columns: repeat(6, 1fr)}
}
.filters .field{
  display:flex;
  flex-direction:column;
  gap:6px;
}

/* FORMS */
label{font-size:12px; color:var(--muted)}
input, select, button, textarea{font:inherit}

input[type="date"],
input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea{
  border:1px solid var(--line);
  background:#fff;
  border-radius:10px;
  padding:10px 12px;
  outline:none;
}

input:focus,
select:focus,
textarea:focus{
  border-color:#93c5fd;
  box-shadow:0 0 0 3px rgba(37,99,235,.10);
}

/* BUTTONS */
.btn{
  border:1px solid var(--line);
  background:#fff;
  color:var(--ink);
  padding:10px 14px;
  border-radius:10px;
  cursor:pointer;
  transition:.15s ease;
}
.btn:hover{
  transform:translateY(-1px);
}
.btn.primary{
  background:var(--accent);
  color:#fff;
  border-color:var(--accent);
}
.btn.primary:hover{
  background:var(--accent2);
  border-color:var(--accent2);
}
.btn.ghost{
  background:#f8fafc;
}
.btn.small{
  padding:6px 10px;
  font-size:12px;
}

/* TABLES */
table{
  width:100%;
  border-collapse:collapse;
}
th, td{
  padding:10px 12px;
  border-bottom:1px solid var(--line);
  text-align:left;
  font-size:13px;
  vertical-align:top;
}
thead th{
  font-size:12px;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:.06em;
}
tbody tr:hover{background:#fafafa}

/* BADGES */
.badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:4px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:600;
  background:#eef2ff;
  color:#1e3a8a;
  border:1px solid #c7d2fe;
}
.badge.ok{
  background:#ecfdf5;
  color:#065f46;
  border-color:#a7f3d0;
}
.badge.warn{
  background:#fffbeb;
  color:#92400e;
  border-color:#fde68a;
}
.badge.danger{
  background:#fef2f2;
  color:#991b1b;
  border-color:#fecaca;
}

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

.media-row,
.imgrow{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.ph{
  width:100%;
  max-width:180px;
  height:100px;
  border-radius:12px;
  background:linear-gradient(135deg,#e5e7eb,#f3f4f6);
  border:1px dashed #cbd5e1;
}
img{
  max-width:180px;
  border-radius:12px;
  border:1px solid var(--line);
}

/* DRAWER */
.drawer{
  position:fixed;
  inset:auto 0 0 auto;
  right:0;
  width:min(760px, 100%);
  max-width:100%;
  height:100%;
  background:#fff;
  border-left:1px solid var(--line);
  box-shadow:-24px 0 48px rgba(2,6,23,.12);
  transform:translateX(100%);
  transition:.3s transform;
  z-index:50;
}
.drawer.open{transform:translateX(0)}
.drawer .bar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 16px;
  border-bottom:1px solid var(--line);
}
.drawer .content{
  padding:16px;
  overflow:auto;
  height:calc(100% - 54px);
}

.right{
  display:flex;
  gap:8px;
  align-items:center;
}
.row{
  display:grid;
  gap:12px;
}
@media (min-width:900px){
  .row.cols-3{grid-template-columns:repeat(3,1fr)}
  .row.cols-2{grid-template-columns:repeat(2,1fr)}
}
.kv{
  display:grid;
  grid-template-columns:180px 1fr;
  gap:8px;
  padding:6px 0;
  border-bottom:1px dashed var(--line);
}

pre.log{
  margin:0;
  background:#0b1220;
  color:#d1d5db;
  padding:12px;
  border-radius:12px;
  overflow:auto;
  font-size:12px;
  white-space:pre-wrap;
  max-height:220px;
}

ul{
  margin:0;
  padding-left:20px;
}

/* RESPONSIVE */
@media (max-width: 980px){
  .login-card{
    grid-template-columns:1fr;
  }
  .app-shell{
    grid-template-columns:1fr;
  }
  .side{
    position:sticky;
    top:0;
    z-index:20;
  }
  .main{
    padding:16px;
  }
}

/* PRINT */
@media print{
  .side, .topbar, .toolbar, .drawer{
    display:none !important;
  }
  .card{
    box-shadow:none;
    border:1px solid #ddd;
  }
  body{background:#fff}
}
