:root {
  color-scheme: dark;
  --bg: #050505;
  --surface: #0d0d0e;
  --surface-2: #141414;
  --surface-3: #1b1b1b;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f4f4f2;
  --muted: rgba(244, 244, 242, 0.58);
  --faint: rgba(244, 244, 242, 0.36);
  --green: #36f08b;
  --gold: #d8bc65;
  --bad: #ff7171;
  --nav-h: 68px;
  --r: 8px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background-color: #050505;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 520;
  letter-spacing: 0;
  overflow-x: hidden;
}

#canvas1 {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: #050505;
  pointer-events: none;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(5, 5, 5, 0.04), rgba(5, 5, 5, 0.18));
  content: "";
  pointer-events: none;
}

.loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 120;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #ffffff, var(--green), transparent);
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left;
  transition: opacity 180ms var(--ease), transform 500ms var(--ease);
}

body.is-loading .loading-bar {
  opacity: 1;
  transform: scaleX(1);
}

body,
button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.navbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  display: grid;
  height: var(--nav-h);
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 7, 7, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 900;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: linear-gradient(180deg, #1c1c1c, #0b0b0b);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08);
}

.brand-name {
  white-space: nowrap;
}

.nav-center {
  position: relative;
  display: flex;
  justify-self: center;
  gap: 0.18rem;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  padding: 0.24rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
}

.nav-indicator {
  position: absolute;
  top: 0.24rem;
  bottom: 0.24rem;
  left: 0;
  z-index: 0;
  width: 0;
  border-radius: 999px;
  background: #f2f2ef;
  box-shadow: 0 12px 26px rgba(255, 255, 255, 0.1);
  transition:
    transform 420ms cubic-bezier(0.22, 1, 0.36, 1),
    width 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.nav-link {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  padding: 0.55rem 0.78rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 780;
  transition: background 180ms var(--ease), color 180ms var(--ease), transform 180ms var(--ease);
}

.nav-link:hover,
.nav-link.active {
  color: #080808;
  transform: translateY(-1px);
}

.nav-right,
.profile-row,
.form-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.icon-btn,
.profile-trigger,
.discord-login,
.primary-action,
.ghost-action,
.square-action,
.menu-action,
.row-remove,
.picker-trigger,
.picker-option,
.product-row button,
.load-table-row button,
.ledger-meta button {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-weight: 850;
  transition:
    transform 220ms var(--ease),
    border-color 220ms var(--ease),
    background 220ms var(--ease),
    box-shadow 220ms var(--ease),
    filter 220ms var(--ease);
}

.icon-btn {
  width: 38px;
  height: 38px;
}

.discord-login,
.primary-action,
.ghost-action,
.menu-action {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0 0.9rem;
}

.primary-action,
.discord-login {
  border-color: rgba(255, 255, 255, 0.24);
  background: #f1f1ef;
  color: #060606;
  box-shadow: 0 12px 28px rgba(255, 255, 255, 0.08);
}

.ghost-action.compact {
  min-height: 34px;
  padding-inline: 0.7rem;
}

.icon-btn:hover,
.profile-trigger:hover,
.ghost-action:hover,
.square-action:hover,
.menu-action:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.09);
  transform: translateY(-1px);
}

.primary-action:hover,
.discord-login:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.profile {
  position: relative;
}

.profile-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0.25rem 0.7rem 0.25rem 0.25rem;
}

.avatar {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: #222;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
}

.avatar-large {
  width: 44px;
  height: 44px;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.trigger-name {
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-menu {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  z-index: 80;
  width: min(320px, calc(100vw - 24px));
  display: grid;
  gap: 0.6rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(12, 12, 12, 0.98);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.54);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}

.profile-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.profile-row {
  align-items: center;
}

.profile-row small {
  display: block;
  margin-top: 0.12rem;
  color: var(--muted);
}

.danger {
  color: var(--bad);
}

.login-view {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: calc(var(--nav-h) + 2rem) 1rem 2rem;
}

.login-card,
.panel-card,
.metric-card,
.load-table-card,
.load-builder {
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018)),
    rgba(12, 12, 12, 0.92);
  box-shadow: 0 22px 72px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(14px);
  transition:
    border-color 240ms var(--ease),
    background 240ms var(--ease),
    transform 240ms var(--ease),
    box-shadow 240ms var(--ease);
}

.panel-card:hover,
.metric-card:hover,
.load-table-card:hover,
.load-builder:hover {
  border-color: var(--line-strong);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025)),
    rgba(14, 14, 14, 0.94);
}

