:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-muted: #eef4f7;
  --text: #162033;
  --muted: #647086;
  --line: #d9e1ea;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #2563eb;
  --danger: #b42318;
  --warning: #a15c07;
  --success: #21725a;
  --radius: 8px;
  --shadow: 0 12px 30px rgba(22, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

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

a:hover,
a:focus {
  text-decoration: underline;
}

input,
textarea,
button {
  font: inherit;
}

button,
.primary-button,
.secondary-button {
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 700;
  text-decoration: none;
}

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

.primary-button:hover,
.primary-button:focus {
  background: var(--primary-dark);
  text-decoration: none;
}

.secondary-button {
  background: #e7eef5;
  color: var(--text);
  border: 1px solid var(--line);
}

.secondary-button:hover,
.secondary-button:focus {
  background: #dce7f0;
  text-decoration: none;
}

.full-width {
  width: 100%;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 3vw, 32px);
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.brand:hover,
.brand:focus {
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

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

.top-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.top-nav a,
.link-button {
  color: var(--text);
  background: transparent;
  padding: 0;
  min-height: 0;
  font-weight: 700;
}

.messages {
  width: min(1180px, calc(100% - 32px));
  margin: 18px auto 0;
  display: grid;
  gap: 10px;
}

.message {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
}

.message-success {
  border-color: rgba(33, 114, 90, 0.35);
  background: #edf8f3;
}

.message-error,
.message-warning {
  border-color: rgba(180, 35, 24, 0.28);
  background: #fff1ed;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 48px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.page-heading h1,
.login-copy h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.05;
  letter-spacing: 0;
}

.page-heading p,
.login-copy p {
  max-width: 720px;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary-dark);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 13px;
}

.login-layout {
  min-height: calc(100vh - 150px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 42px;
  align-items: center;
}

.login-panel,
.filters-panel,
.cart-panel,
.table-panel,
.detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-panel {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.login-panel h2 {
  margin: 0;
}

.login-panel label,
.search-form label,
.quantity-form label,
.submit-order label {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-weight: 700;
}

.login-panel input,
.search-form input,
.quantity-control input,
.submit-order textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
}

.form-error {
  padding: 10px 12px;
  background: #fff1ed;
  border: 1px solid rgba(180, 35, 24, 0.28);
  border-radius: var(--radius);
  color: var(--danger);
}

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

.filters-panel,
.cart-panel {
  position: sticky;
  top: 82px;
  padding: 16px;
}

.search-form {
  display: grid;
  gap: 10px;
}

.category-list {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.category-list a {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
}

.category-list a.active {
  border-color: rgba(15, 118, 110, 0.45);
  background: #e7f5f2;
  color: var(--primary-dark);
  font-weight: 800;
}

.product-list {
  display: grid;
  gap: 12px;
}

.product-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 190px;
  gap: 16px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.product-thumb {
  width: 86px;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel-muted);
  display: grid;
  place-items: center;
  color: var(--primary-dark);
  font-size: 30px;
  font-weight: 800;
}

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

.product-main h2 {
  margin: 4px 0;
  font-size: 20px;
  line-height: 1.2;
}

.product-main p {
  margin: 0;
  color: var(--muted);
}

.product-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.product-meta span,
.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  background: #edf2f7;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.quantity-form {
  display: grid;
  gap: 8px;
}

.quantity-form label span {
  color: var(--muted);
  font-weight: 400;
}

.quantity-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  gap: 8px;
}

.quantity-control button {
  background: var(--text);
  color: #fff;
}

.cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.cart-header h2 {
  margin: 0;
}

.cart-header span {
  color: var(--muted);
  font-weight: 700;
}

.cart-groups {
  display: grid;
  gap: 14px;
}

.cart-groups h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.submit-order {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.empty-cart,
.empty-state {
  color: var(--muted);
  background: var(--panel-muted);
  border-radius: var(--radius);
  padding: 18px;
}

.table-panel {
  padding: 16px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 14px;
}

.status-sent {
  background: #e7f8f1;
  color: var(--success);
}

.status-failed {
  background: #fff1ed;
  color: var(--danger);
}

.status-pending {
  background: #fff8e6;
  color: var(--warning);
}

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

.detail-panel {
  padding: 18px;
}

.detail-panel h2 {
  margin: 0 0 14px;
}

.order-group {
  margin-bottom: 20px;
}

.order-group h3 {
  margin: 0 0 10px;
  color: var(--primary-dark);
}

.order-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.order-line span,
.dispatch-card p {
  display: block;
  color: var(--muted);
}

.dispatch-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}

.dispatch-card > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.dispatch-error {
  color: var(--danger);
}

.notes {
  white-space: pre-wrap;
  color: var(--muted);
}

@media (max-width: 980px) {
  .catalog-layout,
  .detail-grid,
  .login-layout {
    grid-template-columns: 1fr;
  }

  .filters-panel,
  .cart-panel {
    position: static;
  }

  .product-row {
    grid-template-columns: 74px minmax(0, 1fr);
  }

  .quantity-form {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .app-header,
  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-nav {
    width: 100%;
    justify-content: space-between;
  }

  .app-shell,
  .messages {
    width: min(100% - 20px, 1180px);
  }

  .product-row {
    grid-template-columns: 1fr;
  }

  .product-thumb {
    width: 100%;
    max-height: 160px;
  }
}
