:root {
  --bg: #0a0c10;
  --bg-elevated: #12151c;
  --bg-card: #181c26;
  --border: rgba(255, 255, 255, 0.08);
  --text: #eef1f6;
  --muted: #8b95a8;
  --accent: #e85d2d;
  --accent-soft: rgba(232, 93, 45, 0.15);
  --accent-glow: rgba(232, 93, 45, 0.35);
  --ok: #3ecf8e;
  --danger: #f07178;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --font: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(232, 93, 45, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(62, 120, 255, 0.06), transparent);
}

.app {
  display: flex;
  min-height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #c44a1f);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.brand strong { display: block; font-size: 0.95rem; }
.brand small { color: var(--muted); font-size: 0.75rem; }

.nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-icon { opacity: 0.85; font-size: 1rem; }

.sidebar-foot { padding: 0.5rem; }
.pill {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(62, 207, 142, 0.12);
  color: var(--ok);
  border: 1px solid rgba(62, 207, 142, 0.25);
}
.pill.error { background: rgba(240,113,120,0.12); color: var(--danger); border-color: rgba(240,113,120,0.3); }

/* Main */
.main {
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1.25rem 1.5rem 2rem;
}

.view {
  display: none;
  animation: fade 0.2s ease;
  min-width: 0;
}
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-head { margin-bottom: 1.5rem; }
.view-head h1 { font-size: 1.65rem; font-weight: 700; letter-spacing: -0.02em; }
.view-head p { color: var(--muted); margin-top: 0.35rem; font-size: 0.9rem; }

/* Master-detail: список слева, редактор справа */
.layout-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.layout-2.layout-fill,
.layout-master-detail {
  --md-height: calc(100vh - 11rem);
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  grid-template-rows: 1fr;
  gap: 1rem;
  height: var(--md-height);
  min-height: 440px;
  max-height: calc(100vh - 5.5rem);
  align-items: stretch;
  min-width: 0;
}

.layout-2.layout-fill > .panel,
.layout-2.layout-fill > .panel-scroll,
.layout-master-detail > .panel,
.layout-master-detail > .panel-scroll {
  min-width: 0;
  min-height: 0;
  max-height: none;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-list {
  background: var(--bg-elevated);
}

.panel-detail {
  background: var(--bg-card);
}

.panel-list .panel-head {
  flex-shrink: 0;
  padding-bottom: 0.65rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.panel-detail .panel-head,
.panel-detail > .empty-state {
  flex-shrink: 0;
}

.panel-detail .detail-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding-right: 0.1rem;
}

.panel-detail > .empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  margin: 0;
}

.panel-scroll {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.entity-list-fill {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
}

.entity-list .entity-item {
  border-radius: 8px;
}

@media (max-width: 1100px) {
  .layout-2.layout-fill,
  .layout-master-detail {
    grid-template-columns: minmax(220px, 38%) minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .layout-2.layout-fill,
  .layout-master-detail {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
    max-height: none;
  }
  .layout-2.layout-fill > .panel-list,
  .layout-master-detail > .panel-list {
    max-height: min(40vh, 320px);
  }
  .layout-2.layout-fill > .panel-detail,
  .layout-master-detail > .panel-detail {
    min-height: min(50vh, 480px);
  }
}
.panel-head-tight { margin-bottom: 0.65rem; }
.panel-head-wrap { flex-wrap: wrap; }
.meta-line { font-size: 0.8rem; margin-top: 0.2rem; }
.compact-grid { gap: 0.5rem; }
.mt-sm { margin-top: 0.5rem; }

.mt { margin-top: 1rem; }

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.panel-head h2 { font-size: 1rem; font-weight: 600; }

.section-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 1rem 0 0.65rem;
  font-weight: 600;
}

.muted { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.75rem; }
.muted code { background: var(--bg); padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.8rem; }

/* Forms */
.input, select.input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  min-width: 0;
  flex: 1;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) {
  .form-grid.cols-3 { grid-template-columns: 1fr 1fr; }
}
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field span { font-size: 0.78rem; color: var(--muted); font-weight: 500; }
.field.check { flex-direction: row; align-items: center; gap: 0.5rem; }

.btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.1s, background 0.15s;
}
.btn:hover { background: rgba(255,255,255,0.06); }
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: linear-gradient(180deg, #f07040, var(--accent));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { background: rgba(240,113,120,0.15); border-color: rgba(240,113,120,0.35); color: var(--danger); }
.btn.sm { padding: 0.35rem 0.65rem; font-size: 0.78rem; }
.btn.icon { width: 36px; height: 36px; padding: 0; font-size: 1.25rem; line-height: 1; }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Lists */
.entity-list {
  overflow-y: auto;
}
.panel-list .entity-list:not(.entity-list-fill) {
  max-height: min(60vh, 520px);
}
.entity-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 0.25rem;
  transition: background 0.12s, border-color 0.12s;
}
.entity-item:hover { background: rgba(255,255,255,0.03); }
.entity-item.active {
  background: var(--accent-soft);
  border-color: rgba(232, 93, 45, 0.35);
}
.entity-item strong { font-size: 0.9rem; }
.entity-item small { color: var(--muted); font-size: 0.75rem; display: block; margin-top: 0.15rem; }

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 2.5rem 1rem;
  font-size: 0.9rem;
}

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.5rem 0.25rem 0.65rem;
  font-size: 0.78rem;
}
.chip button {
  border: none;
  background: rgba(240,113,120,0.2);
  color: var(--danger);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
}

