:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e6e8ec;
  --text: #111827;
  --muted: #6b7280;
  --brand: #00a884;
  --brand-dark: #008069;
  --danger: #dc2626;
  --warn: #d97706;
  --info: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 18px; margin: 0; }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 32px; display: grid; gap: 14px; box-shadow: var(--shadow);
}
.login-card label { display: grid; gap: 6px; font-weight: 500; font-size: 13px; }

/* Layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border); padding: 20px 14px;
  display: flex; flex-direction: column; gap: 20px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; padding: 0 8px; }
.logo {
  width: 28px; height: 28px; border-radius: 8px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
#nav { display: grid; gap: 2px; }
#nav a {
  padding: 9px 10px; border-radius: 8px; color: #374151; font-weight: 500;
  display: flex; justify-content: space-between; align-items: center;
}
#nav a:hover { background: #f3f4f6; }
#nav a.active { background: #e7f6f2; color: var(--brand-dark); }
.pill { background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 600; }
.pill:empty { display: none; }
.me { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--border); display: grid; gap: 4px; }
.me #me-name { font-weight: 600; }
.main { padding: 28px 32px 60px; min-width: 0; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

/* Controls */
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
  border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 9px 11px; outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0, 168, 132, 0.12); }
textarea { resize: vertical; min-height: 84px; width: 100%; }
.btn {
  border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 8px 14px; cursor: pointer;
  font-weight: 600; white-space: nowrap;
}
.btn:hover { background: #f9fafb; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.warn { color: var(--warn); border-color: #f3d19e; }
.btn.ghost { border-color: transparent; background: transparent; padding-left: 0; text-align: left; color: var(--muted); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Cards & stats */
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px; }
.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat.alert .value { color: var(--danger); }
.two-col { grid-template-columns: 1fr 1fr; }
.card h2 { font-size: 14px; margin: 0 0 14px; font-weight: 600; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; }
tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #fafbfc; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: #e5e7eb; flex-shrink: 0; object-fit: cover;
  display: grid; place-items: center; font-weight: 600; color: #4b5563; font-size: 13px;
}
.person .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: #f3f4f6; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #f3f4f6; color: #374151; }
.badge.active, .badge.resolved, .badge.cleared { background: #e7f6f2; color: var(--brand-dark); }
.badge.suspended, .badge.medium, .badge.reviewing, .badge.investigating { background: #fef3c7; color: #92400e; }
.badge.banned, .badge.high, .badge.open { background: #fee2e2; color: #991b1b; }
.badge.low, .badge.dismissed { background: #f3f4f6; color: #4b5563; }
.badge.business { background: #e0e7ff; color: #3730a3; }
.badge.admin, .badge.moderator { background: #111827; color: #fff; }
.badge.actioned { background: #ede9fe; color: #5b21b6; }

.pager { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); }

/* Charts */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bar { flex: 1; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; opacity: 0.85; }
.bar:hover { opacity: 1; }
.bar span { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--muted); }
.bar-labels { display: flex; gap: 6px; margin-top: 6px; }
.bar-labels div { flex: 1; text-align: center; font-size: 10px; color: var(--muted); }

.feed { display: grid; }
.feed-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: center; }
.feed-item:last-child { border-bottom: none; }
.feed-item .what { flex: 1; min-width: 0; }
.feed-item .when { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* Drawer */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(17, 24, 39, 0.35); }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(720px, 100%); background: var(--bg);
  overflow-y: auto; padding: 28px; box-shadow: -8px 0 24px rgba(0, 0, 0, 0.08);
}
.drawer-close { position: absolute; top: 14px; right: 18px; border: none; background: none; font-size: 26px; cursor: pointer; color: var(--muted); }
.section { margin-top: 18px; }
.section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; }
.kv div:nth-child(odd) { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 6px; font-weight: 500; font-size: 13px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
pre.json { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 12px; margin: 0; }
.message { padding: 8px 12px; background: #fff; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; }
.message .meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff;
  padding: 10px 18px; border-radius: 8px; z-index: 60; font-weight: 500;
}
.toast.error { background: var(--danger); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  #nav { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .main { padding: 20px 16px; }
}
