:root {
  --bg: #f7f5f1;
  --panel: #ffffff;
  --line: #ded8cd;
  --text: #20242a;
  --muted: #6b6257;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --warning: #a15c07;
  --ok: #18794e;
  --soft: #eef3ef;
  --radius: 8px;
  --shadow: 0 14px 38px rgba(31, 36, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: 0;
}

a {
  color: var(--accent-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: #fffdf8;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  font-weight: 800;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: #23201c;
  color: #fffaf0;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 6px;
  margin-top: 28px;
}

.nav a {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 650;
}

.nav a.active,
.nav a:hover {
  background: var(--soft);
  color: var(--accent-dark);
  text-decoration: none;
}

.logout-form {
  margin-top: auto;
}

.content {
  min-width: 0;
  padding: 30px;
}

.page-header,
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

h1,
h2 {
  margin: 0;
  color: var(--text);
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

.stat,
.panel,
.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat {
  padding: 18px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1.1;
}

.section {
  margin-top: 28px;
}

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

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  white-space: nowrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover {
  text-decoration: none;
}

.button.primary {
  background: var(--accent);
  color: #fff;
}

.button.primary:hover {
  background: var(--accent-dark);
}

.button.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.button.ghost {
  background: transparent;
  color: var(--muted);
}

.button.danger {
  background: var(--danger);
  color: #fff;
}

.button.small {
  min-height: 32px;
  padding: 7px 10px;
  font-size: 13px;
}

.button.full {
  width: 100%;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #ebe6dc;
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.ok,
.status-delivered,
.status-paid {
  background: #e4f3ea;
  color: var(--ok);
}

.status-pending_payment {
  background: #fff0d8;
  color: var(--warning);
}

.status-reserved,
.stock-резерв {
  background: #fff0d8;
  color: var(--warning);
}

.danger-badge,
.status-cancelled,
.stock-продано {
  background: #ffe4df;
  color: var(--danger);
}

.muted-badge,
.status-expired,
.stock-скрыто {
  background: #ece8e1;
  color: var(--muted);
}

.stock-свободно {
  background: #e4f3ea;
  color: var(--ok);
}

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

.center {
  text-align: center;
}

.form {
  display: grid;
  gap: 16px;
}

.form.panel,
.panel {
  padding: 18px;
}

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

.form-grid.align-end {
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  align-self: end;
}

.checkbox-row.compact {
  min-height: 0;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.search,
.filters {
  display: flex;
  gap: 8px;
  min-width: min(420px, 100%);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.65fr);
  gap: 18px;
}

.details {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px 14px;
  margin: 16px 0 0;
}

.details dt {
  color: var(--muted);
}

.details dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.stack {
  display: grid;
  gap: 14px;
}

.copy-line input {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.alert {
  padding: 12px;
  border-radius: var(--radius);
  font-weight: 700;
}

.alert.danger {
  background: #ffe4df;
  color: var(--danger);
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 22px;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav a {
    justify-content: center;
    text-align: center;
  }

  .logout-form {
    margin-top: 18px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split,
  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .content {
    padding: 20px 14px;
  }

  .page-header,
  .section-header {
    align-items: stretch;
    flex-direction: column;
  }

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

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search,
  .filters {
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
  }
}
