:root {
  --bg: #0d0d0e;
  --panel: #141417;
  --panel-2: #1a1a1f;
  --line: rgba(255, 255, 255, 0.07);
  --line-accent: rgba(34, 163, 90, 0.25);
  --accent: #22a35a;
  --accent-dark: #157a3b;
  --text: #f1f5f9;
  --muted: #8b93a4;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, sans-serif;
}
.hidden { display: none !important; }
a { color: var(--accent); }

.brand {
  font-family: Orbitron, sans-serif;
  font-weight: 900;
  letter-spacing: 3px;
  font-size: 16px;
}
.brand span { color: var(--accent); font-size: 11px; letter-spacing: 2px; margin-left: 4px; }

/* --- Вход --- */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px;
  background: var(--panel); border: 1px solid var(--line-accent);
  border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px;
}
.login-card .brand { text-align: center; margin-bottom: 8px; }

/* --- Каркас --- */
.app { display: flex; min-height: 100%; }
.nav {
  width: 220px; flex-shrink: 0; background: var(--panel);
  border-right: 1px solid var(--line); padding: 22px 14px;
  display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
.nav .brand { padding: 0 8px; }
.nav nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav nav a {
  padding: 9px 12px; border-radius: 8px; color: var(--muted);
  text-decoration: none; font-weight: 600; cursor: pointer;
}
.nav nav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.03); }
.nav nav a.active { color: var(--text); background: rgba(34, 163, 90, 0.14); }
.view { flex: 1; min-width: 0; padding: 28px 32px 60px; max-width: 1180px; }

@media (max-width: 760px) {
  .app { flex-direction: column; }
  .nav { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; gap: 10px; }
  .nav nav { flex-direction: row; flex-wrap: wrap; flex-basis: 100%; order: 3; }
  .nav nav a { padding: 6px 10px; }
  .nav #logout { margin-left: auto; }
  .view { padding: 18px 16px 48px; }
}

/* --- Заголовки --- */
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
h1 { font-size: 22px; margin: 0; font-weight: 800; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 700; }
.sub { color: var(--muted); font-size: 13px; }

