:root {
    --bg-deep: #070b16;
    --bg: #0b1220;
    --card: #13192a;
    --card-edge: #2a3552;
    --text: #e8dfc8;
    --text-muted: #7a8497;
    --brass: #d4a24c;
    --brass-hi: #e8b95c;
    --brass-lo: #5c4519;
    --magic: #5dd4e8;
    --danger: #b94228;
    --ok: #4ade80;
}

html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
    min-height: 100vh;
}

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 22px;
    border-bottom: 1px solid var(--brass-lo);
    background: linear-gradient(180deg, #0f1626 0%, var(--bg-deep) 100%);
}
.topbar h1 {
    font-size: 16px; margin: 0;
    color: var(--brass-hi);
    font-weight: 600; letter-spacing: 0.04em;
}

.status-pill {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px; border-radius: 99px;
    background: var(--bg-deep); border: 1px solid var(--card-edge);
    font-size: 13px;
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.status-pill.online .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.status-pill.offline .dot { background: var(--danger); }

.layout {
    max-width: 1400px; margin: 22px auto; padding: 0 22px;
    display: grid; grid-template-columns: 280px 1fr 280px; gap: 18px;
}
/* Below the 3-column breakpoint: drop the right sidebar to a new full-width row
   under the main + left sidebar so cards still get reasonable horizontal space. */
@media (max-width: 1100px) {
    .layout { grid-template-columns: 280px 1fr; }
    .aside-right { grid-column: 1 / -1; }
}
@media (max-width: 800px) {
    .layout { grid-template-columns: 1fr; }
    .aside-right { grid-column: 1 / -1; }
}

.card {
    background: linear-gradient(180deg, #13192a 0%, #0a0f1a 100%);
    border: 1px solid var(--brass-lo);
    border-radius: 8px;
    padding: 18px;
}
.card + .card { margin-top: 14px; }
.card h2 {
    margin: 0 0 14px;
    font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--brass-hi); font-weight: 600;
}

.stat-row { display: flex; justify-content: space-between; margin: 6px 0; font-size: 13px; }
.stat-row .key { color: var(--text-muted); }
.stat-row .val { color: var(--text); font-family: "SF Mono", Consolas, monospace; }

.name-list { list-style: none; padding: 0; margin: 0; }
.name-list li {
    padding: 6px 8px; background: var(--bg-deep); border-radius: 4px;
    margin-bottom: 4px; font-size: 13px;
    display: flex; align-items: center; justify-content: space-between;
}
.name-list li button {
    background: transparent; border: 1px solid var(--card-edge);
    color: var(--text-muted); padding: 2px 8px; font-size: 11px;
    border-radius: 3px; cursor: pointer;
}
.name-list li button:hover { color: var(--danger); border-color: var(--danger); }
.empty-state { color: var(--text-muted); font-size: 13px; padding: 8px 0; font-style: italic; }

.console-pane {
    background: #050810;
    border: 1px solid var(--card-edge);
    border-radius: 4px;
    padding: 12px;
    font-family: "SF Mono", Consolas, "Cascadia Mono", monospace;
    font-size: 12px; line-height: 1.4;
    color: #b7c0d6;
    height: 480px; overflow-y: auto;
    white-space: pre-wrap; word-break: break-word;
}
.console-pane .err { color: #ff8a72; }

.input-row { display: flex; gap: 8px; margin-top: 10px; }
.input-wrap {
    flex: 1; position: relative;
    background: var(--bg-deep);
    border: 1px solid var(--card-edge);
    border-radius: 4px;
}
.input-wrap:focus-within { border-color: var(--brass); }

.ghost {
    position: absolute; inset: 0;
    padding: 8px 12px;
    font-family: "SF Mono", Consolas, monospace; font-size: 13px;
    line-height: normal;
    color: var(--text-muted);
    pointer-events: none;
    white-space: pre;
    overflow: hidden;
    opacity: 0.55;
}
.ghost .typed { color: transparent; }

.input-wrap input {
    width: 100%; box-sizing: border-box;
    background: transparent;
    border: none;
    color: var(--text);
    padding: 8px 12px;
    font-family: "SF Mono", Consolas, monospace; font-size: 13px;
    position: relative;
}
.input-wrap input:focus { outline: none; }
/* Hide the browser's built-in number-input spinner -- looks out of place against the dark theme */
.input-wrap input[type="number"]::-webkit-inner-spin-button,
.input-wrap input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none; margin: 0;
}
.input-wrap input[type="number"] { -moz-appearance: textfield; }

/* Suggestion dropdown -- shown below the command input with multiple matches */
.suggest-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--bg-deep);
    border: 1px solid var(--brass-lo);
    border-radius: 4px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
    display: none;
}
.suggest-list.show { display: block; }
.suggest-item {
    padding: 7px 12px;
    cursor: pointer;
    font-family: "SF Mono", Consolas, monospace;
    font-size: 13px;
    color: var(--text);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}
