:root {
  --bg: #151515;
  --surface: #ffffff;
  --surface-soft: #f4f4f4;
  --text: #181818;
  --muted: #6f6f6f;
  --line: #dddddd;
  --orange: #f47718;
  --orange-dark: #d85b08;
  --orange-soft: #fff0e5;
  --green: #237a4b;
  --red: #bd2d22;
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--surface-soft);
}

body.login-page {
  background:
    radial-gradient(circle at top, rgba(244, 119, 24, 0.18), transparent 330px),
    linear-gradient(145deg, #202020 0%, #111111 56%, #2a2a2a 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.sidebar {
  min-height: 100vh;
  padding: 22px;
  color: #ffffff;
  background: linear-gradient(180deg, #1d1d1d 0%, #101010 100%);
}

.brand {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  color: #ffffff;
  background: var(--orange);
  box-shadow: 0 12px 26px rgba(244, 119, 24, 0.32);
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 1rem;
  line-height: 1.2;
}

.brand span {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.82rem;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-link {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.94rem;
  font-weight: 700;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.nav-link.is-active,
.nav-link:hover {
  color: #ffffff;
  background: rgba(244, 119, 24, 0.18);
}

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

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow,
.topbar h1,
.panel-heading h2,
.form-message,
.empty-state {
  margin: 0;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--orange-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h1 {
  font-size: 2rem;
  line-height: 1.1;
  letter-spacing: 0;
}

.owner-chip {
  min-height: 54px;
  display: grid;
  align-content: center;
  min-width: 150px;
  grid-template-columns: 1fr auto;
  column-gap: 12px;
  padding: 8px 10px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.owner-chip span,
.owner-chip strong {
  display: block;
}

.owner-chip span {
  color: var(--muted);
  font-size: 0.74rem;
}

.owner-chip strong {
  font-size: 0.92rem;
}

.logout-button {
  grid-row: 1 / span 2;
  grid-column: 2;
  min-height: 34px;
  align-self: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  font-size: 0.8rem;
  font-weight: 800;
}

.logout-button:hover {
  background: var(--surface-soft);
}

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

.login-card {
  width: min(100%, 410px);
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
  padding-bottom: 22px;
  border-bottom: 1px solid #eeeeee;
}

.login-brand p,
.login-brand h1 {
  margin: 0;
}

.login-brand p {
  margin-bottom: 5px;
  color: var(--orange-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-brand h1 {
  font-size: 1.68rem;
  line-height: 1.1;
  letter-spacing: 0;
}

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

.view-panel {
  display: none;
}

.view-panel.is-visible {
  display: block;
}

.stat-card {
  min-height: 88px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.stat-card span,
.stat-card strong {
  display: block;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.stat-card strong {
  margin-top: 8px;
  font-size: 1.8rem;
  line-height: 1;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.menu-workspace-grid {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.form-stack {
  display: grid;
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.form-panel {
  padding: 22px;
}

.compact-form {
  padding-bottom: 18px;
}

.panel-heading {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-heading h2 {
  font-size: 1.18rem;
  line-height: 1.2;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: inline-block;
  margin-bottom: 7px;
  font-size: 0.9rem;
  font-weight: 800;
}

.field input,
.field select,
.field textarea,
.search-field input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  outline: 0;
}

.field input,
.field select,
.field textarea {
  min-height: 46px;
  padding: 0 12px;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-field:focus-within {
  border-color: var(--orange);
  box-shadow: 0 0 0 4px rgba(244, 119, 24, 0.14);
}

.field textarea {
  min-height: 86px;
  padding-top: 12px;
  resize: vertical;
}

.field small {
  min-height: 17px;
  display: block;
  margin-top: 5px;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 700;
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea,
.field.has-error .password-control {
  border-color: rgba(189, 45, 34, 0.78);
}

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

.password-control {
  min-height: 46px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.password-control input {
  min-height: 44px;
  border: 0;
  box-shadow: none;
}

.password-control:focus-within {
  border-color: var(--orange);
  box-shadow: 0 0 0 4px rgba(244, 119, 24, 0.14);
}

.icon-button {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
}

.icon-button:hover {
  background: var(--orange-soft);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.primary-button {
  width: 100%;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  box-shadow: 0 13px 28px rgba(244, 119, 24, 0.28);
  font-weight: 800;
}

.primary-button:hover {
  transform: translateY(-1px);
}

.primary-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.secondary-action-button {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(244, 119, 24, 0.36);
  border-radius: 8px;
  color: var(--orange-dark);
  background: var(--orange-soft);
  font-weight: 800;
}

.secondary-action-button:hover {
  background: #ffe2cc;
}

.button-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.button-row .primary-button {
  min-width: 0;
}

.form-cancel {
  min-height: 48px;
  display: none;
}

.form-cancel.is-visible {
  display: inline-flex;
  align-items: center;
}

.form-message {
  min-height: 20px;
  margin-top: 14px;
  color: var(--green);
  font-size: 0.86rem;
  font-weight: 800;
  text-align: center;
}

.form-message.is-error {
  color: var(--red);
}

.table-panel {
  min-width: 0;
  padding: 18px;
}

.table-heading {
  align-items: center;
}

.search-field {
  width: min(260px, 100%);
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.search-field svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.search-field input {
  min-height: 38px;
  padding: 0;
  border: 0;
}

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

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

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid #eeeeee;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  font-size: 0.9rem;
}

.name-cell strong,
.name-cell span {
  display: block;
}

.name-cell span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  color: #7a3304;
  background: var(--orange-soft);
  font-size: 0.78rem;
  font-weight: 800;
}

.badge.is-quiet {
  color: #3f3f3f;
  background: #eeeeee;
}

.category-stack {
  display: grid;
  justify-items: start;
  gap: 4px;
}

.production-text {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.2;
}

.status {
  color: var(--green);
  font-weight: 800;
}

.status.is-muted {
  color: var(--red);
}

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

.secondary-button,
.danger-button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  font-size: 0.82rem;
  font-weight: 800;
}

.danger-button {
  color: var(--red);
}

.secondary-button:hover,
.danger-button:hover {
  background: var(--surface-soft);
}

.empty-state {
  display: none;
  padding: 28px 0 12px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.empty-state.is-visible {
  display: block;
}

.table-panel.is-empty .table-wrap {
  display: none;
}

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

.check-field {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 800;
}

.check-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--orange);
}

.category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.category-pill {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
}

.category-pill span {
  color: var(--muted);
  font-weight: 700;
}

.product-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.product-thumb {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid #eeeeee;
  border-radius: 8px;
  color: var(--orange-dark);
  background: var(--orange-soft);
  font-size: 0.8rem;
  font-weight: 900;
}

.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-meta strong,
.product-meta span {
  display: block;
}

.product-meta span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.price-text {
  font-weight: 900;
}

.products-table {
  min-width: 660px;
}

.products-table th,
.products-table td {
  padding-left: 8px;
  padding-right: 8px;
}

.products-table .row-actions {
  gap: 6px;
}

.products-table .secondary-button,
.products-table .danger-button {
  padding: 0 8px;
}

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

  .sidebar {
    min-height: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
  }

  .brand {
    margin-bottom: 0;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
  }

  .nav-link {
    white-space: nowrap;
  }

  .workspace-grid,
  .menu-workspace-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .main-content {
    padding: 18px;
  }

  .topbar,
  .table-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .owner-chip {
    width: 100%;
  }

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

  .field-grid,
  .toggle-grid,
  .button-row {
    grid-template-columns: 1fr;
  }

  .form-cancel.is-visible {
    justify-content: center;
  }

  .sidebar {
    align-items: stretch;
    flex-direction: column;
  }

  .search-field {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
