/* ═══════════════════════════════════════════════
   ШРИФТЫ
   ═══════════════════════════════════════════════ */
@font-face {
  font-family: 'Inter';
  src: local('Inter'), local('Inter-Regular'), sans-serif;
  font-weight: 100 900;
  font-display: swap;
}

/* ═══════════════════════════════════════════════
   ПЕРЕМЕННЫЕ
   ═══════════════════════════════════════════════ */
:root {
  --bg:        #141a20;
  --surface:   #1c232b;
  --surface-2: #232b34;
  --line:      #2e3843;

  --ink:       #f2e8d5;
  --ink-soft:  #d4c4a8;
  --muted:     #8a8378;

  --accent:       #c4a052;
  --accent-hover: #d4b062;
  --accent-ink:   #1a1a1a;

  --green:  #8fb88f;
  --warn:   #e89b47;
  --danger: #e85d5d;

  --radius:    14px;
  --radius-sm: 9px;

  --shadow:     0 10px 24px rgba(0, 0, 0, 0.35);
  --shadow-sm:  0 4px 12px rgba(0, 0, 0, 0.25);

  --font: 'Inter', system-ui, -apple-system, sans-serif;

  color-scheme: dark;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════════
   СБРОСЫ
   ═══════════════════════════════════════════════ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body { line-height: 1.5; overflow-x: hidden; }
body.is-loading { overflow: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; opacity: 0.46; }
a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
h2 { font-size: 1.1rem; font-weight: 800; line-height: 1.3; }
h3 { font-size: 1rem; font-weight: 700; }
p  { color: var(--ink-soft); }
small { font-size: 0.78rem; }
dl, dd { margin: 0; }
[hidden] { display: none !important; }

/* ═══════════════════════════════════════════════
   КАРКАС
   ═══════════════════════════════════════════════ */
.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 100px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--ink);
  text-decoration: none;
}
.brand small {
  display: block;
  font-size: 11px;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: var(--muted);
  margin-top: 3px;
  text-transform: uppercase;
}

.wallet {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  transition: background 0.15s;
}
.wallet:hover:not(:disabled) { background: var(--surface-2); }
.wallet__icon { font-size: 15px; }
.wallet b { font-weight: 800; color: var(--accent); }

main { padding: 24px 0; }

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 8px 0 24px;
}
.page-heading p { margin-top: 6px; font-size: 0.9rem; }

.boot { text-align: center; padding: 60px 12px; }
.boot h1 { margin-bottom: 10px; }

/* ═══════════════════════════════════════════════
   КНОПКИ
   ═══════════════════════════════════════════════ */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 11px 18px;
  border: 0;
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 0.9rem;
  text-align: center;
  transition: background 0.15s, transform 0.1s;
  user-select: none;
}
.button:active:not(:disabled) { transform: translateY(1px); }

.button.primary { background: var(--accent); color: var(--accent-ink); }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); }

.button.secondary { background: var(--surface-2); color: var(--ink); }
.button.secondary:hover:not(:disabled) { background: var(--line); }

