:root {
  --bg: #0d1117;
  --panel: #171d24;
  --card: #202933;
  --text: #f5f0dc;
  --muted: #b9b5a7;
  --accent: #78c26a;
  --accent-2: #d8b35d;
  --danger: #d36f59;
  --border: #3c4a55;
  --slot-bg: #7a7a7a;
  --slot-shadow: #4b4b4b;
  --slot-highlight: #c8c8c8;
  --slot-inner: #8b8b8b;
  --panel-deep: #11161c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Verdana", sans-serif;
  background:
    radial-gradient(circle at top, rgba(120, 194, 106, 0.09), transparent 32%),
    linear-gradient(180deg, #131a20, #0f1418 45%, #0b0f13);
  color: var(--text);
  min-height: 100vh;
}

body.auth-view {
  min-height: 100dvh;
  overflow: hidden;
}

#app {
  width: min(1740px, calc(100vw - 24px));
  max-width: 1740px;
  margin: 32px auto;
  padding: 0 12px 40px;
}

body.auth-view #app {
  width: min(560px, calc(100vw - 24px));
  max-width: 560px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

h2 {
  margin: 0 0 10px 0;
  font-size: 18px;
  letter-spacing: 0.4px;
}

h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.3px;
}

.status {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(9, 14, 19, 0.9);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.dashboard-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.dashboard-column,
.dashboard-stack {
  display: grid;
  gap: 16px;
  align-content: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  align-self: start;
}

.card.wide {
  grid-column: span 2;
}

.login-shell {
  margin-bottom: 18px;
}

.login-card {
  width: 100%;
  margin: 0 auto;
  padding: 0;
  border-radius: 14px;
  background: transparent;
  border: none;
  box-shadow: none;
}

.login-form {
  display: grid;
  gap: 14px;
  padding: 22px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border);
}

.login-heading {
  margin-bottom: 2px;
}

.login-heading h2 {
  margin: 0;
  font-size: 18px;
}

.login-field {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.login-field span {
  font-weight: 700;
  color: var(--text);
}

.login-password-wrap {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.login-password-wrap input {
  min-width: 0;
}

.login-pass-toggle {
  flex: none;
  min-width: 72px;
  padding: 8px 12px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.login-pass-toggle:hover {
  color: var(--text);
  border-color: rgba(120, 194, 106, 0.4);
}

.login-remember {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  user-select: none;
  margin-top: -2px;
}

.login-remember input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  flex: none;
}

.login-submit {
  width: 100%;
  min-height: 44px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
}

.login-submit:disabled {
  opacity: 0.72;
  cursor: wait;
  transform: none;
}

.login-form .error {
  margin-top: 0;
  min-height: 18px;
}

.row {
  display: flex;
  gap: 8px;
  margin: 8px 0;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab-btn {
  background: #111820;
  border: 1px solid var(--border);
  color: var(--muted);
}

.tab-btn.active {
  background: var(--accent);
  color: #12210d;
  border-color: transparent;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

input {
  flex: 1;
  background: #121920;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background-color 0.18s ease;
}

input::placeholder,
textarea::placeholder {
  color: #7f8993;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: rgba(120, 194, 106, 0.7);
  box-shadow: 0 0 0 3px rgba(120, 194, 106, 0.1);
  background: #121920;
}

textarea {
  width: 100%;
  resize: vertical;
  background: #121920;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font: inherit;
}

button {
  background: var(--accent);
  border: none;
  color: #13200f;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition:
    transform 0.14s ease,
    filter 0.14s ease,
    box-shadow 0.14s ease;
}

button:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(120, 194, 106, 0.14);
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  margin-top: 16px;
}

button.danger-btn {
  background: rgba(211, 111, 89, 0.16);
  color: #f1b3a5;
  border: 1px solid rgba(211, 111, 89, 0.45);
}

pre {
  background: #10161d;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 10px;
  border-radius: 8px;
  max-height: 260px;
  overflow: auto;
  font-size: 12px;
}

ul {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  max-height: 220px;
  overflow: auto;
}

li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px dashed #263246;
}

.error {
  color: var(--danger);
  margin-top: 8px;
  font-size: 13px;
}

.muted {
  color: var(--muted);
  font-size: 12px;
  margin: 6px 0 12px;
}

.table-wrap {
  overflow-x: auto;
}

.alerts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.alerts-table th,
.alerts-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px dashed #263246;
  white-space: nowrap;
}

.alerts-table td:nth-child(4) {
  white-space: normal;
  min-width: 240px;
}

.inventory-table td:nth-child(4) {
  white-space: normal;
  min-width: 280px;
}

.inventory-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1.95fr) 340px;
  gap: 18px;
  align-items: start;
}

.inventory-section-heading {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--accent-2);
  margin-bottom: 10px;
}