.suggest-item + .suggest-item {
    border-top: 1px solid #1a2436;
}
.suggest-item:hover, .suggest-item.active {
    background: var(--card);
    color: var(--brass-hi);
}
.suggest-item .args {
    color: var(--text-muted);
    font-size: 11px;
    font-style: italic;
}
.suggest-item .args em { font-style: normal; color: var(--brass); }
.suggest-empty { padding: 8px 12px; color: var(--text-muted); font-size: 12px; font-style: italic; }

.hint {
    font-size: 11px; color: var(--text-muted);
    padding: 6px 0 0 4px; min-height: 16px;
}
.hint kbd {
    background: var(--bg-deep); border: 1px solid var(--card-edge);
    padding: 1px 4px; border-radius: 2px; font-size: 10px;
}

button {
    background: linear-gradient(180deg, var(--brass-hi) 0%, var(--brass) 50%, var(--brass-lo) 100%);
    color: #1a140f;
    border: 1px solid var(--brass-lo);
    padding: 8px 16px; border-radius: 4px;
    font-weight: 600; cursor: pointer; font-size: 13px;
}
button:hover { filter: brightness(1.1); }
button.danger {
    background: linear-gradient(180deg, #d65a3e 0%, var(--danger) 50%, #6a2814 100%);
    color: #fff;
    border-color: #6a2814;
}
button.ghost-btn {
    background: var(--bg-deep);
    color: var(--text);
    border-color: var(--card-edge);
}

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.footer { color: var(--text-muted); font-size: 11px; text-align: center; padding: 22px; }

/* Modal dialogs (Pregen / Backups / Wipe / etc.) */
.modal {
    position: fixed; inset: 0; z-index: 50;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(7, 11, 22, 0.85);
    backdrop-filter: blur(2px);
}
.modal-dialog {
    position: relative;
    background: linear-gradient(180deg, #13192a 0%, #0a0f1a 100%);
    border: 1px solid var(--brass-lo);
    border-radius: 8px;
    padding: 24px;
    width: 100%; max-width: 520px;
    max-height: 85vh; overflow-y: auto;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6);
}
.modal-dialog.danger { border-color: #6a2814; }
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--card-edge);
}
.modal-header h2 {
    margin: 0;
    font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--brass-hi); font-weight: 600;
}
.modal-dialog.danger .modal-header h2 { color: #d65a3e; }
.modal-close {
    background: transparent; border: none;
    color: var(--text-muted); font-size: 22px; line-height: 1;
    cursor: pointer; padding: 0 4px;
}
.modal-close:hover { color: var(--text); }

/* Trigger button list (the "World" card, etc.) */
.trigger-list {
    display: flex; flex-direction: column; gap: 6px;
}
.trigger-list button {
    width: 100%; text-align: left;
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px;
}
.trigger-list .badge {
    background: var(--bg-deep); border: 1px solid var(--card-edge);
    color: var(--text-muted);
    padding: 1px 6px; border-radius: 99px;
    font-size: 10px; font-weight: 500;
}
.trigger-list .badge.ok    { color: var(--ok);    border-color: var(--ok); }
.trigger-list .badge.warn  { color: var(--brass-hi); border-color: var(--brass-lo); }

/* Topbar server icon */
.topbar-icon {
    height: 28px; width: 28px;
    margin-right: 10px;
    image-rendering: -webkit-optimize-contrast;
}
.topbar-left {
    display: flex; align-items: center;
}

/* Login overlay */
.login-overlay {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(7, 11, 22, 0.92);
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(2px);
}
.login-overlay[hidden] { display: none; }
.login-box {
    background: linear-gradient(180deg, #13192a 0%, #0a0f1a 100%);
    border: 1px solid var(--brass-lo);
    border-radius: 8px;
    padding: 28px 32px;
    width: 320px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6);
}
.login-box h2 {
    margin: 0 0 4px;
    font-size: 16px; letter-spacing: 0.04em;
    color: var(--brass-hi); font-weight: 600;
}
.login-box p {
    margin: 0 0 16px; color: var(--text-muted); font-size: 13px;
}
.login-box .input-wrap { margin-bottom: 12px; }
.login-box button { width: 100%; }
.login-error { color: var(--danger); font-size: 12px; min-height: 14px; padding-top: 8px; }

/* Account card */
.acct-form { font-size: 12px; }
.acct-msg { font-size: 12px; min-height: 14px; margin-top: 8px; color: var(--danger); }
.acct-msg.ok { color: var(--ok); }

/* Modpack update card */
#updateCard .update-note {
    font-size: 12px; color: var(--text-muted);
    margin: 10px 0 0; line-height: 1.4;
}
#updateCard .update-progress { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--card-edge); }
#updateCard .update-phase {
    font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--brass-hi); font-weight: 600; margin-bottom: 6px;
}
#updateCard .update-status { font-size: 12px; color: var(--text); margin-top: 6px; }
#updateCard .update-progress button { margin-top: 10px; }
/* Pulsing border highlight when an update is available */
#updateCard.has-update {
    border-color: var(--brass);
    box-shadow: 0 0 0 1px var(--brass-lo), 0 0 18px rgba(212, 162, 76, 0.18);
}

