:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-alt: #f0f4f3;
  --ink: #161a21;
  --muted: #667085;
  --line: #d9e0e7;
  --line-soft: #edf1f4;
  --teal: #0f766e;
  --red: #b42318;
  --amber: #b7791f;
  --green: #067647;
  --shadow: 0 18px 45px rgba(16, 24, 40, .08);
}

* {
  box-sizing: border-box;
}

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 {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

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

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

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

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

.brand small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.top-tabs {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.tab-button {
  min-width: 86px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 720;
}

.tab-button.is-active {
  background: var(--ink);
  color: #fff;
}

.health-pill {
  min-width: 74px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.health-pill.ok {
  border-color: #a7f3d0;
  color: var(--green);
  background: #ecfdf3;
}

.health-pill.bad {
  border-color: #fecaca;
  color: var(--red);
  background: #fff1f1;
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
}

#shopView {
  grid-template-columns: 300px minmax(0, 1fr) 330px;
  gap: 18px;
  padding: 18px;
  align-items: start;
}

#adminView {
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  align-items: start;
}

.side-panel,
.cart-panel,
.workspace,
.admin-workspace,
.data-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.side-panel,
.cart-panel {
  position: sticky;
  top: 82px;
  overflow: hidden;
}

.workspace,
.admin-workspace {
  padding: 20px;
  min-height: calc(100vh - 118px);
}

.panel-section {
  padding: 16px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-section:last-child {
  border-bottom: 0;
}

.section-title,
.workspace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-title {
  margin-bottom: 12px;
  font-weight: 800;
}

.workspace-head {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0;
}

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

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .12);
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 780;
}

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

.primary-button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.secondary-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.ghost-button {
  background: transparent;
  color: var(--muted);
  padding: 0 4px;
}

.icon-button {
  width: 34px;
  border-color: var(--line);
  background: #fff;
}

.full {
  width: 100%;
}

.hidden {
  display: none !important;
}

.muted-box,
.identity-box {
  min-height: 42px;
  display: grid;
  align-content: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  margin-bottom: 12px;
}

.identity-box strong {
  color: var(--ink);
}

.inline-status {
  min-height: 18px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.inline-status.ok {
  color: var(--green);
}

.inline-status.error {
  color: var(--red);
}

.search-row {
  display: grid;
  grid-template-columns: minmax(180px, 320px) auto;
  gap: 10px;
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.category-chip {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 0 13px;
  font-weight: 740;
}

.category-chip.is-active {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

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

.product-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.product-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.product-mark {
  width: 46px;
  aspect-ratio: 1;
  flex: 0 0 auto;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #e6f4f1;
  color: var(--teal);
  font-weight: 850;
}

.product-card h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.product-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.product-price {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.product-price strong {
  font-size: 19px;
}

.stock-tag {
  color: var(--green);
  font-size: 12px;
  font-weight: 780;
}

.product-actions,
.qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty-control input {
  min-height: 36px;
  text-align: center;
}

.product-actions {
  justify-content: space-between;
}

.cart-lines,
.compact-list {
  display: grid;
  gap: 8px;
}

.empty-state {
  min-height: 42px;
  color: var(--muted);
  display: grid;
  align-content: center;
  font-size: 13px;
}

.cart-line,
.list-item {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fff;
}

.cart-line-head,
.list-item-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.cart-line small,
.list-item small {
  color: var(--muted);
}

.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
  margin-bottom: 12px;
}

.cart-total strong {
  font-size: 23px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

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

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 27px;
}

.admin-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.data-panel {
  padding: 16px;
  box-shadow: none;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

td select {
  min-height: 34px;
}

.invoice-tools {
  display: grid;
  grid-template-columns: minmax(260px, 380px) 1fr;
  gap: 14px;
}

@media (max-width: 1180px) {
  #shopView,
  #adminView,
  .admin-columns,
  .invoice-tools {
    grid-template-columns: 1fr;
  }

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

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

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

  #shopView,
  #adminView {
    padding: 10px;
  }

  .workspace,
  .admin-workspace {
    padding: 14px;
  }

  .workspace-head,
  .search-row {
    grid-template-columns: 1fr;
    display: grid;
  }

  h1 {
    font-size: 25px;
  }

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