/* Gather resources */
.gather-type-block {
  margin-bottom: 1.25rem;
}
.gather-type-block h2 {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
}
.resource-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  text-align: center;
  transition: border-color 0.15s;
}
.resource-card:hover { border-color: rgba(232, 93, 45, 0.4); }
.resource-card img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  margin: 0 auto 0.35rem;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
}
.resource-card .name {
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  line-height: 1.2;
}
.resource-card input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  margin: 0.25rem 0;
}
.resource-card .mult-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  justify-content: center;
}
.resource-card .mult-row input[type="number"] {
  width: 52px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.25rem;
  font-size: 0.8rem;
  text-align: center;
}
.resource-card .mult-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 2.5rem;
}
.resource-card .btn-reset {
  margin-top: 0.35rem;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  opacity: 0.7;
}

.dispenser-card img { width: 40px; height: 40px; }

/* Kit items */
.view-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.view-head-row .btn { flex-shrink: 0; }
.kit-warn {
  font-size: 0.8rem;
  color: var(--danger);
  background: rgba(240, 113, 120, 0.1);
  border: 1px solid rgba(240, 113, 120, 0.35);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  margin-bottom: 0.65rem;
}
.kit-warn.hidden { display: none; }
.kit-meta-grid { margin-bottom: 0.5rem; }
.kit-containers { display: flex; flex-direction: column; gap: 0.65rem; margin-top: 0.5rem; }
.kit-containers-compact .kit-container { padding: 0.55rem 0.65rem; }
.kit-container {
  background: var(--bg);
  border-radius: 10px;
  padding: 0.85rem;
  border: 1px solid var(--border);
}
.kits-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}
.kits-toolbar .input { flex: 1; min-width: 100px; max-width: 200px; }
.kits-player-details {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.kits-player-details summary { cursor: pointer; margin-bottom: 0.35rem; }
.kit-empty-hint { font-size: 0.75rem; padding: 0.35rem 0; }
.kit-cond {
  font-size: 0.7rem;
  color: var(--ok);
  margin-left: 0.25rem;
}
.kit-cond.bad { color: var(--danger); }
.container-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
}
.container-head h3 { font-size: 0.85rem; font-weight: 600; }

.item-slots { display: flex; flex-direction: column; gap: 0.4rem; min-height: 48px; }

