/* Giza Team-Chat Intelligence - enterprise UI (vanilla) */
:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1a2230;
  --ink-soft: #5a6678;
  --muted: #8a94a6;
  --line: #e7ebf1;
  --brand: #16a34a;
  --brand-d: #15803d;
  --blue: #3b82f6;
  --red: #ef4444;
  --amber: #f59e0b;
  --rail: #131a26;
  --rail-hi: #22c55e;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.05);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

#app-shell { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: linear-gradient(180deg, #131a26 0%, #0f1622 100%);
  color: #c6cfdc;
  display: flex; flex-direction: column;
  padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 18px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff; font-weight: 800; font-size: 20px;
  display: grid; place-items: center;
  box-shadow: 0 4px 14px rgba(34,197,94,.35);
}
.brand-name { font-weight: 800; font-size: 17px; color: #fff; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: #7f8ba0; margin-top: 1px; }

.nav { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px;
  color: #aab4c5; font-weight: 500; cursor: pointer;
  transition: background .15s, color .15s; position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #e8edf4; }
.nav-item.active { background: rgba(34,197,94,.16); color: #fff; }
.nav-item.active::before {
  content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px;
  width: 4px; border-radius: 0 4px 4px 0; background: var(--rail-hi);
}
.nav-ico { width: 22px; text-align: center; font-size: 16px; }
.nav-label { flex: 1; }
.nav-badge {
  background: #2b3647; color: #cfd8e6; font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  display: inline-grid; place-items: center;
}
.nav-badge-red { background: var(--red); color: #fff; }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }

.sidebar-foot { margin-top: auto; padding-top: 14px; }
.conn-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: #8b96a8;
  background: rgba(255,255,255,.04); padding: 9px 11px; border-radius: 10px;
}
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: #6b7689; }
.conn-dot.conn-ok { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.conn-dot.conn-bad { background: var(--amber); box-shadow: 0 0 0 3px rgba(245,158,11,.18); }

/* ---------- Content ---------- */
.content { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.topbar-title h1 { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -.2px; }
.topbar-title p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; gap: 10px; }
.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line);
  background: #fff; color: var(--ink); padding: 9px 15px; border-radius: 10px;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn:hover { box-shadow: var(--shadow); }
.btn-ghost { background: #f7f9fc; }
.btn-primary { background: linear-gradient(135deg, #22c55e, #16a34a); border-color: transparent; color: #fff; }
.btn-primary:hover { box-shadow: 0 4px 14px rgba(34,197,94,.4); }

.view-root { padding: 24px 28px 40px; }
.loading, .muted { color: var(--muted); padding: 24px 0; }
.errbox {
  background: #fff4f4; border: 1px solid #ffd9d9; color: #b42318;
  padding: 14px 16px; border-radius: 12px; margin: 8px 0;
}
.src-note {
  background: #fff8eb; border: 1px solid #fde9c0; color: #92600a;
  padding: 9px 14px; border-radius: 10px; font-size: 12.5px; margin-bottom: 16px;
}

/* ---------- KPI cards ---------- */
.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px;
}
.kpi-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: flex; gap: 14px; align-items: center; box-shadow: var(--shadow);
}
.kpi-ico {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  font-size: 22px; background: #eef2f7; flex-shrink: 0;
}
.kpi-blue .kpi-ico { background: #e8f0fe; }
.kpi-red .kpi-ico { background: #fdeaea; }
.kpi-green .kpi-ico { background: #e6f7ed; }
.kpi-amber .kpi-ico { background: #fef3e0; }
.kpi-value { font-size: 28px; font-weight: 800; line-height: 1; letter-spacing: -.5px; }
.kpi-label { color: var(--ink-soft); font-weight: 600; margin-top: 5px; font-size: 13px; }
.kpi-sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.kpi-red .kpi-value { color: var(--red); }
.kpi-green .kpi-value { color: var(--brand-d); }
.kpi-amber .kpi-value { color: #b4750a; }

/* ---------- Cards / grid ---------- */
.dash-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; margin-bottom: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 15.5px; font-weight: 700; }
.lnk { color: var(--brand-d); font-weight: 600; font-size: 13px; }
.lnk:hover { text-decoration: underline; }

/* ---------- Trend chart ---------- */
.trend-svg { width: 100%; height: auto; display: block; }
.trend-svg .ax { fill: #9aa4b4; font-size: 10px; }
.legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-soft); }
.lg { width: 11px; height: 11px; border-radius: 3px; display: inline-block; margin-left: 6px; }
.lg-blue { background: var(--blue); }
.lg-green { background: var(--brand); }

/* ---------- Health chips ---------- */
.health-row { display: grid; grid-template-columns: 1fr; gap: 11px; }
.health-chip { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fbfcfe; }
.hc-top { display: flex; align-items: center; gap: 9px; }
.hc-ico { font-size: 16px; }
.hc-name { font-weight: 700; flex: 1; }
.hc-dot { width: 10px; height: 10px; border-radius: 50%; }
.hc-green { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.16); }
.hc-amber { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.16); }
.hc-red { background: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.16); }
.hc-status { font-weight: 600; margin-top: 6px; font-size: 13px; }
.health-green .hc-status { color: var(--brand-d); }
.health-amber .hc-status { color: #b4750a; }
.health-red .hc-status { color: #b42318; }
.hc-sync { color: var(--muted); font-size: 11.5px; margin-top: 2px; }

/* ---------- Table ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); font-weight: 700;
}
.tbl td { padding: 11px 12px; border-bottom: 1px solid #f1f4f8; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: #f9fbfd; }
.tbl .num { text-align: center; }

/* ---------- Pills ---------- */
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 700; line-height: 1.5;
}
.pill-gray { background: #eef1f5; color: #5a6678; }
.pill-blue { background: #e8f0fe; color: #1d4ed8; }
.pill-green { background: #e6f7ed; color: #15803d; }
.pill-red { background: #fdeaea; color: #c0392b; }
.pill-amber { background: #fef3e0; color: #b4750a; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  #app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .kpi-grid { grid-template-columns: 1fr; }
}
