:root {
  --bg: #0d0d0d;
  --bg-elev: #161616;
  --bg-panel: #1c1c1c;
  --line: #333;
  --text: #e8e8e8;
  --muted: #888;
  --accent: #f0f0f0;
  --danger: #d94a4a;
  --warn: #d4a017;
  --ok: #3d9e6f;
  --sidebar: 240px;
  --font: "IBM Plex Mono", "Consolas", "Courier New", monospace;
  --display: "Georgia", "Times New Roman", serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
}

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

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255,255,255,0.06), transparent 40%),
    linear-gradient(160deg, #111 0%, #0a0a0a 50%, #151515 100%);
}

.login-card {
  width: min(380px, 92vw);
  background: var(--bg-panel);
  border: 1px solid var(--line);
  padding: 28px 24px;
}

.login-brand {
  font-family: var(--display);
  font-size: 34px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-sub, .login-hint, .muted {
  color: var(--muted);
}

.login-sub { margin: 4px 0 22px; }
.login-hint { margin-top: 16px; font-size: 11px; }

.login-card label {
  display: block;
  margin: 10px 0 4px;
  color: #bbb;
  font-size: 11px;
}

.login-card input,
.search-input,
.select-input,
.field-input,
.field-textarea {
  width: 100%;
  background: #111;
  border: 1px solid #444;
  padding: 8px 10px;
  outline: none;
}

.login-card input:focus,
.search-input:focus,
.select-input:focus,
.field-input:focus,
.field-textarea:focus {
  border-color: #888;
}

.form-error {
  color: var(--danger);
  margin-top: 10px;
  font-size: 12px;
}

.btn {
  border: 1px solid #555;
  background: #222;
  color: var(--text);
  padding: 7px 12px;
  cursor: pointer;
}

.btn:hover { background: #2c2c2c; }
.btn-primary { background: #f2f2f2; color: #111; border-color: #f2f2f2; }
.btn-primary:hover { background: #ddd; }
.btn-danger { background: #3a1515; border-color: #8a3030; color: #ffb4b4; }
.btn-danger:hover { background: #4a1c1c; }
.btn-warn { background: #3a2e10; border-color: #8a7020; color: #ffd97a; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; margin-top: 14px; }
.btn-sm { padding: 4px 8px; font-size: 11px; }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #121212;
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 22px;
  padding: 4px 6px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #666;
  font-family: var(--display);
  font-size: 18px;
}

.sidebar-brand small {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  padding: 9px 10px;
  cursor: pointer;
  color: #bbb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-item:hover { background: #1a1a1a; color: #fff; }
.nav-item.active {
  background: #222;
  border-color: #444;
  color: #fff;
}

.badge {
  background: var(--warn);
  color: #111;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: bold;
}

.sidebar-footer { margin-top: auto; }
.admin-identity {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
  padding: 0 4px;
}

.main {
  padding: 18px 22px 40px;
  min-width: 0;
}

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

.topbar h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 26px;
  font-weight: normal;
}

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

.view { display: none; }
.view.active { display: block; }

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

.stat-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  padding: 14px;
}

.stat-card .label { color: var(--muted); font-size: 11px; }
.stat-card .value {
  font-family: var(--display);
  font-size: 28px;
  margin-top: 6px;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  padding: 14px;
  margin-bottom: 14px;
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 15px;
  font-family: var(--display);
  font-weight: normal;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.search-input { max-width: 360px; }
.select-input { max-width: 220px; }

.split {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 12px;
  align-items: start;
}

.table-panel { overflow: auto; max-height: calc(100vh - 160px); padding: 0; }
.detail-panel { min-height: 280px; position: sticky; top: 12px; }

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

.data-table th,
.data-table td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid #2a2a2a;
  vertical-align: top;
}

.data-table th {
  position: sticky;
  top: 0;
  background: #202020;
  color: #aaa;
  font-size: 11px;
  font-weight: normal;
  z-index: 1;
}

.data-table tbody tr {
  cursor: pointer;
}

.data-table tbody tr:hover { background: #222; }
.data-table tbody tr.active { background: #2a2a2a; }

.pill {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid #555;
  font-size: 10px;
}

.pill.ok { border-color: #2f6b4d; color: #8fd6b0; }
.pill.danger { border-color: #8a3030; color: #ffb4b4; }
.pill.warn { border-color: #8a7020; color: #ffd97a; }
.pill.info { border-color: #456; color: #9ab; }

.detail-header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.detail-header img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border: 1px solid #444;
  background: #111;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.posts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  margin-top: 10px;
}

.post-item {
  border: 1px solid #333;
  padding: 8px;
  background: #141414;
}

.post-item .meta {
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 4px;
}

.field-group { margin-bottom: 10px; }
.field-group label {
  display: block;
  margin-bottom: 4px;
  color: #aaa;
  font-size: 11px;
}

.field-textarea { min-height: 90px; resize: vertical; }

.evidence-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.evidence-list a {
  color: #cfcfcf;
  font-size: 11px;
}

.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #222;
  border: 1px solid #555;
  padding: 10px 14px;
  min-width: 220px;
  max-width: 360px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.toast.error { border-color: #8a3030; }
.toast.success { border-color: #2f6b4d; }

.modal[hidden], [hidden] { display: none !important; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.72);
}

.modal-card {
  position: relative;
  width: min(480px, 92vw);
  background: #1a1a1a;
  border: 1px solid #444;
  z-index: 1;
}

.modal-header, .modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #333;
}

.modal-footer {
  border-bottom: none;
  border-top: 1px solid #333;
  justify-content: flex-end;
  gap: 8px;
}

.modal-header h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: normal;
}

.modal-body { padding: 14px; }

.icon-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .split { grid-template-columns: 1fr; }
  .detail-panel { position: static; }
}
