/* =========================================================
   NekoLabs Admin — stylesheet mandiri (tidak lagi bergantung
   pada /css/style.css). Gaya disamakan dengan halaman docs:
   monospace, sudut tajam, border tipis abu, aksen slate gelap.
   Mode gelap aktif lewat class "dark" di <html>.
   ========================================================= */

:root {
  --font: 'Ubuntu Mono', 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --bg: #f8fafc;
  --surface: #ffffff;
  --panel: #f8fafc;
  --ink: #0f172a;
  --ink-hover: #1e293b;
  --on-ink: #ffffff;
  --text: #334155;
  --desc: #64748b;
  --muted: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --badge: #374151;
  --danger: #b91c1c;

  color-scheme: light;
}

html.dark {
  --bg: #0b1120;
  --surface: #111a2e;
  --panel: #0f1829;
  --ink: #e2e8f0;
  --ink-hover: #f8fafc;
  --on-ink: #0b1120;
  --text: #cbd5e1;
  --desc: #94a3b8;
  --muted: #64748b;
  --line: #1e293b;
  --line-strong: #334155;
  --badge: #475569;
  --danger: #f87171;

  color-scheme: dark;
}

* {
  box-sizing: border-box;
  border-radius: 0;
}

html { background: var(--bg); }

html, body {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(900px 520px at 100% 0%, color-mix(in srgb, var(--surface) 90%, transparent) 0%, transparent 70%),
    var(--bg);
}

h1, h2, h3, h4, p { margin: 0; }
a { color: var(--ink); }
[hidden] { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

::placeholder { color: var(--muted); opacity: 1; }

code {
  font-family: inherit;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 0 0.3rem;
  color: var(--ink);
}

.adm-dim { color: var(--desc); }
.small, .adm-dim.small { font-size: 0.75rem; }
.mono { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ============ TOPBAR ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  max-width: 72rem;
  min-height: 48px;
  margin: 0 auto;
  padding: 0 20px;
}

.brand { font-size: 14px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.brand .adm-dim { font-weight: 400; }

.topbar-actions { display: flex; align-items: center; gap: 14px; }

.toplink {
  background: none;
  border: 0;
  padding: 0;
  font-size: 12px;
  color: var(--desc);
  text-decoration: none;
}
.toplink:hover { color: var(--ink); }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink);
}
.theme-toggle:hover { background: var(--bg); }
.ico { width: 16px; height: 16px; }
.ico-moon { display: none; }
html.dark .ico-sun { display: none; }
html.dark .ico-moon { display: inline; }

.adm-main { max-width: 72rem; margin: 0 auto; padding: 32px 20px 64px; }

/* ============ BUTTON ============ */
.adm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
}
.adm-btn:hover { background: var(--bg); }
.adm-btn.solid { background: var(--ink); color: var(--on-ink); }
.adm-btn.solid:hover { background: var(--ink-hover); border-color: var(--ink-hover); }
.adm-btn.ghost { border-color: var(--line-strong); font-weight: 400; }
.adm-btn.tiny { height: 28px; padding: 0 9px; font-size: 11px; }
.adm-btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* ============ FORM CONTROLS ============ */
input[type="text"], input[type="password"], input[type="number"], input[type="search"], select {
  height: 36px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: 13px;
  -webkit-appearance: none;
  appearance: none;
}
select { padding-right: 8px; }
input:focus, select:focus { outline: none; border-color: var(--ink); }
input[type="checkbox"] { accent-color: var(--ink); }

/* ============ LOGIN ============ */
.login-wrap { min-height: calc(100dvh - 12rem); display: grid; place-items: center; }

.login-card {
  display: grid;
  gap: 14px;
  width: min(22rem, 100%);
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.login-title { font-size: 16px; color: var(--ink); }
.login-card input { width: 100%; height: 44px; }
.login-err {
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--danger);
  color: var(--ink);
  font-size: 12px;
}

/* ============ STAT CARDS ============ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.stat-label { font-size: 12px; color: var(--desc); }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.2; color: var(--ink); }
.stat-note { font-size: 11px; }

/* ============ TABS ============ */
.adm-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin-bottom: 20px;
  background: var(--line);
  border: 1px solid var(--line);
}
.adm-tab {
  height: 42px;
  padding: 0 8px;
  border: 0;
  background: var(--surface);
  color: var(--desc);
  font-size: 13px;
  font-weight: 700;
}
.adm-tab:hover:not(.active) { color: var(--ink); background: var(--bg); }
.adm-tab.active { background: var(--ink); color: var(--on-ink); }

