/* ZfPanel, Catppuccin Mocha with Mauve as accent (base shared with the ZfPerms editor) */
:root {
  --crust: #11111b;
  --mantle: #181825;
  --base: #1e1e2e;
  --surface0: #313244;
  --surface1: #45475a;
  --surface2: #585b70;
  --overlay0: #6c7086;
  --overlay1: #7f849c;
  --subtext0: #a6adc8;
  --subtext1: #bac2de;
  --text: #cdd6f4;
  --mauve: #cba6f7;
  --lavender: #b4befe;
  --red: #f38ba8;
  --green: #a6e3a1;
  --yellow: #f9e2af;
  --peach: #fab387;
  --sky: #89dceb;

  --radius: 10px;
  --sans: Inter, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scrollbar-color: var(--surface1) transparent; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--base);
  color: var(--text);
  font: 14px/1.5 var(--sans);
}

h1, h2, h3 { margin: 0 0 .6em; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1rem; color: var(--subtext1); }
h3 { font-size: .85rem; color: var(--subtext0); text-transform: uppercase; letter-spacing: .06em; }
p { margin: .4em 0; }
code, .mono { font-family: var(--mono); font-size: .92em; }
code { background: var(--surface0); padding: .1em .4em; border-radius: 5px; }
.muted { color: var(--subtext0); }
.small { font-size: .85em; }
[hidden] { display: none !important; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px;
  background: var(--mantle);
  border-bottom: 1px solid var(--surface0);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; }
.brand-zf { color: var(--sky); }
.brand-perms { color: var(--peach); margin-left: -8px; }
.brand-sub { color: var(--overlay1); font-weight: 500; font-size: .9rem; }
.tabs { display: flex; gap: 4px; }
.tabs button {
  background: none; border: 0; color: var(--subtext0);
  padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer;
}
.tabs button:hover { background: var(--surface0); color: var(--text); }
.tabs button.active { background: var(--surface0); color: var(--mauve); }
.session { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--subtext1); }
.session-player::before { content: "●"; color: var(--green); margin-right: 6px; font-size: .8em; }

/* ---- layout ---- */
main { padding: 24px; max-width: 1400px; margin: 0 auto; }
.screen.center { display: grid; place-items: center; min-height: 70vh; }
.split { display: grid; grid-template-columns: 330px 1fr; gap: 24px; align-items: start; }
.sidebar { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 76px; max-height: calc(100vh - 100px); }
.detail { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
  .topbar { flex-wrap: wrap; gap: 12px; padding: 10px 16px; }
  main { padding: 16px; }
}

.card {
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: var(--radius);
  padding: 18px;
}
.card.narrow { max-width: 460px; text-align: center; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.empty { color: var(--overlay1); padding: 40px; text-align: center; border: 1px dashed var(--surface1); border-radius: var(--radius); }

/* ---- inputs ---- */
input, select {
  width: 100%;
  background: var(--base);
  color: var(--text);
  border: 1px solid var(--surface1);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--mauve); outline-offset: -1px; border-color: transparent; }
input.mono { font-family: var(--mono); }
input[type=color] { padding: 2px; width: 42px; height: 36px; cursor: pointer; }
label { display: block; color: var(--subtext0); font-size: .85rem; margin-bottom: 4px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { min-width: 0; }
.row > input, .row > select { flex: 1 1 0; width: auto; }
.row > input[type=color] { flex: none; width: 42px; }
.row > button { flex: none; }
.weight { max-width: 100px; }
.field { margin-bottom: 14px; }
.hint { color: var(--overlay1); font-size: .8rem; margin-top: 4px; }

button {
  font: inherit; font-weight: 500;
  border-radius: 8px; padding: 8px 14px;
  border: 1px solid var(--surface1);
  background: var(--surface0); color: var(--text);
  cursor: pointer; white-space: nowrap;
}
button:hover { background: var(--surface1); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--mauve); color: var(--crust); border-color: var(--mauve); }
button.primary:hover { background: var(--lavender); border-color: var(--lavender); }
button.danger { color: var(--red); }
button.danger:hover { background: color-mix(in srgb, var(--red) 15%, transparent); }
button.ghost { background: none; border-color: transparent; color: var(--subtext0); }
button.ghost:hover { background: var(--surface0); color: var(--text); }
button.icon { padding: 4px 8px; line-height: 1; }
.create { display: flex; flex-direction: column; gap: 10px; }
.create h2 { margin: 0; }

/* ---- lists ---- */
.list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; padding-right: 2px; }
.list-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background: var(--mantle); border: 1px solid var(--surface0);
  padding: 10px 12px;
}
.list-item:hover { background: var(--surface0); }
.list-item.selected { border-color: var(--mauve); background: color-mix(in srgb, var(--mauve) 10%, var(--mantle)); }
.list-item .name { font-weight: 600; }
.badge {
  display: inline-block; min-width: 2.6em; text-align: center;
  font-family: var(--mono); font-size: .78rem;
  background: var(--surface0); color: var(--subtext1);
  border-radius: 6px; padding: 2px 6px;
}
.list-item .preview { margin-left: auto; font-size: .85rem; padding: 2px 8px; max-width: 62%; overflow: hidden; text-overflow: ellipsis; }