.button.danger { background: var(--danger); color: #fff; }

.button.full { width: 100%; }
.button.compact { padding: 9px 14px; min-height: 42px; font-size: 0.83rem; }

/* ═══════════════════════════════════════════════
   КАРТОЧКИ
   ═══════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.card h2 { margin-bottom: 12px; }

.big-number { font-size: 1.8rem; font-weight: 900; color: var(--ink); margin: 12px 0; }
.big-number small { color: var(--muted); font-size: 0.9rem; font-weight: 600; }

.rate-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  font-size: 0.85rem;
}
.rate-line span { color: var(--muted); }
.rate-line b { color: var(--ink); font-weight: 800; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.stats-grid dt { color: var(--muted); font-size: 0.78rem; }
.stats-grid dd { font-size: 1.1rem; font-weight: 800; margin-top: 2px; }
.stats-grid dd small { font-weight: 600; color: var(--muted); }

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.section-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.section-line > span { font-size: 0.8rem; color: var(--muted); }

/* ═══════════════════════════════════════════════
   ФАБРИКА
   ═══════════════════════════════════════════════ */
.farm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.farm-main { margin-bottom: 10px; }
.farm-main .big-number { font-size: 1.8rem; margin: 8px 0 10px; }
.farm-main .rate-line { padding: 4px 0; font-size: 0.82rem; }
.farm-main .button { margin-top: 10px; min-height: 44px; }

/* Компактная полоса: сырьё · хватит · питание */
.compact-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}
.compact-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  min-width: 0;
}
.compact-item .icon {
  width: 18px;
  height: 18px;
  color: var(--accent);
  flex-shrink: 0;
}
.compact-item > div { min-width: 0; overflow: hidden; }
.compact-item small {
  display: block;
  font-size: 0.65rem;
  color: var(--muted);
  line-height: 1.1;
}
.compact-item b {
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress {
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
  margin: 10px 0;
}
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.3s; }
.progress.overloaded span { background: var(--danger); }

.warning-text {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(232, 155, 71, 0.15);
  color: var(--warn);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  margin: 12px 0;
}

.success-text { color: var(--green); font-size: 0.85rem; }
.hint { font-size: 0.78rem; color: var(--muted); margin-top: 10px; }
.positive { color: var(--green); }

/* Склад */
.warehouse-list { display: grid; gap: 8px; }
.warehouse-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--surface-2);
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--ink);
  text-align: left;
  font-size: 0.85rem;
}
.warehouse-item:hover { background: var(--line); }
.warehouse-item img { flex-shrink: 0; }

/* Стеллажи (на фабрике) */
.rack-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.rack-tabs button {
  padding: 8px 12px;
  background: var(--surface-2);
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
}
.rack-tabs button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}
.rack-tabs button:hover:not([aria-pressed="true"]) { background: var(--line); }

.rack-slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.rack-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  min-height: 90px;
  justify-content: center;
  font-size: 0.72rem;
}
.rack-slot img { width: 48px; height: 36px; object-fit: contain; }
.rack-slot strong { font-size: 0.72rem; text-align: center; line-height: 1.2; }
.rack-slot small { color: var(--muted); font-size: 0.68rem; }
.rack-slot.vacant { border-style: dashed; color: var(--muted); }
.rack-slot:hover { border-color: var(--accent); }

/* ═══════════════════════════════════════════════
   МАГАЗИН — вкладки
   ═══════════════════════════════════════════════ */
.shop-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  overflow-x: auto;
}
.shop-tabs button {
  flex: 1;
  padding: 9px 12px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.82rem;
  white-space: nowrap;
}
.shop-tabs button[aria-selected="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

/* ═══════════════════════════════════════════════
   МАГАЗИН — СТАНКИ (2 колонки, без переноса)
   ═══════════════════════════════════════════════ */
.machines-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.machine-card {
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--line);
  transition: border-color 0.15s;
  min-width: 0;
}
.machine-card:hover { border-color: var(--accent); }

