@font-face {
  font-family: "EDInika";
  src: url("/admin/static/ed/fonts/Inika.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "EDRounded";
  src: url("/admin/static/ed/fonts/ARLRDBD.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #0f131d;
  --bg-deep: #090c13;
  --surface: #1b2234;
  --surface-alt: #232c43;
  --surface-inner: #131826;
  --text: #f4efe1;
  --muted: #a6b0c7;
  --line: #364362;
  --accent: #f3bd48;
  --accent-strong: #ffcf5c;
  --accent-text: #1c1304;
  --gold-border: #b88728;
  --ok-bg: #163826;
  --ok: #7ce89f;
  --err-bg: #441a20;
  --err: #ff9494;
  --warn-bg: #3e2e11;
  --warn: #ffd579;
  --radius: 8px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 50% 0%, rgba(72, 102, 168, 0.22), transparent 60%),
    radial-gradient(circle at 85% 20%, rgba(243, 189, 72, 0.09), transparent 45%),
    linear-gradient(180deg, #131929 0%, #0d111b 100%);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

img.ed-icon,
img.ed-icon-xs,
img.ed-icon-sm,
img.ed-icon-lg,
img.brand-icon,
img.page-banner-icon,
.login-art img {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  object-fit: contain;
  flex-shrink: 0;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
a:hover {
  color: var(--accent-strong);
}

code {
  font: 0.9em ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(9, 12, 19, 0.65);
  border: 1px solid var(--line);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  color: #ffe39e;
}
.break { word-break: break-all; }

h1, h2, h3, legend, .brand-title, .stat-num {
  font-family: "EDInika", Georgia, serif;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.75);
}

h1 {
  font-size: 1.75rem;
  line-height: 1.2;
  margin: 0;
  color: #fff6dc;
}
h2 {
  font-size: 1.25rem;
  line-height: 1.3;
  margin: 0 0 0.65rem;
  color: #ffe6a8;
}
h3 {
  font-size: 1.05rem;
  margin: 1.15rem 0 0.45rem;
  color: #f3d792;
}

/* --- Top Navigation Header --- */
header.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1.25rem;
  padding: 0.7rem 1.5rem;
  background: linear-gradient(180deg, #232d46 0%, #171e30 100%);
  border-bottom: 3px solid var(--gold-border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text);
}
.brand-icon {
  width: 38px;
  height: 38px;
  padding: 3px;
  background: #121724;
  border: 2px solid var(--gold-border);
  border-radius: 6px;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand-title {
  font-size: 1.2rem;
  color: #ffe6a3;
}
.brand-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

header nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
}
header nav a {
  display: inline-flex;
  align-items: center;
  padding: 0.48rem 0.85rem;
  border-radius: 6px;
  text-decoration: none;
  font-family: "EDInika", Georgia, serif;
  font-weight: 700;
  font-size: 0.96rem;
  color: #dbe3f7;
  background: rgba(15, 20, 32, 0.55);
  border: 1px solid #354366;
  transition: transform 0.08s ease, border-color 0.12s ease, background-color 0.12s ease;
}
header nav a:hover {
  border-color: var(--accent);
  color: #fff;
  background: rgba(38, 50, 78, 0.85);
}
header nav a[aria-current="page"] {
  background: linear-gradient(180deg, #f3bd48 0%, #c9881d 100%);
  color: #1c1102;
  border-color: #ffe49c;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
  box-shadow: 0 2px 8px rgba(243, 189, 72, 0.3);
}

.top-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.tele-pill,
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.72rem;
  border-radius: 999px;
  background: rgba(13, 18, 29, 0.88);
  border: 1px solid #39486b;
  color: #e4ecff;
  font-size: 0.83rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tele-pill:hover,
.live-pill:hover {
  border-color: var(--accent);
  color: #fff;
}
.tele-pill strong,
.live-pill strong {
  color: #ffe28a;
  font-weight: 700;
}
.tele-sep {
  color: var(--muted);
}
.live-dot {
  display: inline-block;
  width: 0.58rem;
  height: 0.58rem;
  border-radius: 50%;
  background: #46e07d;
  box-shadow: 0 0 8px rgba(70, 224, 125, 0.8);
}
.live-badge[data-state="paused"] .live-dot,
.live-pill[data-state="paused"] .live-dot {
  background: #f3bd48;
  box-shadow: none;
}
.live-badge[data-state="offline"] .live-dot,
.live-pill[data-state="offline"] .live-dot {
  background: #ff6e6e;
  box-shadow: none;
}

.logout { margin: 0; }
.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* --- Main Layout & Page Header --- */
main {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.35rem 1.5rem 3rem;
  flex: 1;
}

footer {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid rgba(54, 67, 98, 0.5);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.page-head,
.head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1.25rem;
  margin-bottom: 1.35rem;
  padding-bottom: 0.9rem;
  border-bottom: 2px solid rgba(184, 135, 40, 0.35);
}
.page-title-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}
.page-banner-icon {
  width: 48px;
  height: 48px;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.6));
}
.page-sub {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.live-status-box {
  display: flex;
   flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  background: rgba(19, 24, 38, 0.9);
  border: 1px solid #3c4d73;
  font-size: 0.88rem;
  color: #dce5fa;
}

/* --- 9-Slice Pixel Cards, KPI Sparklines & Panels --- */
.kpi-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-bottom: 1.15rem;
}
.kpi-grid > .card {
  margin-bottom: 0;
}
.kpi-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.card-head-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.card-head-inline h2 {
  margin: 0;
  font-size: 1.12rem;
}
.kpi-big {
  font-family: "EDInika", Georgia, serif;
  font-size: 1.45rem;
  font-weight: 700;
  color: #ffe28a;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.kpi-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 0.65rem;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.25rem;
  font-variant-numeric: tabular-nums;
}
.kpi-foot strong {
  color: #f4efe1;
}

.sparkline {
  width: 100%;
  height: 44px;
  display: block;
  background: rgba(10, 14, 23, 0.78);
  border: 1px solid #2e3b59;
  border-radius: 6px;
  margin: 0.3rem 0;
}
.sparkline-lg {
  height: 54px;
  margin: 0.45rem 0 0.65rem;
}
.spark-line {
  fill: none;
  stroke-width: 2.2px;
  vector-effect: non-scaling-stroke;
}
.spark-area {
  stroke: none;
}
.spark-line.cpu { stroke: #f3bd48; }
.spark-area.cpu { fill: rgba(243, 189, 72, 0.2); }
.spark-line.ram { stroke: #5ec2ff; }
.spark-area.ram { fill: rgba(94, 194, 255, 0.2); }
.spark-line.lag { stroke: #ff7d7d; }
.spark-area.lag { fill: rgba(255, 125, 125, 0.2); }

.cards {
  display: grid;
  gap: 1.1rem;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  margin-bottom: 1.25rem;
}
.cards-2col {
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
}
.ops-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  align-items: start;
}
.ops-grid > .panel-section {
  margin-top: 0.75rem;
  min-width: 0;
}

.ml-auto { margin-left: auto; }
.text-err { color: var(--err); }
.err-badge { background: var(--err-bg); color: var(--err); border: 1px solid rgba(255, 148, 148, 0.4); }
.warn-badge { background: var(--warn-bg); color: var(--warn); border: 1px solid rgba(255, 213, 121, 0.4); }

/* --- Spike & Anomaly List --- */
.spike-list {
  display: grid;
  gap: 0.5rem;
}
.spike-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.55rem 0.85rem;
  background: rgba(19, 24, 38, 0.88);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  font-size: 0.92rem;
}
.spike-item.sev-error {
  border-left-color: var(--err);
  background: rgba(68, 26, 32, 0.35);
}
.spike-item.sev-error .lv {
  background: var(--err-bg);
  color: var(--err);
}
.spike-item.sev-warn {
  border-left-color: var(--warn);
  background: rgba(62, 46, 17, 0.35);
}
.spike-item.sev-warn .lv {
  background: var(--warn-bg);
  color: var(--warn);
}
.spike-title {
  color: #fff6dc;
}

/* --- Opcode Latency Bar --- */
.bar-cell {
  min-width: 8rem;
  width: 22%;
}
.lag-bar-track {
  width: 100%;
  height: 10px;
  background: rgba(9, 12, 20, 0.85);
  border: 1px solid #334162;
  border-radius: 999px;
  overflow: hidden;
}
.lag-bar-fill {
  height: 100%;
  border-radius: 999px;
}
.lag-bar-fill.status-ok { background: linear-gradient(90deg, #3cc972, #7ce89f); }
.lag-bar-fill.status-warn { background: linear-gradient(90deg, #e09f2d, #ffd579); }
.lag-bar-fill.status-err { background: linear-gradient(90deg, #d94343, #ff9494); }

.quick-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.quick-pills a.chip {
  text-decoration: none;
}
.quick-pills a.chip:hover {
  color: var(--accent-strong);
}

dl.compact-dl {
  gap: 0.3rem 0.85rem;
  font-size: 0.92rem;
}

.card {
  background-color: var(--surface);
  border: 14px solid transparent;
  border-image: url("/admin/static/ed/ui/UI_BGFrame_Blue.png") 31 32 34 31 fill / 16px 16px 18px 16px;
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  margin: 0 0 1.25rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}
.cards > .card {
  margin-bottom: 0;
}

.card.card-gold {
  border-image: url("/admin/static/ed/ui/UI_BGFrame_Gold.png") 33 33 33 33 fill / 16px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.card-head h2 {
  margin: 0;
}
.card-foot {
  margin: 0.9rem 0 0;
}

.panel-section {
  margin-top: 1.75rem;
}
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  margin-bottom: 0.75rem;
}
.section-head h2 {
  margin: 0;
}

/* --- Stat Tiles on Overview --- */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin-top: 0.35rem;
}
.stat-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 0.6rem;
  background-color: #141926;
  border: 6px solid transparent;
  border-image: url("/admin/static/ed/ui/UI_Playerbox.png") 7 7 7 7 fill / 7px;
  text-align: center;
}
.stat-num {
  font-size: 2.05rem;
  line-height: 1.1;
  color: #ffe28a;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 0.88rem;
  color: #e6ecf8;
  margin-top: 0.28rem;
  font-weight: 500;
}

/* --- Definition Lists --- */
dl {
  display: grid;
  grid-template-columns: minmax(7.5rem, max-content) 1fr;
  gap: 0.45rem 1rem;
  margin: 0;
  align-items: baseline;
}
dt {
  color: var(--muted);
  font-size: 0.92rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
dd {
  margin: 0;
  min-width: 0;
}

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.9rem; margin: 0.5rem 0; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 0.25rem 0; }
ul.attach-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
ul.attach-list li { padding: 0; }

/* --- Pixel Icon Frames & Cells --- */
.cell-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}
.icon-frame,
.item-icon-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 4px;
  background-color: #141926;
  border: 4px solid transparent;
  border-image: url("/admin/static/ed/ui/UI_Playerbox.png") 7 7 7 7 fill / 6px;
  flex-shrink: 0;
}
.icon-frame-lg {
  width: 62px;
  height: 62px;
  padding: 5px;
}
.ed-icon { width: 28px; height: 28px; }
.ed-icon-lg { width: 48px; height: 48px; }
.ed-icon-sm { width: 18px; height: 18px; }
.ed-icon-xs { width: 20px; height: 20px; vertical-align: -4px; }

.reward-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.3rem;
}

/* --- Tables & Scroll Containers --- */
.scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background-color: var(--surface-inner);
  border: 6px solid transparent;
  border-image: url("/admin/static/ed/ui/UI_innerWrapBG.png") 7 6 7 6 fill / 7px 6px;
  border-radius: 8px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95rem;
}
th, td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid rgba(58, 73, 108, 0.55);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.03); }

