:root {
  color-scheme: dark;
  --ink: #f4f4f5;
  --muted: #a1a1aa;
  --line: #333333;
  --surface: #1f1f1f;
  --surface-soft: #121212;
  --surface-hover: #2b2b2b;
  --nav: #0f0f0f;
  --accent: #4b5563;
  --accent-2: #9ca3af;
  --danger: #ff9ca7;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html {
  min-height: 100%;
  background: var(--surface-soft);
}
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--surface-soft);
  font-family: Arial, Helvetica, sans-serif;
}
button, input, select, textarea { font: inherit; }
button {
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  padding: 10px 14px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}
button:hover { background: #374151; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  color: var(--ink);
  background: #262626;
}
option {
  color: var(--ink);
  background: #262626;
}
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--ink);
  box-shadow: 0 0 0 1000px #262626 inset;
  transition: background-color 9999s ease-in-out 0s;
}
::selection {
  color: #ffffff;
  background: var(--accent);
}
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: #121212;
}
::-webkit-scrollbar-thumb {
  border: 2px solid #121212;
  border-radius: 999px;
  background: #525252;
}
textarea { resize: vertical; }
label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 8px; color: var(--accent-2); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.error { color: var(--danger); min-height: 20px; }
.stack { display: grid; gap: 14px; }

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(156, 163, 175, .16), transparent 42%),
    var(--surface-soft);
}
.login-panel {
  display: grid;
  gap: 24px;
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 32px;
  background: var(--surface);
  box-shadow: 0 18px 42px rgba(0,0,0,.35);
}
.login-panel h1 { margin: 0; }
.login-brand {
  display: grid;
  gap: 18px;
}
.brand-logo-full {
  display: block;
  width: min(270px, 82%);
  height: auto;
  object-fit: contain;
  opacity: .96;
  filter: brightness(1.18) contrast(1.05) drop-shadow(0 12px 24px rgba(0,0,0,.38));
}
.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: #e5e5e5;
  font-size: 12px;
  background: #262626;
}

.app-shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 28px;
  height: 100vh;
  padding: 24px;
  background: var(--nav);
}
.sidebar h1, .topbar h2 { margin: 0; }
.sidebar-brand {
  display: grid;
  gap: 14px;
}
.brand-mark {
  display: block;
  width: 56px;
  height: 56px;
  border-radius: 13px;
  object-fit: cover;
  box-shadow: 0 12px 26px rgba(0,0,0,.32);
}
.sidebar nav { display: grid; align-content: start; gap: 8px; }
.nav-button, .ghost-button {
  border: 1px solid rgba(255,255,255,.12);
  color: var(--ink);
  background: transparent;
  text-align: left;
}
.nav-button.active { color: #fff; background: var(--accent); }
.ghost-button:hover, .nav-button:hover { background: var(--surface-hover); }
.user-box { display: grid; gap: 8px; border-top: 1px solid rgba(255,255,255,.12); padding-top: 18px; }
.user-box span { color: var(--muted); font-size: 13px; }

.workspace { min-width: 0; padding: 28px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.view { min-width: 0; }
.metrics-grid { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 14px; }
.metric, .panel, .article-detail, .article-card, .article-form {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.metric { display: grid; gap: 8px; padding: 18px; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { font-size: 30px; }
.panel { margin-top: 18px; padding: 20px; }
.panel h3 { margin: 0 0 14px; }
.events-list { display: grid; gap: 10px; }
.event-row { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding-top: 10px; color: var(--muted); }

.filters { display: grid; grid-template-columns: minmax(260px,1.5fr) repeat(4,minmax(150px,1fr)); gap: 10px; margin-bottom: 16px; }
.content-grid { display: grid; grid-template-columns: minmax(290px, 420px) 1fr; gap: 16px; align-items: start; }
.article-list { display: grid; gap: 10px; }
.article-card { display: grid; gap: 9px; padding: 14px; cursor: pointer; }
.article-card.active { border-color: var(--accent-2); box-shadow: 0 0 0 2px rgba(156,163,175,.18); }
.article-card h3 { margin: 0; font-size: 16px; }
.article-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.article-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.article-detail { min-height: 520px; padding: 22px; }
.article-detail h3 { margin: 0 0 10px; font-size: 26px; }
.article-detail .body { color: #e5e5e5; line-height: 1.65; white-space: pre-wrap; }
.empty-state { display: grid; place-items: center; color: var(--muted); text-align: center; }
.detail-actions, .form-actions, .upload-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }
.detail-actions .ghost-button { color: var(--ink); }
.article-image { margin: 18px 0; border: 1px solid var(--line); border-radius: 9px; padding: 10px; background: #181818; white-space: normal; }
.article-image img { display: block; width: 100%; max-height: 520px; object-fit: contain; border-radius: 7px; }
.comments-panel { display: grid; gap: 12px; border-top: 1px solid var(--line); margin-top: 22px; padding-top: 18px; }
.comment-form { display: grid; gap: 10px; }
.comment-form button { justify-self: end; }
.comment-item { border: 1px solid var(--line); border-radius: 9px; padding: 12px; background: #181818; }
.comment-item header { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; color: var(--muted); }
.comment-item p { margin: 0; line-height: 1.5; }

.article-form { padding: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(220px,1fr)); gap: 14px; }
.form-grid.compact { grid-template-columns: repeat(2, minmax(0,1fr)); }
.span-2 { grid-column: span 2; }
.form-actions { justify-content: flex-end; }
.form-message { min-height: 20px; color: var(--accent-2); font-weight: 700; }
.upload-button { display: inline-flex; width: auto; min-height: 40px; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 7px; padding: 10px 14px; cursor: pointer; }
.upload-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.users-layout { display: grid; grid-template-columns: minmax(360px,520px) 1fr; gap: 16px; align-items: start; }
.users-list { display: grid; gap: 10px; }
.user-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 9px; padding: 12px; background: #181818; }
.user-row.inactive { opacity: .58; }
.user-row div { display: grid; gap: 4px; }
.user-row span { color: var(--muted); font-size: 13px; }
.danger-button { color: #ffb3b9; border-color: rgba(255,156,167,.4); }
.governance-grid { display: grid; grid-template-columns: repeat(3, minmax(220px,1fr)); gap: 16px; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .metrics-grid, .filters, .content-grid, .users-layout, .governance-grid, .form-grid, .form-grid.compact { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
}