.inventory-panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.inventory-panel-top .inventory-section-heading {
  margin-bottom: 0;
}

.inventory-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-2);
  background: rgba(216, 179, 93, 0.08);
  border: 1px solid rgba(216, 179, 93, 0.18);
}

.inventory-roster,
.inventory-workspace,
.inventory-editor {
  background: linear-gradient(180deg, rgba(14, 20, 26, 0.9), rgba(20, 27, 34, 0.9));
  border: 1px solid rgba(98, 114, 126, 0.42);
  border-radius: 14px;
  padding: 18px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 10px 20px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.inventory-roster,
.inventory-editor {
  position: sticky;
  top: 18px;
  align-self: start;
  height: fit-content;
  max-height: calc(100vh - 42px);
}

.inventory-player-grid {
  display: grid;
  gap: 10px;
  align-content: start;
  overflow: auto;
  max-height: calc(100vh - 150px);
  padding-right: 4px;
  scrollbar-gutter: stable;
}

.inventory-player-card {
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(109, 126, 138, 0.35);
  background:
    linear-gradient(180deg, rgba(34, 45, 56, 0.92), rgba(21, 29, 37, 0.96)),
    linear-gradient(135deg, rgba(120, 194, 106, 0.08), transparent 45%);
  color: var(--text);
  min-height: 0;
}

.inventory-player-card.active {
  border-color: rgba(120, 194, 106, 0.62);
  box-shadow: 0 0 0 1px rgba(120, 194, 106, 0.24);
}

.inventory-player-card-empty {
  padding: 16px;
  border: 1px dashed rgba(109, 126, 138, 0.35);
  border-radius: 12px;
  color: var(--muted);
}

.inventory-player-name {
  font-weight: 700;
  margin: 0;
  font-size: 16px;
}

.inventory-stage-header {
  display: flex;
  justify-content: flex-start;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.inventory-stage-title .muted {
  margin-bottom: 0;
}

.inventory-top-strip {
  max-width: 460px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}

.inventory-top-strip:empty {
  display: none;
}

.inventory-stage {
  position: relative;
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr);
  gap: 24px;
  padding: 20px;
  border-radius: 14px;
  border: 1px solid rgba(98, 114, 126, 0.35);
  background:
    linear-gradient(180deg, rgba(21, 28, 35, 0.95), rgba(15, 21, 27, 0.95)),
    radial-gradient(circle at top, rgba(216, 179, 93, 0.08), transparent 34%);
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.inventory-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 28%),
    url("/assets/gui-texture?id=inventory");
  background-size: auto, 256px 256px;
  background-repeat: no-repeat, no-repeat;
  background-position: top left, calc(100% + 18px) 12px;
  image-rendering: pixelated;
  opacity: 0.12;
  pointer-events: none;
}

.inventory-stage > * {
  position: relative;
  z-index: 1;
}

.inventory-side-panel {
  display: grid;
  gap: 12px;
  align-content: start;
}

.inventory-side-title,
.inventory-board-header {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.inventory-armor,
.inventory-offhand {
  display: grid;
  gap: 8px;
}

.inventory-board {
  display: grid;
  gap: 12px;
  padding: 14px 16px 16px;
  border-radius: 12px;
  border: 1px solid rgba(112, 125, 134, 0.18);
  background: rgba(11, 16, 20, 0.26);
  overflow-x: auto;
  min-width: 0;
}

.inventory-grid {
  display: grid;
  gap: 10px;
}

.inventory-grid-main,
.inventory-grid-hotbar {
  grid-template-columns: repeat(9, minmax(0, 1fr));
  min-width: 710px;
}

.inventory-slot {
  position: relative;
  min-height: 92px;
  padding: 10px;
  border-radius: 0;
  border-top: 2px solid var(--slot-highlight);
  border-left: 2px solid var(--slot-highlight);
  border-right: 2px solid var(--slot-shadow);
  border-bottom: 2px solid var(--slot-shadow);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 34%),
    url("/assets/gui-texture?id=slot"),
    linear-gradient(180deg, var(--slot-highlight), var(--slot-inner) 14%, var(--slot-bg) 100%);
  background-size: cover, cover, cover;
  background-position: center;
  background-repeat: no-repeat;
  color: #181818;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 4px;
  align-items: start;
  overflow: hidden;
  image-rendering: pixelated;
  transition:
    transform 0.12s ease,
    filter 0.12s ease,
    box-shadow 0.12s ease;
}

.inventory-slot::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  pointer-events: none;
}

.inventory-slot.occupied {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 34%),
    url("/assets/gui-texture?id=slot"),
    linear-gradient(
      180deg,
      hsl(var(--slot-hue), 65%, 82%, 0.82),
      hsl(var(--slot-hue), 42%, 65%, 0.82) 16%,
      hsl(var(--slot-hue), 25%, 48%, 0.82) 100%
    );
  background-size: cover, cover, cover;
  background-position: center;
  background-repeat: no-repeat;
  color: #111;
}

