:root {
  --bg: #f4f7f2;
  --bg-soft: #ebf5e8;
  --panel: #ffffff;
  --ink: #1f2b24;
  --muted: #64706b;
  --line: #d5e2d6;
  --brand: #16a34a;
  --brand-dark: #0f7c37;
  --brand-soft: #def4e4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 0% 0%, #e8f6e9 0%, transparent 46%),
    radial-gradient(circle at 100% 100%, #e5f3e6 0%, transparent 42%),
    var(--bg);
  color: var(--ink);
  padding: 20px;
}

.shell { width: min(1100px, 100%); margin: 0 auto; }

/* ── Brandbar ──────────────────────────────────────────────────── */

.brandbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 8px 20px rgba(18,54,30,.06);
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(155deg, var(--brand) 0%, #28bf5c 100%);
  color: white; font-family: "Sora", sans-serif; font-size: 13px; font-weight: 700;
}

.brand-text { font-family: "Sora", sans-serif; font-size: 18px; letter-spacing: .03em; }

.brand-tag {
  font-size: 12px; color: var(--brand-dark); background: var(--brand-soft);
  border: 1px solid #b7e7c4; border-radius: 999px; padding: 6px 10px;
}

/* ── Tabs ──────────────────────────────────────────────────────── */

.tabs {
  display: flex; gap: 4px; margin-top: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 4px;
}

.tab {
  flex: 1; height: 40px; border: none; border-radius: 8px; cursor: pointer;
  background: transparent; color: var(--muted);
  font: 600 14px/1 "Manrope", sans-serif; transition: all .2s;
}

.tab:hover { background: var(--bg-soft); color: var(--ink); }
.tab.active { background: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(22,163,74,.3); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Stats Grid ────────────────────────────────────────────────── */

.stats-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 14px;
}

.stat-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; text-align: center;
  box-shadow: 0 4px 12px rgba(18,54,30,.05);
}

.stat-value {
  font-family: "Sora", sans-serif; font-size: 1.8rem; font-weight: 700;
  color: var(--brand);
}

.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Card ──────────────────────────────────────────────────────── */

.card {
  margin-top: 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 0; box-shadow: 0 12px 30px rgba(24,52,30,.08);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--line); background: #f8fcf9;
}

.card-header h2 {
  margin: 0; font-family: "Sora", sans-serif; font-size: 1.1rem;
}

/* ── Table ─────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

thead th {
  text-align: left; padding: 10px 16px; font-weight: 600; font-size: 12px;
  color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--line); background: #fbfefc;
}

tbody td {
  padding: 10px 16px; border-bottom: 1px solid #eef4ef; vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-soft); }

td.empty { text-align: center; color: var(--muted); padding: 24px; }

/* ── Badges ────────────────────────────────────────────────────── */

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}

.badge-ok { background: #def4e4; color: #0f7c37; }
.badge-err { background: #fde8e8; color: #b91c1c; }

.badge-tool {
  display: inline-block; padding: 1px 6px; border-radius: 6px;
  font-size: 11px; background: #e8f0fe; color: #1a56db; margin: 1px 2px;
}

.msg-preview {
  max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── REST panel (dark) ─────────────────────────────────────────── */

.rest-card {
  background: #121826; color: #dbe8ff; border-color: #2a3242; padding: 22px;
}

.rest-card p, .rest-card .rest-label { color: #a8b8d6; }

.rest-form { margin-top: 14px; display: grid; gap: 8px; }
.rest-label { font-size: 13px; font-weight: 600; }

.rest-input, .rest-body {
  width: 100%; border: 1px solid #2e3850; background: #0b1020;
  color: #dce7ff; border-radius: 10px; padding: 10px 12px;
  font: 500 14px/1.4 "Manrope", sans-serif;
}

.rest-body { min-height: 110px; resize: vertical; }
.rest-send { margin-top: 6px; height: 44px; }

.rest-shortcuts { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }

.rest-chip {
  border-radius: 999px; border: 1px solid #33415d; background: #1d263a;
  height: 34px; color: #e2ecff; padding: 0 12px; font-size: 12px;
  cursor: pointer;
}

.rest-result {
  margin-top: 12px; border: 1px solid #2e3850; border-radius: 10px;
  background: #071022; color: #d9e7ff; min-height: 120px; padding: 12px;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px; line-height: 1.5;
}

button {
  border: 1px solid #11813a; border-radius: 10px;
  background: linear-gradient(180deg, #1db252 0%, var(--brand) 100%);
  color: #fff; padding: 0 18px; font: 700 14px/1 "Manrope", sans-serif;
  cursor: pointer; transition: transform .15s ease, box-shadow .15s ease;
}

button:hover { transform: translateY(-1px); box-shadow: 0 8px 16px rgba(22,163,74,.25); }
button:disabled { opacity: .7; cursor: wait; transform: none; box-shadow: none; }

h2 { margin: 0 0 8px; font-family: "Sora", sans-serif; font-size: 1.4rem; }
p { margin: 0; color: var(--muted); }

textarea {
  width: 100%; min-height: 96px; resize: vertical;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fbfefc; color: var(--ink); padding: 12px;
  font: 500 15px/1.5 "Manrope", sans-serif;
}

/* ── Responsive ────────────────────────────────────────────────── */

@media (max-width: 720px) {
  body { padding: 12px; }
  .brandbar { flex-direction: column; align-items: flex-start; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid .stat-card:last-child { grid-column: span 2; }
  .stats-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .rest-chip { width: 100%; border-radius: 10px; }
  table { font-size: 13px; }
  thead th, tbody td { padding: 8px 10px; }
}

/* ── Provider detail ──────────────────────────────────────────── */

.detail-header {
  margin-top: 14px; padding: 16px 20px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 8px 20px rgba(18,54,30,.06);
}

.detail-header h2 { margin: 8px 0 2px; font-family: "Sora", sans-serif; }

.back-btn {
  background: transparent; border: 1px solid var(--line); color: var(--ink);
  padding: 6px 14px; height: auto; font-size: 13px; border-radius: 8px;
}
.back-btn:hover { background: var(--bg-soft); box-shadow: none; transform: none; }

.detail-meta {
  display: flex; gap: 20px; margin-top: 10px; padding: 0 4px;
  font-size: 13px; color: var(--muted);
}

.stats-grid-4 { grid-template-columns: repeat(4, 1fr); }

.limit-bar {
  margin-top: 6px; height: 4px; border-radius: 2px; background: var(--line);
  overflow: hidden;
}
.limit-fill { height: 100%; border-radius: 2px; transition: width .3s ease; }

.provider-row:hover { background: var(--brand-soft) !important; }

.hidden { display: none; }