/* ---- Minecraft-style preview ---- */
.preview {
  font-family: var(--mono);
  background: #0c0c12;
  color: #ffffff;
  border-radius: 6px;
  padding: 10px 14px;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, .55);
  white-space: pre;
  overflow-x: auto;
}
.preview.big { font-size: 1.15rem; padding: 14px 18px; }

/* ---- detail parts ---- */
.title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.title h1 { margin: 0; }
.title .spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .grid2 { grid-template-columns: 1fr; } }

.swatches { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
.swatch {
  width: 24px; height: 24px; padding: 0; border-radius: 6px;
  border: 2px solid transparent; outline: 1px solid var(--surface1);
}
.swatch.selected { border-color: var(--text); }
.swatch.none { background: repeating-linear-gradient(45deg, var(--surface0) 0 4px, var(--base) 4px 8px); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface0); border-radius: 999px;
  padding: 3px 4px 3px 12px; font-size: .88rem;
}
.chip .expires { color: var(--yellow); font-size: .8em; }
.chip button { padding: 0 7px; border: 0; border-radius: 999px; background: none; color: var(--overlay1); }
.chip button:hover { background: var(--surface1); color: var(--red); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--overlay1); font-weight: 500; font-size: .8rem; padding: 6px 8px; border-bottom: 1px solid var(--surface0); }
td { padding: 6px 8px; border-bottom: 1px solid var(--surface0); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.node { font-family: var(--mono); word-break: break-all; }
td.actions { text-align: right; width: 1%; white-space: nowrap; }
.value {
  font-family: var(--mono); font-size: .8rem; border-radius: 6px; padding: 2px 10px; border: 0;
}
.value.true { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.value.false { background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--red); }
.server { color: var(--sky); font-family: var(--mono); font-size: .8rem; }
.expires { color: var(--yellow); font-size: .82rem; }
.add-row { display: grid; grid-template-columns: 1fr 110px 140px 130px auto; gap: 8px; margin-top: 12px; }
@media (max-width: 1100px) { .add-row { grid-template-columns: 1fr 1fr; } }

/* ---- waiting screen ---- */
.code {
  font-family: var(--mono); font-size: 2.6rem; font-weight: 700; letter-spacing: .25em;
  color: var(--mauve); margin: 18px 0; padding: 12px; border-radius: var(--radius);
  background: var(--base); border: 1px solid var(--surface0);
}

/* ---- audit ---- */
.audit { display: flex; flex-direction: column; }
.audit-entry { display: grid; grid-template-columns: 150px 130px 1fr; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--surface0); }
.audit-entry:last-child { border-bottom: 0; }
.audit-entry .time { color: var(--overlay1); font-family: var(--mono); font-size: .82rem; }
.audit-entry .who { color: var(--subtext1); }
.audit-entry .via { font-size: .72rem; color: var(--overlay1); margin-left: 6px; }
@media (max-width: 860px) { .audit-entry { grid-template-columns: 1fr; gap: 2px; } }

/* ---- toasts ---- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 20; }
.toast {
  background: var(--surface0); border-left: 4px solid var(--green);
  padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
  max-width: 420px; animation: toast-in .15s ease-out;
}
.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.spaced { margin-top: 12px; }

/* ==== panel ==================================================================================== */

.busy { color: var(--peach); font-size: .85rem; }
.busy::before { content: "◌"; display: inline-block; margin-right: 6px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- plugin list ---- */
.toolbar { display: flex; flex-direction: column; gap: 10px; }
.toolbar .row > button { flex: 1 1 0; }
.filters { display: flex; gap: 4px; }
.filters button { flex: 1; padding: 6px 8px; font-size: .85rem; background: none; border-color: var(--surface0); color: var(--subtext0); }
.filters button.active { background: var(--surface0); color: var(--mauve); border-color: var(--surface1); }
label.check { display: flex; align-items: center; gap: 8px; margin: 0; cursor: pointer; }
label.check input { width: auto; }
.list-item .avatar { flex: none; }
.list-item .text { display: flex; flex-direction: column; min-width: 0; }
.list-item .text .sub { color: var(--overlay1); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .flags { margin-left: auto; display: flex; gap: 4px; flex: none; }

.avatar {
  width: 32px; height: 32px; border-radius: 8px; object-fit: cover;
  display: grid; place-items: center; font-weight: 700; color: var(--crust); background: var(--lavender);
}
.avatar.big { width: 56px; height: 56px; border-radius: 12px; font-size: 1.4rem; }

.flag { font-size: .72rem; font-weight: 600; border-radius: 999px; padding: 1px 8px; }
.flag.update { background: color-mix(in srgb, var(--yellow) 20%, transparent); color: var(--yellow); }
.flag.restart { background: color-mix(in srgb, var(--peach) 20%, transparent); color: var(--peach); }
.flag.failed { background: color-mix(in srgb, var(--red) 20%, transparent); color: var(--red); }
.flag.unknown { background: var(--surface0); color: var(--overlay1); }

/* ---- plugin detail ---- */
.plugin-head { display: flex; gap: 16px; align-items: flex-start; }
.plugin-head .info { flex: 1; min-width: 0; }
.plugin-head h1 { margin: 0 0 4px; }
.source-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--subtext0); font-size: .88rem; }
.source-line a { color: var(--sky); }
a { color: var(--sky); }

