:root {
  --bg: #0b1020;
  --bg-soft: #121a31;
  --text: #e7efff;
  --muted: #9db0d8;
  --card: rgba(255,255,255,0.06);
  --line: rgba(153, 178, 230, 0.25);
  --primary: #3b82f6;
  --primary-2: #06b6d4;
  --ok: #22c55e;
  --danger: #ef4444;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: "Noto Sans Lao", "Phetsarath OT", "Avenir Next", sans-serif; }
body { min-height: 100vh; }

.bg-layer {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(900px 380px at -10% -20%, #1d4ed8 0%, transparent 60%),
    radial-gradient(820px 300px at 100% 0%, #0f766e 0%, transparent 58%),
    linear-gradient(180deg, var(--bg) 0%, #0e1730 100%);
}

.app-wrap {
  position: relative; z-index: 1; max-width: 760px; margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 14px 26px;
}

.topbar {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  margin-bottom: 12px;
}
.brand { margin: 0; font-size: .78rem; color: var(--muted); letter-spacing: .04em; }
h1 { margin: 4px 0 4px; font-size: 1.5rem; line-height: 1.18; }
.subtitle { margin: 0; color: var(--muted); font-size: .9rem; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255,255,255,.08); color: #fff; font-size: 1.15rem;
}

.kpi-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px;
}
.kpi {
  border: 1px solid var(--line); border-radius: 14px; padding: 10px;
  background: rgba(15, 23, 42, .5); backdrop-filter: blur(12px);
}
.kpi .label { margin: 0; color: var(--muted); font-size: .75rem; }
.kpi .value { margin: 4px 0 0; font-size: .95rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.service { box-shadow: inset 0 0 0 1px #3b82f644; }
.kpi.browser { box-shadow: inset 0 0 0 1px #06b6d444; }
.kpi.time { box-shadow: inset 0 0 0 1px #8b5cf644; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px; margin-bottom: 10px; backdrop-filter: blur(14px);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h2, .card h3 { margin: 0 0 8px; font-size: 1rem; }
.helper { margin: 0 0 8px; color: var(--muted); font-size: .82rem; }

.status-dot { width: 10px; height: 10px; border-radius: 999px; background: #64748b; box-shadow: 0 0 0 5px #64748b22; }
.status-dot.ok { background: var(--ok); box-shadow: 0 0 0 5px #22c55e33; }

.tab-row {
  position: sticky; top: 8px; z-index: 3;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin: 4px 0 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(12px);
}
.tab {
  border-radius: 10px; border: 1px solid #6b8ac444; background: #1b2844; color: #d7e7ff;
  padding: 8px 6px; font-size: .78rem; font-weight: 700;
}
.tab.active { background: linear-gradient(90deg, var(--primary), var(--primary-2)); color: #fff; border-color: transparent; }

.module { display: none; animation: fade .22s ease; }
.module.active { display: block; }
.module-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }

.metric { margin: 0 0 10px; color: #d9e7ff; }
.model-name {
  margin: 4px 0 10px; font-size: .95rem; line-height: 1.35; word-break: break-word;
  color: #f3f7ff; font-weight: 700;
}

.input-row { display: flex; gap: 8px; align-items: center; }
input, select, button, .quick, .tiny {
  border-radius: 12px; border: 1px solid var(--line); font-size: .92rem; padding: 10px 12px;
}
input, select {
  width: 100%; min-width: 0; color: #fff; background: rgba(2, 6, 23, 0.45);
}
button, .quick {
  background: linear-gradient(90deg, var(--primary), var(--primary-2)); color: #fff; font-weight: 800;
}
button.ghost, .quick.ghost, .tiny { background: rgba(255,255,255,.06); color: #d8e6ff; }
button.danger { background: linear-gradient(90deg, #ef4444, #dc2626); }

.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick { text-decoration: none; text-align: center; }

.tab-list {
  max-height: 280px; overflow: auto; border: 1px dashed #7ea3df66; border-radius: 12px;
  padding: 8px; background: rgba(2, 6, 23, 0.45);
}
.tab-item { border-bottom: 1px solid #5f7eb333; padding: 8px 0; }
.tab-item:last-child { border-bottom: 0; }
.tab-item strong { display: block; font-size: .86rem; }
.tab-item span { color: var(--muted); font-size: .76rem; word-break: break-all; }

.chip-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid #7ea3df55; border-radius: 999px; padding: 6px 10px; font-size: .76rem; background: rgba(15, 23, 42, .45); }

pre {
  margin: 0; max-height: 340px; overflow: auto; border-radius: 12px;
  background: #060d22; color: #d0e2ff; padding: 10px; font-size: .73rem; line-height: 1.45;
}

.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(80px);
  bottom: 16px; z-index: 9; opacity: 0; transition: .22s ease;
  background: #020817; color: #fff; border: 1px solid #85a3da66; border-radius: 999px; padding: 9px 14px; font-size: .8rem;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 560px) {
  .kpi-row { grid-template-columns: 1fr; }
  .tab-row { position: static; }
}

@keyframes fade { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: translateY(0);} }

.model-health-card { border: 1px solid #3a78f380; }
.mh-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.mh-pill { border-radius: 12px; padding: 8px; border: 1px solid var(--line); background: rgba(12, 18, 35, 0.7); }
.mh-pill span { display: block; color: var(--muted); font-size: .72rem; }
.mh-pill strong { font-size: 1rem; }
.mh-pill.ok { box-shadow: inset 0 0 0 1px #22c55e55; }
.mh-pill.warn { box-shadow: inset 0 0 0 1px #f59e0b55; }
.mh-pill.wait { box-shadow: inset 0 0 0 1px #8b5cf655; }
.mh-reco { display: grid; grid-template-columns: 1fr; gap: 6px; margin: 8px 0; }
.mh-reco-item { border: 1px dashed #7ea3df66; border-radius: 10px; padding: 7px 9px; font-size: .8rem; }
.mh-list { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
.mh-item { border: 1px solid #37598f66; border-radius: 12px; padding: 8px; background: rgba(7,12,24,.6); }
.mh-item .line1 { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.mh-item .model { font-size: .82rem; font-weight: 700; word-break: break-all; }
.mh-badge { border-radius: 999px; padding: 3px 9px; font-size: .7rem; font-weight: 800; }
.mh-badge.usable { background: #14532d; color: #bbf7d0; }
.mh-badge.waiting { background: #78350f; color: #fde68a; }
.mh-badge.degraded { background: #1e3a8a; color: #bfdbfe; }
.mh-badge.unavailable { background: #7f1d1d; color: #fecaca; }
.mh-meta { margin-top: 4px; color: var(--muted); font-size: .74rem; }
@media (max-width: 560px) { .mh-summary { grid-template-columns: 1fr; } }
