:root {
  --bg: #0a0a0f;
  --surface: #111118;
  --border: #1e1e2e;
  --accent: #3b82f6;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --text: #f1f5f9;
  --muted: #64748b;
  --sidebar-w: 240px;
  --font: 'IBM Plex Sans', 'Inter', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', 'JetBrains Mono', monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

.admin-notice {
  position: relative;
  padding: 0.5rem 2.25rem 0.5rem 0.75rem;
  font-size: 12px;
  background: rgba(245, 158, 11, 0.15);
  border-bottom: 1px solid var(--warning);
  color: var(--text);
}
.admin-notice code {
  font-size: 11px;
}
.admin-notice-dismiss {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.25rem;
}
.admin-notice-dismiss:hover {
  color: var(--text);
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
}

.sidebar-brand {
  padding: 1.25rem 1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  color: var(--accent);
  margin-right: 0.35rem;
}

.sidebar-nav {
  padding: 0.75rem 0;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: block;
  padding: 0.6rem 1rem;
  color: var(--muted);
  text-decoration: none;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.nav-item.active {
  color: var(--text);
  background: rgba(59, 130, 246, 0.08);
  border-left-color: var(--accent);
}

.sidebar-foot {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.nav-user {
  font-size: 12px;
  color: var(--danger);
  margin-bottom: 0.5rem;
  word-break: break-all;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font: inherit;
}

.btn-link:hover {
  text-decoration: underline;
}

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 1.5rem 2rem;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 100vh;
}

.page-title {
  margin: 0 0 1.25rem;
  font-size: 1.35rem;
  font-weight: 600;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.page-head .page-title {
  margin: 0;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.stat-num {
  font-size: 2rem;
  font-weight: 600;
  margin: 0.35rem 0;
}

.stat-sub {
  font-size: 12px;
  color: var(--muted);
}

.section-title {
  font-size: 1rem;
  margin: 0 0 0.75rem;
  color: var(--muted);
}

.mono {
  font-family: var(--mono);
  font-size: 13px;
}

.inp {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
  font: inherit;
  min-width: 140px;
}

.inp:focus {
  outline: none;
  border-color: var(--accent);
}

.inp-search {
  min-width: 200px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

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

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.2rem 0.5rem;
}

.btn-icon:hover {
  color: var(--text);
}

.page-loading,
.page-error {
  color: var(--muted);
}

.text-danger {
  color: var(--danger);
}

.row-muted {
  opacity: 0.6;
}

.italic {
  font-style: italic;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1rem;
}

.danger-zone {
  border-color: rgba(239, 68, 68, 0.45);
}

.sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

.sql-area {
  width: 100%;
  min-height: 120px;
  font-family: var(--mono);
  font-size: 13px;
  margin: 0.5rem 0;
}

.env-block {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  white-space: pre-wrap;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.mini-table th,
.mini-table td {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.pager {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  color: var(--muted);
}

.field {
  margin-bottom: 0.85rem;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.field-row {
  display: flex;
  gap: 1rem;
}

.field-row .field {
  flex: 1;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0.5rem 0 0;
}

.signin-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
}

.signin-wrap {
  width: 100%;
  max-width: 420px;
  padding: 1.5rem;
}

.signin-title {
  text-align: center;
  margin-bottom: 1.5rem;
  font-weight: 600;
}

.audit-filters {
  flex-wrap: wrap;
}

.audit-table-wrap {
  max-height: calc(100vh - 220px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.audit-table {
  width: 100%;
  border-collapse: collapse;
}

.audit-table th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.audit-json {
  margin: 0;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  font-size: 12px;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.audit-expand td {
  border-top: none !important;
}