.state { font-size: .78rem; font-weight: 600; border-radius: 6px; padding: 2px 8px; white-space: nowrap; }
.state.ok { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.state.restart { background: color-mix(in srgb, var(--peach) 18%, transparent); color: var(--peach); }
.state.failed { background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--red); }
.state.disabled, .state.unknown { background: var(--surface0); color: var(--overlay1); }
.update { color: var(--yellow); white-space: nowrap; }
td.file { font-family: var(--mono); font-size: .8rem; color: var(--subtext0); word-break: break-all; }
td.version { font-family: var(--mono); font-size: .85rem; white-space: nowrap; }

.channel { font-size: .72rem; font-weight: 600; border-radius: 6px; padding: 1px 7px; text-transform: uppercase; letter-spacing: .04em; }
.channel.release { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.channel.beta { background: color-mix(in srgb, var(--yellow) 18%, transparent); color: var(--yellow); }
.channel.alpha { background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--red); }
.mc { font-size: .72rem; border-radius: 6px; padding: 1px 7px; background: var(--surface0); color: var(--subtext0); }
.mc.yes { color: var(--sky); }

.releases { display: flex; flex-direction: column; }
.release { padding: 10px 2px; border-bottom: 1px solid var(--surface0); }
.release:last-child { border-bottom: 0; }
.release .top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.release .top .version { font-family: var(--mono); font-weight: 600; }
.release .top .date { color: var(--overlay1); font-size: .82rem; }
.release .top .spacer { flex: 1; }
.release details { margin-top: 6px; }
.release summary { cursor: pointer; color: var(--subtext0); font-size: .85rem; }
.changelog { white-space: pre-wrap; font-size: .85rem; color: var(--subtext1); background: var(--base); border-radius: 8px; padding: 10px; max-height: 320px; overflow: auto; margin-top: 6px; }

.history-entry { display: flex; gap: 10px; align-items: center; padding: 8px 2px; border-bottom: 1px solid var(--surface0); }
.history-entry:last-child { border-bottom: 0; }
.history-entry .what { flex: 1; min-width: 0; word-break: break-word; }
.history-entry .when { color: var(--overlay1); font-family: var(--mono); font-size: .8rem; white-space: nowrap; }
.history-entry.undone .what { color: var(--overlay1); text-decoration: line-through; }
.notice { border-radius: 8px; padding: 10px 12px; background: color-mix(in srgb, var(--yellow) 12%, transparent); color: var(--yellow); }
.notice.error { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }
.notice.ok { background: color-mix(in srgb, var(--green) 12%, transparent); color: var(--green); }

/* ---- servers ---- */
.server-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.server-card h2 { color: var(--text); font-size: 1.15rem; display: flex; align-items: center; gap: 8px; }
.server-card .players { color: var(--subtext1); margin: 6px 0 12px; min-height: 1.5em; word-break: break-word; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--overlay0); }
.dot.active { background: var(--green); }
.dot.failed { background: var(--red); }
.dot.activating, .dot.deactivating { background: var(--peach); }

/* ---- dialogs ---- */
dialog {
  border: 1px solid var(--surface1); border-radius: 14px; padding: 0;
  background: var(--mantle); color: var(--text);
  width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
}
dialog::backdrop { background: rgba(17, 17, 27, .7); }
dialog:focus, dialog:focus-visible { outline: none; }
#dialog-body { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-head h2 { margin: 0; color: var(--text); font-size: 1.15rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.server-choice { display: flex; flex-direction: column; gap: 6px; }
.server-choice label.check { padding: 8px 10px; border: 1px solid var(--surface0); border-radius: 8px; }
.server-choice .what { color: var(--overlay1); font-size: .82rem; margin-left: auto; font-family: var(--mono); text-align: right; }
.joblog {
  font-family: var(--mono); font-size: .8rem; background: var(--crust); border-radius: 8px;
  padding: 10px 12px; max-height: 240px; overflow: auto; white-space: pre-wrap; color: var(--subtext1);
}
.report { border: 1px solid var(--surface0); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.report .title { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.report ul { margin: 0; padding-left: 20px; }
.report li { font-size: .85rem; word-break: break-word; }
.report .problems { font-family: var(--mono); font-size: .78rem; color: var(--subtext0); max-height: 180px; overflow: auto; }
.search-results { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; }
.search-results .list-item .text .sub { white-space: normal; }
input[type=file] { padding: 6px; }
