:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --text: #172033;
  --muted: #69758a;
  --border: #dfe5ef;
  --primary: #5b4ce3;
  --primary-dark: #4537c7;
  --primary-soft: #eeecff;
  --success: #138a60;
  --success-soft: #e7f7f1;
  --warning: #b36a00;
  --warning-soft: #fff3dc;
  --danger: #c43a4b;
  --danger-soft: #ffebee;
  --shadow: 0 18px 45px rgba(31, 41, 66, 0.08);
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

code,
.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.hidden {
  display: none !important;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(420px, 0.85fr);
}

.auth-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(48px, 8vw, 120px);
  color: #fff;
  background: radial-gradient(circle at 15% 20%, rgba(155, 143, 255, 0.62), transparent 35%), linear-gradient(145deg, #171536 0%, #312b7a 55%, #4c3fd1 100%);
}

.auth-brand::after {
  content: "";
  position: absolute;
  width: 460px;
  height: 460px;
  right: -180px;
  bottom: -220px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  box-shadow: 0 0 0 80px rgba(255, 255, 255, 0.03), 0 0 0 160px rgba(255, 255, 255, 0.025);
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(145deg, #8e80ff, #5b4ce3);
  color: #fff;
  font-size: 25px;
  font-weight: 800;
  box-shadow: 0 12px 30px rgba(46, 33, 170, 0.32);
}

.brand-mark.small {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 20px;
}

.eyebrow {
  margin: 0 0 7px;
  color: #8c96a9;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.auth-brand .eyebrow {
  color: #c8c3ff;
  margin-top: 42px;
}

.auth-brand h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(42px, 5.2vw, 78px);
  line-height: 1.02;
  letter-spacing: -0.05em;
}

.auth-copy {
  max-width: 650px;
  margin: 28px 0 44px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 18px;
  line-height: 1.7;
}

.feature-list {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  max-width: 760px;
}

.feature-list div {
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(8px);
}

.feature-list strong,
.feature-list span {
  display: block;
}

.feature-list span {
  margin-top: 7px;
  color: rgba(255, 255, 255, 0.64);
  font-size: 13px;
  line-height: 1.5;
}

.auth-panel {
  display: grid;
  place-items: center;
  padding: 40px;
  background: var(--surface);
}

.auth-card {
  width: min(100%, 440px);
}

.brand-row,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-row span,
.sidebar-brand span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 42px 0 28px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-soft);
}

.tab-button {
  border: 0;
  border-radius: 9px;
  padding: 11px 14px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.tab-button.active {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 3px 10px rgba(23, 32, 51, 0.08);
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 20px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-soft);
}

.image-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.image-result {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}

.image-result img {
  display: block;
  width: 100%;
  height: auto;
  background: #111827;
}

.image-result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--muted);
}

.image-result-meta a {
  margin-left: auto;
  font-weight: 700;
}

.output-box .output-placeholder {
  color: #9ca3af;
}

.code-sample {
  margin: 0;
}

