:root {
  --bg: #0f172a;
  --page: #f1f5f9;
  --card: #ffffff;
  --border: #d8e2ec;
  --text: #0f172a;
  --muted: #52637a;
  --primary: #0f766e;
  --primary-dark: #0b5d56;
  --soft: #e6f6f4;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--page); color: var(--text); font-size: 14.5px; }
.hidden { display: none !important; }
.muted { color: var(--muted); margin: 4px 0; }
.small { font-size: 12.5px; }
.mono { font-family: Consolas, monospace; font-size: 13px; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }

.topbar {
  background: linear-gradient(135deg, #091827 0%, #0f4c5c 100%);
  color: #fff;
  padding: 14px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-ico { font-size: 28px; width: 46px; height: 46px; border-radius: 12px; background: rgba(255,255,255,0.14); display: grid; place-items: center; }
.topbar h1 { margin: 0; font-size: 19px; }
.sub { font-size: 12.5px; opacity: 0.82; }
.top-right { display: flex; align-items: center; gap: 10px; }
.url-pill { background: rgba(255,255,255,0.14); padding: 6px 12px; border-radius: 999px; font-family: Consolas, monospace; font-size: 12.5px; }

.tabs {
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 6px;
  padding: 0 18px;
  overflow-x: auto;
  position: sticky;
  top: 0;
  z-index: 20;
}
.tab {
  border: none;
  background: transparent;
  padding: 13px 16px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.badge { background: var(--primary); color: #fff; font-size: 11.5px; padding: 2px 7px; border-radius: 99px; }
.badge-warn { background: var(--warn); }

.container { max-width: 1420px; margin: 0 auto; padding: 18px; }
.panel { display: none; }
.panel.active { display: block; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 18px; box-shadow: 0 2px 8px rgba(15,23,42,0.05); }
.card h2 { margin: 0; font-size: 17px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.kpi.hl { background: var(--soft); border-color: #99d5ce; }
.kpi-v { font-size: 24px; font-weight: 900; color: var(--text); }
.kpi-l { font-size: 11.5px; text-transform: uppercase; font-weight: 700; color: var(--muted); margin-top: 3px; }
.kpi-s { font-size: 12px; color: var(--primary-dark); font-weight: 600; margin-top: 2px; }

.alerts-box {
  margin-top: 14px;
  background: #fffbeb;
  border: 1.5px solid #fcd34d;
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.grid-2 { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; align-items: start; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-stack { display: flex; flex-direction: column; gap: 11px; }

label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.chk { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; cursor: pointer; }
input[type="text"], input[type="password"], input[type="number"], input[type="month"], input[type="date"], select, textarea {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 9px; font-family: inherit; font-size: 14px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 15px; border-radius: 9px; border: 1.5px solid transparent;
  font-weight: 700; font-size: 13.5px; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #e8f0f6; color: var(--text); border-color: var(--border); }
.btn-light { background: rgba(255,255,255,0.18); color: #fff; border-color: rgba(255,255,255,0.28); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.table-wrap { overflow-x: auto; }
.small-scroll { max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: 9px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid #e6edf3; text-align: left; vertical-align: middle; }
.table th { background: #f8fafc; font-size: 11.5px; text-transform: uppercase; color: var(--muted); }

.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 800; }
.p-ok { background: #dcfce7; color: #166534; }
.p-warn { background: #fef3c7; color: #92400e; }
.p-danger { background: #fee2e2; color: #991b1b; }
.p-info { background: #e0f2fe; color: #075985; }
.p-muted { background: #e2e8f0; color: #334155; }

.bar-bg { background: #e2e8f0; height: 9px; border-radius: 99px; min-width: 80px; overflow: hidden; }
.bar-fill { background: var(--primary); height: 100%; }

.info-box { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.log-pre { background: #0b1220; color: #cbd5e1; padding: 14px; border-radius: 10px; max-height: 62vh; overflow: auto; font-family: Consolas, monospace; font-size: 12px; white-space: pre-wrap; }

.modal { position: fixed; inset: 0; background: rgba(15,23,42,0.62); display: grid; place-items: center; padding: 16px; z-index: 100; }
.modal-card { background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 580px; max-height: 92vh; overflow-y: auto; }
.modal-wide { max-width: 820px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { margin: 0; }
.icon-close { border: none; background: #f1f5f9; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toast { position: fixed; bottom: 20px; right: 20px; background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 10px; font-weight: 700; z-index: 200; }

.login-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #07131f 0%, #0f3d4c 60%, #0f766e 100%);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 500;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: #ffffff;
  border-radius: 16px;
  padding: 28px 26px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
}
.login-brand { text-align: center; }
.login-ico {
  width: 56px;
  height: 56px;
  margin: 0 auto 10px;
  border-radius: 14px;
  background: var(--soft);
  font-size: 28px;
  display: grid;
  place-items: center;
}
.login-brand h2 { margin: 0; font-size: 20px; color: var(--text); }
.login-error {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
}

@media (max-width: 1000px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .row-2 { grid-template-columns: 1fr; }
}
