:root {
  --bg: #f4efe6;
  --panel: #fffdf9;
  --ink: #171717;
  --muted: #6e685f;
  --line: #ded6c7;
  --gold: #d9aa35;
  --gold-deep: #9c7414;
  --wine: #742b3b;
  --green: #2f6a4b;
  --danger: #9d2f2f;
  --shadow: 0 14px 40px rgba(26, 22, 15, .10);
  --radius: 22px;
}

* {
  box-sizing: border-box
}

html {
  scroll-behavior: smooth
}

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

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

button {
  cursor: pointer
}

a {
  color: inherit
}

.hidden {
  display: none !important
}

.shell {
  min-height: 100vh
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 14px clamp(18px, 3vw, 42px);
  background: rgba(18, 18, 18, .96);
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  backdrop-filter: blur(14px)
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: #121212;
  font-weight: 900;
  letter-spacing: -1px;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .18)
}

.brand-text {
  min-width: 0
}

.brand-text strong {
  display: block;
  font-family: Georgia, serif;
  font-size: 1.12rem
}

.brand-text span {
  display: block;
  font-size: .76rem;
  color: #d5d0c7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px
}

.icon-btn,
.ghost-btn,
.primary-btn,
.danger-btn {
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 700;
  transition: .2s transform, .2s background, .2s opacity
}

.icon-btn,
.ghost-btn {
  background: rgba(255, 255, 255, .10);
  color: #fff
}

.icon-btn:hover,
.ghost-btn:hover {
  background: rgba(255, 255, 255, .16)
}

.primary-btn {
  background: var(--gold);
  color: #171717
}

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

.danger-btn {
  background: #efe0df;
  color: var(--danger)
}

.hero {
  padding: clamp(40px, 8vw, 92px) clamp(18px, 5vw, 72px) 30px;
  background: radial-gradient(circle at 78% 25%, rgba(217, 170, 53, .19), transparent 23%), linear-gradient(145deg, #171717 0%, #24211c 56%, #403623 100%);
  color: white;
  position: relative;
  overflow: hidden
}

.hero:after {
  content: "";
  position: absolute;
  right: -90px;
  bottom: -155px;
  width: 420px;
  height: 420px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 50%;
  box-shadow: 0 0 0 50px rgba(255, 255, 255, .025), 0 0 0 100px rgba(255, 255, 255, .02)
}

.hero-inner {
  max-width: 1120px;
  margin: auto;
  position: relative;
  z-index: 1
}

.eyebrow {
  color: #f3cf75;
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: .74rem;
  font-weight: 800
}

.hero h1 {
  font-family: Georgia, serif;
  font-weight: 500;
  font-size: clamp(2.6rem, 7vw, 6.2rem);
  line-height: .93;
  margin: 12px 0 16px;
  max-width: 820px
}

.hero p {
  max-width: 720px;
  color: #e0dbd1;
  font-size: clamp(1rem, 2vw, 1.18rem);
  line-height: 1.65
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px
}

.hero-stat {
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .09);
  border: 1px solid rgba(255, 255, 255, .08);
  font-size: .86rem
}

.content {
  max-width: 1260px;
  margin: 0 auto;
  padding: 24px clamp(16px, 3vw, 36px) 72px
}

.control-panel {
  margin-top: -12px;
  position: relative;
  z-index: 3;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 24px;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) repeat(3, minmax(150px, .7fr));
  gap: 10px
}

.control-panel .search-wrap {
  position: relative
}

.search-wrap input,
.control-panel select,
.admin-toolbar input,
.admin-toolbar select,
.form-grid input,
.form-grid select,
.form-grid textarea,
.settings-grid input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--ink);
  outline: none
}

.search-wrap input {
  padding-left: 42px
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted)
}

.search-wrap input:focus,
.control-panel select:focus,
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  border-color: #c59a30;
  box-shadow: 0 0 0 3px rgba(217, 170, 53, .12)
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin: 36px 0 16px
}

.section-title h2 {
  font-family: Georgia, serif;
  font-weight: 500;
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  margin: 0
}

.section-title p {
  margin: 0;
  color: var(--muted)
}

.chips {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding: 2px 0 6px;
  scrollbar-width: none
}

.chips::-webkit-scrollbar {
  display: none
}

.chip {
  white-space: nowrap;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .78);
  border-radius: 999px;
  padding: 9px 14px;
  color: #4a463f;
  font-weight: 750
}

.chip.active {
  background: #181818;
  color: #fff;
  border-color: #181818
}

.chip .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 7px;
  background: var(--gold)
}

.featured-grid,
.wine-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px
}

.wine-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr))
}

.wine-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  min-height: 245px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: .2s transform, .2s box-shadow
}

.wine-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow)
}

.wine-card.featured {
  min-height: 280px;
  background: linear-gradient(145deg, #fffdf9 0%, #f8edcf 150%)
}

.wine-card:before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--category-color, var(--wine))
}

