:root {
  --ink: #172033;
  --muted: #647084;
  --line: #d7deea;
  --panel: #f6f8fb;
  --panel-2: #eef3f7;
  --navy: #102a43;
  --blue: #1769aa;
  --teal: #0f766e;
  --amber: #b7791f;
  --white: #fff;
  --danger: #b42318;
  --ok: #067647;
  --shadow: 0 14px 35px rgba(15, 23, 42, .08);
  --radius: 8px;
}

* { box-sizing: border-box; }

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

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  border-radius: var(--radius);
  height: 38px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 700;
}

button:hover { border-color: #9fb2c8; }
button svg { width: 17px; height: 17px; }
button.primary { background: var(--blue); color: var(--white); border-color: var(--blue); }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 286px minmax(720px, 1fr) 330px;
}

.customer-panel,
.cart-panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px;
  overflow: auto;
}

.cart-panel {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.mark {
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  background: var(--navy);
  color: var(--white);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .04em;
}

.brand-lockup strong,
.cart-head strong {
  display: block;
  font-size: 16px;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  height: 38px;
  padding: 0 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 105, 170, .14);
}

.panel-block {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.panel-title {
  font-size: 12px;
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 10px;
}

.check-list,
.discount-list {
  display: grid;
  gap: 8px;
}

.check-row,
.discount-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.check-row input {
  width: 16px;
  height: 16px;
}

.discount-row {
  grid-template-columns: 1fr 72px;
}

.workspace {
  min-width: 0;
  padding: 18px 20px 24px;
}

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

h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
  line-height: 1.1;
}

p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-radius: 0;
  height: 36px;
}

.segmented button.active {
  background: var(--navy);
  color: var(--white);
}

.brand-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.brand-tab {
  height: 40px;
  flex: 0 0 auto;
  background: var(--white);
}

.brand-tab.active {
  border-color: var(--blue);
  color: var(--blue);
  box-shadow: inset 0 -3px 0 var(--blue);
}

.filters {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 190px 220px 170px auto;
  gap: 10px;
  margin-bottom: 12px;
}

.searchbox {
  position: relative;
}

.searchbox svg {
  position: absolute;
  left: 11px;
  top: 10px;
  width: 17px;
  height: 17px;
  color: var(--muted);
}

.searchbox input {
  padding-left: 36px;
}

.table-wrap {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  max-height: calc(100vh - 150px);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  color: #40516a;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.qty-col { width: 78px; }
.qty-input { width: 64px; text-align: right; }
.desc-cell strong { display: block; font-size: 13px; }
.desc-cell small { font-size: 11px; }
.money { white-space: nowrap; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}
.status-badge.matched {
  background: #ecfdf3;
  color: var(--ok);
}
.status-badge.pending {
  background: #fff7ed;
  color: var(--amber);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  max-height: calc(100vh - 150px);
  overflow: auto;
}

.product-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  gap: 10px;
  box-shadow: var(--shadow);
}

.product-image {
  position: relative;
  height: 128px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, #f9fafb, #edf3f8);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.photo-status {
  position: absolute;
  left: 8px;
  top: 8px;
}

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

.placeholder {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--navy);
  color: var(--white);
  font-weight: 900;
}

.product-card h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.25;
  letter-spacing: 0;
}

.card-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 12px;
}

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

.card-foot {
  display: grid;
  grid-template-columns: 1fr 76px;
  gap: 8px;
  align-items: center;
}

.cart-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

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

.cart-brand {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}

.cart-brand strong {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 8px;
}

.cart-line {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid #edf1f6;
  font-size: 12px;
}

.cart-line b { font-variant-numeric: tabular-nums; }
.cart-total {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.cart-total span {
  color: var(--muted);
  font-weight: 800;
}

.cart-total strong {
  font-size: 20px;
  color: var(--navy);
}

.empty-state {
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.hidden { display: none !important; }

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 250px minmax(580px, 1fr);
  }
  .cart-panel {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: 360px;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }
  .customer-panel,
  .cart-panel {
    border: 0;
    border-bottom: 1px solid var(--line);
  }
  .toolbar,
  .filters {
    display: grid;
    grid-template-columns: 1fr;
  }
  .toolbar-actions {
    justify-content: stretch;
  }
  .toolbar-actions button,
  .segmented {
    width: 100%;
  }
}
