:root {
  --bg: #f4f2ea;
  --panel: #fffdf7;
  --ink: #1c1b18;
  --muted: #6e685d;
  --line: #ddd4c2;
  --brand: #0f6a5a;
  --brand-alt: #d95f3c;
  --danger: #b52025;
  --success: #176c36;
  --shadow: 0 14px 40px rgba(26, 29, 25, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  min-height: 100vh;
  background: radial-gradient(circle at 10% -10%, #f7d7b2 0%, transparent 40%),
    radial-gradient(circle at 90% 10%, #c9e9df 0%, transparent 38%),
    var(--bg);
}

.bg-shape {
  position: fixed;
  z-index: -1;
  border-radius: 45% 55% 60% 40% / 40% 35% 65% 60%;
  filter: blur(40px);
  opacity: 0.35;
}

.shape-one {
  width: 260px;
  height: 260px;
  right: 4%;
  top: 8%;
  background: #ffd88c;
}

.shape-two {
  width: 320px;
  height: 320px;
  left: -120px;
  bottom: -100px;
  background: #9ed2c7;
}

.pos-root {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
}

.login-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 6px;
}

h1, h2, h3 {
  margin: 0 0 14px;
  font-family: "Syne", "Arial Black", sans-serif;
}

h1 {
  font-size: clamp(1.8rem, 3vw, 2.3rem);
}

h2 {
  font-size: clamp(1.4rem, 2.6vw, 1.9rem);
}

h3 {
  font-size: 1.1rem;
}

p {
  margin: 0 0 14px;
}

.form-grid {
  display: grid;
  gap: 9px;
}

label {
  font-size: 0.86rem;
  color: var(--muted);
}

input,
select,
textarea,
button {
  width: 100%;
  font: inherit;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(15, 106, 90, 0.26);
  border-color: var(--brand);
}

button {
  border: none;
  border-radius: 10px;
  padding: 11px 14px;
  font-weight: 700;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.primary-btn {
  background: linear-gradient(140deg, var(--brand), #1b8f79);
}

.ghost-btn {
  width: auto;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 9px 14px;
}

.hint,
.error-text,
.success-text {
  margin-top: 10px;
  display: block;
}

.error-text {
  color: var(--danger);
}

.success-text {
  color: var(--success);
}

.app-screen {
  display: grid;
  gap: 14px;
}

.topbar {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  background: #f3f0e6;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab {
  width: auto;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: #f8f4ea;
}

.tab.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
  gap: 12px;
  animation: rise 0.28s ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-grid {
  display: grid;
  gap: 12px;
}

.panel-grid.two {
  grid-template-columns: 1fr 1fr;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.card.narrow {
  max-width: 580px;
}

.toolbar {
  margin-bottom: 10px;
}

.scroll-list {
  border: 1px solid var(--line);
  border-radius: 10px;
  max-height: 360px;
  overflow: auto;
  background: #fff;
}

.scroll-list.tall {
  max-height: 560px;
}

/* ── Product image thumbnails ── */
.product-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  border: 1px solid var(--line);
}

.product-thumb-placeholder {
  background: var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
}

.img-upload-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.img-preview {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid #efe8d7;
}

.list-row:last-child {
  border-bottom: none;
}

.list-row strong {
  display: block;
}

.mini {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.qty-control {
  display: flex;
  gap: 6px;
  align-items: center;
}

.qty-control button {
  width: 30px;
  padding: 4px;
  border-radius: 7px;
  background: #e9f5f2;
  color: var(--ink);
}

.remove-btn {
  width: auto;
  background: #fde8e8;
  color: var(--danger);
  padding: 6px 9px;
}

.inline-grid {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: #f0ece3;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
}

.mode-btn {
  width: 100%;
  border: none;
  border-radius: 8px;
  padding: 8px 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.mode-btn.active {
  background: #ffffff;
  color: var(--brand);
  box-shadow: 0 2px 8px rgba(26, 29, 25, 0.09);
}

.inline-grid.two-cols {
  grid-template-columns: 1fr 1fr;
}

.totals {
  margin: 12px 0;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 10px;
  display: grid;
  gap: 4px;
  background: #fefcf5;
}

.totals .total-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.94rem;
}

.totals .grand {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  font-weight: 800;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
}

.kpi {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px;
}

.kpi .label {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.kpi .value {
  margin: 3px 0 0;
  font-size: 1.2rem;
  font-weight: 800;
}

@media (max-width: 980px) {
  .panel-grid.two {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .pos-root {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .inline-grid.two-cols {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .sale-row-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
}

/* ── Sell tab header ── */
.sell-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.sell-header h3 {
  margin: 0;
}

.pill-btn {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.02em;
}

.pill-btn:hover {
  background: #0a5246;
}

/* ── Product Picker Overlay ── */
.picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.18s ease;
}

.picker-overlay.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.picker-drawer {
  background: var(--panel);
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 640px;
  padding: 18px 18px 24px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.22s ease;
}

@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.picker-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.picker-head h3 {
  margin: 0;
}

.modal-close-btn {
  background: #f0ece3;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.picker-list {
  flex: 1;
  overflow: auto;
  max-height: 52vh;
}

/* ── Sales list mobile ── */
.sale-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 10px;
  border-bottom: 1px solid #efe8d7;
}

.sale-row:last-child {
  border-bottom: none;
}

.sale-row-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.sale-badge {
  display: inline-block;
  background: #e9f5f2;
  color: var(--brand);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
  text-transform: uppercase;
}