.card-kicker {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .10em;
  color: var(--muted);
  font-weight: 850;
  margin-bottom: 10px
}

.wine-card h3 {
  font-family: Georgia, serif;
  font-weight: 600;
  font-size: 1.23rem;
  line-height: 1.18;
  margin: 0 0 9px
}

.wine-meta {
  font-size: .82rem;
  color: var(--muted);
  line-height: 1.45
}

.grapes {
  margin-top: 10px;
  color: #423e38;
  line-height: 1.48;
  font-size: .88rem
}

.card-bottom {
  margin-top: auto;
  padding-top: 16px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  justify-content: space-between
}

.price {
  font-family: Georgia, serif;
  font-size: 1.45rem;
  font-weight: 700
}

.price small {
  display: block;
  font: 600 .72rem Inter, system-ui;
  color: var(--muted);
  margin-bottom: 2px
}

.availability {
  font-size: .76rem;
  border-radius: 999px;
  padding: 6px 9px;
  font-weight: 800;
  background: #edf4ef;
  color: var(--green)
}

.availability.low {
  background: #fff3cf;
  color: #7c5a00
}

.availability.out {
  background: #f4e4e2;
  color: var(--danger)
}

.availability.untracked {
  background: #ece8e0;
  color: #6b6358
}

.note {
  margin-top: 12px;
  color: #5d554c;
  font-size: .84rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden
}

.review-badge {
  position: absolute;
  right: 12px;
  top: 12px;
  background: #fff0bd;
  color: #795800;
  font-weight: 850;
  font-size: .66rem;
  padding: 5px 8px;
  border-radius: 999px
}

.empty {
  grid-column: 1/-1;
  padding: 44px;
  text-align: center;
  background: rgba(255, 255, 255, .7);
  border: 1px dashed var(--line);
  border-radius: 20px;
  color: var(--muted)
}

.footer {
  padding: 28px;
  text-align: center;
  color: #79736b;
  font-size: .82rem
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 12, 12, .64);
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px
}

.modal {
  background: #fffdf9;
  border-radius: 24px;
  width: min(720px, 100%);
  max-height: 88vh;
  overflow: auto;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .28)
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line)
}

.modal-body {
  padding: 22px
}

.close-btn {
  border: 0;
  background: #efebe4;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 1.2rem
}

.detail-name {
  font-family: Georgia, serif;
  font-size: 2rem;
  margin: 0 0 6px
}

.detail-price {
  font-family: Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
  margin: 20px 0
}

.detail-list {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 10px 16px;
  margin: 18px 0
}

.detail-list dt {
  color: var(--muted);
  font-weight: 700
}

.detail-list dd {
  margin: 0
}

.detail-note {
  background: #f5efe4;
  border-radius: 16px;
  padding: 16px;
  line-height: 1.6;
  color: #4a433b
}

/* Admin */
.admin-body {
  background: #f1eee8
}

.admin-shell {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh
}

.sidebar {
  background: #171717;
  color: #fff;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh
}

.sidebar .brand {
  margin-bottom: 26px;
  padding: 0 8px
}

.nav {
  display: grid;
  gap: 6px
}

.nav button {
  border: 0;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  color: #d7d2ca;
  background: transparent;
  font-weight: 750
}

.nav button.active,
.nav button:hover {
  background: #2b2925;
  color: #fff
}

.nav small {
  display: block;
  margin: 26px 12px 8px;
  color: #777067;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .65rem
}

.sidebar-footer {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 20px
}

.sidebar-footer a,
.sidebar-footer button {
  width: 100%;
  display: block;
  text-align: center;
  margin-top: 8px;
  text-decoration: none
}

.admin-main {
  padding: 28px clamp(18px, 3vw, 42px) 60px;
  min-width: 0
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px
}

.admin-header h1 {
  font-family: Georgia, serif;
  font-weight: 500;
  margin: 0;
  font-size: 2.2rem
}

.admin-header p {
  color: var(--muted);
  margin: 5px 0 0
}

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

.admin-actions .ghost-btn {
  background: #fff;
  color: #2a2824;
  border: 1px solid var(--line)
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0 22px
}

.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px
}

.metric .label {
  color: var(--muted);
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 850
}

.metric .value {
  font-family: Georgia, serif;
  font-size: 2rem;
  margin-top: 7px
}

.metric .hint {
  font-size: .76rem;
  color: var(--muted);
  margin-top: 4px
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 6px 22px rgba(34, 28, 19, .04);
  overflow: hidden
}

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

.panel-head h2 {
  font-family: Georgia, serif;
  margin: 0;
  font-size: 1.35rem
}

.admin-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 160px;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line)
}

.table-wrap {
  overflow: auto
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px
}

.admin-table th,
.admin-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #eee8df;
  text-align: left;
  vertical-align: middle
}

.admin-table th {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  background: #fbf9f5;
  position: sticky;
  top: 0
}

.admin-table td {
  font-size: .86rem
}

.wine-cell strong {
  display: block
}