/* Resources card -- Memory + CPU with progress bars */
.res-block { margin-bottom: 14px; }
.res-block:last-child { margin-bottom: 0; }
.res-label {
    display: flex; justify-content: space-between; align-items: baseline;
    font-size: 12px; color: var(--text-muted);
    margin-bottom: 6px;
}
.res-label .res-val { color: var(--text); font-family: "SF Mono", Consolas, monospace; }
.res-bar {
    height: 6px;
    background: var(--bg-deep);
    border: 1px solid var(--card-edge);
    border-radius: 3px;
    overflow: hidden;
}
.res-bar > div {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--brass-lo), var(--brass-hi));
    transition: width 0.4s ease;
}
.res-sub {
    display: flex; justify-content: space-between;
    margin-top: 6px;
    font-size: 11px; color: var(--text-muted);
}
.res-sub strong {
    color: var(--text); font-family: "SF Mono", Consolas, monospace;
    font-weight: 500; margin-left: 4px;
}

/* Collapsible cards (h2 click toggles) */
.card.collapsible .collapsible-toggle {
    cursor: pointer;
    user-select: none;
    display: flex; align-items: center; gap: 8px;
}
.card.collapsible .caret {
    display: inline-block;
    transition: transform 0.2s ease;
    color: var(--brass);
    font-size: 12px;
}
.card.collapsible:not(.expanded) .caret { transform: rotate(-90deg); }
.card.collapsible:not(.expanded) .card-body { display: none; }
.card.collapsible:not(.expanded) h2 { margin: 0; }