th {
  font-family: "EDInika", Georgia, serif;
  font-weight: 700;
  color: #f3d486;
  background: rgba(26, 34, 54, 0.92);
  border-bottom: 2px solid rgba(184, 135, 40, 0.45);
  white-space: nowrap;
}

.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.inactive td { color: var(--muted); opacity: 0.78; }
td.msg { min-width: 16rem; vertical-align: top; }

/* --- compact event list (when / who / what) + event detail page --- */
tr.ev-row { cursor: pointer; }
tr.ev-row:hover td { background: rgba(255, 255, 255, 0.035); }
table.events td.msg { max-width: 0; width: 100%; }
.ev-kind { margin: 0 0.3rem; }
.ev-short { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #d6def0; margin-top: 0.15rem; }
.ev-who { white-space: nowrap; }
.ev-dev { display: block; color: var(--muted); font-size: 0.8rem; }
td.ev-go { white-space: nowrap; text-align: right; font-size: 0.85rem; }
pre.ev-msg { font-size: 0.95rem; word-break: break-word; }
pre.ev-stack { max-height: 28rem; overflow: auto; word-break: normal; white-space: pre; }
.card.ev-message { margin-bottom: 1rem; }
details summary { cursor: pointer; color: var(--accent); font-size: 0.85rem; margin-top: 0.25rem; }
pre {
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 0.8rem;
  margin: 0.35rem 0 0;
  padding: 0.5rem;
  background: rgba(8, 11, 18, 0.8);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.lv {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #d6def0;
}
.lv-error .lv { background: var(--err-bg); color: var(--err); border: 1px solid rgba(255, 148, 148, 0.4); }
.lv-warn .lv { background: var(--warn-bg); color: var(--warn); border: 1px solid rgba(255, 213, 121, 0.4); }

/* --- Badges, Tags & Chips --- */
.tag {
  display: inline-flex;
  align-items: center;
  font-size: 0.8rem;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  background: rgba(15, 20, 32, 0.85);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 600;
}
.tag.on {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: rgba(124, 232, 159, 0.45);
}
.tag.warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: rgba(255, 213, 121, 0.45);
}
.tag.err {
  background: var(--err-bg);
  color: var(--err);
  border-color: rgba(255, 148, 148, 0.45);
}
.dot {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.4rem 0;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  background-color: #141926;
  border: 4px solid transparent;
  border-image: url("/admin/static/ed/ui/UI_Playerbox.png") 7 7 7 7 fill / 6px;
  border-radius: 6px;
  padding: 0.22rem 0.65rem;
  font-size: 0.9rem;
  color: #f7f2e4;
}
.chip-sm {
  padding: 0.1rem 0.45rem;
  font-size: 0.8rem;
}

.empty-state {
  padding: 1rem 1.2rem;
  background: rgba(19, 24, 38, 0.65);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

/* --- Flash Messages & Parchment Preview --- */
.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin: 0.6rem 0 1.2rem;
  border: 1px solid var(--line);
  font-weight: 500;
}
.flash ul { margin: 0; padding-left: 1.2rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: rgba(124, 232, 159, 0.45); }
.flash.err { background: var(--err-bg); color: var(--err); border-color: rgba(255, 148, 148, 0.45); }
.flash.warn { background: var(--warn-bg); color: var(--warn); border-color: rgba(255, 213, 121, 0.45); }

.parchment-box {
  background: #2b2318;
  border: 2px solid #8c6a32;
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
  margin: 0.75rem 0;
}
.preview .mail-title {
  font-size: 1.15rem;
  color: #ffe399;
  margin: 0 0 0.45rem;
}
.preview .mail-text {
  white-space: pre-wrap;
  background: rgba(12, 10, 8, 0.55);
  border: 1px solid rgba(184, 135, 40, 0.35);
  border-radius: 6px;
  padding: 0.75rem;
  margin: 0;
}
.confirm { font-weight: 600; }

/* --- Forms & Pixel Buttons --- */
form label {
  display: block;
  margin: 0.9rem 0 0.3rem;
  font-weight: 600;
  color: #f3e6c8;
}
form label.choice {
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.45rem 0;
  min-height: 2.6rem;
  cursor: pointer;
}

input, select, textarea, button, .button {
  font: inherit;
  color: inherit;
  border-radius: 6px;
  min-height: 2.65rem;
}

input:not([type=radio]):not([type=checkbox]),
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 2px solid #3c4b6e;
  background: #101522;
  color: #f7f3e8;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}
input:not([type=radio]):not([type=checkbox]):focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
}

