:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-muted: #f1f5f9;
  --sidebar-bg: #eef2f7;
  --text: #0f172a;
  --muted: #64748b;
  --border: #d9e2ec;
  --accent: #0f766e;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --warn: #f59e0b;
  --danger: #dc2626;
  --code-bg: #e8eef5;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  --radius: 14px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1116;
  --panel: #141923;
  --panel-muted: #1d2430;
  --sidebar-bg: #111620;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #243044;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.15);
  --warn: #fbbf24;
  --danger: #f87171;
  --code-bg: #101520;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(to right, rgba(15, 23, 42, 0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15, 23, 42, 0.06) 1px, transparent 1px),
    radial-gradient(circle at 10% 20%, rgba(15, 118, 110, 0.12), transparent 45%),
    radial-gradient(circle at 90% 0%, rgba(56, 189, 248, 0.12), transparent 45%);
  background-size: 28px 28px, 28px 28px, auto, auto;
  min-height: 100vh;
}

.admin-body {
  display: block;
}

.admin-app {
  display: grid;
  grid-template-columns: minmax(230px, 260px) 1fr;
  min-height: 100vh;
}

.admin-sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand-title {
  font-weight: 600;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-nav-link {
  text-decoration: none;
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
}

.admin-nav-link:hover,
.admin-nav-link.is-active {
  background: var(--panel);
  color: var(--text);
  border-color: var(--border);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}

.admin-sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

.meta-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-label {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 10px;
}

.meta-value {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  color: var(--text);
  word-break: break-all;
}

.admin-main {
  padding: 28px 36px 64px;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.chip {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

.chip--muted {
  color: var(--muted);
}

.user-pill {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-width: 180px;
}

.user-name {
  font-weight: 600;
  font-size: 13px;
}

.user-email {
  font-size: 12px;
  color: var(--muted);
}

.admin-signin {
  min-height: 40px;
  display: flex;
  align-items: center;
}

.status-line {
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 13px;
  margin-bottom: 20px;
}

.status-line[data-tone="ok"] {
  border-color: rgba(15, 118, 110, 0.3);
  background: var(--accent-soft);
  color: var(--accent);
}

.status-line[data-tone="warn"] {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.14);
  color: var(--warn);
}

.status-line[data-tone="danger"] {
  border-color: rgba(220, 38, 38, 0.3);
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
}

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 32px;
}

.banner-title {
  font-weight: 600;
  font-size: 16px;
}

.banner-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.admin-section {
  margin-bottom: 36px;
}

.section-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.section-head h2 {
  margin: 0;
  font-size: 22px;
}

.section-head p {
  margin: 0;
  color: var(--muted);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card {
  padding: 16px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.metric-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.metric-value {
  font-size: 22px;
  font-weight: 600;
  margin: 8px 0 6px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

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

.section-grid {
  display: grid;
  gap: 18px;
}

.section-grid.two-col {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 0;
}

.panel-head h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.panel-body {
  padding: 16px 18px 18px;
}

.panel-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.panel-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

input,
select,
textarea {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.button-stack {
  display: grid;
  gap: 10px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn.small {
  padding: 6px 10px;
  font-size: 11px;
}

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

.btn.secondary {
  background: var(--panel-muted);
  color: var(--text);
  border-color: var(--border);
}

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

.btn.danger {
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.4);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

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

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

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

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--panel-muted);
  color: var(--muted);
}

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

.badge--warn {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warn);
}

.badge--danger {
  background: rgba(220, 38, 38, 0.12);
  color: var(--danger);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--panel-muted);
  font-size: 11px;
  margin-right: 6px;
  margin-bottom: 4px;
}

.list-stack {
  display: grid;
  gap: 10px;
}

.list-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--panel-muted);
  border: 1px solid var(--border);
}

.list-title {
  font-weight: 600;
  font-size: 13px;
}

.list-detail {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.list-meta {
  font-size: 12px;
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.code-textarea {
  width: 100%;
  min-height: 160px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  resize: vertical;
}

.code-block {
  margin: 0;
  padding: 14px 16px;
  background: var(--code-bg);
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 12px;
  overflow-x: auto;
}

[data-animate] {
  animation: fade-up 0.5s ease both;
  animation-delay: var(--delay, 0s);
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-animate] {
    animation: none;
  }

  .btn {
    transition: none;
  }
}

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

  .admin-sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .admin-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .admin-sidebar-footer {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
  }
}

@media (max-width: 720px) {
  .admin-main {
    padding: 24px 20px 56px;
  }

  .admin-topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .banner {
    flex-direction: column;
    align-items: flex-start;
  }

  .user-pill {
    width: 100%;
  }
}
