:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #20242a;
  --muted: #68707d;
  --line: #d9dee7;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --danger: #b42318;
  --focus: #d97706;
}

* {
  box-sizing: border-box;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 24px;
  background: #16201f;
  color: #ffffff;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 700;
}

h2 {
  font-size: 17px;
  font-weight: 700;
}

.topbar p {
  margin-top: 4px;
  color: #cad5d2;
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.8fr);
  gap: 16px;
  padding: 16px;
  max-width: 1280px;
  margin: 0 auto;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.sale-panel {
  min-height: 420px;
}

.cart-panel {
  align-self: start;
}

.history-panel {
  grid-column: 1 / -1;
}

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

.product-button {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
  padding: 12px;
  cursor: pointer;
}

.product-button:hover {
  border-color: var(--primary);
}

.product-button strong {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}

.product-button span {
  display: block;
  margin-top: 10px;
  color: var(--primary-dark);
  font-weight: 700;
}

.cart-items {
  display: grid;
  gap: 8px;
  min-height: 160px;
}

.cart-item,
.invoice-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.cart-item small,
.invoice-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.qty-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 18px 0 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 18px;
}

button {
  border: 0;
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary {
  width: 100%;
  background: var(--primary);
  color: #ffffff;
  margin-top: 8px;
}

.primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.danger {
  background: var(--danger);
}

.secondary {
  background: #e7f4f2;
  color: var(--primary-dark);
}

.ghost {
  background: transparent;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #edf2f7;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.muted {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.product-form {
  display: grid;
  grid-template-columns: 120px minmax(180px, 1fr) 120px auto;
  gap: 10px;
}

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

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

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

.invoice-actions a,
.invoice-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  background: #edf2f7;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

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

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

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