:root {
    color-scheme: dark;
    --bg: #070a10;
    --surface: #101722;
    --surface-2: #151f2d;
    --line: #273345;
    --text: #edf3fa;
    --muted: #91a0b4;
    --accent: #e3b341;
    --accent-2: #76b7ff;
    --danger: #ff6577;
    --success: #52d695;
    --radius: 14px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(circle at 15% 0%, #182337 0, transparent 35rem), var(--bg); }
a { color: inherit; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
code { color: #b7ccdf; }

.site-header { min-height: 72px; padding: 12px clamp(18px, 4vw, 58px); display: flex; align-items: center; gap: 28px; border-bottom: 1px solid var(--line); background: rgba(7, 10, 16, .92); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; margin-right: auto; }
.brand-logo { width: 48px; height: 48px; object-fit: contain; filter: drop-shadow(0 3px 9px rgba(0, 0, 0, .45)); }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
nav { display: flex; gap: 7px; }
nav a { color: var(--muted); padding: 9px 11px; border-radius: 8px; text-decoration: none; }
nav a:hover, nav a:focus-visible { color: var(--text); background: var(--surface-2); }
.user-menu { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.user-menu form { margin: 0; }

.page-shell { width: min(1440px, calc(100% - 36px)); margin: 0 auto; padding: 42px 0 64px; }
.site-footer { padding: 28px; border-top: 1px solid var(--line); color: var(--muted); text-align: center; font-size: 13px; }
.page-heading, .section-title { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.page-heading { margin-bottom: 26px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(30px, 4vw, 52px); letter-spacing: -.04em; margin-bottom: 7px; }
h2 { letter-spacing: -.02em; }
h3 { margin-bottom: 0; }
.page-heading p, .form-hint, small { color: var(--muted); }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; margin-bottom: 7px; }

.panel, .server-card, .auth-panel, .empty-state { background: linear-gradient(145deg, rgba(23, 32, 45, .95), rgba(13, 19, 28, .95)); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 20px 50px rgba(0, 0, 0, .22); }
.panel { padding: 24px; margin-bottom: 24px; }
.narrow, .auth-panel { max-width: 640px; }
.auth-panel { margin: 6vh auto; padding: clamp(26px, 5vw, 52px); }
.auth-crest { display: block; width: clamp(110px, 15vw, 170px); height: auto; margin: -16px auto 24px; filter: drop-shadow(0 16px 20px rgba(0, 0, 0, .45)); }
.empty-state { padding: 48px; text-align: center; }
.server-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 20px; }
.server-card { padding: 24px; position: relative; overflow: hidden; }
.server-card::before, .roster-section::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--squadron-color, var(--accent)); }
.server-card-head, .member-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; }
.server-facts, .member-facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; padding: 18px 0; margin: 16px 0; border-block: 1px solid var(--line); }
dt { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
dd { margin: 4px 0 0; overflow-wrap: anywhere; }
.mission-picker { margin: 0 0 18px; }
.input-action, .button-row { display: flex; gap: 9px; align-items: center; }
.input-action select { flex: 1; }
.button-row { flex-wrap: wrap; }
.compact-row { flex-wrap: nowrap; }

.button { appearance: none; display: inline-flex; justify-content: center; align-items: center; min-height: 40px; padding: 9px 15px; border: 1px solid transparent; border-radius: 9px; color: var(--text); background: var(--surface-2); text-decoration: none; font-weight: 700; transition: .16s ease; }
.button:hover { transform: translateY(-1px); filter: brightness(1.12); }
.button:disabled { opacity: .5; transform: none; cursor: wait; }
.button.primary { color: #171203; background: var(--accent); }
.button.secondary { border-color: #3f638d; background: #17314d; }
.button.danger { border-color: #873846; background: #4a1d27; }
.button.ghost { border-color: var(--line); background: transparent; }
.button.compact { min-height: 32px; padding: 6px 10px; font-size: 12px; }

.status-pill, .trust-badge { display: inline-flex; align-items: center; width: max-content; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.status-running, .trusted, .roster-active, .review-approved { color: var(--success); border-color: #276947; background: #102c20; }
.status-crashed, .status-stopped, .outside, .roster-retired, .review-rejected { color: var(--danger); border-color: #743340; background: #30161d; }
.status-starting, .status-stopping, .status-restarting, .review-quarantined, .roster-leave { color: var(--accent); border-color: #6a5627; background: #2a2414; }
.roster-reserve { color: var(--accent-2); }

.stacked-form { display: grid; gap: 17px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
label { display: grid; gap: 7px; color: #cdd8e5; font-size: 13px; font-weight: 700; }
input, select { width: 100%; border: 1px solid #344258; border-radius: 8px; color: var(--text); background: #0a1019; padding: 11px 12px; outline: none; }
input:focus, select:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(118, 183, 255, .12); }
.checkline { display: flex; align-items: center; gap: 9px; }
.checkline input, td input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
fieldset { min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
legend { padding: 0 7px; font-weight: 800; }
.form-hint { font-size: 12px; margin: 0; }

.flash { border: 1px solid #355072; border-radius: 9px; padding: 13px 16px; margin-bottom: 18px; background: #14273c; }
.flash.error { border-color: #753544; background: #351920; }
.flash.success { border-color: #2c6b4b; background: #132d21; }
.flash.info { border-color: #355072; background: #14273c; }

.table-panel { padding: 0; overflow: hidden; }
.table-panel > .section-title { padding: 22px 24px 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: rgba(6, 9, 14, .35); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
td small, td strong { display: block; }
tr:last-child td { border-bottom: 0; }

.roster-section { position: relative; overflow: hidden; --squadron-color: #9aa4b2; }
.squadron-306th { --squadron-color: #d4af37; }
.squadron-307th { --squadron-color: #d12626; }
.squadron-308th { --squadron-color: #1e6cff; }
.squadron-309th { --squadron-color: #229954; }
.squadron-310th { --squadron-color: #71318b; }
.roster-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 18px; }
.member-card { border: 1px solid var(--line); border-radius: 10px; padding: 18px; background: rgba(5, 9, 14, .38); }
.member-facts { font-size: 13px; margin-bottom: 0; }
.rank { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.billet { color: var(--muted); margin: 5px 0 0; }
.admin-grid { display: grid; grid-template-columns: minmax(420px, 1.1fr) minmax(440px, .9fr); gap: 22px; align-items: start; }
.editor-panel { position: sticky; top: 92px; }
.permission-table th, .permission-table td { text-align: center; padding: 9px; }
.permission-table th:first-child, .permission-table td:first-child { text-align: left; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; max-width: 420px; padding: 13px 17px; border: 1px solid #355072; border-radius: 10px; background: #14273c; box-shadow: 0 15px 40px #0008; }
.toast.error { border-color: #753544; background: #351920; }

.instance-switcher { min-width: 240px; }
.logs-grid { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 20px; align-items: start; }
.log-files-panel { padding: 0; overflow: hidden; max-height: 74vh; }
.log-files-panel .section-title { padding: 20px 20px 12px; }
.log-file-list { overflow-y: auto; max-height: calc(74vh - 72px); }
.log-file { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 18px; border-top: 1px solid var(--line); color: var(--text); text-decoration: none; }
.log-file:hover, .log-file.active { background: #1a2738; }
.log-file.active { box-shadow: inset 3px 0 var(--accent); }
.log-file strong, .log-file small { display: block; overflow-wrap: anywhere; }
.log-file time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.log-viewer-panel { min-width: 0; }
.log-actions { display: flex; align-items: center; gap: 14px; }
.log-meta { color: var(--muted); font-size: 12px; margin: 4px 0 12px; }
.log-output { height: 64vh; min-height: 420px; overflow: auto; margin: 0; padding: 18px; border: 1px solid #25364b; border-radius: 9px; background: #05080d; color: #c9d6e4; font: 12px/1.55 "Cascadia Mono", Consolas, monospace; white-space: pre; tab-size: 4; }
.dcs-log-dialog { width: min(1180px, calc(100vw - 32px)); max-width: none; margin: auto; padding: 0; border: 1px solid #344258; border-radius: var(--radius); color: var(--text); background: #0c121c; box-shadow: 0 30px 90px #000c; }
.dcs-log-dialog::backdrop { background: rgba(0, 0, 0, .78); backdrop-filter: blur(3px); }
.dcs-log-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); }
.dcs-log-dialog-head h2 { margin-bottom: 0; }
.dcs-log-dialog-head form { margin: 0; }
.dcs-log-toolbar { display: flex; align-items: end; gap: 14px; padding: 14px 22px; }
.dcs-log-toolbar label { width: 170px; }
.dcs-log-toolbar .log-meta { margin: 0 0 9px auto; text-align: right; }
.dcs-log-output { height: min(65vh, 720px); min-height: 360px; margin: 0 22px 22px; }

@media (max-width: 900px) {
    .site-header { flex-wrap: wrap; }
    nav { width: 100%; order: 3; overflow-x: auto; }
    .admin-grid { grid-template-columns: 1fr; }
    .logs-grid { grid-template-columns: 1fr; }
    .log-files-panel { max-height: 300px; }
    .log-file-list { max-height: 230px; }
    .editor-panel { position: static; }
    .dcs-log-toolbar { align-items: stretch; flex-direction: column; }
    .dcs-log-toolbar label { width: 100%; }
    .dcs-log-toolbar .log-meta { margin: 0; text-align: left; }
}
@media (max-width: 620px) {
    .page-shell { width: min(100% - 22px, 1440px); padding-top: 24px; }
    .site-header { padding-inline: 12px; gap: 14px; }
    .user-menu > span { display: none; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .form-grid, .server-facts, .member-facts { grid-template-columns: 1fr; }
    .server-grid { grid-template-columns: 1fr; }
}