.machine-card__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  min-width: 0;
}
.machine-card__icon {
  width: 40px;
  height: 30px;
  object-fit: contain;
  flex-shrink: 0;
}
.machine-card__name {
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.15;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.machine-card__specs {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
  font-size: 0.75rem;
}
.machine-card__specs > div {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: baseline;
  min-width: 0;
}
.machine-card__specs dt {
  color: var(--muted);
  font-size: 0.7rem;
  white-space: nowrap;
}
.machine-card__specs dd {
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
  font-size: 0.76rem;
}

.machine-card__buy {
  margin-top: auto;
  min-height: 36px;
  font-size: 0.74rem;
  padding: 7px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══════════════════════════════════════════════
   МАГАЗИН — СТЕЛЛАЖИ (3 колонки × 3 ряда)
   ═══════════════════════════════════════════════ */
.racks-shop {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.rack-product {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color 0.15s;
  min-width: 0;
  text-align: center;
}
.rack-product:hover { border-color: var(--accent); }

.rack-product__icon {
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}
.rack-product__icon img {
  max-width: 60%;
  max-height: 100%;
  object-fit: contain;
}
.rack-product__name {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 2px;
}
.rack-product__slots {
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 4px;
  white-space: nowrap;
}
.rack-product__price {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 6px;
  white-space: nowrap;
}
.rack-product__buy {
  min-height: 32px;
  font-size: 0.7rem;
  padding: 6px 6px;
  margin-top: auto;
}

/* ═══════════════════════════════════════════════
   МАГАЗИН — СЫРЬЁ
   ═══════════════════════════════════════════════ */
.raw-shop { display: block; }

.raw-current {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 14px;
}
.raw-current b { color: var(--ink); font-weight: 800; }

.raw-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.raw-info__item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.raw-info__item span {
  font-size: 0.72rem;
  color: var(--muted);
}
.raw-info__item b {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--ink);
}

.raw-subtitle {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 18px 0 10px;
}

.raw-packages {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.raw-packages .button {
  min-height: 42px;
  font-size: 0.82rem;
  padding: 8px 10px;
}

.raw-custom {
  display: grid;
  gap: 10px;
}
.raw-custom input {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 0.95rem;
  text-align: center;
  font-weight: 700;
}
.raw-custom input::placeholder {
  color: var(--muted);
  font-weight: 500;
}
.raw-custom input:focus { border-color: var(--accent); }

.raw-custom__total {
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}
.raw-custom__total b {
  color: var(--accent);
  font-weight: 900;
  font-size: 1rem;
}

/* Электросеть */
.power-ladder { margin: 16px 0; }
.power-ladder > div {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}
.power-ladder > div:last-child { border-bottom: 0; }
.power-ladder .current { color: var(--accent); font-weight: 800; }
.power-ladder .complete { color: var(--green); }
.power-ladder small { margin-left: auto; font-size: 0.75rem; color: var(--muted); }
.power-ladder .icon { width: 16px; height: 16px; }

/* ═══════════════════════════════════════════════
   ИСТОРИЯ / ТОП
   ═══════════════════════════════════════════════ */
.history-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}
.history-row:last-child { border-bottom: 0; }
.history-row strong { font-weight: 700; color: var(--ink); }
.history-row b { white-space: nowrap; }

.top-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}
.top-row:last-child { border-bottom: 0; }
.top-row.is-mine { background: rgba(196, 160, 82, 0.08); margin: 0 -20px; padding: 12px 20px; }
.top-place { width: 24px; text-align: center; font-weight: 800; color: var(--muted); }
.top-info { flex: 1; min-width: 0; }
.top-info strong { display: block; font-weight: 700; }
.top-info small { color: var(--muted); font-size: 0.75rem; }
.top-row > b { white-space: nowrap; font-size: 0.8rem; }

/* ═══════════════════════════════════════════════
   АВАТАРКА
   ═══════════════════════════════════════════════ */
.avatar {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--accent);
  font-size: 1rem;
  font-weight: 900;
  flex-shrink: 0;
}
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.profile-card .avatar {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  font-size: 1.6rem;
}

.top-row .avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 1rem;
}

/* ═══════════════════════════════════════════════
   ПРОФИЛЬ (компактный)
   ═══════════════════════════════════════════════ */
.profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
}
.profile-card h2 { font-size: 1.15rem; }
.profile-card p { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

/* ═══════════════════════════════════════════════
   НАВИГАЦИЯ
   ═══════════════════════════════════════════════ */
.navigation {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  gap: 4px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  max-width: calc(100% - 32px);
}

.navigation button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 68px;
  padding: 8px 12px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  transition: background 0.15s, color 0.15s;
}
.navigation button:hover { color: var(--ink); }
.navigation button[aria-current="page"] {
  background: var(--accent);
  color: var(--accent-ink);
}
.navigation .icon { width: 21px; height: 21px; }

