:root {
  /* Тёплая нейтральная палитра, монохромный акцент */
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --text: #1b1a17;
  --muted: #6f6c64;
  --faint: #a6a29a;
  --border: #eae7e0;
  --border-strong: #ddd9d0;
  --accent: #1b1a17;
  --accent-press: #35322b;
  --accent-soft: #efece5;
  --ok: #3f7d54;
  --ok-bg: #e9f1ea;
  --danger: #b0473c;
  --danger-bg: #f6ece9;
  --warn-bg: #f1e7d3;
  --warn-text: #866634;
  --ring: rgba(27, 26, 23, 0.13);
  --radius: 16px;
  --radius-sm: 11px;
  --tap: 46px;
  --shadow-sm: 0 1px 2px rgba(28, 25, 20, 0.04), 0 2px 8px -4px rgba(28, 25, 20, 0.05);
}

* {
  box-sizing: border-box;
}

/* Атрибут hidden всегда побеждает авторские display-правила. */
[hidden] {
  display: none !important;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    15px/1.5 system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 22px 18px 132px;
}

h1 {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 2px 0 18px;
}
h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 28px 0 12px;
}
a {
  color: var(--text);
  text-decoration: none;
}

.muted {
  color: var(--muted);
}
.empty {
  color: var(--faint);
  text-align: center;
  padding: 40px 8px;
  font-size: 14px;
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

summary {
  list-style: none;
}
summary::-webkit-details-marker {
  display: none;
}

/* --- Top bar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(246, 245, 242, 0.82);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 13px 18px;
}
.topbar .brand {
  font-weight: 650;
  letter-spacing: -0.01em;
}
.topbar nav {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  align-items: center;
}
.topbar nav a {
  padding: 7px 12px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  transition:
    color 0.15s,
    background 0.15s;
}
.topbar nav a:hover {
  color: var(--text);
}
.topbar nav a.active {
  background: var(--accent-soft);
  color: var(--text);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  transition:
    background 0.15s,
    border-color 0.15s,
    transform 0.05s,
    opacity 0.15s;
}
.btn:hover {
  border-color: var(--faint);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled,
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-press);
  border-color: var(--accent-press);
}
.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger-bg);
}
.btn-sm {
  min-height: 36px;
  padding: 0 13px;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 9px;
}
.btn-block {
  width: 100%;
}

/* --- Forms --- */
.field {
  margin: 14px 0;
}
.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 7px;
}
input[type='text'],
input[type='password'],
input[type='number'],
input[type='date'],
input[type='file'],
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}
textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
}
.checkbox input {
  width: 20px;
  height: 20px;
  min-height: 0;
  accent-color: var(--accent);
}

/* --- Messages --- */
.msg {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin: 14px 0;
  font-size: 14px;
}
.msg.error {
  background: var(--danger-bg);
  color: var(--danger);
}
.msg.ok {
  background: var(--ok-bg);
  color: var(--ok);
}

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin: 14px 0;
}
details.card > summary {
  font-weight: 600;
  cursor: pointer;
}

/* --- Login --- */
.login {
  max-width: 400px;
  margin: 12vh auto 0;
}
.login h1 {
  text-align: center;
  margin-bottom: 6px;
}
.login > .muted {
  text-align: center;
  margin-bottom: 22px;
}

/* --- Issue tiles --- */
.tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (min-width: 560px) {
  .tiles {
    grid-template-columns: repeat(3, 1fr);
  }
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.tile:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.tile .photo {
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tile .photo img,
.tile .photo svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tile .name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.tile .stock {
  color: var(--muted);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.tile.out {
  opacity: 0.5;
}

.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--warn-bg);
  color: var(--warn-text);
}
.badge.role {
  background: var(--accent-soft);
  color: var(--muted);
}

/* --- Sizes --- */
.sizes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}
.size-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 6px 6px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
}
.size-row.out {
  opacity: 0.5;
}
.size-label {
  font-weight: 650;
  font-size: 14px;
  letter-spacing: 0.02em;
}
.size-stock {
  font-size: 12.5px;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.size-row .badge {
  margin-left: auto;
}
.size-row .stepper {
  margin: 0;
  justify-content: flex-end;
  gap: 4px;
}
.size-row .stepper button {
  width: 36px;
  height: 36px;
  font-size: 17px;
}

/* --- Stepper --- */
.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
}
.stepper button {
  width: 42px;
  height: 42px;
  font-size: 20px;
  line-height: 1;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition:
    background 0.12s,
    border-color 0.12s;
}
.stepper button:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--faint);
}
.stepper button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.stepper .count {
  font-size: 17px;
  font-weight: 650;
  min-width: 26px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* --- Sticky bottom action bar --- */
.bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border);
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
}
.bottombar .inner {
  max-width: 720px;
  margin: 0 auto;
}