.inventory-slot.empty {
  color: rgba(14, 14, 14, 0.62);
}

.inventory-slot.selected {
  outline: 2px solid rgba(216, 179, 93, 0.9);
  outline-offset: 1px;
  filter: brightness(1.08);
}

.inventory-slot:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.inventory-slot-badge {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.8;
}

.inventory-slot-media {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 2px;
}

.inventory-slot-image {
  width: 44px;
  height: 44px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, 0.35));
}

.inventory-slot-icon {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
  align-self: center;
  justify-self: center;
  line-height: 1;
}

.inventory-slot-icon:empty,
.inventory-slot-name:empty {
  display: none;
}

.inventory-slot-name {
  font-size: 11px;
  line-height: 1.2;
  font-weight: 700;
  text-align: center;
  color: rgba(19, 19, 19, 0.72);
  min-height: 12px;
}

.inventory-slot-count {
  position: absolute;
  right: 6px;
  bottom: 4px;
  font-size: 14px;
  font-weight: 800;
  color: #f8f0d2;
  text-shadow:
    1px 1px 0 rgba(0, 0, 0, 0.8),
    0 0 2px rgba(0, 0, 0, 0.5);
}

.inventory-empty-state {
  padding: 14px 16px;
  margin-bottom: 12px;
  border-radius: 12px;
  border: 1px dashed rgba(109, 126, 138, 0.35);
  color: var(--muted);
}

.inventory-top-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(14, 20, 24, 0.8);
  border: 1px solid rgba(216, 179, 93, 0.18);
  color: var(--accent-2);
  font-size: 12px;
  line-height: 1.25;
}

.inventory-top-chip-image {
  width: 18px;
  height: 18px;
  object-fit: contain;
  image-rendering: pixelated;
  flex: none;
}

.inventory-top-chip-label {
  white-space: nowrap;
}

.inventory-top-empty {
  color: var(--muted);
  font-size: 12px;
}

.slot-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin: 4px 0 10px;
  border-radius: 10px;
  background: rgba(11, 16, 21, 0.8);
  border: 1px solid rgba(98, 114, 126, 0.35);
  color: var(--accent-2);
  font-size: 14px;
}

.slot-preview-image {
  width: 42px;
  height: 42px;
  object-fit: contain;
  image-rendering: pixelated;
  flex: none;
}

.inventory-editor .row {
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.inventory-editor .row button {
  flex: 1 1 120px;
}

.inventory-editor .ghost {
  align-self: flex-start;
  margin-top: 8px;
}

.inventory-editor .error {
  margin-top: 8px;
}

.inventory-editor label {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

.inventory-editor {
  overflow: auto;
  scrollbar-gutter: stable;
}

.muted-cell {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.badge-critical {
  background: rgba(248, 113, 113, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(248, 113, 113, 0.5);
}

.badge-warning {
  background: rgba(251, 191, 36, 0.2);
  color: #fcd34d;
  border: 1px solid rgba(251, 191, 36, 0.5);
}

.badge-info {
  background: rgba(56, 189, 248, 0.2);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.5);
}

.hidden {
  display: none;
}

body.auth-view .panel {
  width: 100%;
  min-height: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
}

body.auth-view .panel-header {
  margin-bottom: 16px;
}

body.auth-view .login-shell {
  margin-bottom: 0;
}

@media (max-width: 1380px) {
  .inventory-shell {
    grid-template-columns: 220px minmax(0, 1.7fr);
  }

  .inventory-editor {
    grid-column: span 2;
    position: static;
    max-height: none;
  }

  .inventory-roster {
    position: static;
    max-height: none;
  }

  .inventory-player-grid {
    max-height: none;
  }
}

@media (max-width: 900px) {
  body.auth-view #app {
    width: calc(100vw - 20px);
    min-height: 100dvh;
    margin: 0 auto;
    padding: 10px;
  }

  body.auth-view .panel {
    padding: 18px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .login-card {
    width: 100%;
  }

  .login-form {
    padding: 18px;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .status {
    align-self: flex-start;
  }

  .dashboard-columns {
    grid-template-columns: 1fr;
  }

  .card.wide {
    grid-column: span 1;
  }

  .inventory-shell {
    grid-template-columns: 1fr;
  }

  .inventory-roster,
  .inventory-editor {
    position: static;
    max-height: none;
  }

  .inventory-player-grid {
    max-height: none;
    overflow: visible;
  }

  .inventory-stage {
    grid-template-columns: 1fr;
  }

  .inventory-stage-header {
    flex-direction: column;
  }

  .inventory-top-strip {
    max-width: none;
    justify-content: flex-start;
  }

  .slot-preview {
    flex-wrap: wrap;
  }
}
