:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #0284c7;
  --primary-dark: #0369a1;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --purple: #7c3aed;
  --radius: 14px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.topbar {
  background: linear-gradient(135deg, #0369a1, #0ea5e9);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.18);
}
.topbar h1 { margin: 0; font-size: 1.15rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.topbar a { color: #e0f2fe; text-decoration: none; font-size: 0.9rem; font-weight: 600; }
.topbar a:hover { color: #fff; }

.container { max-width: 1200px; margin: 0 auto; padding: 18px; }
.container-sm { max-width: 560px; margin: 0 auto; padding: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.card h2, .card h3 { margin: 0 0 10px; font-size: 1rem; }

.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.kpi .label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.kpi .val { font-size: 1.55rem; font-weight: 800; margin-top: 4px; }
.kpi .sub { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.05s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-amber { background: var(--amber); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-purple { background: var(--purple); color: #fff; }
.btn-outline { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-lg { padding: 14px 16px; font-size: 1rem; border-radius: 12px; }
.btn-sm { padding: 6px 10px; font-size: 0.82rem; border-radius: 8px; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
}
.badge-blue { background: #e0f2fe; color: #0369a1; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-gray { background: #e2e8f0; color: #475569; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--text);
}
label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 14px;
}
.tab {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; }
th { font-size: 0.78rem; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.table-wrap { overflow-x: auto; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 0.86rem; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }

/* Simulator chat */
.chat-box {
  background: #e5ddd5;
  border-radius: 12px;
  padding: 12px;
  height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bubble {
  max-width: 85%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 0.9rem;
  white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.bubble.in { align-self: flex-end; background: #dcf8c6; }
.bubble.out { align-self: flex-start; background: #fff; }
.sim-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.sim-btn {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}
.sim-btn:hover { background: #bae6fd; }
