@font-face {
  font-family: "Uncage";
  src: url("/fonts/UNCAGE-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
}
@font-face {
  font-family: "Uncage";
  src: url("/fonts/UNCAGE-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: "Inter";
  src: url("/fonts/Inter-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
}
@font-face {
  font-family: "Inter";
  src: url("/fonts/Inter-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
}

:root {
  /* Подземелье brand palette */
  --bg: #16120f;
  --surface: #211b17;
  --surface-2: #2a231d;
  --text: #f3ece4;
  --muted: #a79a8c;
  --border: #392e27;
  --accent: #c94d3d;
  --accent-dark: #a83c2f;
  --good: #c9e897;
  --warn: #d9a441;
  --bad: #e2685a;
  --radius: 12px;
  --font-display: "Uncage", sans-serif;
  --font-body: "Inter", sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body), -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px;
}

.wrap.narrow { max-width: 420px; }

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

header.topbar h1 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--accent);
  font-size: 1.2rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

header.topbar > .flex {
  flex-wrap: wrap;
  row-gap: 8px;
}

@media (max-width: 480px) {
  header.topbar { padding: 12px 14px; }
  header.topbar h1 { font-size: 1.05rem; }
  header.topbar .who { width: 100%; order: -1; }
}

.logo {
  height: 34px;
  width: 34px;
  border-radius: 7px;
  object-fit: cover;
  vertical-align: middle;
}

header.topbar .who {
  font-size: 0.85rem;
  color: var(--muted);
}

button, .btn {
  font: inherit;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  font-weight: 600;
  transition: background 0.15s;
}
button:hover, .btn:hover { background: var(--accent-dark); }
button.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
button.secondary:hover { background: var(--surface); }
button.danger { background: var(--bad); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input.changed {
  border-color: var(--warn);
  background: rgba(217, 164, 65, 0.14);
}

input, select {
  font: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  width: 100%;
}
input::placeholder { color: var(--muted); }

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 4px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

label { font-size: 0.85rem; color: var(--muted); display: block; margin-bottom: 4px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 640px) {
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
}

.stat {
  text-align: center;
}
.stat .value { font-size: 1.6rem; font-weight: 600; }
.stat .label { font-size: 0.8rem; color: var(--muted); }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; white-space: nowrap; }
tr:last-child td { border-bottom: none; }

td button, td button.secondary {
  text-transform: none;
  font-weight: 500;
  font-size: 0.85rem;
  padding: 6px 10px;
  letter-spacing: normal;
  white-space: nowrap;
}
td input { padding: 7px 9px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge.A { background: rgba(201, 232, 151, 0.16); color: var(--good); }
.badge.B { background: rgba(217, 164, 65, 0.16); color: var(--warn); }
.badge.C { background: rgba(226, 104, 90, 0.16); color: var(--bad); }
.badge.low { background: rgba(226, 104, 90, 0.16); color: var(--bad); }

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 280px;
  margin: 0 auto;
}
.pin-pad button {
  font-size: 1.3rem;
  padding: 18px 0;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.pin-pad button:hover { background: var(--surface-2); }
.pin-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 20px 0;
}
.pin-dots span {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
}
.pin-dots span.filled { background: var(--accent); border-color: var(--accent); }

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.item-row:last-child { border-bottom: none; }
.item-row > div:first-child { flex: 1 1 auto; min-width: 0; }
.item-row .name { font-weight: 500; }
.item-row .meta { font-size: 0.78rem; color: var(--muted); }
.qty-control {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
}
.qty-control button {
  width: 36px; height: 36px; padding: 0;
  font-size: 1.1rem;
  line-height: 1;
}
.qty-control input {
  width: 56px;
  text-align: center;
  padding: 8px 4px;
}

.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.error { color: var(--bad); font-size: 0.85rem; margin-top: 8px; }
.muted { color: var(--muted); }
.section-title { font-family: var(--font-display); font-weight: 500; letter-spacing: 0.01em; text-transform: uppercase; font-size: 1.05rem; margin: 0 0 12px; color: var(--text); }

.category-heading {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin: 18px 0 4px;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 100;
}
.toast.show { opacity: 1; }

.flex { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.flex.between { justify-content: space-between; }
.right { text-align: right; }