/* ═══════════════════════════════════════════════
   ИКОНКИ
   ═══════════════════════════════════════════════ */
.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  vertical-align: middle;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ═══════════════════════════════════════════════
   ДИАЛОГ
   ═══════════════════════════════════════════════ */
dialog {
  border: 0;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 440px;
  width: calc(100% - 32px);
  max-height: calc(100dvh - 40px);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
dialog h2 { margin-right: 32px; margin-bottom: 14px; }
dialog p  { font-size: 0.88rem; line-height: 1.55; margin-top: 10px; }
dialog .stats-grid { margin: 18px 0; }

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}
.dialog-close:hover { background: var(--line); }

/* ═══════════════════════════════════════════════
   УВЕДОМЛЕНИЕ
   ═══════════════════════════════════════════════ */
.notice {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  max-width: min(520px, calc(100% - 32px));
  width: max-content;
  padding: 12px 18px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 0.86rem;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ═══════════════════════════════════════════════
   СТАТУСЫ
   ═══════════════════════════════════════════════ */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 700;
}
.status i {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status.online  { color: var(--green); }
.status.warning { color: var(--warn); }
.status.muted   { color: var(--muted); }

/* ═══════════════════════════════════════════════
   ЗАГРУЗЧИК
   ═══════════════════════════════════════════════ */
.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  background: var(--bg);
  color: var(--ink);
  overflow: auto;
  transition: opacity 0.25s ease-out;
}
.loader.is-ready { opacity: 0; pointer-events: none; }

.loader__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 900;
}
.loader__brand small {
  display: block;
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin-top: 3px;
}

.loader__content {
  width: min(100%, 400px);
  margin: auto;
  text-align: center;
  padding: 20px 0;
}
.loader__content h1 { font-size: clamp(24px, 5vw, 32px); margin-bottom: 12px; }
.loader__content p { font-size: 0.9rem; }

.loader__track {
  width: min(220px, 75%);
  height: 4px;
  margin: 24px auto 14px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}
.loader__track span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s;
}