.tab-body:not([hidden]) { animation: adm-tab-in 0.18s ease both; }
@keyframes adm-tab-in {
  from { opacity: 0.4; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.adm-h { font-size: 14px; font-weight: 700; color: var(--ink); margin-bottom: 10px; }
.adm-h .small { font-weight: 400; }
.tab-body > .adm-h + .top-list { margin-bottom: 28px; }

/* ============ TOP ENDPOINTS ============ */
.top-list { background: var(--surface); }
.top-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-bottom: none;
  font-size: 12px;
  color: var(--ink);
}
.top-row:last-child { border-bottom: 1px solid var(--line); }
.top-row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-row .count { font-weight: 700; }
.top-row .bar-wrap { grid-column: 1 / -1; height: 3px; background: var(--line); }
.top-row .bar { height: 100%; background: var(--ink); }

/* ============ TABLE ============ */
.table-wrap { background: var(--surface); border: 1px solid var(--line); overflow-x: auto; }
.adm-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.adm-table th {
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  color: var(--desc);
}
.adm-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--text);
}
.adm-table tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  min-width: 34px;
  padding: 1px 8px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--desc);
  font-size: 11px;
  font-weight: 700;
}
.badge.on { background: var(--badge); border-color: var(--badge); color: #fff; }
.badge.warn { border-color: var(--ink); color: var(--ink); }
.badge.err { border-color: var(--danger); color: var(--danger); }

/* ============ KEYS & USERS ============ */
.card-pad { padding: 20px; background: var(--surface); border: 1px solid var(--line); }
.card-pad > .adm-h { margin-bottom: 4px; }
.card-pad > .adm-dim { display: block; margin-bottom: 16px; }
.key-create { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; margin-bottom: 20px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.user-avatar { width: 28px; height: 28px; display: block; object-fit: cover; border: 1px solid var(--line); }

/* ============ REQUEST LOG ============ */
.req-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.req-toolbar input[type="search"] { flex: 1 1 16rem; min-width: 10rem; }
.req-auto { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--desc); white-space: nowrap; }
.req-meta { margin-bottom: 8px; }

.req-table { min-width: 62rem; }
.req-table td { white-space: nowrap; }
.req-table tbody tr.req-row { cursor: pointer; }
.req-table tbody tr.req-row:hover { background: var(--bg); }
.req-table .req-path { max-width: 22rem; overflow: hidden; text-overflow: ellipsis; font-weight: 700; color: var(--ink); }
.req-table .req-loc { max-width: 13rem; overflow: hidden; text-overflow: ellipsis; }
.req-table .req-ua { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; }

.req-detail > td { padding: 16px; white-space: normal; background: var(--panel); }
.req-detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 12px 20px; }
.req-field { min-width: 0; }
.req-field .k { display: block; margin-bottom: 2px; font-size: 11px; color: var(--desc); }
.req-field .v { display: block; font-size: 12px; color: var(--ink); overflow-wrap: anywhere; }
.req-block { margin-top: 16px; }
.req-block:first-child { margin-top: 0; }
.req-block h4 { margin: 0 0 6px; font-size: 11px; font-weight: 700; color: var(--desc); }
.req-query { display: flex; flex-wrap: wrap; gap: 6px; }
.req-q { padding: 1px 7px; background: var(--surface); border: 1px solid var(--line); font-size: 11px; color: var(--ink); overflow-wrap: anywhere; }
.req-pre {
  margin: 0;
  padding: 10px 12px;
  max-height: 16rem;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: inherit;
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.req-map { display: block; width: 100%; height: 18rem; margin-bottom: 6px; background: var(--surface); border: 1px solid var(--line); }

.req-pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 10px; }
.req-note { max-width: 60rem; margin-top: 12px; line-height: 1.6; }

/* ============ DIALOG & TOAST ============ */
.adm-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.45);
}
.adm-dialog { width: 100%; max-width: 24rem; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); }
.adm-dialog p { margin-bottom: 14px; color: var(--ink); font-size: 13px; }
.adm-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.adm-toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 100;
  max-width: 24rem;
  padding: 9px 14px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 12px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: transform 0.18s ease, opacity 0.18s ease;
}
.adm-toast.show { opacity: 1; transform: translateY(0); }

/* ============ RESPONSIVE ============ */
@media (max-width: 48rem) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .adm-tabs { grid-template-columns: repeat(2, 1fr); }
  .key-create { grid-template-columns: 1fr; }
  .req-pager { justify-content: space-between; }
}

@media (max-width: 400px) {
  .brand .adm-dim { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tab-body:not([hidden]) { animation: none; }
  .adm-toast { transition: none; }
}