:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #657286;
  --line: #dfe5ef;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --warm: #f59e0b;
  --danger: #b42318;
  --shadow: 0 18px 55px rgba(28, 39, 49, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

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

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto auto;
  gap: 18px;
  align-items: center;
  padding: 14px clamp(16px, 4vw, 46px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 42%),
    linear-gradient(135deg, var(--accent), #0b4f49);
  color: #fff;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.24);
  overflow: hidden;
}

.brand-mark::after {
  content: "";
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--warm);
}

.brand-initials {
  position: relative;
  z-index: 1;
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand small {
  display: block;
  white-space: nowrap;
}

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

.brand small,
.section-heading p,
.drawer-header p,
.hero-copy p,
.category,
.payment-note {
  color: var(--muted);
  font-size: 0.84rem;
}

.search-wrap input,
.section-heading select,
.checkout-form input,
.checkout-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.search-wrap input {
  min-height: 46px;
  padding: 0 16px;
}

.search-wrap input:focus,
.section-heading select:focus,
.checkout-form input:focus,
.checkout-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.cart-button,
.primary-link,
.checkout-button,
.product-bottom button,
.admin-toggle,
.secondary-button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.cart-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 16px;
}

.admin-toggle {
  min-height: 46px;
  padding: 0 16px;
}

.secondary-button {
  min-height: 44px;
  padding: 0 16px;
}

.ghost-button,
.danger-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  padding: 0 12px;
}

.danger-button {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--danger);
}

.cart-button strong {
  display: grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 99px;
  background: #fff;
  color: var(--accent);
}

.hero {
  min-height: clamp(190px, 28vh, 260px);
  display: flex;
  align-items: end;
  padding: clamp(18px, 4vw, 38px) clamp(16px, 4vw, 46px);
  background:
    linear-gradient(90deg, rgba(15, 23, 42, 0.88), rgba(15, 23, 42, 0.52), rgba(15, 23, 42, 0.1)),
    url("https://images.unsplash.com/photo-1607083206968-13611e3d76db?auto=format&fit=crop&w=1600&q=80") center / cover;
  color: #fff;
}

.hero-copy {
  width: min(560px, 100%);
  padding-bottom: 4px;
}

.hero-copy p {
  color: #d8dee9;
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 800;
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(1.05rem, 1.75vw, 1.6rem);
  line-height: 1.22;
}

.primary-link {
  display: inline-flex;
  margin-top: 14px;
  min-height: 40px;
  align-items: center;
  padding: 0 16px;
}

.catalog-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 34px auto 70px;
}

