:root {
  --bg: #0b0f14;
  --surface: #141b24;
  --border: #2a3544;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --ok: #22c55e;
  --warn: #f59e0b;
  --error: #ef4444;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; text-decoration: none; }

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}
.auth-card { width: 100%; max-width: 420px; }
.brand { font-size: 28px; font-weight: 800; }
.subtitle { color: var(--muted); margin-top: 4px; }

label { display: block; margin: 0 0 6px; color: var(--muted); font-size: 13px; font-weight: 500; }
input, textarea, select, button {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #1c2633;
  color: var(--text);
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px #3b82f655;
}
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  color-scheme: dark;
}
select option {
  background: #1c2633;
  color: var(--text);
}
button {
  background: var(--primary);
  border: none;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 24px; }
.muted { color: var(--muted); margin: 4px 0 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}
.stat strong { display: block; font-size: 28px; }
.stat span { color: var(--muted); font-size: 12px; }

.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 12px; align-items: end; }
.grid-form .field { min-width: 0; }
.grid-form .full { grid-column: 1 / -1; }
.grid-form button { margin-top: 4px; }

.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; }
.alert.error { background: #ef444422; color: #fecaca; border: 1px solid #ef444455; }
.alert.ok { background: #22c55e22; color: #bbf7d0; border: 1px solid #22c55e55; }

.pill { padding: 8px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.ok { background: #22c55e22; color: var(--ok); }
.pill.warn { background: #f59e0b22; color: var(--warn); }
.btn.ghost { border: 1px solid var(--border); padding: 8px 12px; border-radius: 8px; }
.btn.download {
  display: inline-block;
  width: auto;
  margin-top: 12px;
  padding: 12px 20px;
}
.download-card .muted { margin-bottom: 4px; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.empty { text-align: center; color: var(--muted); }
.status { padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; text-transform: capitalize; }
.status.sent { background: #22c55e22; color: var(--ok); }
.status.pending, .status.processing { background: #f59e0b22; color: var(--warn); }
.status.failed { background: #ef444422; color: var(--error); }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 12px;
}
.section-head h2 { margin: 0 0 4px; }

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  align-items: center;
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #1c2633;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}
.page-btn:hover { border-color: #3b82f6; }
.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.page-btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.api-doc {
  background: #0f141b;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.api-doc-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  margin-bottom: 8px;
  font-weight: 700;
}
.code-block, code.token {
  display: block;
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
}
.code-block {
  background: #1c2633;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
code.token {
  color: #93c5fd;
}
.api-url {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.4;
}
.small { font-size: 12px; line-height: 1.5; }
.api-key-form { margin-bottom: 16px; }
.actions-cell { white-space: nowrap; }
.inline-form {
  display: inline-block;
  margin-right: 6px;
  margin-bottom: 4px;
}
.btn-inline {
  width: auto;
  margin-top: 0;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
}
.btn-inline.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-inline.danger {
  background: #ef444422;
  border: 1px solid #ef444455;
  color: #fecaca;
}

@media (max-width: 720px) {
  .stats { grid-template-columns: 1fr; }
  .grid-form { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
}