.stack-form {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 7px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.spaced-top {
  margin-top: 24px;
}

.code-sample {
  min-height: auto;
  margin-top: 16px;
}

.field label,
.form-grid label {
  color: #3a4558;
  font-size: 13px;
  font-weight: 700;
}

.field small {
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 11px 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #8b7ff0;
  box-shadow: 0 0 0 3px rgba(91, 76, 227, 0.12);
}

textarea {
  min-height: 130px;
  resize: vertical;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 9px;
}

.checkbox-field input {
  width: 17px;
  height: 17px;
}

.toggle-row {
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}

.toggle-row > span {
  display: grid;
  gap: 4px;
}

.field-hint.inline {
  margin: 0;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.preview-box {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}

.preview-box > strong {
  font-size: 13px;
}

.preview-list table {
  font-size: 12px;
}

.warning-box {
  padding: 12px 14px;
  border: 1px solid #f0c48a;
  border-radius: 12px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 12px;
  font-weight: 600;
}

.form-grid.two-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.quick-amounts {
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: -6px;
}

.quick-amounts-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

#custom-credit-total {
  color: var(--primary);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  color: var(--text);
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 750;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
}

.button:hover {
  transform: translateY(-1px);
}

.button.primary {
  color: #fff;
  background: var(--primary);
}

.button.primary:hover {
  background: var(--primary-dark);
}

.button.secondary {
  border-color: #d8d3ff;
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.button.success {
  color: #fff;
  background: var(--success);
}

.button.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.button.ghost {
  border-color: var(--border);
  background: transparent;
}

.button.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.button.full {
  width: 100%;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.auth-footnote {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.link-button {
  justify-self: center;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

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

.auth-form-spaced {
  margin-top: 40px;
}

.auth-form-head h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.auth-form-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.notice-box {
  padding: 12px 14px;
  border: 1px solid #a9c3f0;
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 12px;
  line-height: 1.6;
}

.notice-box.notice-error {
  border-color: #f0c48a;
  background: var(--warning-soft);
  color: var(--warning);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 22px;
  border-bottom: 1px solid var(--border);
}

/* Nav taking the leftover height is what keeps the footer (and the logout
   button) reachable on short phone screens: the nav scrolls on its own
   instead of pushing the footer off-screen. */
.sidebar-nav {
  display: grid;
  align-content: start;
  gap: 5px;
  margin-top: 20px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.sidebar-close {
  display: none;
  margin-left: auto;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
}

.nav-button:hover,
.nav-button.active {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.nav-index {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: inherit;
  background: rgba(91, 76, 227, 0.09);
  font-size: 10px;
}

.sidebar-footer {
  display: grid;
  gap: 12px;
  margin-top: auto;
  padding-top: 18px;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--border);
  flex: 0 0 auto;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  border: 0;
  padding: 0;
  background: rgba(15, 23, 42, 0.45);
}

.role-badge {
  justify-self: start;
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.workspace {
  min-width: 0;
}

/* Only for screen readers: the select-all column header carries no label of
   its own, the checkbox below it is labelled per row. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Power toggle: the model on/off switch is the most important control on the
   card, so it stays large and high-contrast instead of a small ghost button. */
.power-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 132px;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.power-toggle .power-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.18);
}

.power-toggle .power-text {
  min-width: 62px;
  text-align: left;
}

.power-toggle .power-hint {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.75;
}

.power-on {
  color: #0f7a4d;
  border-color: rgba(15, 122, 77, 0.35);
  background: rgba(15, 122, 77, 0.1);
}

.power-on .power-dot {
  box-shadow: 0 0 0 4px rgba(15, 122, 77, 0.18);
}

.power-off {
  color: #9a3412;
  border-color: rgba(154, 52, 18, 0.3);
  background: rgba(154, 52, 18, 0.08);
}

.model-card.is-inactive {
  border-color: rgba(154, 52, 18, 0.28);
  background: repeating-linear-gradient(135deg, rgba(154, 52, 18, 0.03) 0 10px, transparent 10px 20px);
}

.model-power {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.modality-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

.modality-chips .chip {
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 11px;
  font-weight: 800;
}

.modality-chips .chip-arrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.modality-field {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 0;
}

.modality-field legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.history-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.history-count {
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 700;
}

.select-cell {
  width: 34px;
  text-align: center;
}

.select-cell input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

/* Logout lives in the sidebar footer, but on phones the drawer can be
   closed, so the same action is mirrored in the topbar. */
.topbar-logout {
  display: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 82px;
  padding: 14px clamp(20px, 4vw, 48px);
  border-bottom: 1px solid rgba(223, 229, 239, 0.88);
  background: rgba(243, 246, 251, 0.9);
  backdrop-filter: blur(15px);
}

.topbar h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.balance-pill {
  display: flex;
  align-items: baseline;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 13px;
  background: var(--surface);
}

.balance-pill span {
  color: var(--muted);
  font-size: 11px;
}

.balance-pill strong {
  font-size: 13px;
}

.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(145deg, #7869ed, #4437be);
  font-weight: 800;
}

.icon-button {
  display: none;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 11px;
  background: var(--surface);
}

.main-content {
  max-width: 1480px;
  margin: 0 auto;
  padding: clamp(22px, 4vw, 48px);
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: -0.035em;
}

.page-heading p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.heading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card,
.panel,
.provider-card,
.model-card,
.package-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(31, 41, 66, 0.035);
}

.metric-card {
  padding: 20px;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-value {
  display: block;
  margin-top: 9px;
  font-size: 25px;
  letter-spacing: -0.03em;
}

.metric-note {
  display: block;
  margin-top: 6px;
  color: #8a94a7;
  font-size: 11px;
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.grid-three {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  overflow: hidden;
  margin-bottom: 20px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-header h3 {
  margin: 0;
  font-size: 15px;
}

.panel-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-body {
  padding: 20px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 8px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.badge.success {
  color: var(--success);
  background: var(--success-soft);
}

.badge.warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.badge.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

/* Pengingat approval admin yang sudah lewat 24 jam. Bersifat informasi,
   tidak memblokir tindakan admin. */
.order-sla-late {
  color: var(--danger);
  font-weight: 700;
}

.badge.primary {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.inline-form.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.inline-form .span-2 {
  grid-column: span 2;
}

.form-actions {
  display: flex;
  align-items: end;
  gap: 9px;
}

.form-actions .button {
  min-height: 42px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.package-card,
.model-card,
.provider-card {
  padding: 20px;
}

.card-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  margin: 0;
  font-size: 17px;
}

.card-description {
  min-height: 42px;
  margin: 9px 0 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.price-row {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 18px 0;
}

.price-row strong {
  font-size: 24px;
  letter-spacing: -0.03em;
}

.price-row span {
  color: var(--muted);
  font-size: 12px;
}

.spec-list {
  display: grid;
  gap: 9px;
  margin: 16px 0 20px;
}

.spec-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
}

.spec-row strong {
  color: var(--text);
  text-align: right;
}

.provider-card .card-description {
  min-height: auto;
  margin-bottom: 16px;
  word-break: break-all;
}

.provider-route-form,
.provider-file-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.field-hint {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.field .field-hint {
  margin-top: 2px;
}

input[type="file"] {
  padding: 8px;
  font-size: 12px;
}

.key-list,
.route-list {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}

.key-row,
.route-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 10px;
  padding: 10px 11px;
  background: var(--surface-soft);
  font-size: 11px;
}

.route-row > div:first-child {
  min-width: 0;
  flex: 1 1 150px;
}

.route-row .table-actions {
  flex-shrink: 0;
  margin-left: auto;
}

/* Route yang hasil tes terakhornya gagal diberi tanda tepi merah supaya mudah
   dibedakan dari route yang belum pernah diuji. */
.route-row-bad {
  box-shadow: inset 3px 0 0 var(--danger);
}

.route-test {
  display: inline-block;
  max-width: 46ch;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.route-test.ok {
  color: var(--success);
}

.route-test.bad {
  color: var(--danger);
  font-weight: 600;
}

.empty-state {
  padding: 34px 20px;
  color: var(--muted);
  text-align: center;
}

.empty-inline {
  color: var(--muted);
  font-style: italic;
}

.endpoint-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid #d8d3ff;
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--primary-soft);
}

.endpoint-caption {
  display: block;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.endpoint-box + .endpoint-caption {
  margin-top: 18px;
}

.copy-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.copy-cell code {
  font-size: 13px;
  word-break: break-all;
}

.payment-method-block {
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}

.payment-method-block:last-child {
  border-bottom: 0;
}

.payment-destination {
  margin: -4px 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.payment-destination-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.payment-destination-head small {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.payment-deadline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 13px;
  font-weight: 600;
}

.payment-deadline strong {
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}

.payment-deadline.expired {
  background: var(--danger-soft);
  color: var(--danger);
}

.modal-note {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

/* Daftar pengguna terpilih pada modal penyesuaian saldo massal. */
.bulk-balance-list {
  margin: 0;
  padding: 10px 14px 10px 30px;
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  font-size: 13px;
  line-height: 1.6;
  word-break: break-all;
}

.endpoint-box code {
  color: var(--primary-dark);
  font-weight: 700;
  word-break: break-all;
}

.playground-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 20px;
}

.output-box {
  min-height: 340px;
  max-height: 620px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: #111827;
  color: #e5e7eb;
  white-space: pre-wrap;
  word-break: break-word;
  font: 13px/1.65 "SFMono-Regular", Consolas, monospace;
}

.output-placeholder {
  color: #818ba1;
}

.modal {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 0;
  border-radius: 18px;
  padding: 0;
  box-shadow: 0 28px 90px rgba(17, 24, 39, 0.24);
}

.modal::backdrop {
  background: rgba(17, 24, 39, 0.5);
  backdrop-filter: blur(3px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
}

.modal-body {
  padding: 22px;
}

.modal-form {
  display: grid;
  gap: 15px;
}

.secret-box {
  border: 1px solid #cceadd;
  border-radius: 12px;
  padding: 16px;
  background: var(--success-soft);
}

.secret-box code {
  display: block;
  overflow-wrap: anywhere;
  margin: 10px 0;
  color: #075e43;
  font-size: 13px;
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 40px));
}

.toast {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 15px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toast-in 0.2s ease-out;
}

.toast.error {
  border-color: #f4bcc4;
  color: var(--danger);
  background: var(--danger-soft);
}

.toast.success {
  border-color: #bde6d7;
  color: var(--success);
  background: var(--success-soft);
}

.callout {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 15px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 14px;
}

.callout.danger {
  border-color: #f4bcc4;
  color: var(--danger);
  background: var(--danger-soft);
}

.loading {
  display: grid;
  place-items: center;
  min-height: 260px;
  color: var(--muted);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

@media (max-width: 1100px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    min-height: 520px;
  }

  .metrics-grid,
  .grid-three,
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(280px, 84vw);
    /* dvh mengikuti tinggi viewport Android yang berubah saat address bar
       menggulir, jadi menu tidak pernah lebih tinggi dari layar. */
    height: 100dvh;
    max-height: 100dvh;
    z-index: 50;
    overflow: hidden;
    transform: translateX(-105%);
    transition: transform 0.2s;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow);
  }

  .sidebar-backdrop:not(.hidden) {
    display: block;
  }

  /* Layar di belakang drawer tidak ikut bergulir, jadi menggeser halaman di
     area gelap tidak akan meninggalkan halaman dalam posisi setengah. */
  body.sidebar-open {
    overflow: hidden;
  }

  .sidebar-close {
    display: inline-flex;
  }

  .icon-button {
    display: inline-flex;
  }

  .topbar {
    justify-content: flex-start;
    gap: 14px;
    min-height: 64px;
  }

  .topbar-user {
    margin-left: auto;
  }

  .topbar-logout {
    display: inline-flex;
  }

  .balance-pill span {
    display: none;
  }

  .grid-two,
  .playground-grid,
  .form-grid,
  .form-grid.two-fields,
  .inline-form,
  .inline-form.three {
    grid-template-columns: 1fr;
  }

  .inline-form .span-2 {
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  .auth-brand {
    min-height: auto;
    padding: 40px 24px;
  }

  .auth-brand h1 {
    font-size: 40px;
  }

  .feature-list {
    grid-template-columns: 1fr;
  }

  .auth-panel {
    padding: 28px 20px;
  }

  .main-content {
    padding: 20px 14px 40px;
  }

  .metrics-grid,
  .grid-three,
  .card-grid {
    grid-template-columns: 1fr;
  }

  .page-heading,
  .endpoint-box {
    align-items: stretch;
    flex-direction: column;
  }

  .balance-pill {
    display: none;
  }

  .power-toggle {
    width: 100%;
    min-width: 0;
  }

  .card-topline {
    align-items: stretch;
    flex-direction: column;
  }

  .model-power {
    align-items: stretch;
  }

  .history-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Keyboard focus: cincin konsisten hanya muncul saat menavigasi dengan
   keyboard; pengguna mouse tidak melihat perubahan apa pun. */
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* prefers-reduced-motion: transisi hover/geser dan animasi toast dimatikan
   untuk pengguna yang meminta gerakan minimal di sistem operasinya. Spinner
   loading tetap berputar karena merupakan penanda status yang esensial. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .button,
  .power-toggle,
  .sidebar,
  input,
  select,
  textarea {
    transition: none;
  }

  .button:hover {
    transform: none;
  }

  .toast {
    animation: none;
  }
}

/* ============================================================
   PWA: banner "Pasang aplikasi".
   Hanya tampil saat browser mengizinkan pemasangan
   (beforeinstallprompt). Semua gaya lewat kelas karena CSP
   aplikasi hanya mengizinkan style dari origin sendiri.
   ============================================================ */
.pwa-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 110;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(23, 32, 51, 0.98);
  color: #fff;
  box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.35);
}

.pwa-banner[hidden] {
  display: none;
}

.pwa-banner-inner {
  width: min(1100px, 100%);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pwa-banner-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.pwa-banner-text strong {
  font-size: 14px;
}

.pwa-banner-text span {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.78);
}

.pwa-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.pwa-banner .button.ghost {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

.pwa-banner .button.ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}

@media (max-width: 560px) {
  .pwa-banner-actions {
    width: 100%;
  }

  .pwa-banner-actions .button {
    flex: 1;
  }
}