/* --- Tables --- */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th {
  color: var(--faint);
  font-weight: 550;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
tbody tr {
  transition: background 0.12s;
}
tbody tr:hover {
  background: var(--surface-2);
}
tr:last-child td {
  border-bottom: none;
}
tr.voided td {
  color: var(--faint);
  text-decoration: line-through;
}
tr.voided td .actor {
  text-decoration: none;
  display: block;
  font-size: 12px;
}
td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.thumb-cell {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
}
.thumb-cell img,
.thumb-cell svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tag {
  font-size: 12px;
  font-weight: 550;
  padding: 3px 9px;
  border-radius: 999px;
}
.tag.on {
  background: var(--ok-bg);
  color: var(--ok);
}
.tag.off {
  background: var(--danger-bg);
  color: var(--danger);
}

.size-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.chip {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  white-space: nowrap;
  color: var(--muted);
}

/* --- Filters row --- */
.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}
@media (min-width: 620px) {
  .filters {
    grid-template-columns: repeat(4, 1fr) auto;
  }
}
.filters label {
  font-size: 12px;
}

/* --- Actions panel (inline forms in table) --- */
details > summary {
  cursor: pointer;
}
.actions-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 2px 6px;
  min-width: 240px;
}
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}
.inline-form label {
  width: 100%;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
}
.inline-form input,
.inline-form select {
  flex: 1;
  min-width: 130px;
  min-height: 40px;
}
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.row-actions form {
  margin: 0;
}

/* --- Pagination --- */
.pager {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin: 20px 0;
  font-size: 14px;
}

/* --- Showcase: filter chips --- */
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 20px;
}
.chip-filter {
  min-height: 40px;
  padding: 0 15px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}
.chip-filter:hover {
  border-color: var(--faint);
}
.chip-filter.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* --- Showcase: catalog sections & clickable tiles --- */
.catalog-section h2 {
  margin: 26px 0 12px;
}
.item-tile {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 100%;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.item-tile:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}
.sel-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Item modal: bottom sheet on phones, centered card on desktop --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(27, 26, 23, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
/* display:flex выше перебил бы атрибут hidden — возвращаем его силу явно. */
.modal-overlay[hidden] {
  display: none;
}
.modal-sheet {
  position: relative;
  width: 100%;
  max-height: 85dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
}
@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
    padding: 24px;
  }
  .modal-sheet {
    max-width: 440px;
    max-height: min(680px, 90dvh);
    border-radius: 22px;
    padding: 22px 22px 22px;
  }
}
html.modal-open,
html.modal-open body {
  overflow: hidden;
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover {
  color: var(--text);
}
.modal-photo {
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-2);
  margin-bottom: 14px;
}
.modal-photo img,
.modal-photo svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.modal-title {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}
.modal-meta {
  display: flex;
  gap: 5px;
  margin-bottom: 12px;
}
.modal-body .sizes {
  margin: 10px 0 16px;
}
.modal-done {
  margin-top: 4px;
}

/* --- Admin users: add-employee button --- */
.add-user summary {
  display: inline-flex;
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.add-user summary::-webkit-details-marker {
  display: none;
}

/* --- Journal: period nav + day separators --- */
.period-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 14px;
}
.period-nav .seg {
  display: flex;
  gap: 6px;
}
.period-switch {
  display: flex;
  align-items: center;
  gap: 10px;
}
.period-cur {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  min-width: 130px;
  text-align: center;
}
tr.day-sep td {
  background: var(--surface-2);
  font-weight: 650;
  font-size: 13px;
  padding: 8px 10px;
}

/* --- Taken list / confirmation --- */
.taken-list li {
  padding: 9px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.taken-list li:last-child {
  border-bottom: none;
}
.big-ok {
  text-align: center;
  font-size: 24px;
  font-weight: 650;
  color: var(--ok);
  letter-spacing: -0.01em;
  margin: 28px 0 10px;
}