.loader__status { font-size: 0.78rem; color: var(--muted); }
.loader__actions { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
.loader__actions a { color: var(--accent); font-size: 0.85rem; text-align: center; }
.loader__footer { font-size: 0.75rem; color: var(--muted); margin-top: 16px; }

/* ═══════════════════════════════════════════════
   АДАПТИВ — ПЛАНШЕТЫ
   ═══════════════════════════════════════════════ */
@media (max-width: 720px) {
  .app-shell { padding: 0 14px 100px; }
  .topbar { height: 64px; }
  .brand { font-size: 15px; }
  .brand small { font-size: 10px; }
  .wallet { padding: 7px 10px; font-size: 13px; }

  .page-heading { margin: 4px 0 20px; align-items: flex-start; }
  .page-heading h1 { font-size: 1.4rem; }
  .page-heading p  { font-size: 0.82rem; }

  .navigation {
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    width: 100%;
    max-width: none;
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .navigation button {
    flex: 1;
    min-width: 0;
    padding: 6px 4px;
    font-size: 0.63rem;
  }
  .navigation .icon { width: 20px; height: 20px; }

  .notice { bottom: 84px; }
  dialog { padding: 20px; }
  .dialog-close { width: 32px; height: 32px; font-size: 20px; }

  .farm-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════
   АДАПТИВ — ТЕЛЕФОНЫ
   ═══════════════════════════════════════════════ */
@media (max-width: 480px) {
  main { padding: 12px 0 84px; }
  .page-heading { margin: 4px 0 12px; }
  .page-heading h1 { font-size: 1.3rem; }
  .card { padding: 14px 12px; margin-bottom: 10px; }
  .card h2 { font-size: 1rem; margin-bottom: 8px; }

  /* Фабрика — компактно */
  .farm-main .big-number { font-size: 1.7rem; margin: 6px 0 8px; }
  .farm-main .rate-line { padding: 3px 0; font-size: 0.78rem; }
  .compact-bar { gap: 5px; margin-bottom: 10px; }
  .compact-item { padding: 8px; gap: 6px; }
  .compact-item .icon { width: 16px; height: 16px; }
  .compact-item small { font-size: 0.6rem; }
  .compact-item b { font-size: 0.72rem; }

  /* Стеллажи — компактнее */
  .rack-slots { gap: 6px; }
  .rack-slot { min-height: 72px; padding: 6px 4px; }
  .rack-slot img { width: 32px; height: 24px; }
  .rack-slot strong { font-size: 0.62rem; }
  .rack-slot small { font-size: 0.58rem; }

  /* Магазин — станки компактнее */
  .machines-grid { gap: 8px; }
  .machine-card { padding: 10px; }
  .machine-card__icon { width: 34px; height: 26px; }
  .machine-card__name { font-size: 0.8rem; }
  .machine-card__specs { font-size: 0.7rem; gap: 4px; margin-bottom: 8px; }
  .machine-card__specs dt { font-size: 0.65rem; }
  .machine-card__specs dd { font-size: 0.72rem; }
  .machine-card__buy { font-size: 0.7rem; min-height: 34px; padding: 6px; }

  /* Магазин — стеллажи компактнее */
  .racks-shop { gap: 6px; }
  .rack-product { padding: 8px 4px; }
  .rack-product__icon { height: 34px; margin-bottom: 4px; }
  .rack-product__name { font-size: 0.78rem; }
  .rack-product__slots { font-size: 0.62rem; }
  .rack-product__price { font-size: 0.66rem; }
  .rack-product__buy { font-size: 0.64rem; min-height: 28px; padding: 4px; }

  /* Магазин — сырьё компактнее */
  .raw-info { gap: 8px; margin-bottom: 14px; }
  .raw-info__item { padding: 10px; }
  .raw-info__item span { font-size: 0.68rem; }
  .raw-info__item b { font-size: 0.82rem; }
  .raw-subtitle { font-size: 0.74rem; margin: 14px 0 8px; }
  .raw-packages { gap: 6px; }
  .raw-packages .button { min-height: 38px; font-size: 0.76rem; }
  .raw-custom input { min-height: 42px; font-size: 0.9rem; }
  .raw-custom__total { font-size: 0.82rem; }

  /* Топ компактно */
  .top-row { flex-wrap: wrap; gap: 8px; padding: 10px 0; }
  .top-row > b { font-size: 0.75rem; }
  .top-info strong { font-size: 0.88rem; }
  .top-info small { font-size: 0.7rem; }

  /* История */
  .history-row { flex-wrap: wrap; gap: 6px; font-size: 0.8rem; }
  .history-row strong { font-size: 0.85rem; }

  /* Профиль */
  .profile-card .avatar { width: 48px; height: 48px; font-size: 1.4rem; }
  .profile-card h2 { font-size: 1.05rem; }
  .profile-card p { font-size: 0.72rem; }
}

/* ═══════════════════════════════════════════════
   ОЧЕНЬ УЗКИЕ ЭКРАНЫ
   ═══════════════════════════════════════════════ */
@media (max-width: 380px) {
  .rate-line { font-size: 0.78rem; padding: 5px 0; }
  .big-number { font-size: 1.4rem; }

  .machine-card { padding: 8px; }
  .machine-card__name { font-size: 0.74rem; }
  .machine-card__specs { font-size: 0.66rem; }
  .machine-card__specs dt { font-size: 0.62rem; }
  .machine-card__buy { font-size: 0.66rem; }

  .rack-product__buy { font-size: 0.6rem; }
}

/* ═══════════════════════════════════════════════
   УМЕНЬШЕНИЕ ДВИЖЕНИЯ
   ═══════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}