/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: #08080f;
  color: #e2e8f0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  display: flex;
  overflow: hidden;
}
a { cursor: pointer; text-decoration: none; }
button { transition: opacity .15s, transform .1s; }
button:active { transform: scale(.97); }
input, select, textarea { font-family: inherit; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: #0c0c1d; }
::-webkit-scrollbar-thumb { background: #1e2040; border-radius: 4px; }
input::placeholder, textarea::placeholder { color: #334155; }
select option { background: #0e0e22; }
@keyframes fadeUp { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: 220px; min-width: 220px;
  background: #0c0c1d;
  border-right: 1px solid #1e2040;
  display: flex; flex-direction: column;
  height: 100vh; overflow-y: auto;
  transition: width .2s, min-width .2s;
  position: relative; z-index: 10;
}
.sidebar.collapsed { width: 60px; min-width: 60px; }
.sidebar.collapsed .nav-section,
.sidebar.collapsed .logo-ver,
.sidebar.collapsed .logo-name,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-item span { display: none; }
.sidebar.collapsed .sidebar-logo { justify-content: center; padding: 16px 0; }

.main { flex: 1; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ── Sidebar components ───────────────────────────────────────────────────── */
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 16px; border-bottom: 1px solid #1e2040;
}
/*.logo-icon {
  width: 36px; height: 36px; flex-shrink: 0;
  background: linear-gradient(135deg,#38bdf8,#6366f1);
  border-radius: 9px; display: flex; align-items: center;
  justify-content: center; font-size: 18px;
  box-shadow: 0 0 18px #38bdf844;
}*/
.logo-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: transparent;
  box-shadow: none;
  
}
.logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 6px
}
.logo-name { font-size: 14px; font-weight: 800; color: #f1f5f9; letter-spacing: -.2px; }
.logo-ver  { font-size: 10px; color: #334155; }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section {
  font-size: 9px; color: #1e2040; font-weight: 800;
  letter-spacing: 1.8px; text-transform: uppercase;
  padding: 14px 16px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; color: #475569; font-size: 13px;
  font-weight: 600; border-radius: 0; cursor: pointer;
  transition: color .15s, background .15s;
  border-left: 2px solid transparent;
}
.nav-item:hover { color: #94a3b8; background: #0f0f24; }
.nav-item.active { color: #38bdf8; background: #38bdf810; border-left-color: #38bdf8; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-top: 1px solid #1e2040;
}
.user-avatar {
  width: 32px; height: 32px; flex-shrink: 0;
  background: linear-gradient(135deg,#38bdf8,#6366f1);
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-weight: 800; font-size: 13px; color: #fff;
}
.user-name { font-size: 12px; font-weight: 700; color: #e2e8f0; }
.user-role { font-size: 10px; color: #334155; }
.btn-logout {
  margin-left: auto; background: none; border: none;
  color: #334155; font-size: 16px; cursor: pointer; padding: 4px;
}
.btn-logout:hover { color: #ef4444; }

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 24px; background: #0c0c1d;
  border-bottom: 1px solid #1e2040;
  position: sticky; top: 0; z-index: 5;
}
.menu-toggle {
  background: none; border: none; color: #475569;
  font-size: 18px; cursor: pointer; padding: 4px 6px;
}
.topbar-title { font-size: 15px; font-weight: 800; color: #f1f5f9; flex: 1; }
.topbar-actions { display: flex; gap: 8px; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
card {
  background: #0c0c1d; border: 1px solid #1e2040;
  border-radius: 12px; padding: 20px;
}

.card.p0 { padding: 0; }
.card-title { font-size: 13px; font-weight: 700; color: #94a3b8; letter-spacing: .3px; }

/* ── KPI Grid ─────────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.kpi-card {
  background: #0c0c1d; border: 1px solid #1e2040;
  border-radius: 12px; padding: 16px;
}
.kpi-label { font-size: 9px; color: #334155; text-transform: uppercase; letter-spacing: 1.3px; font-weight: 700; margin-bottom: 6px; }
.kpi-val   { font-size: 20px; font-weight: 800; color: #f1f5f9; font-family: monospace; }

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

/* ── Toolbar ──────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex; gap: 8px; margin-bottom: 14px;
  flex-wrap: wrap; align-items: center;
}

/* ── Inputs ───────────────────────────────────────────────────────────────── */
.inp {
  background: #0c0c1d; border: 1px solid #1e2040;
  border-radius: 8px; padding: 9px 13px; color: #e2e8f0;
  font-size: 13px; outline: none; font-family: inherit;
  transition: border .2s;
}
.inp:focus { border-color: #38bdf8; }
.inp[type="date"] { color-scheme: dark; }
.inp-full { width: 100%; }
.inp-grid { display: grid; gap: 12px; }
.lbl {
  display: block; font-size: 10px; color: #475569;
  font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.4px; margin-bottom: 5px;
}
.err { font-size: 11px; color: #ef4444; margin-top: 3px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
  background: linear-gradient(135deg,#38bdf8,#6366f1);
  color: #fff; border: none; border-radius: 8px;
  padding: 9px 16px; font-weight: 800; font-size: 13px;
  cursor: pointer; white-space: nowrap;
}
.btn-primary:hover { opacity: .9; }
.btn-sm {
  border-radius: 6px; padding: 5px 8px; font-size: 12px;
  cursor: pointer; border: 1px solid; font-weight: 700;
}
.btn-edit { background: #38bdf818; border-color: #38bdf840; color: #38bdf8; }
.btn-del  { background: #ef444418; border-color: #ef444440; color: #ef4444; }
.btn-sec  { background: transparent; border: 1px solid #1e2040; color: #475569; border-radius: 8px; padding: 9px 16px; font-size: 13px; cursor: pointer; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 600px; }
.tbl thead tr { background: #0f0f24; border-bottom: 1px solid #1e2040; }
.tbl th {
  padding: 9px 13px; text-align: left; color: #334155;
  font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; font-size: 9px; white-space: nowrap;
}
.tbl td { padding: 10px 13px; border-bottom: 1px solid #0f0f24; vertical-align: middle; }
.tbl tbody tr:hover td { background: #0f0f24; }
.tbl-footer {
  padding: 9px 14px; border-top: 1px solid #0f0f24;
  color: #334155; font-size: 11px;
  display: flex; justify-content: space-between;
}

/* ── Chips / Badges ───────────────────────────────────────────────────────── */
.chip {
  font-size: 10px; padding: 2px 8px; border-radius: 4px;
  font-weight: 700; border: 1px solid; letter-spacing: .5px;
  display: inline-block;
}
.badge-ok  { background:#22c55e20; color:#22c55e; border-color:#22c55e40; font-size:9px; font-weight:800; padding:2px 7px; border-radius:4px; letter-spacing:.8px; }
.badge-low { background:#f59e0b20; color:#f59e0b; border-color:#f59e0b40; font-size:9px; font-weight:800; padding:2px 7px; border-radius:4px; letter-spacing:.8px; }
.badge-out { background:#ef444420; color:#ef4444; border-color:#ef444440; font-size:9px; font-weight:800; padding:2px 7px; border-radius:4px; letter-spacing:.8px; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: #00000099;
  z-index: 300; display: none; align-items: center;
  justify-content: center; padding: 16px;
  backdrop-filter: blur(4px); animation: fadeIn .2s;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #0e0e22; border: 1px solid #1e2040;
  border-radius: 18px; padding: 28px; width: 100%;
  max-width: 620px; max-height: 92vh; overflow-y: auto;
  box-shadow: 0 32px 80px #000a; animation: fadeUp .25s;
}
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; }
.modal-title  { font-size: 15px; font-weight: 800; color: #f1f5f9; }
.modal-sub    { font-size: 11px; color: #475569; margin-top: 2px; }
.modal-close  { background: none; border: none; color: #334155; font-size: 24px; cursor: pointer; line-height: 1; padding: 0 4px; margin-top: 2px; }
.modal-close:hover { color: #e2e8f0; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  background: #38bdf818; border: 1px solid #38bdf855;
  color: #e2e8f0; border-radius: 11px; padding: 12px 20px;
  font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 32px #0008;
  animation: fadeUp .3s ease; max-width: 340px;
  display: none; pointer-events: none;
}
.toast.show { display: block; }
.toast.warn { background: #f59e0b18; border-color: #f59e0b55; }
.toast.err  { background: #ef444418; border-color: #ef444455; }

/* ── Alert & Recent lists ─────────────────────────────────────────────────── */
.alert-list, .recent-list { margin-top: 12px; display: grid; gap: 8px; }
.alert-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: #0f0f24; border-radius: 8px;
  border-left: 3px solid #ef4444; font-size: 12px;
}
.alert-item.low { border-left-color: #f59e0b; }
.recent-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: #0f0f24; border-radius: 8px; font-size: 12px;
}

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeUp .25s; }
.empty-state { text-align: center; padding: 50px 20px; color: #334155; }
.empty-state .es-icon { font-size: 44px; margin-bottom: 12px; }
.empty-state .es-msg  { color: #475569; font-size: 14px; }
.admin-only { display: none; }
.form-row  { display: grid; gap: 12px; margin-bottom: 13px; }
.form-row.cols2 { grid-template-columns: 1fr 1fr; }
.form-row.cols3 { grid-template-columns: 1fr 1fr 1fr; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }
.mono { font-family: monospace; }
.text-green { color: #22c55e; }
.text-yellow{ color: #f59e0b; }
.text-red   { color: #ef4444; }
.text-muted { color: #475569; }
.text-dim   { color: #334155; }
.fw7 { font-weight: 700; }
.fw8 { font-weight: 800; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { position: fixed; height: 100vh; z-index: 50; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.mobile-open { transform: translateX(0); }
  .main { width: 100%; }
  .content { padding: 16px; }
  .form-row.cols2, .form-row.cols3 { grid-template-columns: 1fr; }
}