.login-card {
  width: min(560px, 100%);
  padding: 2rem;
}

.login-card h1 {
  margin: 0 0 0.8rem;
  font-size: 3.1rem;
  line-height: 0.96;
}

.setup-note {
  margin-top: 1rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--gold);
  overflow-wrap: anywhere;
}

.app-shell {
  position: relative;
  z-index: 2;
  width: min(1880px, 100%);
  margin: 0 auto;
  padding: calc(var(--nav-h) + 1.35rem) 1rem 3rem;
}

.page {
  display: none;
  will-change: transform, opacity;
}

.page.active {
  display: block;
  animation: page-in-forward 360ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.app-shell[data-transition="back"] .page.active {
  animation-name: page-in-back;
}

.page-head,
.panel-head,
.builder-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.page-head {
  margin-bottom: 1rem;
}

.page-head h1,
.panel-head h2 {
  margin: 0;
}

.page-head h1 {
  font-size: 2.2rem;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--faint);
  font-size: 0.74rem;
  font-weight: 920;
  text-transform: uppercase;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.metric-card {
  min-height: 112px;
  display: grid;
  align-content: space-between;
  padding: 1rem;
}

.metric-card span,
.field span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
  text-transform: uppercase;
}

.metric-card strong {
  font-size: 2rem;
}

.overview-grid,
.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 0.9rem;
}

.panel-card,
.load-builder {
  padding: 1rem;
}

.stock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.65rem;
}

.compact-stock {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.stock-item,
.mineral-field,
.simple-row,
.material-line,
.admin-price-row,
.admin-material-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  min-height: 62px;
  padding: 0.72rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: rgba(255, 255, 255, 0.035);
}

.stock-item.compact {
  min-height: 54px;
}

.stock-item small,
.mineral-label small {
  display: block;
  margin-top: 0.12rem;
  color: var(--muted);
}

.stock-item b,
.stock-item.positive b,
.money-profit {
  color: var(--green);
}

.stock-item.empty b {
  color: var(--faint);
}

.stock-item.negative b {
  color: var(--bad);
}

.mineral-img {
  display: block;
  width: 42px;
  height: 42px;
  object-fit: contain;
  filter: drop-shadow(0 12px 14px rgba(0, 0, 0, 0.45));
  transform: translateZ(0);
}

.form-grid {
  display: grid;
  gap: 0.85rem;
}

.field {
  display: grid;
  gap: 0.4rem;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  outline: 0;
  background: #080808;
  color: var(--text);
  padding: 0.78rem 0.85rem;
  transition: border-color 160ms var(--ease), background 160ms var(--ease), box-shadow 160ms var(--ease);
}

select option {
  background: #101010;
  color: var(--text);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(255, 255, 255, 0.34);
  background: #0c0c0c;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.split-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.42fr);
  gap: 0.75rem;
}

.split-fields.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mineral-inputs,
.admin-price-list,
.admin-materials {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.6rem;
}

.admin-price-list > .primary-action {
  grid-column: 1 / -1;
}

.mineral-field {
  grid-template-columns: auto minmax(0, 1fr) 7rem;
}

.mineral-field input,
.admin-price-row input,
.admin-material-row input {
  text-align: center;
  font-weight: 850;
}

.inline-total {
  color: var(--green);
  font-size: 1.65rem;
}

.recipe-hint {
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
}

.recipe-card-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.65rem;
  max-height: 350px;
  overflow: auto;
}

.recipe-card {
  display: grid;
  gap: 0.35rem;
  min-height: 124px;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  text-align: left;
}

.recipe-card:hover,
.recipe-card.active {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.07);
}

.recipe-card strong,
.money-ask {
  color: var(--gold);
}

.recipe-card small,
.recipe-card em {
  color: var(--muted);
  font-size: 0.8rem;
  font-style: normal;
}

.load-builder {
  margin-bottom: 0.9rem;
}

.builder-top {
  display: grid;
  grid-template-columns: minmax(0, 0.45fr) minmax(0, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.load-rows {
  display: grid;
  gap: 0.65rem;
}

.load-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px 42px;
  gap: 0.75rem;
  align-items: end;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  transition:
    border-color 220ms var(--ease),
    background 220ms var(--ease),
    transform 220ms var(--ease),
    box-shadow 220ms var(--ease);
}

.load-row:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.055);
  transform: translateY(-1px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.26);
}

.load-row-title {
  grid-column: 1 / -1;
  color: var(--muted);
}

