/* Modbot dashboard — Discord's own palette, so the tool reads as an
   extension of the client the moderators already have open all day.
   Status colours are identical to the bot's embed colours in app/ui.py:
   red means the same thing here as it does in the modlog. */

:root {
  color-scheme: dark;

  --bg-deep:   #1e1f22;   /* sidebar, page behind everything */
  --bg:        #313338;   /* content area */
  --bg-card:   #2b2d31;   /* cards, table headers */
  --bg-hover:  #35373c;
  --bg-input:  #1e1f22;
  --line:      #3f4147;

  --ink:       #f2f3f5;
  --ink-dim:   #b5bac1;
  --ink-faint: #80848e;

  --accent:    #5865f2;
  --accent-dim:#4752c4;
  --danger:    #ed4245;
  --success:   #57f287;
  --warning:   #fee75c;

  --radius: 8px;
  --sidebar-w: 236px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* The icon sprite is markup, not content: never let it take up space. */
.sprite { display: none; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }

.icon { width: 18px; height: 18px; flex: 0 0 auto; }
.icon-sm { width: 15px; height: 15px; }

/* ---------------------------------------------------------- layout */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.brand .dot {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent);
  display: grid; place-items: center;
  color: #fff;
}
.brand small { display: block; color: var(--ink-faint); font-weight: 400; font-size: 12px; }

.nav { padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 6px;
  color: var(--ink-dim); font-size: 14px; font-weight: 500;
}
.nav a:hover { background: var(--bg-hover); color: var(--ink); }
.nav a.on { background: var(--accent); color: #fff; }

.me {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-top: 1px solid var(--line);
  font-size: 13px;
}
.me img { width: 30px; height: 30px; border-radius: 50%; }
.me .who { flex: 1; min-width: 0; }
.me .who b { display: block; font-weight: 600; }
.me .who span { color: var(--ink-faint); font-size: 11px; }
.me a { color: var(--ink-faint); display: grid; place-items: center; padding: 6px; border-radius: 6px; }
.me a:hover { background: var(--bg-hover); color: var(--danger); }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 28px; border-bottom: 1px solid var(--line);
}
.topbar .sub { color: var(--ink-faint); font-size: 13px; }
.content { padding: 24px 28px 56px; max-width: 1440px; }

/* ----------------------------------------------------------- cards */

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.card > h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.card > h2 .icon { color: var(--ink-faint); }
.card .hint { color: var(--ink-faint); font-size: 12.5px; margin: -8px 0 14px; }

.grid { display: grid; gap: 18px; align-items: start; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid.two { grid-template-columns: 1fr 1fr; }

.kpi-card { background: var(--bg-card); border: 1px solid var(--line);
            border-radius: var(--radius); padding: 16px 18px; }
.kpi-card .label {
  color: var(--ink-faint); font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  display: flex; align-items: center; gap: 6px;
}
.kpi-card .value {
  font-size: 30px; font-weight: 700; margin-top: 6px;
  font-variant-numeric: tabular-nums;   /* digits must not jitter */
}
.kpi-card .value.accent { color: var(--accent); }
.kpi-card .value.warn { color: var(--warning); }
.kpi-card .value.bad { color: var(--danger); }

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

.scroll { overflow-x: auto; }        /* wide tables scroll, the page never does */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; padding: 9px 12px;
  color: var(--ink-faint); font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--bg-hover); }