.wine-cell span {
  display: block;
  color: var(--muted);
  font-size: .77rem;
  margin-top: 2px
}

.stock-control {
  display: flex;
  align-items: center;
  gap: 7px
}

.stock-control button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  font-weight: 900
}

.stock-value {
  min-width: 34px;
  text-align: center;
  font-weight: 800
}

.mini-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 7px 9px;
  font-weight: 750
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .77rem;
  font-weight: 800
}

.status-dot:before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green)
}

.status-dot.off:before {
  background: #aaa
}

.status-dot.low:before {
  background: #d49d13
}

.status-dot.out:before {
  background: #c84848
}

.section {
  display: none
}

.section.active {
  display: block
}

.split-grid {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 16px
}

.history-list {
  max-height: 560px;
  overflow: auto
}

.history-item {
  padding: 14px 18px;
  border-bottom: 1px solid #eee8df;
  display: flex;
  gap: 14px;
  justify-content: space-between
}

.history-item strong {
  display: block
}

.history-item span {
  font-size: .78rem;
  color: var(--muted)
}

.movement-qty {
  font-weight: 900
}

.movement-qty.plus {
  color: var(--green)
}

.movement-qty.minus {
  color: var(--danger)
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px
}

.form-grid label,
.settings-grid label {
  display: grid;
  gap: 6px;
  color: #403b34;
  font-weight: 750;
  font-size: .83rem
}

.form-grid .full {
  grid-column: 1/-1
}

.form-grid textarea {
  min-height: 96px;
  resize: vertical
}

.checkbox-row {
  display: flex !important;
  grid-auto-flow: column;
  justify-content: start;
  align-items: center;
  gap: 9px !important
}

.checkbox-row input {
  width: auto !important
}

.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 20px
}

.callout {
  background: #fff8e7;
  border: 1px solid #efdc9c;
  border-radius: 16px;
  padding: 14px 16px;
  color: #5f4d18;
  line-height: 1.5;
  font-size: .85rem
}

.upload-zone {
  border: 2px dashed #d9d0c1;
  border-radius: 18px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  background: #fcfaf6
}

.login-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(150deg, #171717, #332b1e);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px
}

.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .3)
}

.login-card h1 {
  font-family: Georgia, serif;
  margin: 10px 0 8px
}

.login-card p {
  color: var(--muted);
  line-height: 1.5
}

.login-card input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  margin: 12px 0
}

.login-card .primary-btn {
  width: 100%
}

.login-note {
  font-size: .76rem;
  color: #888;
  margin-top: 12px;
  text-align: center
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  background: #171717;
  color: #fff;
  padding: 12px 15px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .25s
}

.toast.show {
  opacity: 1;
  transform: translateY(0)
}

@media (max-width:1050px) {
  .wine-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr))
  }

  .featured-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr))
  }

  .metric-grid {
    grid-template-columns: repeat(2, 1fr)
  }

  .split-grid {
    grid-template-columns: 1fr
  }

  .control-panel {
    grid-template-columns: 1.4fr 1fr 1fr
  }

  .control-panel select:last-child {
    grid-column: 2/4
  }

  .admin-shell {
    grid-template-columns: 210px 1fr
  }
}

@media (max-width:760px) {
  .topbar {
    padding: 12px 14px
  }

  .brand-text span {
    display: none
  }

  .hero {
    padding-top: 52px
  }

  .hero h1 {
    font-size: 3rem
  }

  .content {
    padding-left: 12px;
    padding-right: 12px
  }

  .control-panel {
    grid-template-columns: 1fr
  }

  .control-panel select:last-child {
    grid-column: auto
  }

  .wine-grid,
  .featured-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr))
  }

  .wine-card {
    min-height: 220px;
    padding: 15px
  }

  .admin-shell {
    display: block
  }

  .sidebar {
    height: auto;
    position: static;
    padding: 12px
  }

  .sidebar .brand,
  .sidebar-footer,
  .nav small {
    display: none
  }

  .nav {
    display: flex;
    overflow: auto
  }

  .nav button {
    white-space: nowrap
  }

  .admin-main {
    padding: 18px 12px 50px
  }

  .admin-header {
    align-items: flex-start
  }

  .metric-grid {
    grid-template-columns: 1fr 1fr
  }

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

  .form-grid,
  .settings-grid {
    grid-template-columns: 1fr
  }

  .form-grid .full {
    grid-column: auto
  }

  .detail-list {
    grid-template-columns: 1fr
  }

  .detail-list dt {
    margin-top: 7px
  }
}

@media (max-width:480px) {

  .wine-grid,
  .featured-grid {
    grid-template-columns: 1fr
  }

  .metric-grid {
    grid-template-columns: 1fr
  }

  .hero h1 {
    font-size: 2.55rem
  }

  .top-actions .ghost-btn {
    padding: 9px
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column
  }

  .admin-header {
    flex-direction: column
  }

  .admin-actions {
    width: 100%
  }

  .admin-actions>* {
    flex: 1
  }
}