/* Dashboard LLM API — mobile-first, vanilla CSS */
:root {
  --bg: #0f1420;
  --bg-soft: #161d2e;
  --card: #1b2338;
  --card-border: #2a3452;
  --text: #eef1f8;
  --muted: #9aa5c0;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.12);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.12);
  --amber: #fbbf24;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* ---------- layout ---------- */
.container {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 16px 64px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 20, 32, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--card-border);
}

.topbar-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
  text-decoration: none;
  color: var(--text);
}

.brand-badge {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}

.nav { display: flex; gap: 4px; }

.nav button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.nav button.active {
  color: var(--text);
  background: var(--card);
}

.nav button:hover { color: var(--text); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 16px;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 16px;
}

.card .sub {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 0; min-width: 0; }

.stat {
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 14px;
  min-width: 140px;
}

.stat .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat .value { font-size: 22px; font-weight: 800; }
.stat .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- buttons / inputs ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.05s ease, opacity 0.15s ease;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; width: 100%; }
.btn-success { background: var(--green); color: #06281c; }
.btn-ghost { background: var(--bg-soft); color: var(--text); border: 1px solid var(--card-border); }
.btn-danger { background: var(--red-soft); color: var(--red); border: 1px solid rgba(248,113,113,0.35); }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"] {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: var(--font);
}

input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.error {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid rgba(248,113,113,0.35);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}
.error.show { display: block; }

.notice {
  background: var(--accent-soft);
  border: 1px solid rgba(91,140,255,0.35);
  color: #bcd0ff;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin-top: 12px;
  line-height: 1.5;
}

/* ---------- auth ---------- */
.auth-wrap {
  max-width: 400px;
  margin: 48px auto 0;
}

.auth-card { text-align: left; }
.auth-card h1 { font-size: 22px; margin: 0 0 6px; }
.auth-card p.lead { color: var(--muted); font-size: 14px; margin: 0 0 20px; line-height: 1.6; }

.auth-switch { text-align: center; margin-top: 16px; font-size: 14px; color: var(--muted); }
.auth-switch button {
  background: none; border: none; color: var(--accent);
  font-weight: 700; font-size: 14px; cursor: pointer; padding: 0;
}

.price-line {
  display: flex;
  justify-content: space-between;
  background: var(--green-soft);
  border: 1px solid rgba(52,211,153,0.3);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 18px;
  color: #a7f3d0;
}

/* ---------- api keys ---------- */
.key-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.key-meta { flex: 1 1 180px; min-width: 0; }
.key-name { font-weight: 700; font-size: 14px; }
.key-value { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 4px; word-break: break-all; }
.key-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.key-actions { display: flex; gap: 8px; }

/* ---------- topup ---------- */
.nominal-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.nominal {
  background: var(--bg-soft);
  border: 2px solid var(--card-border);
  border-radius: 12px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  color: var(--text);
  font-family: var(--font);
}

.nominal .rp { font-weight: 800; font-size: 16px; display: block; }
.nominal .tok { font-size: 12px; color: var(--muted); display: block; margin-top: 4px; }
.nominal.selected { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal-backdrop.show { display: flex; }

.modal {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 20px 18px 28px;
}

.modal h3 { margin: 0 0 4px; font-size: 17px; }
.modal .sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

/* ---------- modal QRIS ---------- */
.qr-box {
  display: flex; justify-content: center;
  background: #fff; border-radius: 14px;
  padding: 16px; margin: 0 auto 14px; width: fit-content;
}
.qr-box img, .qr-box canvas { display: block; }
.qr-meta { display: grid; gap: 8px; margin-bottom: 12px; }
.qr-meta > div {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg); border: 1px solid var(--card-border);
  border-radius: 10px; padding: 10px 12px; font-size: 13px;
}
.qr-meta span { color: var(--muted); }
.qr-status {
  text-align: center; font-size: 14px; font-weight: 600;
  color: var(--amber, #d97706); margin: 4px 0 10px;
}
.qr-status.paid { color: var(--green, #16a34a); }
.qr-status.expired { color: var(--red, #dc2626); }
.qr-instructions {
  margin: 0 0 6px; padding-left: 20px;
  font-size: 13px; color: var(--muted);
}
.qr-instructions li { margin-bottom: 4px; }

/* ---------- usage chart ---------- */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 140px;
  padding-top: 8px;
}

.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.bar {
  width: 100%;
  max-width: 44px;
  background: linear-gradient(180deg, var(--accent), #3a5fc0);
  border-radius: 6px 6px 2px 2px;
  min-height: 4px;
}
.bar-col .day { font-size: 11px; color: var(--muted); }
.bar-col .val { font-size: 10px; color: var(--muted); }

table.usage {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 12px;
}
table.usage th {
  text-align: left; color: var(--muted); font-weight: 600;
  padding: 8px 6px; border-bottom: 1px solid var(--card-border);
  font-size: 12px;
}
table.usage td { padding: 10px 6px; border-bottom: 1px solid rgba(42,52,82,0.5); }
table.usage tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- docs ---------- */
pre.code {
  background: #0b0f1a;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 14px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: #c9d4f2;
  margin: 10px 0 0;
}

.doc-step { margin-bottom: 6px; }
.doc-step h3 { font-size: 15px; margin: 18px 0 6px; }
.doc-step p, .doc-step li { font-size: 14px; color: var(--muted); line-height: 1.65; }
.doc-step code {
  font-family: var(--mono); font-size: 12.5px;
  background: var(--bg-soft); padding: 2px 6px; border-radius: 6px; color: var(--text);
}

.copy-btn { float: right; }

/* ---------- misc ---------- */
.hidden { display: none !important; }
.mt { margin-top: 16px; }
.center { text-align: center; }
.small { font-size: 12px; color: var(--muted); }
.demo-badge {
  display: inline-block;
  background: var(--amber);
  color: #3a2a00;
  font-size: 11px; font-weight: 800;
  padding: 3px 10px; border-radius: 999px;
  margin-left: 8px; vertical-align: middle;
}

.empty {
  text-align: center; color: var(--muted); font-size: 14px;
  padding: 24px 12px; border: 1px dashed var(--card-border); border-radius: 12px;
}

/* ---------- badges ---------- */
.badge {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px;
  white-space: nowrap;
}
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: rgba(251,191,36,0.12); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-gray { background: var(--bg-soft); color: var(--muted); border: 1px solid var(--card-border); }

/* ---------- admin ---------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table.admin {
  width: 100%; min-width: 560px;
  border-collapse: collapse; font-size: 13px; margin-top: 12px;
}
table.admin th {
  text-align: left; color: var(--muted); font-weight: 600;
  padding: 8px 8px; border-bottom: 1px solid var(--card-border); font-size: 12px;
}
table.admin td { padding: 10px 8px; border-bottom: 1px solid rgba(42,52,82,0.5); vertical-align: middle; }
table.admin tr:last-child td { border-bottom: none; }
.mono { font-family: var(--mono); font-size: 12px; word-break: break-all; }

.form-grid { display: grid; gap: 0; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }
.form-actions .btn { flex: 1; }

.switch-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 14px; }
.switch-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }

select {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: var(--font);
}

.breakdown {
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}
.breakdown .line { display: flex; justify-content: space-between; padding: 4px 0; color: var(--muted); }
.breakdown .line.total { color: var(--text); font-weight: 800; border-top: 1px solid var(--card-border); margin-top: 6px; padding-top: 10px; }
.breakdown .line .hl { color: var(--green); font-weight: 700; }

@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal { border-radius: 18px; }
  .nominal-grid { grid-template-columns: repeat(4, 1fr); }
}