.item-row {
  display: grid;
  grid-template-columns: 40px 1fr auto auto auto;
  gap: 0.5rem;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
}
.item-row.compact {
  grid-template-columns: 32px 1fr 52px 44px 28px;
  padding: 0.3rem 0.4rem;
  gap: 0.35rem;
}
.item-row.compact img { width: 28px; height: 28px; }
.input.sm-num {
  width: 100%;
  padding: 0.25rem 0.35rem;
  font-size: 0.78rem;
}
.item-row img { width: 36px; height: 36px; object-fit: contain; }
.item-row .item-name { font-size: 0.82rem; font-weight: 500; }
.item-row .item-name small { display: block; color: var(--muted); font-weight: 400; font-size: 0.72rem; }
.item-row input[type="number"] {
  width: 64px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.3rem;
  font-size: 0.8rem;
}

.advanced summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; margin-bottom: 0.5rem; }
.code {
  width: 100%;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  padding: 0.75rem;
}

.kit-stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}
.kit-stat-name { font-weight: 500; min-width: 4rem; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
}
.modal-sheet {
  position: relative;
  width: min(720px, 100%);
  max-height: 85vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  z-index: 1;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.modal-head h2 { font-size: 1.1rem; }
#item-search { margin-bottom: 0.75rem; width: 100%; flex: none; }

.item-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 0.4rem;
  overflow-y: auto;
  flex: 1;
  min-height: 200px;
  max-height: 55vh;
  padding: 0.25rem;
}

.picker-cell {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.12s, transform 0.1s;
}
.picker-cell:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.picker-cell img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  display: block;
  margin: 0 auto 0.25rem;
}
.picker-cell span {
  font-size: 0.65rem;
  color: var(--muted);
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.85rem 1.25rem;
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  max-width: 360px;
  animation: slideUp 0.25s ease;
}
.toast.error { border-color: rgba(240,113,120,0.5); color: var(--danger); }
.toast.hidden { display: none; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.hidden { display: none !important; }

.subnav {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.subnav button {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--muted);
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.subnav button.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(232, 93, 45, 0.4);
  font-weight: 600;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}
.chip-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  cursor: pointer;
}
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
.chip-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.chip-btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem 0.35rem 0.45rem;
  border-radius: 10px;
}
.chip-btn-icon img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}
.qs-furnace-row { gap: 0.5rem; }

.check-inline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.bl-tables { max-height: 420px; }
.mt { margin-top: 0.75rem; }

/* Permissions */
.perms-panel { min-width: 0; }
.perm-scroll-box {
  max-height: min(36vh, 340px);
  min-height: 7rem;
  overflow-y: auto;
  margin-bottom: 0.5rem;
  padding-right: 0.15rem;
}
#group-perms-by-plugin {
  flex: 1 1 auto;
  min-height: 7rem;
}
.panel-detail .detail-body:not(.hidden) {
  min-height: 12rem;
}
.perm-catalog-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin-top: 0.35rem;
  padding-right: 0.1rem;
}
.catalog-plugin-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0.65rem 0.5rem 0.2rem;
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  z-index: 1;
}
.catalog-detail-head h2 {
  font-size: 0.95rem;
  font-weight: 600;
  word-break: break-all;
  line-height: 1.3;
  max-width: min(100%, 28rem);
}
.catalog-detail-inner {
  padding-top: 0.15rem;
}
.catalog-code {
  display: block;
  font-size: 0.85rem;
  margin: 0.5rem 0;
  padding: 0.55rem 0.7rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  word-break: break-all;
}
.catalog-hint {
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text);
  margin-bottom: 0.75rem;
}
.catalog-meta {
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
}
.panel-list .chip-row {
  flex-shrink: 0;
  margin-bottom: 0.35rem;
}
/* Поиск в левой колонке — не растягивать по высоте (flex: 1 в колонке ломал layout) */
.panel-list > .input[type="search"],
#perm-catalog-search,
#bl-table-search {
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  padding: 0.38rem 0.6rem;
  font-size: 0.8125rem;
  line-height: 1.25;
  margin-bottom: 0.35rem;
}
.panel-list .panel-head .input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 14rem;
  padding: 0.38rem 0.55rem;
  font-size: 0.8125rem;
}
.perm-catalog-section { margin-bottom: 1rem; }
.perm-catalog-heading {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.perm-plugin-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.45rem;
  background: var(--bg);
}
.perm-plugin-block summary {
  cursor: pointer;
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.perm-plugin-block summary::-webkit-details-marker { display: none; }
.perm-plugin-block[open] summary { border-bottom: 1px solid var(--border); }
.perm-list { padding: 0.35rem 0.5rem 0.5rem; }
.perm-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.perm-row:last-child { border-bottom: none; }
.perm-row-main { min-width: 0; flex: 1; }
.perm-code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.75rem;
  color: var(--accent);
  word-break: break-all;
}
.perm-hint {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.15rem;
  line-height: 1.35;
}
.perm-badge {
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--muted);
}
.perm-empty-hint { font-size: 0.8rem; padding: 0.5rem 0; }
.catalog-grant-bar { flex-wrap: wrap; }
.catalog-grant-bar .input { min-width: 120px; max-width: 180px; }

