:root {
  --bg: #f7f7f4;
  --panel: #ffffff;
  --text: #202124;
  --muted: #686b70;
  --line: #d9ddd7;
  --accent: #0f766e;
  --accent-dark: #0b5e59;
  --warn: #b45309;
  --danger: #b42318;
  --shadow: 0 10px 24px rgba(22, 28, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Arial, sans-serif;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px clamp(16px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 247, 244, 0.96);
  backdrop-filter: blur(14px);
}

.brand {
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
  text-decoration: none;
}

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-status {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-dark);
  font-weight: 800;
}

.nav-button,
.button,
.ghost-button,
.danger-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 14px;
  font-weight: 700;
}

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

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

.button-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

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

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

.app {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 44px) 56px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
  gap: 24px;
  align-items: end;
  padding: 28px 0 26px;
}

.hero h1 {
  max-width: 760px;
  margin: 0 0 10px;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1;
  letter-spacing: 0;
}

.hero p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.summary-item {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.summary-label {
  color: var(--muted);
  font-size: 12px;
}

.summary-value {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 800;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin: 16px 0;
}

.search {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

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

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.catalog-workspace {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.catalog-tree {
  position: sticky;
  top: 86px;
  max-height: calc(100vh - 104px);
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.tree-groups {
  display: grid;
  gap: 8px;
}

.tree-group {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.tree-group summary {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.tree-children {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}

.tree-button,
.tree-child {
  display: flex;
  width: 100%;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 7px 8px;
  text-align: left;
}

.tree-button {
  margin-bottom: 10px;
  border-color: var(--line);
  background: #fff;
  font-weight: 800;
}

.tree-child {
  color: var(--muted);
  font-size: 13px;
}

.tree-button.active,
.tree-child.active {
  border-color: #99d7cf;
  background: #e8f7f5;
  color: var(--accent-dark);
}

.product-card {
  display: grid;
  grid-template-rows: 180px 1fr;
  min-height: 418px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 2px 10px rgba(22, 28, 36, 0.04);
}

.image-button {
  width: 100%;
  height: 180px;
  padding: 0;
  border: 0;
  background: #eceee9;
}

.product-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.product-body {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 14px;
}

.product-meta,
.product-size,
.product-availability {
  color: var(--muted);
  font-size: 13px;
}

.product-title {
  min-height: 44px;
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
}

.product-price {
  display: grid;
  gap: 2px;
  font-size: 19px;
  font-weight: 800;
}

.product-price small,
.price-stack small {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.old-price {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: line-through;
}

.price-stack {
  display: grid;
  gap: 4px;
  margin: 8px 0 12px;
  font-size: 20px;
}

.product-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

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

.side-panel,
.login-panel,
.public-panel,
.modal-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.side-panel {
  position: sticky;
  top: 86px;
  max-height: calc(100vh - 104px);
  overflow: auto;
  padding: 16px;
}

.side-panel > .button {
  width: 100%;
}

.panel-title {
  margin: 0 0 12px;
  font-size: 20px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

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

.field input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.field select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.hidden {
  display: none !important;
}

.readonly-input {
  color: var(--muted);
  background: #f4f5f2;
}

.estimate-list {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.estimate-item {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.estimate-item img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: #eceee9;
  border-radius: 6px;
}

.estimate-name {
  font-weight: 700;
}

.qty-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
}

.qty-row input {
  width: 86px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
}

.login-panel {
  max-width: 460px;
  padding: 22px;
}

.notice {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #f4d6a3;
  background: #fff7ed;
  color: #7c2d12;
}

.success {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #a7f3d0;
  background: #ecfdf5;
  color: #065f46;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-header h1 {
  margin: 6px 0;
}

.alert-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid #f4d6a3;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
  font-weight: 800;
}

.alert-box {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid #f4d6a3;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
  font-weight: 800;
}

.link-box {
  display: grid;
  gap: 8px;
  overflow-wrap: anywhere;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfa;
}

.public-panel {
  padding: 22px;
}

.public-actions {
  margin: 14px 0;
}

.public-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.4fr);
  gap: 20px;
  align-items: start;
}

.public-image {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eceee9;
}

.price-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 18px;
}

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

.price-table th {
  color: var(--muted);
  font-size: 13px;
}

.table-product {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.public-product-link {
  color: var(--text);
  text-decoration: none;
}

.public-product-link:hover strong,
.text-link:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

.public-product-link span {
  display: grid;
  gap: 3px;
}

.text-link {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.table-thumb {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 6px;
  background: #eceee9;
}

.total-row {
  font-weight: 800;
}

.admin-table input {
  width: 110px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}

.cart-panel .button {
  width: 100%;
}

.cart-totals {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.cart-totals div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.cart-totals span {
  color: var(--muted);
}

.designer-estimates {
  margin-top: 22px;
}

.proposal-row td {
  padding-top: 0;
  background: #fbfbfa;
}

.proposal-section {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.proposal-list {
  display: grid;
  gap: 10px;
}

.proposal-item {
  display: grid;
  grid-template-columns: 120px 56px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.proposal-item img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 6px;
  background: #eceee9;
}

.proposal-badge {
  width: max-content;
  max-width: 110px;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
}

.proposal-status {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.proposal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.proposal-add .proposal-badge {
  background: #ecfdf5;
  color: #065f46;
}

.proposal-remove .proposal-badge {
  background: #fff7ed;
  color: #9a3412;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.45);
}

.modal-panel {
  width: min(880px, 100%);
  max-height: min(760px, 90vh);
  overflow: auto;
  padding: 18px;
}

.modal-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
}

.modal-image {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: 8px;
  background: #eceee9;
}

.details-list {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 8px 12px;
  margin-top: 12px;
  color: var(--muted);
}

.details-list strong {
  color: var(--text);
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

@media (max-width: 980px) {
  .hero,
  .layout,
  .catalog-workspace,
  .public-header,
  .modal-grid {
    grid-template-columns: 1fr;
  }

  .side-panel,
  .catalog-tree {
    position: static;
    max-height: none;
  }

  .designer-layout .side-panel {
    order: -1;
  }

  .section-header {
    display: grid;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .summary-strip {
    grid-template-columns: 1fr;
  }

  .product-card {
    grid-template-rows: 160px 1fr;
  }

  .image-button {
    height: 160px;
  }

  .price-table {
    font-size: 13px;
  }

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

  .table-thumb {
    width: 44px;
    height: 44px;
  }
}
