:root {
  --ink: #111216;
  --muted: #666a73;
  --line: #e5e7ec;
  --paper: #f7f7f4;
  --white: #ffffff;
  --red: #b3192a;
  --royal: #123fbd;
  --green: #0f7a3d;
  --gold: #9a6a00;
  --violet: #6650c8;
  --teal: #087f86;
  --module-accent: var(--red);
  --radius: 8px;
  --shadow: 0 20px 60px rgba(17, 18, 22, 0.12);
}

body[data-active-module="stock"] {
  --module-accent: var(--royal);
}

body[data-active-module="access"] {
  --module-accent: var(--ink);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

.process-bar {
  pointer-events: none;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  width: 100%;
  height: 4px;
  overflow: hidden;
  opacity: 0;
  background: rgba(179, 25, 42, 0.12);
  transition: opacity 180ms ease;
}

.process-bar.is-active {
  opacity: 1;
}

.process-bar span {
  display: block;
  width: 42%;
  height: 100%;
  background: linear-gradient(90deg, var(--red), #111216);
  border-radius: 999px;
  transform: translateX(-100%);
}

.process-bar.is-active span {
  animation: process-slide 1.1s ease-in-out infinite;
}

.status-toast {
  pointer-events: none;
  position: fixed;
  top: calc(env(safe-area-inset-top) + 92px);
  right: max(14px, env(safe-area-inset-right));
  z-index: 120;
  max-width: min(420px, calc(100vw - 28px));
  padding: 14px 16px;
  color: var(--white);
  background: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 180ms ease, transform 180ms ease, background 180ms ease;
}

.status-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.status-toast.is-success {
  background: #0f7a3d;
}

.status-toast.is-error {
  background: var(--red);
}

.status-toast.is-warning {
  background: #8a5a00;
}

@keyframes process-slide {
  0% {
    transform: translateX(-110%);
  }

  50% {
    transform: translateX(80%);
  }

  100% {
    transform: translateX(260%);
  }
}

.auth-pending .admin-header,
.auth-pending .module-tabs,
.auth-pending .admin-layout {
  visibility: hidden;
}

.admin-loading {
  display: none;
}

.auth-pending .admin-loading {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  padding: 24px;
  color: var(--muted);
  background: var(--paper);
  font-weight: 900;
  text-align: center;
}

.admin-loading img {
  width: min(260px, 64vw);
  filter: drop-shadow(0 18px 34px rgba(17, 18, 22, 0.14));
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(179, 25, 42, 0.12), transparent 34%),
    var(--paper);
}

.login-shell {
  width: min(460px, calc(100vw - 32px));
}

.login-card {
  padding: clamp(24px, 5vw, 42px);
  text-align: center;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(229, 231, 236, 0.92);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-card img {
  width: min(260px, 74vw);
  margin: 0 auto 24px;
}

.login-eyebrow {
  margin: 0 0 8px;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.login-card h1 {
  margin: 0 0 22px;
  font-size: clamp(34px, 8vw, 54px);
  line-height: 1;
}

.login-card form {
  display: grid;
  gap: 14px;
  text-align: left;
}

.login-card button {
  cursor: pointer;
  min-height: 46px;
  color: var(--white);
  background: var(--ink);
  border: 0;
  border-radius: 999px;
  font-weight: 800;
}

.login-card button:hover {
  background: var(--red);
}

.login-status {
  min-height: 22px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-switch {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 18px 0 0;
  font-size: 0;
  font-weight: 800;
}

.login-switch a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
  color: var(--white);
  background: rgba(7, 24, 68, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(7, 24, 68, 0.12);
  text-decoration: none;
  transition:
    background 220ms ease,
    color 220ms ease,
    transform 520ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 220ms ease;
}

.login-switch a:hover {
  color: var(--white);
  background: var(--red);
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(179, 25, 42, 0.18);
}

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

.admin-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px clamp(18px, 5vw, 70px);
  background: rgba(247, 247, 244, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  width: 128px;
  min-width: 128px;
}

.brand img {
  width: 100%;
  max-height: 42px;
  object-fit: contain;
  object-position: left center;
}

.admin-header p {
  margin: 0 0 4px;
  color: var(--module-accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-header h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
}

.connection-status {
  display: inline-flex;
  margin-top: 10px;
  padding: 7px 10px;
  color: var(--white);
  background: var(--muted);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.optimization-status {
  display: inline-flex;
  margin-top: 8px;
  padding: 7px 10px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.connection-status.is-online {
  background: #0f7a3d;
}

.connection-status.is-local {
  background: var(--red);
}

body[data-active-module="stock"] .connection-status.is-online,
body[data-active-module="stock"] .process-bar span {
  background: var(--royal);
}

.admin-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.module-tabs {
  position: sticky;
  top: 89px;
  z-index: 9;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 14px clamp(18px, 5vw, 70px);
  background: rgba(247, 247, 244, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.module-tabs button {
  cursor: pointer;
  min-height: 42px;
  padding: 0 18px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  font: inherit;
  font-weight: 900;
}

.module-tabs button.is-active {
  color: var(--white);
  background: var(--module-accent);
  border-color: var(--module-accent);
}

body[data-active-module="catalog"] .module-tabs button[data-admin-tab="catalog"],
body[data-active-module="stock"] .module-tabs button[data-admin-tab="stock"],
body[data-active-module="history"] .module-tabs button[data-admin-tab="history"],
body[data-active-module="access"] .module-tabs button[data-admin-tab="access"] {
  box-shadow: 0 10px 24px rgba(17, 18, 22, 0.14);
}

.admin-header a,
.admin-header button,
.admin-nav-exit,
.import-button,
.save-button,
.variant-heading button,
.list-heading button,
.danger-button {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  color: var(--white);
  background: var(--ink);
  border: 0;
  border-radius: 999px;
  font-weight: 800;
  text-decoration: none;
}

.admin-header a:hover,
.admin-header button:hover,
.admin-nav-exit:hover,
.import-button:hover,
.save-button:hover,
.variant-heading button:hover,
.list-heading button:hover,
.danger-button:hover {
  background: var(--module-accent);
}

.import-button input {
  display: none;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(320px, 1.1fr);
  gap: 18px;
  padding: clamp(18px, 5vw, 70px);
}

.admin-form,
.admin-import,
.admin-list,
.module-note {
  padding: clamp(18px, 3vw, 30px);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.admin-import {
  grid-column: 1 / -1;
}

.module-note {
  grid-column: 1 / -1;
  padding-block: 16px;
  color: var(--muted);
  background: color-mix(in srgb, var(--module-accent) 7%, white);
  border-left: 5px solid var(--module-accent);
  box-shadow: none;
}

.module-note p {
  margin: 0;
  font-weight: 800;
  line-height: 1.45;
}

h2 {
  margin: 0 0 18px;
  font-size: 28px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.run-checks {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.run-checks legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.run-checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--ink);
  font-size: 13px;
  text-transform: none;
}

.run-checks input {
  width: 16px;
  min-height: 16px;
}

.wide {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  background: #f7f7f4;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.variant-box {
  margin-top: 22px;
}

.variant-heading,
.list-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.report-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.model-search {
  margin-bottom: 12px;
}

.request-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 220px);
  gap: 10px;
  margin: 14px 0;
}

.import-intro {
  margin: -8px 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

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

.csv-help {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  padding: 12px;
  background: #f7f7f4;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.csv-help span {
  color: var(--muted);
  font-size: 13px;
}

.csv-help button {
  justify-self: start;
  cursor: pointer;
  min-height: 36px;
  padding: 0 12px;
  color: var(--white);
  background: var(--ink);
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

.bulk-summary {
  margin-bottom: 12px;
  padding: 12px;
  color: var(--muted);
  background: #f7f7f4;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-weight: 800;
}

.bulk-preview {
  display: grid;
  gap: 12px;
  max-height: 520px;
  overflow: auto;
  margin-bottom: 14px;
  padding-right: 4px;
}

.bulk-style {
  padding: 14px;
  background: #f7f7f4;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.bulk-style h3 {
  margin: 0 0 6px;
}

.bulk-style p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.bulk-variants {
  display: grid;
  gap: 8px;
}

.bulk-variant {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.bulk-variant img {
  width: 96px;
  height: 76px;
  object-fit: contain;
  background: #f7f7f4;
  border-radius: var(--radius);
}

.bulk-variant strong {
  display: block;
  margin-bottom: 4px;
}

.bulk-variant span {
  color: var(--muted);
  font-size: 12px;
}

.photo-status {
  padding: 6px 9px;
  color: var(--white);
  background: var(--red);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.photo-status.is-ok {
  background: #0f7a3d;
}

.variant-heading h3,
.list-heading h2 {
  margin: 0;
}

.variant-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  background: #f7f7f4;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.variant-editor h4,
.variant-editor .danger-button {
  grid-column: 1 / -1;
}

.variant-editor h4 {
  margin: 0;
}

.save-button {
  width: 100%;
  margin-top: 10px;
}

.stock-admin,
.stock-list-section {
  grid-column: 1 / -1;
}

.stock-size-editor {
  margin-top: 16px;
  padding: 14px;
  background: #f7f7f4;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.size-breakdown-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.size-breakdown-head strong {
  color: var(--ink);
}

.stock-size-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.stock-package-rule {
  grid-column: 1 / -1;
  margin: 0;
  padding: 10px 12px;
  color: var(--violet);
  background: rgba(102, 80, 200, 0.09);
  border: 1px solid rgba(102, 80, 200, 0.18);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 900;
}

.stock-size-point {
  display: grid;
  gap: 6px;
}

.stock-line-point {
  grid-column: 1 / -1;
}

.stock-size-point span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.stock-size-point input {
  min-height: 40px;
  padding: 0 8px;
  text-align: center;
}

.stock-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.stock-row {
  grid-template-columns: 92px 1fr auto auto;
}

.stock-row > strong {
  color: var(--white);
  background: var(--green);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  white-space: nowrap;
}

.admin-tags,
.style-row h3 {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.data-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 4px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

.brand-chip {
  color: var(--ink);
  background: #eef1f5;
  border-color: #dce2ea;
}

.collection-chip {
  color: var(--teal);
  background: rgba(8, 127, 134, 0.09);
  border-color: rgba(8, 127, 134, 0.18);
}

.model-chip,
.sku-chip {
  color: var(--royal);
  background: rgba(18, 63, 189, 0.09);
  border-color: rgba(18, 63, 189, 0.18);
}

.color-chip {
  color: var(--red);
  background: rgba(179, 25, 42, 0.08);
  border-color: rgba(179, 25, 42, 0.18);
}

.lot-chip {
  color: var(--gold);
  background: rgba(154, 106, 0, 0.09);
  border-color: rgba(154, 106, 0, 0.18);
}

.run-chip {
  color: var(--violet);
  background: rgba(102, 80, 200, 0.09);
  border-color: rgba(102, 80, 200, 0.18);
}

.pairs-chip {
  color: var(--green);
  background: rgba(15, 122, 61, 0.09);
  border-color: rgba(15, 122, 61, 0.18);
}

.style-row {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.row-actions {
  display: grid;
  gap: 8px;
}

.row-actions button {
  cursor: pointer;
  min-height: 34px;
  padding: 0 12px;
  color: var(--white);
  background: var(--ink);
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

.row-actions button:hover {
  background: var(--red);
}

.access-row {
  grid-template-columns: 1fr auto;
  align-items: start;
}

.permission-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  background: #f7f7f4;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.role-select-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.role-select-label select {
  min-height: 36px;
  padding: 0 10px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  font: inherit;
  font-weight: 800;
}

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

.permission-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 9px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.permission-check input {
  accent-color: var(--module-accent);
}

.variant-preview {
  grid-column: 1 / -1;
  width: 96px;
  height: 96px;
  object-fit: contain;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.style-row:first-child {
  border-top: 0;
}

.style-row img {
  width: 92px;
  height: 92px;
  object-fit: contain;
  background: #f7f7f4;
  border-radius: var(--radius);
}

.style-row h3 {
  margin: 0 0 4px;
}

.style-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

  .admin-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .module-tabs {
    top: 0;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .admin-layout,
  .form-grid,
  .variant-editor,
  .run-checks,
  .import-steps,
  .bulk-variant {
    grid-template-columns: 1fr;
  }

  .stock-size-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stock-actions,
  .stock-row {
    grid-template-columns: 1fr;
  }

  .permission-grid,
  .access-row {
    grid-template-columns: 1fr;
  }

  .stock-row > strong,
  .stock-row .row-actions {
    justify-self: start;
  }
}