#gather-sections .panel,
#qs-sections .panel {
  min-width: 0;
  overflow: hidden;
}
#tab-kits .layout-2.layout-fill {
  flex: 1;
  min-height: 0;
}
#tab-kits #kit-editor.detail-body {
  min-width: 0;
}

/* Dashboard */
.dash-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
@media (max-width: 900px) {
  .dash-cards { grid-template-columns: repeat(2, 1fr); }
}
.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  min-width: 0;
}
.dash-card-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}
.dash-card-value {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
}
.dash-stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}
@media (max-width: 900px) {
  .dash-stats-row { grid-template-columns: repeat(2, 1fr); }
}
.dash-stat {
  text-align: center;
  padding: 0.5rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}
.dash-stat-val {
  display: block;
  font-size: 1.1rem;
  font-weight: 600;
}
.dash-stat-lbl {
  font-size: 0.72rem;
  color: var(--muted);
}
.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
@media (max-width: 960px) {
  .dash-grid { grid-template-columns: 1fr; }
}
.dash-warnings {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 220px;
  overflow-y: auto;
}
.dash-warn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  font-size: 0.82rem;
  border: 1px solid var(--border);
}
.dash-warn span { flex: 1; min-width: 0; }
.dash-warn-warn { border-color: rgba(232, 180, 45, 0.35); background: rgba(232, 180, 45, 0.08); }
.dash-warn-error { border-color: rgba(240, 113, 120, 0.4); background: rgba(240, 113, 120, 0.1); }
.dash-warn-info { border-color: var(--border); background: rgba(255, 255, 255, 0.02); }
.dash-ok { font-size: 0.85rem; padding: 0.25rem 0; }
.dash-modules {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}
@media (max-width: 600px) {
  .dash-modules { grid-template-columns: 1fr; }
}
.dash-module {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  min-width: 0;
}
.dash-module:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dash-module-off { opacity: 0.75; }
.dash-module-title { font-weight: 600; font-size: 0.85rem; }
.dash-module-hint { font-size: 0.72rem; line-height: 1.3; }
.dash-module-pill {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  margin-top: 0.15rem;
}
.dash-module-pill.ok { background: rgba(62, 207, 142, 0.15); color: var(--ok); }
.dash-module-pill.off { background: rgba(139, 149, 168, 0.15); color: var(--muted); }
.dash-activity {
  max-height: 280px;
  overflow-y: auto;
}
.dash-activity-row {
  display: grid;
  grid-template-columns: 7rem 5.5rem 1fr;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.8rem;
  align-items: baseline;
}
@media (max-width: 700px) {
  .dash-activity-row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
}
.dash-activity-time { color: var(--muted); font-size: 0.75rem; }
.dash-activity-cat {
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--accent);
}
.dash-activity-detail {
  word-break: break-word;
  color: var(--text);
}

