/*
 * SaveEarth Admin Panel — single self-contained stylesheet. No external
 * fonts/CDNs/JS frameworks. Light + dark (prefers-color-scheme), responsive
 * down to phone widths.
 */

:root {
  --se-green-50:  #eafaf3;
  --se-green-100: #cdf0dd;
  --se-green-300: #79d1a6;
  --se-green-500: #1f9d63;
  --se-green-600: #178055;
  --se-green-700: #12643f;

  --amber-500: #b9770e;
  --amber-100: #fbe8c8;
  --red-500:   #c0392b;
  --red-100:   #f8d7d2;
  --blue-100:  #dbe9fb;
  --blue-500:  #2f6fb0;

  --surface:      #ffffff;
  --surface-alt:  #f4f7f5;
  --border:       #dbe4de;
  --text:         #16211c;
  --text-muted:   #5b6b62;
  --shadow:       0 1px 2px rgba(16, 40, 28, 0.06), 0 1px 8px rgba(16, 40, 28, 0.05);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --se-green-50:  #123424;
    --se-green-100: #163f2b;
    --se-green-300: #2f8a5d;
    --se-green-500: #3fc788;
    --se-green-600: #59d69a;
    --se-green-700: #85e2b4;

    --amber-500: #e0a83c;
    --amber-100: #3a2e10;
    --red-500:   #e5695c;
    --red-100:   #3a1917;
    --blue-100:  #142a3e;
    --blue-500:  #6fa8dc;

    --surface:     #131a16;
    --surface-alt: #1a221d;
    --border:      #2a352d;
    --text:        #e8f0ea;
    --text-muted:  #9fb1a6;
    --shadow:      0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 10px rgba(0, 0, 0, 0.3);

    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--surface-alt);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
code {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05em 0.4em;
  font-size: 0.9em;
}

a { color: var(--se-green-600); }
a:hover { color: var(--se-green-700); }

.muted { color: var(--text-muted); }
.small { font-size: 0.85em; }

/* ------------------------------------------------------------- top nav -- */

.topbar {
  background: var(--se-green-700);
  color: #fff;
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.6rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.4em;
  white-space: nowrap;
}
.brand:hover { color: #fff; opacity: 0.9; }

.mainnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  flex: 1;
}
.mainnav a {
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  font-size: 0.92rem;
}
.mainnav a:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.88rem;
}
.who { display: flex; align-items: center; gap: 0.4em; white-space: nowrap; }

.role-badge {
  display: inline-block;
  padding: 0.1em 0.5em;
  border-radius: 999px;
  font-size: 0.75em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: rgba(255, 255, 255, 0.2);
}
.role-badge.role-superadmin { background: var(--amber-500); color: #1a1a1a; }

/* ------------------------------------------------------------ container -- */

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.25rem;
}
.footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ---------------------------------------------------------------- flash -- */

.flash {
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.92rem;
  border: 1px solid transparent;
}
.flash-success { background: var(--se-green-50); border-color: var(--se-green-300); color: var(--se-green-700); }
.flash-error   { background: var(--red-100);     border-color: var(--red-500);      color: var(--red-500); }

/* ----------------------------------------------------------------- card -- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.notice-card { max-width: 640px; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  align-items: start;
}
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------- stat grid -- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .stat-grid { grid-template-columns: 1fr; } }

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.stat-tile-alert { border-color: var(--amber-500); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); }
.stat-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-link { font-size: 0.82rem; margin-top: 0.15rem; }

/* ------------------------------------------------------------- bar chart -- */

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  height: 160px;
  padding: 0.5rem 0.25rem 0;
  overflow-x: auto;
}
.bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  flex: 1;
  min-width: 2.5rem;
}
.bar-value { font-size: 0.78rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.bar-track {
  width: 100%;
  height: 110px;
  display: flex;
  align-items: flex-end;
  background: var(--surface-alt);
  border-radius: 4px;
}
.bar-fill {
  width: 100%;
  min-height: 2px;
  background: var(--se-green-500);
  border-radius: 4px 4px 0 0;
}
.bar-label { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; }

.table-toggle { margin-top: 0.75rem; }
.table-toggle summary { cursor: pointer; color: var(--se-green-600); font-size: 0.88rem; }

/* ------------------------------------------------------------------ kv --- */

.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 0.9rem; margin: 0; }
.kv dt { color: var(--text-muted); font-size: 0.85rem; }
.kv dd { margin: 0; word-break: break-word; }

/* --------------------------------------------------------------- tables -- */