.admin-panel {
  width: min(1180px, calc(100% - 32px));
  margin: 34px auto 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.admin-login {
  width: min(460px, calc(100% - 32px));
  margin: 34px auto 0;
}

.login-form h2 {
  margin: 0;
  font-size: 1.35rem;
}

.login-error {
  margin: 0;
  color: var(--danger);
  font-weight: 700;
  text-align: center;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(280px, 680px);
  gap: 16px;
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.admin-list-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
}

.admin-list-heading h3 {
  margin: 0;
  font-size: 1rem;
}

.product-editor {
  margin-bottom: 16px;
}

.modal-open {
  overflow: hidden;
}

.modal-panel {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-panel[hidden] {
  display: none;
}

.modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.modal-card {
  position: relative;
  width: min(620px, 100%);
  max-height: min(86vh, 760px);
  overflow: auto;
  box-shadow: var(--shadow);
}

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

.admin-form {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.admin-form h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.admin-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.admin-form input,
.admin-form textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 10px 12px;
  resize: vertical;
}

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

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

.admin-products {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.admin-product {
  display: grid;
  grid-template-columns: 58px minmax(160px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.admin-product img {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  object-fit: cover;
  background: #e8edf5;
}

.admin-product h3,
.admin-product p {
  margin: 0;
}

.admin-product h3 {
  font-size: 0.98rem;
}

.admin-product p {
  color: var(--muted);
  font-size: 0.88rem;
}

.top-invoice-alert {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f8fb;
  color: var(--muted);
  font-weight: 800;
  justify-self: start;
}

.top-invoice-alert.has-pending {
  border-color: rgba(245, 158, 11, 0.45);
  background: #fff7e6;
  color: #8a5a00;
}

.invoice-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}

.invoice-basket {
  display: grid;
  gap: 12px;
  align-content: start;
  min-height: 220px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.basket-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.basket-heading h3 {
  margin: 0;
  font-size: 1rem;
}

.basket-heading span {
  display: grid;
  min-width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 99px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

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

.invoice-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.invoice-card h4,
.invoice-card p {
  margin: 0;
}

.invoice-card h4 {
  font-size: 0.98rem;
}

.invoice-card p {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

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

.compact-empty {
  margin: 24px 0;
}

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

.section-heading p,
.section-heading h2,
.drawer-header p,
.drawer-header h2 {
  margin: 0;
}

.section-heading h2,
.drawer-header h2 {
  font-size: clamp(1.45rem, 3vw, 2.2rem);
}

.section-heading select {
  max-width: 260px;
  min-height: 44px;
  padding: 0 12px;
}

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

.product-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.product-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: #e8edf5;
}

.product-info {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.product-info h3 {
  min-height: 44px;
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.description {
  min-height: 40px;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.42;
}

.category {
  margin: 0;
  font-weight: 700;
  text-transform: uppercase;
}

.product-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

.product-options {
  display: grid;
  gap: 8px;
}

.product-options select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  outline: none;
}

.product-options select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.product-bottom strong {
  white-space: nowrap;
}

.product-bottom button {
  min-height: 38px;
  padding: 0 13px;
}

.empty-state {
  margin: 40px 0;
  color: var(--muted);
  text-align: center;
}

.cart-panel {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  visibility: hidden;
}

.cart-panel.is-open {
  pointer-events: auto;
  visibility: visible;
}

.cart-scrim {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  opacity: 0;
  transition: opacity 180ms ease;
}

.cart-panel.is-open .cart-scrim {
  opacity: 1;
}

.cart-drawer {
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  grid-template-rows: auto minmax(220px, 0.9fr) auto;
  width: min(620px, 100%);
  height: 100%;
  background: #fff;
  box-shadow: var(--shadow);
  transform: translateX(100%);
  transition: transform 180ms ease;
}

.cart-panel.is-open .cart-drawer {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.cart-items {
  overflow: auto;
  padding: 14px 24px;
  background: #fbfcfe;
}

.cart-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.cart-item img {
  width: 76px;
  height: 76px;
  border-radius: 8px;
  object-fit: cover;
}

.cart-item h3,
.cart-item p,
.cart-item-side strong {
  margin: 0;
}

.cart-item h3 {
  font-size: 0.95rem;
  line-height: 1.3;
}

.cart-item p {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.cart-item-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.cart-item-side {
  display: grid;
  gap: 10px;
  justify-items: end;
  align-content: center;
}

.cart-item-side strong {
  font-size: 1rem;
  white-space: nowrap;
}

.quantity {
  display: inline-grid;
  grid-template-columns: 34px 34px 34px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.quantity button {
  width: 34px;
  height: 34px;
  border: 0;
  background: #f6f8fb;
  color: var(--ink);
  font-weight: 800;
}

.quantity span {
  text-align: center;
  font-weight: 700;
}

.remove-button {
  border: 0;
  background: transparent;
  color: var(--danger);
  padding: 2px 0 0;
  font-weight: 700;
  justify-self: start;
}

.checkout-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  padding: 14px 24px 18px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.checkout-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.checkout-form input,
.checkout-form textarea {
  min-height: 40px;
  padding: 10px 12px;
  resize: vertical;
}

.checkout-form label:nth-of-type(3),
.checkout-form label:nth-of-type(4),
.totals,
.checkout-button,
.payment-note {
  grid-column: 1 / -1;
}

.totals {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #f6f8fb;
}

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

.checkout-button {
  min-height: 46px;
  padding: 0 16px;
}

.payment-note {
  margin: 0;
  text-align: center;
}

.admin-mode .search-wrap,
.admin-mode .cart-button,
.admin-mode .admin-toggle,
.admin-mode .hero,
.admin-mode .catalog-shell,
.admin-mode .cart-panel {
  display: none;
}

.admin-mode .topbar {
  grid-template-columns: auto auto;
  justify-content: start;
}

.admin-mode .admin-login,
.admin-mode .admin-panel {
  margin-top: 24px;
}

.admin-mode.admin-auth-lock .top-invoice-alert,
.admin-mode.admin-auth-lock .admin-panel {
  display: none;
}

.admin-mode.admin-auth-lock main {
  min-height: calc(100vh - 79px);
  display: grid;
  place-items: center;
}

.admin-mode.admin-auth-lock .admin-login {
  width: min(440px, calc(100% - 32px));
  margin: 0 auto;
}

.admin-mode.admin-auth-lock .login-form {
  padding: 24px;
  box-shadow: var(--shadow);
}

.admin-mode .admin-panel {
  width: min(1280px, calc(100% - 32px));
}

@media (max-width: 720px) {
  .topbar {
    grid-template-columns: 1fr auto auto;
  }

  .search-wrap {
    grid-column: 1 / -1;
    order: 3;
  }

  .brand small,
  .cart-button span {
    display: none;
  }

  .admin-toggle,
  .cart-button {
    padding: 0 12px;
  }

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

  .section-heading select {
    max-width: none;
  }

  .hero {
    min-height: 230px;
  }

  .admin-layout,
  .admin-product,
  .invoice-board,
  .invoice-card {
    grid-template-columns: 1fr;
  }

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

  .admin-product img {
    width: 100%;
    height: 140px;
  }

  .cart-item {
    grid-template-columns: 64px minmax(0, 1fr);
    align-items: start;
  }

  .cart-item img {
    width: 64px;
    height: 64px;
  }

  .quantity {
    width: max-content;
  }

  .cart-item-side {
    grid-column: 2;
    justify-items: start;
    grid-template-columns: auto auto;
    align-items: center;
  }

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