/* Shared layout fixes */
#tab-perms.view.active,
#tab-kits.view.active,
#tab-betterloot.view.active {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 6rem);
}
#tab-admin.view.active {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 6rem);
}
#tab-admin .layout-2.layout-fill {
  flex: 1;
  min-height: 0;
}
.admin-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
.admin-tag {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
}
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.pill.warn {
  border-color: #b8860b;
  color: #e8c547;
}
.list-search {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 14rem;
}
#tab-perms .perms-panel:not(.hidden),
#tab-betterloot .bl-panel:not(.hidden) {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
#tab-perms .perms-panel:not(.hidden) .layout-2.layout-fill,
#tab-betterloot .bl-panel:not(.hidden) .layout-2.layout-fill {
  flex: 1;
  min-height: 0;
}
.empty-inline {
  font-size: 0.82rem;
  padding: 0.5rem 0;
}
.sticky-save {
  margin-top: 0.75rem;
  flex-shrink: 0;
}

/* Loot tables (BetterLoot, Kits) */
.loot-table-wrap {
  overflow: auto;
  max-height: min(42vh, 420px);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 0.35rem;
}
.loot-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.loot-table th {
  text-align: left;
  padding: 0.45rem 0.5rem;
  background: var(--bg-elevated);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  position: sticky;
  top: 0;
  z-index: 1;
}
.loot-table td {
  padding: 0.35rem 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}
.loot-table .loot-icon img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}
.loot-table .loot-name strong {
  display: block;
  font-size: 0.82rem;
}
.loot-table .loot-name small {
  color: var(--muted);
  font-size: 0.68rem;
}

/* BetterLoot editor */
.bl-editor-scroll {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  max-height: min(58vh, 560px);
  padding-right: 0.15rem;
}
.bl-editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.bl-container-summary {
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}
.bl-loot-section {
  margin-bottom: 1rem;
}
.bl-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.bl-profile-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.5rem;
  background: var(--bg);
}
.bl-profile-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
}
.bl-profile-head .input[data-f="name"] {
  flex: 1;
  min-width: 120px;
}
.bl-prob-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  white-space: nowrap;
}
.bl-warn-text {
  color: var(--danger) !important;
  font-size: 0.78rem;
}
.catalog-list .entity-item small {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.catalog-detail-code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.9rem;
  color: var(--accent);
  word-break: break-all;
  margin-bottom: 0.5rem;
}
.catalog-detail-hint {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  margin-bottom: 1rem;
}
#bl-group-items.loot-table-wrap,
#bl-group-items .loot-table-wrap {
  max-height: min(50vh, 480px);
}

/* Kits */
.kit-tabs {
  margin: 0.65rem 0;
  flex-wrap: wrap;
}
.kit-tabs .kit-tab-add {
  margin-left: auto;
}
.kit-items-panel {
  min-height: 120px;
}
.kit-meta-grid {
  margin-bottom: 0.65rem;
}

/* QuickSmelt */
.qs-page {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.qs-top {
  padding: 1rem;
}
.qs-options {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.qs-furnace-row {
  flex-wrap: wrap;
}
.qs-mult-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.65rem;
}
.qs-mult-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}
.qs-mult-title {
  font-size: 0.85rem;
  font-weight: 600;
  width: 100%;
}
.qs-mult-hint {
  font-size: 0.72rem;
  width: 100%;
}
.qs-mult-icon {
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}
.qs-mult-val {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}
.qs-mult-card .qs-range {
  width: 100%;
  accent-color: var(--accent);
}
.qs-output-panel {
  padding: 1rem;
}
.qs-output-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.55rem;
}
.qs-out-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem;
  text-align: center;
}
.qs-out-card img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}
.qs-out-card .name {
  font-size: 0.75rem;
  font-weight: 600;
  margin: 0.25rem 0;
}
.qs-out-card input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