input[type=radio],
input[type=checkbox] {
  width: 1.25rem;
  height: 1.25rem;
  min-height: 0;
  margin: 0;
  accent-color: var(--accent);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

textarea { resize: vertical; }

fieldset {
  border: 2px solid #39486b;
  background: rgba(14, 18, 29, 0.45);
  border-radius: 8px;
  margin: 1.1rem 0 0;
  padding: 0.65rem 1rem 1rem;
}
legend {
  font-weight: 700;
  padding: 0 0.45rem;
  color: #ffe298;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 1.15rem;
  border: 8px solid transparent;
  border-image: url("/admin/static/ed/ui/btn_SpBtn_Green.png") 11 11 12 11 fill / 10px;
  background-color: transparent;
  color: #ffffff;
  font-family: "EDInika", Georgia, serif;
  font-weight: 700;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.75);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.06s ease, filter 0.12s ease;
}
button:hover,
.button:hover {
  filter: brightness(1.08);
  color: #ffffff;
}
button:active,
.button:active {
  transform: translateY(1px);
}

button.secondary,
.button.secondary {
  border-image: url("/admin/static/ed/ui/btn_MenuCom_110x89.png") 13 13 16 13 fill / 10px;
  color: #eef3ff;
}
button.danger,
.button.danger {
  border-image: url("/admin/static/ed/ui/btn_retreat_270x89.png") 20 40 20 39 fill / 10px 16px;
  color: #fff2f2;
}
button.btn-sm,
.button.btn-sm {
  min-height: 2.2rem;
  padding: 0.25rem 0.8rem;
  font-size: 0.88rem;
}
button.link {
  border: 1px solid #3a496d;
  border-image: none;
  background: rgba(15, 20, 32, 0.65);
  color: #e1e8fa;
  padding: 0.35rem 0.7rem;
  min-height: 2.2rem;
  font-size: 0.88rem;
  font-family: inherit;
  font-weight: 500;
  text-shadow: none;
}
button.link:hover {
  border-color: var(--accent);
  color: #fff;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

/* --- Item Picker Rows --- */
.item-rows {
  display: grid;
  gap: 0.6rem;
}
.item-row {
  display: grid;
  grid-template-columns: 38px 1fr 7.5rem;
  gap: 0.55rem;
  align-items: center;
}
fieldset.items .add-row {
  margin-top: 0.75rem;
}

/* --- Filter & Search Bars --- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 0.9rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}
.filters label {
  margin: 0;
  font-weight: 500;
  color: var(--muted);
  font-size: 0.88rem;
  flex: 1.3 1 10.5rem;
}
.filters label:nth-of-type(3),
.filters label:nth-of-type(5) {
  flex: 0.6 1 5.5rem;
}
.filters label input,
.filters label select {
  margin-top: 0.25rem;
}
.filters button,
.filters .button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.search {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 1.2rem;
}
.search input { flex: 1; }

.rename-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem;
}
.rename-bar label {
  margin: 0;
  flex: 1;
  min-width: 14rem;
}
.rename-bar label input {
  margin-top: 0.25rem;
}

/* --- Login Card --- */
.login {
  max-width: 25rem;
  margin: 6vh auto 0;
  text-align: center;
}
.login-art {
  display: flex;
  justify-content: center;
  margin-bottom: 0.5rem;
}
.login-art img {
  max-width: 210px;
  height: auto;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.65));
}
.login-sub {
  margin: 0.2rem 0 0.8rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.login form {
  text-align: left;
}
.login button {
  width: 100%;
  margin-top: 1.1rem;
}

/* --- Responsive Mobile Layout (<= 640px) --- */
@media (max-width: 640px) {
  body { font-size: 15px; }
  main { padding: 1rem 0.85rem 2.5rem; }
  .cards-2col,
  .ops-grid {
    grid-template-columns: 1fr;
  }
  .tele-pill {
    display: none;
  }
  header.top {
    display: grid;
    grid-template-columns: 1fr auto;
    padding: 0.6rem 0.85rem;
    gap: 0.5rem;
  }
  header .top-right {
    grid-row: 1;
    grid-column: 2;
  }
  header nav {
    grid-row: 2;
    grid-column: 1 / -1;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.15rem;
  }
  header nav a {
    white-space: nowrap;
    padding: 0.4rem 0.7rem;
    font-size: 0.9rem;
  }
  .logout-btn span {
    display: none;
  }
  .item-row {
    grid-template-columns: 38px 1fr 5.5rem;
  }
  dl {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
  dd {
    margin-bottom: 0.45rem;
  }
  .scroll.stacked {
    border: 0;
    border-image: none;
    background: none;
    overflow: visible;
    box-shadow: none;
  }
  table.stack,
  table.stack tbody,
  table.stack tr,
  table.stack td {
    display: block;
    width: 100%;
  }
  table.stack thead {
    display: none;
  }
  table.stack tr {
    background-color: var(--surface);
    border: 10px solid transparent;
    border-image: url("/admin/static/ed/ui/UI_BGFrame_Blue.png") 31 32 34 31 fill / 12px;
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    padding: 0.35rem 0.55rem;
  }
  table.stack td {
    position: relative;
    border: 0;
    padding: 0.2rem 0 0.2rem 6.8rem;
    min-height: 1.7rem;
    text-align: left;
    white-space: normal;
  }
  table.stack td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    width: 6.3rem;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
  }
  table.stack td.msg {
    padding-left: 0;
    min-width: 0;
    max-width: none;
    padding-top: 0.35rem;
  }
  table.stack td.msg::before {
    display: none;
  }
  table.events td:not(.msg) {
    display: inline-block;
    width: auto;
    padding: 0 0.55rem 0 0;
    min-height: 0;
  }
  table.events td:not(.msg)::before {
    display: none;
  }
  table.events td.ev-go { display: none; }
}

/* --- Analyse (gameplay analytics): ED cards, SVG bars and chart (CSP: no inline styles), run timeline --- */
.an-filters { display: flex; flex-wrap: wrap; gap: 0.5rem 0.7rem; align-items: end; margin: 0; }
.an-filters label { margin: 0; font-size: 0.85rem; color: var(--muted); font-weight: 400; }
.an-filters select { width: 8.5rem; }
.an-filters input { width: 6.5rem; }
.an-kpis { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 1.2rem; }
.an-kpis > .card { margin: 0; }
.an-kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.an-kpis .kpi-top { flex-wrap: wrap; margin-bottom: 0; }
.an-kpis .card-head-inline h2 { font-size: 1rem; }
.an-kpis .kpi-big { flex-basis: 100%; font-size: 1.9rem; line-height: 1.15; margin-top: 0.15rem; }
.an-kpis .kpi-big.bad { color: var(--err); }
.an-kpis .kpi-big.good { color: var(--ok); }
.an-kpis .kpi-big.warn { color: var(--warn); }
.an-grid { display: grid; gap: 0 1.4rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); align-items: start; }
.an-grid > .panel-section { min-width: 0; }
.an-grid td, .an-grid th { white-space: nowrap; }
.section-head .card-head-inline h2 { font-size: 1.15rem; }
.legend { color: var(--muted); font-size: 0.85rem; display: inline-flex; align-items: center; gap: 0.35rem; }
.sw { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 2px; margin-left: 0.5rem; border: 1px solid rgba(0, 0, 0, 0.5); }
.sw.runs { background: #f3bd48; }
.sw.deaths { background: #ff7d7d; }
svg.chart { width: 100%; height: auto; display: block; background: rgba(10, 14, 23, 0.78); border: 1px solid #2e3b59; border-radius: 6px; margin-top: 0.4rem; }
svg.chart rect.runs { fill: #f3bd48; }
svg.chart rect.deaths { fill: #ff7d7d; }
svg.chart rect:hover { fill: #ffe28a; }
svg.chart .axis { stroke: #3c4d73; stroke-width: 1; }
svg.chart text { fill: var(--muted); font-size: 11px; }
td.barcell { min-width: 8.5rem; }
.an-grid td.barcell { min-width: 7rem; }
svg.bar { width: calc(100% - 3.6rem); max-width: 12rem; height: 0.75rem; vertical-align: middle; }
.an-grid svg.bar { max-width: 7rem; }
svg.bar rect { fill: #f3bd48; }
svg.bar rect.bad { fill: #ff7d7d; }
svg.bar rect.good { fill: #7ce89f; }
svg.bar rect.neutral { fill: #5ec2ff; }
svg.bar rect.track { fill: rgba(9, 12, 20, 0.9); stroke: #334162; stroke-width: 1; }
.barnum { display: inline-block; min-width: 3rem; padding-left: 0.45rem; font-variant-numeric: tabular-nums; }
.t-bad { color: var(--err); font-weight: 700; }
.fps { font-weight: 700; }
.fps.good { color: var(--ok); }
.fps.warn { color: var(--warn); }
.fps.bad { color: var(--err); }
.res { font-size: 0.82rem; padding: 0.1rem 0.55rem; border-radius: 999px; font-weight: 700; border: 1px solid transparent; }
.res-win { background: var(--ok-bg); color: var(--ok); border-color: rgba(124, 232, 159, 0.4); }
.res-fail { background: var(--err-bg); color: var(--err); border-color: rgba(255, 148, 148, 0.4); }
.res-quit { background: var(--warn-bg); color: var(--warn); border-color: rgba(255, 213, 121, 0.4); }
.an-chips { margin: 0.2rem 0 1rem; }
a.chip { text-decoration: none; color: var(--text); }
a.chip.on { color: #ffe28a; border-image-source: url("/admin/static/ed/ui/btn_Tag_On.png"); }
td .ed-icon-xs, .ev .ed-icon-xs { vertical-align: middle; }

ol.timeline { list-style: none; margin: 0; padding: 0; }
.ev { display: grid; grid-template-columns: 3.6rem 1.6rem 1fr; gap: 0.6rem; padding: 0.5rem 0.9rem; border-bottom: 1px solid rgba(58, 73, 108, 0.55); align-items: start; }
.ev:last-child { border-bottom: 0; }
.ev.divider { background: rgba(26, 34, 54, 0.92); border-bottom-color: rgba(184, 135, 40, 0.45); }
.ev.divider .title { font-family: "EDInika", Georgia, serif; color: #f3d486; }
.ev .t { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.9rem; padding-top: 0.15rem; text-align: right; }
.ev .ico { width: 24px; height: 24px; image-rendering: pixelated; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6)); }
.ev .body { min-width: 0; }
.ev .title { font-weight: 700; }
.ev .detail { color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }
.ev details summary { font-size: 0.75rem; }
.ev-death .title { color: var(--err); }
.ev-teamdeath .title { color: #ffb4a8; }
.ev-bosskill .title, .ev-boss .title { color: #ffe28a; }
.ev-revive .title { color: var(--ok); }
.ev-server .title { color: #9fc4ff; }
@media (max-width: 560px) {
  .an-kpis { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
  .an-kpis .kpi-big { font-size: 1.35rem; }
  .ev { grid-template-columns: 3rem 1.4rem 1fr; padding: 0.45rem 0.6rem; gap: 0.45rem; }
  td.barcell { min-width: 0; }
  table.stack td.barcell svg.bar { width: 55%; }
}