td.num, th.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; color: var(--ink-dim); }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--bg-hover); color: var(--ink-dim);
}
.tag.ban, .tag.tempban, .tag.softban, .tag.kick { background: #3d2224; color: #f8878a; }
.tag.warn, .tag.timeout { background: #3d3722; color: #f5d76e; }
.tag.unban, .tag.untimeout { background: #1f3a2a; color: #6ee7a0; }
.tag.temprole { background: #262a45; color: #97a1f5; }
.tag.off { opacity: 0.55; text-decoration: line-through; }

.role-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 500;
  background: var(--bg-hover); border: 1px solid var(--line);
}
.role-chip::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--chip, var(--ink-faint));
}

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

label { display: block; font-size: 12.5px; font-weight: 600;
        color: var(--ink-dim); margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.field .note { color: var(--ink-faint); font-size: 12px; margin-top: 5px; }

input[type=text], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px;
  background: var(--bg-input); color: var(--ink);
  border: 1px solid var(--bg-input); border-radius: 5px;
  font-family: inherit; font-size: 14px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
}
select[multiple] { min-height: 150px; padding: 4px; }
select[multiple] option { padding: 5px 7px; border-radius: 4px; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }

.check { display: flex; align-items: center; gap: 9px; font-size: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.check label { margin: 0; font-weight: 500; color: var(--ink); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: 5px; border: 0;
  background: var(--accent); color: #fff;
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--accent-dim); }
.btn.ghost { background: var(--bg-hover); color: var(--ink); }
.btn.ghost:hover { background: var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.sm { padding: 5px 9px; font-size: 12.5px; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }

.sticky-save {
  position: sticky; bottom: 0;
  background: var(--bg); border-top: 1px solid var(--line);
  padding: 14px 0; margin-top: 18px;
  display: flex; align-items: center; gap: 12px;
}

/* --------------------------------------------------------- notices */

.flash { display: flex; align-items: center; gap: 9px;
         padding: 11px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.flash.success { background: #1f3a2a; color: #86efac; }
.flash.error { background: #3d2224; color: #fca5a5; }
.banner { background: #3d3722; color: #f5d76e; }

.empty { text-align: center; padding: 34px 18px; color: var(--ink-faint); font-size: 14px; }
.empty .icon { width: 26px; height: 26px; margin-bottom: 8px; opacity: 0.6; }

/* ----------------------------------------------------- pagination */

.pager { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.pager .spacer { flex: 1; }
.pager .at { color: var(--ink-faint); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ----------------------------------------------- permission matrix */

.perm { border-bottom: 1px solid var(--line); padding: 14px 0; }
.perm:last-child { border-bottom: 0; }
.perm-head { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.perm-head code {
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  background: var(--bg-deep); padding: 3px 8px; border-radius: 4px;
}
.perm-head .spacer { flex: 1; }
.mode { display: flex; gap: 4px; background: var(--bg-deep); padding: 3px; border-radius: 6px; }
.mode label {
  margin: 0; padding: 4px 10px; border-radius: 4px; cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--ink-faint);
}
.mode input { position: absolute; opacity: 0; pointer-events: none; }
.mode input:checked + span { background: var(--accent); color: #fff; }
.mode span { display: block; padding: 4px 10px; border-radius: 4px; }
.inherit-note { color: var(--ink-faint); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }

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

.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--bg-deep); }
.login-box {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 10px; padding: 34px; width: min(400px, 90vw); text-align: center;
}
.login-box .dot {
  width: 52px; height: 52px; border-radius: 14px; background: var(--accent);
  display: grid; place-items: center; margin: 0 auto 16px; color: #fff;
}
.login-box .dot .icon { width: 26px; height: 26px; }
.login-box p { color: var(--ink-dim); font-size: 14px; margin: 8px 0 22px; }
.login-box .btn { width: 100%; justify-content: center; }

/* -------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static;
    flex-direction: row; align-items: center; gap: 4px;
    overflow-x: auto; padding: 0 8px;
  }
  .brand { border-bottom: 0; padding: 12px; white-space: nowrap; }
  .brand small { display: none; }
  .nav { flex-direction: row; padding: 8px 0; flex: 1; }
  .nav a span { display: none; }
  .me { border-top: 0; padding: 8px; }
  .me .who { display: none; }
  .grid.two { grid-template-columns: 1fr; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
}

/* ---------------------------------------------------------- charts */
/* Hand-rolled SVG rather than a charting library: two chart shapes do not
   justify 200 KB of dependency, and this way the marks inherit the theme
   tokens directly and the CSP stays script-src 'self'. */

.chart { position: relative; }
.chart .bars {
  display: flex; align-items: flex-end; gap: 3px;
  height: 132px; padding-bottom: 1px;
  border-bottom: 1px solid var(--line);
}
.chart .bar {
  flex: 1 1 0; height: var(--h);
  min-height: 3px;                 /* an empty day is still a visible tick */
  border-radius: 3px 3px 0 0;
  background: var(--accent);
  transition: background 0.12s;
}
.chart .bar:hover { background: #7983f5; }
.chart .bar.zero { background: var(--line); }
.chart .axis {
  display: flex; justify-content: space-between;
  color: var(--ink-faint); font-size: 11.5px; margin-top: 7px;
  font-variant-numeric: tabular-nums;
}
.chart .tip {
  position: absolute; pointer-events: none;
  background: var(--bg-deep); border: 1px solid var(--line);
  border-radius: 5px; padding: 5px 9px; font-size: 12.5px;
  white-space: nowrap; transform: translate(-50%, -130%);
  box-shadow: 0 4px 14px rgba(0,0,0,0.45);
}
.chart .tip b { font-variant-numeric: tabular-nums; }

.hbar { background: var(--bg-deep); border-radius: 4px; height: 9px; overflow: hidden; }
.hbar .fill { display: block; height: 100%; border-radius: 4px; background: var(--ink-faint); }
.hbar .fill.ban, .hbar .fill.tempban, .hbar .fill.softban,
.hbar .fill.kick { background: var(--danger); }
.hbar .fill.warn, .hbar .fill.timeout { background: var(--warning); }
.hbar .fill.unban, .hbar .fill.untimeout { background: var(--success); }
.hbar .fill.temprole { background: var(--accent); }
