:root {
  --bg: #ffffff;
  --bg-soft: #fdfbf9;
  --surface: #ffffff;
  --line: #f1e8e1;
  --line-strong: #e4d6c9;
  --ink: #1c1917;
  --ink-soft: #57534e;
  --ink-mute: #a8a29e;
  --orange: #ea580c;
  --orange-dark: #c2410c;
  --orange-soft: #fff4ec;
  --orange-line: #fed7aa;
  --green: #15803d;
  --green-soft: #f0fdf4;
  --red: #b91c1c;
  --red-soft: #fef2f2;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(28, 25, 23, .04), 0 12px 32px -20px rgba(28, 25, 23, .28);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--orange-dark); }

/* ---------- login ---------- */

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 50% -10%, #fff2e6 0%, rgba(255, 255, 255, 0) 70%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 392px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px 28px 28px;
}

.login-mark {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, #fb923c, var(--orange));
  color: #fff;
  box-shadow: 0 8px 20px -8px rgba(234, 88, 12, .55);
  margin-bottom: 18px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.login-card p.sub {
  margin: 0 0 22px;
  color: var(--ink-mute);
  font-size: 13px;
}

/* ---------- shell ---------- */

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

.topbar-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, #fb923c, var(--orange));
  color: #fff;
  flex: none;
}

.brand-text { min-width: 0; }
.brand-text strong {
  display: block;
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.brand-text span {
  display: block;
  font-size: 11.5px;
  color: var(--ink-mute);
  letter-spacing: .02em;
  white-space: nowrap;
}

.topbar-spacer { flex: 1; }

.conn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ink-mute);
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.conn .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(21, 128, 61, .12);
}

.page {
  max-width: 1140px;
  margin: 0 auto;
  padding: 24px 24px 64px;
}

.page-head { margin-bottom: 20px; }
.page-head h2 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.01em;
}
.page-head p {
  margin: 0;
  color: var(--ink-mute);
  font-size: 13px;
}

/* ---------- stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.stat .label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-mute);
  font-weight: 600;
}
.stat .value {
  margin-top: 6px;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat .hint {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--ink-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat.accent { background: linear-gradient(180deg, #fffaf6, #ffffff); border-color: var(--orange-line); }

/* ---------- layout ---------- */

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.stack { display: grid; gap: 16px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-head h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: -.005em;
}
.panel-head .sub {
  font-size: 11.5px;
  color: var(--ink-mute);
  margin-left: auto;
  text-align: right;
}
.panel-body { padding: 16px 18px; }
.panel-body.tight { padding: 12px 18px; }
.panel-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: 12px;
  color: var(--ink-mute);
}

/* ---------- accounts ---------- */

.account {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.account:first-child { padding-top: 2px; }
.account:last-child { border-bottom: 0; padding-bottom: 2px; }

.avatar {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--orange-soft);
  border: 1px solid var(--orange-line);
  color: var(--orange-dark);
  font-weight: 650;
  font-size: 14px;
}

.account-main { flex: 1; min-width: 0; }
.account-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.account-title .name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -.005em;
}
.account-meta {
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-mute);
}
.account-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 9px;
}
.quota-line {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--bg-soft);
  border: 1px dashed var(--line-strong);
  border-radius: 9px;
  padding: 7px 10px;
}
.quota-line strong { font-weight: 650; }
.quota-bar {
  margin-top: 6px;
  height: 5px;
  border-radius: 999px;
  background: #f4ece6;
  overflow: hidden;
}
.quota-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #fb923c, var(--orange));
}

/* ---------- badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.primary { background: var(--orange-soft); color: var(--orange-dark); border-color: var(--orange-line); }
.badge.ok { background: var(--green-soft); color: var(--green); border-color: #dcfce7; }
.badge.warn { background: var(--amber-soft); color: var(--amber); border-color: #fde68a; }
.badge.danger { background: var(--red-soft); color: var(--red); border-color: #fecaca; }
.badge.muted { background: #f7f5f3; color: var(--ink-soft); border-color: var(--line); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 550;
  transition: background .14s ease, border-color .14s ease, color .14s ease, transform .1s ease;
}
.btn:hover { background: var(--bg-soft); border-color: #d9c8b8; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
  box-shadow: 0 8px 18px -12px rgba(234, 88, 12, .9);
}
.btn-primary:hover { background: var(--orange-dark); border-color: var(--orange-dark); }

.btn-ghost { border-color: var(--line); color: var(--ink-soft); }
.btn-ghost:hover { color: var(--ink); }

.btn-danger { color: var(--red); border-color: #f3d6d6; }
.btn-danger:hover { background: var(--red-soft); border-color: #eab8b8; }

.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-icon { padding: 7px; border-radius: 9px; }

/* ---------- forms ---------- */