.table-wrap { overflow-x: auto; border-radius: 10px; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.9rem;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.data-table td.muted { white-space: normal; }
.compact-table th, .compact-table td { padding: 0.4rem 0.6rem; }

.meta-pre {
  margin: 0;
  max-width: 320px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.82rem;
}

/* --------------------------------------------------------------- badges -- */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.15em 0.6em;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.status-pill::before { content: "●"; font-size: 0.7em; }
.status-active    { background: var(--se-green-100); color: var(--se-green-700); }
.status-suspended { background: var(--amber-100);    color: var(--amber-500); }
.status-banned    { background: var(--red-100);      color: var(--red-500); }
.status-pending   { background: var(--amber-100);    color: var(--amber-500); }
.status-accepted  { background: var(--se-green-100); color: var(--se-green-700); }
.status-declined  { background: var(--red-100);      color: var(--red-500); }

/* ------------------------------------------------------- access-request PIN -- */

.pin-relay {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.75rem;
}
.pin-code {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--se-green-700);
}

.badge {
  display: inline-block;
  padding: 0.15em 0.55em;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  text-transform: capitalize;
}
.badge-message { background: var(--blue-100); color: var(--blue-500); }
.badge-user     { background: var(--se-green-100); color: var(--se-green-700); }
.badge-group, .badge-channel { background: var(--amber-100); color: var(--amber-500); }
.badge-role-superadmin { background: var(--amber-100); color: var(--amber-500); }

/* ------------------------------------------------------- admins (Batch 6) -- */

.perm-list { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.totp-reveal { border-color: var(--amber-500); }
.totp-uri { display: inline-block; word-break: break-all; }

.reason-pill {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.1em 0.5em;
  font-size: 0.78rem;
}

/* ----------------------------------------------------------------- forms -- */

form label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}
input[type="text"], input[type="search"], input[type="email"], input[type="password"],
select, textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; min-height: 2.4em; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--se-green-500);
  outline-offset: 1px;
}

.filter-bar {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  align-items: center;
}
.filter-bar input[type="search"] { flex: 1; min-width: 220px; margin-top: 0; }
.filter-bar select { width: auto; margin-top: 0; }

.action-forms { display: flex; flex-direction: column; gap: 0.9rem; }
.action-form { border-top: 1px solid var(--border); padding-top: 0.75rem; }
.action-form:first-child { border-top: none; padding-top: 0; }

.inline-form { display: inline-block; margin: 0; }
.action-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.action-inline input[type="text"] { width: auto; flex: 1; min-width: 160px; margin-top: 0; }

.config-form { display: flex; flex-direction: column; gap: 0.6rem; }
.config-row { display: grid; grid-template-columns: 220px 1fr; gap: 0.75rem; align-items: center; }
.config-key { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 0.85rem; color: var(--text); }
@media (max-width: 640px) { .config-row { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------- buttons -- */

.btn {
  display: inline-block;
  padding: 0.5rem 0.95rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.3;
}
.btn-block { width: 100%; text-align: center; margin-top: 0.5rem; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.82rem; }

.btn-primary   { background: var(--se-green-600); color: #fff; }
.btn-primary:hover   { background: var(--se-green-700); }
.btn-secondary { background: var(--surface-alt); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-warn      { background: var(--amber-500); color: #1a1a1a; }
.btn-warn:hover      { opacity: 0.9; }
.btn-danger    { background: var(--red-500); color: #fff; }
.btn-danger:hover    { opacity: 0.9; }
.btn-ghost     { background: transparent; color: inherit; border-color: rgba(255, 255, 255, 0.4); }
.btn-ghost:hover     { background: rgba(255, 255, 255, 0.12); }

/* ----------------------------------------------------------- report list -- */

.report-list { display: flex; flex-direction: column; gap: 1rem; }
.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
}
.report-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
  font-size: 0.85rem;
}
.report-id { font-weight: 700; }
.target-preview {
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  margin: 0.4rem 0;
}
.message-preview {
  margin: 0.4rem 0 0;
  padding-left: 0.75rem;
  border-left: 3px solid var(--border);
  color: var(--text);
}
.reporter-note { font-size: 0.9rem; }
.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* ------------------------------------------------------------ login page -- */

body.bare {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--se-green-700), var(--se-green-600));
}
.bare-wrap { width: 100%; max-width: 420px; padding: 1rem; }

.auth-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 1.75rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.auth-brand h1 { font-size: 1.25rem; margin: 0; }
.brand-mark { font-size: 1.4rem; }

.dev-hint {
  background: var(--blue-100);
  color: var(--blue-500);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font-size: 0.82rem;
  margin-bottom: 1rem;
}

/* ------------------------------------------------------------ small nav -- */

@media (max-width: 640px) {
  .topbar-inner { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .topbar-user { margin-left: 0; justify-content: space-between; }
}