.row-remove,
.square-action {
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 1.45rem;
}

.row-remove {
  color: var(--bad);
}

.load-row-preview {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.86rem;
}

.product-picker {
  position: relative;
}

.picker-trigger {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.62rem 0.75rem;
  text-align: left;
}

.picker-trigger span,
.picker-option span {
  min-width: 0;
}

.picker-trigger strong,
.picker-trigger small,
.picker-option strong,
.picker-option small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-trigger small,
.picker-option small {
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.picker-trigger b {
  transition: transform 220ms var(--ease);
}

.product-picker.open .picker-trigger {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.08);
}

.product-picker.open .picker-trigger b {
  transform: rotate(180deg);
}

.picker-menu {
  position: absolute;
  right: 0;
  left: 0;
  top: calc(100% + 0.42rem);
  z-index: 90;
  display: grid;
  gap: 0.45rem;
  max-height: min(420px, 58vh);
  overflow: hidden;
  padding: 0.55rem;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(13, 13, 13, 0.98);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.54);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top;
  transition:
    opacity 220ms var(--ease),
    transform 220ms var(--ease);
}

.product-picker.open .picker-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.picker-menu input {
  min-height: 42px;
}

.picker-options {
  display: grid;
  gap: 0.3rem;
  max-height: 330px;
  overflow: auto;
  padding-right: 0.15rem;
}

.picker-option {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0.72rem;
  text-align: left;
}

.picker-option:hover,
.picker-option.selected {
  border-color: rgba(255, 255, 255, 0.26);
  background: rgba(255, 255, 255, 0.09);
  transform: translateX(2px);
}

.picker-option b {
  flex: 0 0 auto;
  color: var(--gold);
}

.picker-empty {
  margin: 0;
  padding: 0.75rem;
  color: var(--muted);
}

.builder-bottom {
  flex-wrap: wrap;
  margin-top: 0.8rem;
}

.load-totals {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.load-totals span {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
}

.load-totals strong {
  color: var(--text);
}

.material-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.material-line {
  min-height: 48px;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  padding: 0.55rem 0.65rem;
}

.material-line small {
  color: var(--muted);
}

.production-headline {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.production-headline h2 {
  margin: 0;
  font-size: 1.25rem;
}

.production-headline strong {
  color: var(--green);
  font-size: 2rem;
  line-height: 1;
}

.production-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.75rem;
}

.production-card {
  display: grid;
  gap: 0.8rem;
  min-height: 280px;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.018)),
    rgba(8, 8, 8, 0.82);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.06);
  transition:
    transform 260ms var(--ease),
    border-color 260ms var(--ease),
    background 260ms var(--ease),
    opacity 260ms var(--ease);
}

.production-card.ready {
  border-color: rgba(54, 240, 139, 0.24);
}

.production-card.blocked {
  opacity: 0.72;
}

.production-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-3px);
}

.production-title {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
}

.production-title strong,
.production-title span,
.production-title em {
  display: block;
}

.production-title strong {
  font-size: 1rem;
}

.production-title span,
.production-title em {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
}

.production-title em {
  flex: 0 0 auto;
  color: var(--gold);
}

.production-number {
  display: grid;
  gap: 0.12rem;
}

.production-number b {
  color: var(--green);
  font-size: 3rem;
  line-height: 0.9;
}

.production-number span {
  color: var(--text);
  font-weight: 900;
}

.production-number small,
.production-missing {
  color: var(--muted);
}

.production-economy {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
}

.production-economy span {
  display: grid;
  gap: 0.14rem;
  min-width: 0;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 0.72rem;
}

