:root {
  color-scheme: light;
  --ink: #13211f;
  --muted: #5d6b67;
  --line: #d9e3df;
  --paper: #f7faf8;
  --surface: #ffffff;
  --brand: #16352f;
  --brand-2: #2e7b68;
  --accent: #d47c2f;
  --danger: #b3261e;
  --ok: #177245;
  --shadow: 0 16px 40px rgba(19, 33, 31, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(46, 123, 104, .18), transparent 34rem),
    linear-gradient(180deg, #edf5f1 0%, var(--paper) 42%, #ffffff 100%);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 14px max(22px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 14px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--brand), var(--brand-2));
  box-shadow: var(--shadow);
}

.brand-mark span {
  width: 22px;
  height: 30px;
  border: 3px solid #f8fbf9;
  border-radius: 13px 13px 8px 8px;
  position: relative;
}

.brand-mark span::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -10px;
  width: 12px;
  height: 8px;
  transform: translateX(-50%);
  border-radius: 4px 4px 2px 2px;
  background: #f8fbf9;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.55rem, 8vw, 2.5rem);
  line-height: 1;
}

h2 {
  font-size: 1.05rem;
}

.icon-button,
.ghost-button,
.primary-button,
.secondary-button,
.stepper button {
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  font-weight: 800;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: var(--surface);
  color: var(--brand);
  box-shadow: 0 8px 24px rgba(19, 33, 31, .1);
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 4px 0 14px;
}

.summary-grid article {
  min-height: 78px;
  padding: 12px 10px;
  border: 1px solid rgba(22, 53, 47, .09);
  border-radius: 8px;
  background: rgba(255, 255, 255, .84);
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 750;
}

.summary-grid strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1rem, 4vw, 1.3rem);
  line-height: 1.1;
  word-break: break-word;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 8px 0;
  background: rgba(247, 250, 248, .94);
  backdrop-filter: blur(10px);
}

.tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 850;
}

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

.panel {
  display: none;
  padding: 10px 0 0;
}

.panel.is-active {
  display: block;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 0 12px;
}

.ghost-button {
  padding: 0 14px;
  background: transparent;
  color: var(--brand-2);
}

.product-list,
.stock-list,
.history-list {
  display: grid;
  gap: 10px;
}

.product-card,
.stock-row,
.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 26px rgba(19, 33, 31, .07);
}

.product-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.product-name {
  display: block;
  font-weight: 900;
}

.product-meta,
.history-meta,
.empty {
  color: var(--muted);
  font-size: .86rem;
}

.stepper {
  display: grid;
  grid-template-columns: 42px 42px 42px;
  align-items: center;
  gap: 4px;
}

.stepper button {
  width: 42px;
  background: #eef5f2;
  color: var(--brand);
  font-size: 1.2rem;
}

.stepper output {
  display: grid;
  place-items: center;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 900;
}

form {
  display: grid;
  gap: 10px;
}

.sale-form,
.product-form {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .9);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
}

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

input:focus,
select:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(46, 123, 104, .15);
}

.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ticket {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #eef5f2;
}

.ticket span {
  color: var(--muted);
  font-weight: 850;
}

.ticket strong {
  font-size: 1.35rem;
}

.primary-button,
.secondary-button {
  width: 100%;
  padding: 0 16px;
}

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

.secondary-button {
  background: var(--brand);
  color: #fff;
}

.stock-row,
.history-item {
  padding: 12px;
}

.row-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.row-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.row-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--brand);
  font-weight: 800;
}

.row-actions .danger {
  color: var(--danger);
}

.history-item header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 900;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef5f2;
  color: var(--brand);
  font-size: .78rem;
  font-weight: 900;
}

.badge.debt {
  background: #fff1df;
  color: #8f4f12;
}

.toast {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: 680px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: .2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.empty {
  padding: 18px 4px;
  text-align: center;
}

@media (min-width: 680px) {
  .app-shell {
    padding-top: 28px;
  }

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