.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: .01em;
}
.input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  padding: 9px 11px;
  font-size: 13.5px;
  outline: none;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.input::placeholder { color: #c4bcb6; }
.input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(234, 88, 12, .14);
}
.input.mono { font-family: var(--mono); font-size: 12.5px; }

.form-row { display: flex; gap: 8px; }
.form-row .input { flex: 1; }

.help {
  font-size: 11.5px;
  color: var(--ink-mute);
  line-height: 1.45;
}

/* ---------- api keys ---------- */

.key {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.key:last-child { border-bottom: 0; padding-bottom: 2px; }
.key-main { flex: 1; min-width: 0; }
.key-name { font-size: 13px; font-weight: 600; }
.key-meta {
  font-size: 11.5px;
  color: var(--ink-mute);
  font-family: var(--mono);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.snippet {
  position: relative;
  background: #1c1917;
  border-radius: 12px;
  padding: 14px 14px 14px;
  overflow-x: auto;
}
.snippet pre {
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  color: #f5ede6;
  white-space: pre;
}
.snippet .copy {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .16);
  color: #f5ede6;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 11px;
}

/* ---------- prompt untuk AI agent ---------- */

.prompt {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-soft);
}
.prompt summary {
  cursor: pointer;
  padding: 10px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 7px;
  list-style: none;
  user-select: none;
}
.prompt summary::-webkit-details-marker { display: none; }
.prompt summary::after {
  content: "+";
  margin-left: auto;
  font-size: 15px;
  color: var(--ink-mute);
  line-height: 1;
}
.prompt[open] summary::after { content: "−"; }
.prompt summary:hover { color: var(--ink); }
.prompt pre {
  margin: 0;
  padding: 12px;
  background: #fff;
  border-top: 1px solid var(--line);
  max-height: 280px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
}
.prompt-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
}

/* ---------- table ---------- */

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 10.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: 0; }
.table .mono { font-family: var(--mono); font-size: 12px; }
.table .time { color: var(--ink-mute); white-space: nowrap; }

/* ---------- empty / misc ---------- */

.empty {
  text-align: center;
  padding: 26px 16px;
  color: var(--ink-mute);
  font-size: 13px;
}
.empty .empty-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 10px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--orange-soft);
  color: var(--orange);
}

.divider { height: 1px; background: var(--line); margin: 16px 0; }

.note {
  display: flex;
  gap: 9px;
  background: var(--orange-soft);
  border: 1px solid var(--orange-line);
  color: #7c2d12;
  border-radius: 11px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
}
.note svg { flex: none; margin-top: 1px; }

.error-text {
  color: var(--red);
  font-size: 12.5px;
  min-height: 18px;
}

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, .38);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 60;
  animation: fade .14s ease;
}
.modal {
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 28px 70px -30px rgba(28, 25, 23, .55);
  overflow: hidden;
  animation: pop .16s ease;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px 12px;
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 650; }
.modal-head p { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-mute); }
.modal-body { padding: 4px 20px 16px; overflow-y: auto; }
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  background: var(--bg-soft);
}
.modal-close {
  margin-left: auto;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-mute);
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex: none;
}
.modal-close:hover { color: var(--ink); background: var(--bg-soft); }

.code-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px dashed var(--orange-line);
  background: var(--orange-soft);
  border-radius: 11px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 13px;
  color: #7c2d12;
  word-break: break-all;
}

.steps { margin: 0 0 14px; padding-left: 18px; font-size: 12.5px; color: var(--ink-soft); line-height: 1.7; }
.steps li::marker { color: var(--orange); font-weight: 700; }

/* ---------- toast ---------- */

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  z-index: 80;
  max-width: 340px;
}
.toast {
  background: #1c1917;
  color: #faf7f4;
  border-radius: 11px;
  padding: 11px 14px;
  font-size: 12.5px;
  box-shadow: 0 16px 40px -18px rgba(0, 0, 0, .6);
  animation: slide .18s ease;
}
.toast.err { background: #7f1d1d; }
.toast.ok { background: #14532d; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes slide { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .page { padding: 16px 14px 48px; }
  .topbar-inner { padding: 12px 14px; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .conn { display: none; }
  .table .hide-sm { display: none; }
}