.production-economy strong {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.production-materials {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
}

.production-material {
  display: grid;
  grid-template-columns: 26px minmax(0, auto);
  column-gap: 0.35rem;
  align-items: center;
  min-width: 126px;
  padding: 0.4rem 0.48rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: rgba(255, 255, 255, 0.035);
}

.production-material.limit {
  border-color: rgba(216, 188, 101, 0.44);
  background: rgba(216, 188, 101, 0.06);
}

.production-material .mineral-img {
  grid-row: span 2;
  width: 26px;
  height: 26px;
}

.production-material span,
.production-material b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.production-material span {
  font-size: 0.76rem;
}

.production-material b {
  color: var(--muted);
  font-size: 0.72rem;
}

.production-missing {
  margin: auto 0 0;
  font-size: 0.82rem;
}

.load-table-card {
  padding: 0.9rem;
  overflow-x: auto;
}

.loads-table,
.products-table {
  display: grid;
  gap: 0.35rem;
}

.load-table-head,
.load-table-row {
  display: grid;
  grid-template-columns: 72px 90px 170px minmax(160px, 0.8fr) minmax(150px, 0.8fr) 130px 140px 130px 96px;
  gap: 0.85rem;
  align-items: center;
  min-width: 1180px;
  padding: 0.72rem;
}

.load-table-head,
.products-head {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #111;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.load-table-row,
.product-row,
.ledger-row {
  border-radius: var(--r);
  background: rgba(255, 255, 255, 0.035);
  transition:
    background 220ms var(--ease),
    transform 220ms var(--ease),
    box-shadow 220ms var(--ease);
}

.load-table-row:nth-child(odd),
.product-row:nth-child(odd) {
  background: rgba(255, 255, 255, 0.052);
}

.load-table-row:hover,
.product-row:hover,
.ledger-row:hover {
  background: rgba(255, 255, 255, 0.075);
  transform: translateX(2px);
}

.mono {
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.status-dot {
  width: 18px;
  height: 18px;
  border: 2px solid var(--green);
  border-radius: 50%;
  background: rgba(54, 240, 139, 0.14);
  box-shadow: 0 0 20px rgba(54, 240, 139, 0.18);
}

.family-pill {
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  padding: 0.32rem 0.68rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.load-table-row button,
.ledger-meta button,
.row-actions button {
  padding: 0.42rem 0.58rem;
  font-size: 0.78rem;
}

.ledger-search {
  max-width: 360px;
}

.ledger-list {
  display: grid;
  gap: 0.55rem;
}

.ledger-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  padding: 0.9rem;
}

.ledger-row strong,
.ledger-row small,
.ledger-row p {
  display: block;
  margin: 0.2rem 0 0;
  overflow-wrap: anywhere;
}

.ledger-row small,
.ledger-row p,
.ledger-meta {
  color: var(--muted);
}

.type-pill {
  display: inline-flex;
  width: fit-content;
  padding: 0.22rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.ledger-meta {
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 0.35rem;
  text-align: right;
}

.products-head,
.product-row {
  display: grid;
  grid-template-columns: minmax(160px, 0.8fr) 140px minmax(280px, 1.3fr) 110px 130px 230px;
  gap: 0.75rem;
  align-items: center;
  min-width: 980px;
  padding: 0.72rem;
}

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

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.inline-price {
  min-height: 38px;
  padding: 0.45rem 0.55rem;
  color: var(--gold);
  font-weight: 900;
  text-align: center;
}

.empty-state {
  margin: 0;
  padding: 0.9rem;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 100;
  max-width: min(360px, calc(100vw - 2rem));
  padding: 0.85rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: #101010;
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@keyframes page-in-forward {
  from {
    opacity: 0;
    transform: translate3d(26px, 0, 0);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
    filter: blur(0);
  }
}

@keyframes page-in-back {
  from {
    opacity: 0;
    transform: translate3d(-26px, 0, 0);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
    filter: blur(0);
  }
}

@media (max-width: 1180px) {
  .overview-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .builder-top,
  .split-fields,
  .split-fields.three {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .navbar {
    grid-template-columns: auto auto;
  }

  .nav-center {
    position: fixed;
    left: 0.65rem;
    right: 0.65rem;
    bottom: 0.65rem;
    z-index: 70;
    justify-content: flex-start;
    border-radius: 14px;
    background: rgba(7, 7, 7, 0.96);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
  }

  .app-shell {
    padding-bottom: 6rem;
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .ledger-search {
    max-width: none;
  }
}

@media (max-width: 640px) {
  .brand-name,
  .trigger-name,
  .icon-btn {
    display: none;
  }

  .navbar {
    padding: 0 0.75rem;
  }

  .app-shell {
    padding-inline: 0.75rem;
  }

  .page-head h1 {
    font-size: 1.8rem;
  }

  .login-card h1 {
    font-size: 2.25rem;
  }

  .mineral-inputs,
  .admin-price-list,
  .admin-materials,
  .stock-grid,
  .compact-stock,
  .material-summary,
  .production-list,
  .production-economy {
    grid-template-columns: 1fr;
  }

  .mineral-field,
  .load-row,
  .ledger-row {
    grid-template-columns: 1fr;
  }

  .production-headline,
  .production-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .ledger-meta {
    justify-items: start;
    text-align: left;
  }

  .builder-bottom,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-action,
  .ghost-action {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}