/* --- Карточки --- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.grid { display: grid; gap: 14px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.stat .value { font-size: 26px; font-weight: 800; margin-top: 4px; }

.item {
  display: flex; gap: 16px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px;
}
.item .thumb { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; background: var(--panel-2); flex-shrink: 0; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 700; font-size: 15px; }
.item .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.item .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 760px) {
  .item { flex-wrap: wrap; }
  .item .actions { width: 100%; justify-content: flex-start; }
}

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 700;
  background: rgba(255, 255, 255, 0.06); color: var(--muted); margin-left: 6px; vertical-align: 1px;
}
.badge.ok { background: rgba(52, 211, 153, 0.12); color: var(--ok); }
.badge.off { background: rgba(248, 113, 113, 0.12); color: var(--danger); }
.badge.accent { background: rgba(34, 163, 90, 0.15); color: #6ee7a0; }
.badge.warn { background: rgba(251, 191, 36, 0.12); color: var(--warn); }

.notice {
  border: 1px solid rgba(251, 191, 36, 0.3); background: rgba(251, 191, 36, 0.06);
  color: #fde68a; padding: 12px 14px; border-radius: var(--radius); font-size: 13px;
}
.notice.info { border-color: var(--line-accent); background: rgba(34, 163, 90, 0.06); color: #d1fae5; }

code, .mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }
pre.snippet {
  background: #0a0a0c; border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 8px 0 0;
}

/* --- Формы --- */
label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
input, select, textarea {
  background: #0f0f12; border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 9px 11px; font: inherit; font-size: 14px; width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 13px; font-weight: 500; }
.check input { width: auto; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.hint { font-weight: 400; color: #6b7280; font-size: 11.5px; }
.form-error { color: var(--danger); font-size: 13px; min-height: 0; }

/* --- Кнопки --- */
.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; font-size: 13px;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: rgba(255, 255, 255, 0.18); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: rgba(248, 113, 113, 0.4); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.wide { width: 100%; padding: 11px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* --- Таблица файлов --- */
.files { width: 100%; border-collapse: collapse; }
.files td { padding: 8px 10px; border-top: 1px solid var(--line); }
.files tr:hover td { background: rgba(255, 255, 255, 0.02); }
.files .name { cursor: default; word-break: break-all; }
.files .dir { color: #6ee7a0; cursor: pointer; font-weight: 600; }
.files .num { color: var(--muted); text-align: right; white-space: nowrap; font-size: 12px; }
.crumbs { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; font-size: 13px; }
.crumbs a { cursor: pointer; text-decoration: none; }
.crumbs span { color: var(--muted); }

.progress { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-dark)); transition: width 0.15s; }

/* --- Опциональные моды в редакторе сервера --- */
.opt-mod { border: 1px dashed var(--line-accent); border-radius: 8px; padding: 12px; }

/* --- Модальные окна --- */
.modal-back {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.65); display: flex;
  align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50;
}
.modal {
  width: 100%; max-width: 760px; background: var(--panel); border: 1px solid var(--line-accent);
  border-radius: 14px; padding: 22px;
}
.modal .modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal .modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.img-preview { max-width: 100%; max-height: 160px; border-radius: 8px; margin-top: 6px; display: block; }

/* --- Тосты --- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line-accent); border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: 8px; max-width: 360px; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.toast.error { border-left-color: var(--danger); }
.empty { color: var(--muted); text-align: center; padding: 30px; }

/* --- Сборка: загрузка --- */
.pack-kv { display: flex; flex-direction: column; margin-right: 18px; }
.pack-kv span { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.pack-kv b { font-size: 15px; }
.dropzone {
  border: 2px dashed var(--line-accent); border-radius: 14px; padding: 28px 20px; text-align: center;
  background: rgba(34, 163, 90, 0.03); transition: background 0.15s, border-color 0.15s;
}
.dropzone.over { background: rgba(34, 163, 90, 0.12); border-color: var(--accent); }
.dropzone .dz-icon { font-size: 30px; color: var(--accent); line-height: 1; }
.dropzone .dz-title { font-weight: 700; font-size: 16px; margin: 8px 0 6px; }
.dropzone .sub { max-width: 720px; margin: 0 auto; }
.dz-progress { max-width: 560px; margin: 16px auto 0; text-align: left; }
.progress > div.indeterminate { width: 35% !important; animation: indet 1.1s infinite ease-in-out; }
@keyframes indet { from { margin-left: -35%; } to { margin-left: 100%; } }

/* --- Сегментированный переключатель --- */
.seg { display: inline-flex; background: #0f0f12; border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 12px; border-radius: 7px; cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--panel-2); color: var(--text); box-shadow: 0 0 0 1px var(--line-accent); }
.seg.small button { font-size: 12px; padding: 4px 9px; }

/* --- Список модов --- */
.mod-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--line); }
.mod-row.disabled .mod-body { opacity: 0.45; }
.mod-row.disabled .mod-name { text-decoration: line-through; }
.mod-row.optional .seg button.active { box-shadow: 0 0 0 1px var(--warn); color: var(--warn); }
.mod-row.disabled .seg button.active { box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.5); color: var(--danger); }
.mod-icon {
  width: 36px; height: 36px; border-radius: 8px; background: var(--panel-2); flex-shrink: 0;
  position: relative; display: grid; place-items: center; overflow: hidden; color: var(--muted); font-weight: 800;
}
.mod-icon img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; background: var(--panel-2); }
.mod-body { flex: 1; min-width: 0; }
.mod-name { font-weight: 700; }
.mod-ver { color: var(--muted); font-weight: 500; font-size: 12px; margin-left: 6px; }
.mod-meta { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 760px) {
  .mod-row { flex-wrap: wrap; }
  .mod-row .seg { order: 3; }
}

/* --- Переключатели (как в лаунчере) --- */
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.opt-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.opt-card input.opt-title { background: transparent; border-color: transparent; font-weight: 700; font-size: 15px; padding: 4px 6px; }
.opt-card textarea.opt-desc { background: transparent; border-color: transparent; min-height: 44px; font-size: 12.5px; color: var(--muted); padding: 4px 6px; }
.opt-card input.opt-title:hover, .opt-card textarea.opt-desc:hover { border-color: var(--line); }
.opt-card input.opt-title:focus, .opt-card textarea.opt-desc:focus { border-color: var(--accent); background: #0f0f12; }
label.inline { flex-direction: row; align-items: center; gap: 6px; }
label.inline input, label.inline select { padding: 5px 8px; font-size: 12px; }
.switch { position: relative; flex-shrink: 0; width: 42px; height: 24px; margin-top: 6px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #2a2a31; border-radius: 99px; transition: background 0.15s; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; background: #0f0f12; border: 1px solid var(--line);
  border-radius: 99px; padding: 2px 4px 2px 10px; font-size: 12px;
}
.chip.missing { border-color: rgba(248, 113, 113, 0.4); color: var(--danger); }
.chip button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 4px; }
.chip button:hover { color: var(--danger); }

/* --- План загрузки --- */
.plan-cat {
  flex-direction: row; align-items: flex-start; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); font-weight: 500;
}
.plan-cat input { width: auto; margin-top: 3px; accent-color: var(--accent); }
.plan-cat.off { opacity: 0.55; }
.plan-samples { color: var(--muted); font-size: 12px; margin-top: 3px; word-break: break-word; }

/* --- Панель сохранения --- */
.savebar {
  position: sticky; bottom: 14px; margin-top: 14px; display: flex; align-items: center; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--accent); border-radius: 12px; padding: 10px 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5); font-weight: 600;
}
