:root {
  color-scheme: dark;
  --bg: #0f1115;
  --panel: #171a21;
  --border: #262b36;
  --text: #e6e8ee;
  --muted: #9aa3b2;
  --accent: #5865f2;
  --accent-hover: #4752c4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

a {
  color: var(--accent);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.nav a {
  color: var(--text);
  text-decoration: none;
}

.nav a:hover {
  color: var(--accent);
}

.who {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.inline {
  display: inline;
  margin: 0;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

.login {
  max-width: 360px;
  margin: 15vh auto 0;
  text-align: center;
}

button,
.button {
  display: inline-block;
  padding: 8px 14px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--accent-hover);
}

input,
select,
textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
}

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

th,
td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

/* ---- Portal pages ---- */

h1 {
  margin: 0 0 16px;
  font-size: 24px;
}

h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.muted {
  color: var(--muted);
}

[hidden] {
  display: none !important;
}

.page-head,
.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.pane-head h2 {
  margin: 0;
}

.card + .card,
.previews > .card + .card {
  margin-top: 16px;
}

.narrow-card {
  max-width: 560px;
}

.flash {
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.flash p,
.flash ul {
  margin: 0;
}

.flash .actions {
  margin-top: 8px;
}

.flash-ok {
  background: #13291c;
  border-color: #23633b;
}

.flash-error {
  background: #2d1517;
  border-color: #7a2a30;
}

.editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

@media (max-width: 900px) {
  .editor {
    grid-template-columns: minmax(0, 1fr);
  }
}

.form label {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

.form input:not([type='checkbox']),
.form select,
.form textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
}

.form label.narrow {
  max-width: 200px;
}

.form label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin: 0 0 12px;
}

legend {
  padding: 0 6px;
  font-weight: 600;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.section-row {
  grid-template-columns: 90px 1fr;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}

.section-row .wide {
  grid-column: 1 / -1;
}

.form .row label {
  margin-bottom: 8px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

button.secondary,
.button.secondary {
  background: #2b2f3a;
}

button.secondary:hover,
.button.secondary:hover {
  background: #363b48;
}

button.danger {
  background: #c03537;
}

button.danger:hover {
  background: #a12c2e;
}

button.small {
  padding: 3px 10px;
  font-size: 13px;
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

.danger-link {
  color: #f0787a;
  margin-left: 8px;
}

td.order {
  white-space: nowrap;
}

.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #2b2f3a;
  color: var(--muted);
}

.pill-ok {
  background: #13291c;
  color: #6fd394;
}

.pill-warn {
  background: #33280f;
  color: #f0c060;
}

/* ---- Discord message preview ---- */

.dc {
  background: #313338;
  border-radius: 6px;
  padding: 12px;
  color: #dbdee1;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.dc-msg {
  display: flex;
  gap: 12px;
}

.dc-msg + .dc-msg {
  margin-top: 16px;
}

.dc-avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.dc-avatar-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #5865f2;
  color: #fff;
  font-weight: 700;
}

.dc-body {
  min-width: 0;
  flex: 1;
}

.dc-name {
  color: #f2f3f5;
  font-weight: 600;
}

.dc-tag {
  margin-left: 6px;
  padding: 0 4px;
  border-radius: 3px;
  background: #5865f2;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  vertical-align: 2px;
}

.dc-content {
  margin-top: 2px;
}

.dc-mention {
  background: rgba(88, 101, 242, 0.3);
  color: #c9cdfb;
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 500;
}

.dc-time {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  padding: 0 2px;
}

.dc code {
  background: #1e1f22;
  border-radius: 3px;
  padding: 0 3px;
  font-size: 13px;
}

.dc pre {
  background: #1e1f22;
  border-radius: 4px;
  padding: 8px;
  overflow: auto;
}

.dc-embed {
  position: relative;
  max-width: 520px;
  margin-top: 6px;
  padding: 8px 16px 12px 16px;
  background: #2b2d31;
  border-radius: 4px;
  overflow: hidden;
}

.dc-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  height: 100%;
}

.dc-title {
  margin-top: 6px;
  color: #f2f3f5;
  font-weight: 600;
}

.dc-desc {
  margin-top: 6px;
  font-size: 14px;
}

.dc-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.dc-field {
  grid-column: 1 / -1;
  font-size: 14px;
}

.dc-field.dc-inline {
  grid-column: auto;
}

.dc-fname {
  color: #f2f3f5;
  font-weight: 600;
  margin-bottom: 2px;
}

.dc-footer {
  margin-top: 8px;
  color: #b5bac1;
  font-size: 12px;
}

.dc-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.dc-btn {
  display: inline-block;
  padding: 2px 16px;
  min-height: 32px;
  line-height: 28px;
  border-radius: 3px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
}

.dc-btn-primary {
  background: #5865f2;
}

.dc-btn-danger {
  background: #da373c;
}

.dc-btn-secondary {
  background: #4e5058;
}

/* Ticket log viewer */
.filters {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.pager {
  margin-top: 16px;
}

.audit .detail {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.tx {
  background: #313338;
  color: #dbdee1;
}

.tx-head {
  border-bottom: 1px solid #4e5058;
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.tx-head h1 {
  margin: 0 0 8px;
  font-size: 20px;
}

.tx-head dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 12px;
  margin: 0;
}

.tx-head dt {
  color: #949ba4;
}

.tx-head dd {
  margin: 0;
}

.tx-msg {
  display: flex;
  gap: 12px;
  padding: 6px 0;
}

.tx-avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
}

.tx-av0 { background: #5865f2; }
.tx-av1 { background: #3ba55d; }
.tx-av2 { background: #faa61a; }
.tx-av3 { background: #ed4245; }
.tx-av4 { background: #eb459e; }
.tx-av5 { background: #1abc9c; }
.tx-av6 { background: #9b59b6; }
.tx-av7 { background: #e67e22; }

.tx-body {
  min-width: 0;
  flex: 1;
}

.tx-name {
  font-weight: 600;
  color: #fff;
}

.tx-time,
.tx-tag {
  color: #949ba4;
  font-size: 12px;
  margin-left: 6px;
}

.tx-bot {
  background: #5865f2;
  color: #fff;
  border-radius: 3px;
  padding: 0 4px;
  font-size: 11px;
  margin-left: 6px;
}

.tx-content {
  overflow-wrap: anywhere;
}

.tx-deleted .tx-content {
  opacity: 0.6;
  text-decoration: line-through;
}

.tx .mention {
  background: #3c4270;
  color: #c9cdfb;
  border-radius: 3px;
  padding: 0 2px;
}

.tx a {
  color: #00a8fc;
}

.tx a.button {
  color: #fff;
}

.tx code {
  background: #1e1f22;
  border-radius: 3px;
  padding: 0 3px;
}

.tx pre {
  background: #1e1f22;
  border-radius: 4px;
  padding: 8px;
  overflow: auto;
}

.tx pre code {
  padding: 0;
}

.tx .embed {
  border-left: 4px solid #4e5058;
  background: #2b2d31;
  border-radius: 4px;
  padding: 8px 12px;
  margin-top: 6px;
}

.tx .embed .etitle,
.tx .embed .efname {
  font-weight: 700;
}

.tx .embed .efield {
  margin-top: 6px;
}

.tx .embed .efoot {
  color: #949ba4;
  font-size: 12px;
  margin-top: 6px;
}

.tx-att {
  margin-top: 6px;
}

.tx-att img {
  max-width: 100%;
  max-height: 400px;
  border-radius: 4px;
  display: block;
}

.tx-revs {
  margin-top: 4px;
  color: #949ba4;
  font-size: 13px;
}