/* Server settings modal */
.settings-section-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}
.settings-grid label {
    display: flex; flex-direction: column; gap: 4px;
    font-size: 11px; color: var(--text-muted);
}
.settings-grid input, .settings-grid select {
    background: var(--bg-deep);
    border: 1px solid var(--card-edge);
    border-radius: 4px;
    color: var(--text);
    padding: 6px 8px;
    font-family: "SF Mono", Consolas, monospace;
    font-size: 12px;
}
.settings-grid input:focus, .settings-grid select:focus {
    outline: none; border-color: var(--brass);
}
.settings-grid label:nth-child(1) { grid-column: 1 / -1; } /* MOTD spans both cols */
.settings-checks {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 14px;
    padding-top: 10px;
    border-top: 1px solid var(--card-edge);
}
.settings-checks label { font-size: 12px; }

/* Whitelist requests */
.wl-req-label {
    font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--brass-hi); font-weight: 600;
    margin: 6px 0 6px 2px;
}
#wlRequests li {
    flex-direction: column; align-items: stretch; gap: 6px;
}
.wl-req-meta { font-size: 11px; color: var(--text); }
.wl-req-msg { font-size: 11px; color: var(--text-muted); font-style: italic; }
.wl-req-actions { display: flex; gap: 4px; }
.wl-req-actions button { padding: 3px 8px; font-size: 10px; }
.card h2 .badge { vertical-align: middle; margin-left: 6px; }

/* Backups card */
.backup-item {
    display: flex; justify-content: space-between; align-items: center;
    gap: 8px; padding: 8px 10px;
    flex-wrap: wrap;
}
.backup-meta { flex: 1; min-width: 0; }
.backup-name {
    font-family: "SF Mono", Consolas, monospace; font-size: 11px;
    color: var(--text); word-break: break-all;
}
.backup-sub { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.backup-actions { display: flex; gap: 4px; flex-shrink: 0; }
.backup-actions button { font-size: 10px; padding: 3px 8px; }

/* Danger zone card */
.danger-card { border-color: #6a2814; }
.danger-card .collapsible-toggle .caret { color: var(--danger); }
.danger-card h2 { color: #d65a3e; }
.danger-note {
    font-size: 12px; color: var(--text-muted);
    margin: 0 0 12px; line-height: 1.45;
}
.danger-note code {
    background: var(--bg-deep); border: 1px solid var(--card-edge);
    padding: 1px 5px; border-radius: 3px; font-size: 11px;
}
.danger-row {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--text);
    cursor: pointer;
}
.danger-row input[type="checkbox"] { margin: 0; }
.danger-section {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid var(--card-edge);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.02);
}
.danger-section-title {
    font-size: 12px; font-weight: 600;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
    letter-spacing: 0.4px;
}
.danger-section .danger-row { margin: 4px 0; }
.danger-section code {
    font-family: var(--mono, monospace);
    font-size: 12px;
    color: var(--accent, #d4a24c);
}
.danger-section input[type="text"] {
    background: var(--input-bg, #0b1220);
    color: var(--text);
    border: 1px solid var(--card-edge);
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 12px;
    font-family: var(--mono, monospace);
}
.danger-section input[type="text"]:disabled { opacity: 0.4; }

/* Pre-generation status panel */
.pg-status {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--card-edge);
    font-size: 12px;
}
.pg-status .stat-row { font-size: 12px; margin: 4px 0; }
.pg-progress-bar {
    height: 6px;
    background: var(--bg-deep);
    border: 1px solid var(--card-edge);
    border-radius: 3px;
    margin: 8px 0 10px;
    overflow: hidden;
}
.pg-progress-bar > div {
    height: 100%;
    background: linear-gradient(90deg, var(--brass-lo), var(--brass-hi));
    width: 0%;
    transition: width 0.4s ease;
}
.pg-state-running  { color: var(--ok); }
.pg-state-paused   { color: var(--brass-hi); }
.pg-state-idle     { color: var(--text-muted); }
.pg-state-cancelling { color: var(--danger); }
