:root {
  --coffee: #3b2416;
  --coffee-2: #6f4e37;
  --caramel: #c78a47;
  --cream: #fff9f2;
  --paper: #ffffff;
  --ink: #2d2d2d;
  --muted: #7d6f63;
  --line: #ead8c4;
  --green: #3fa55b;
  --red: #d9534f;
  --shadow: 0 18px 45px rgba(59, 36, 22, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(199, 138, 71, 0.16), transparent 32rem),
    var(--cream);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 18rem minmax(22rem, 28rem);
  justify-content: center;
  gap: 2rem;
  min-height: 100vh;
  padding: 2rem 1rem 6rem;
}

.sidebar {
  align-self: start;
  position: sticky;
  top: 2rem;
  min-height: calc(100vh - 4rem);
  padding: 1.25rem;
  border-radius: 1.5rem;
  background: linear-gradient(160deg, var(--coffee), #7b4316);
  color: #fff7ed;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 2rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 1rem;
  font-size: 1.9rem;
}

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

.brand span,
.topbar-title span {
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.8rem;
}

.side-nav {
  display: grid;
  gap: 0.4rem;
}

.nav-item,
.bottom-nav button {
  border: 0;
  background: transparent;
  color: inherit;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  padding: 0.85rem;
  border-radius: 0.8rem;
  color: #fff7ed;
  text-align: left;
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.14);
}

.phone-frame {
  position: relative;
  overflow: hidden;
  min-height: 48rem;
  border: 1px solid rgba(111, 78, 55, 0.22);
  border-radius: 2rem;
  background: var(--cream);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 5rem;
  padding: 1rem;
  background: linear-gradient(135deg, var(--coffee), #793d0c);
  color: #fff;
}

.topbar-title {
  text-align: center;
}

.topbar-title strong,
.topbar-title span {
  display: block;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
  font-size: 1.8rem;
  line-height: 1;
}

.screen {
  display: none;
  padding: 1rem;
}

.screen.active {
  display: block;
}

.greeting h1 {
  margin: 0;
  font-size: 1.2rem;
}

.greeting p,
.report-card p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.summary-grid,
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.summary-grid article,
.total-card,
.metric-list,
.selected-client,
.cart-card,
.profile-card,
.statement-total,
.report-card,
.client-card,
.timeline-day,
.report-list article {
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 20px rgba(59, 36, 22, 0.06);
}

.summary-grid article {
  padding: 1rem;
}

.summary-grid span,
.total-card span,
.report-card span {
  display: block;
  color: var(--coffee);
  font-size: 0.88rem;
}

.summary-grid strong {
  display: block;
  margin-top: 0.45rem;
  color: var(--green);
  font-size: 1.25rem;
}

.summary-grid article:nth-child(4) strong {
  color: #e36b12;
}

.total-card {
  margin-top: 0.75rem;
  padding: 1rem;
}

.total-card strong {
  display: block;
  margin: 0.2rem 0 1rem;
  font-size: 1.7rem;
}

.sparkline {
  display: flex;
  align-items: end;
  gap: 0.55rem;
  height: 4.3rem;
}

.sparkline i {
  flex: 1;
  border-radius: 0.35rem 0.35rem 0 0;
  background: linear-gradient(var(--caramel), #9b561e);
}

.sparkline i:nth-child(1) { height: 44%; }
.sparkline i:nth-child(2) { height: 58%; }
.sparkline i:nth-child(3) { height: 40%; }
.sparkline i:nth-child(4) { height: 52%; }
.sparkline i:nth-child(5) { height: 30%; }
.sparkline i:nth-child(6) { height: 68%; }
.sparkline i:nth-child(7) { height: 46%; }

.metric-list,
.cart-card,
.statement-total,
.report-card {
  margin-top: 0.75rem;
  padding: 0.8rem;
}

.metric-list p,
.cart-card p,
.report-list p {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0;
  padding: 0.8rem 0.25rem;
  border-bottom: 1px solid var(--line);
}

.metric-list p:last-child,
.cart-card p:last-child {
  border-bottom: 0;
}

.danger {
  color: var(--red);
}

.search-wrap {
  position: relative;
  margin-bottom: 0.9rem;
}

.search-wrap input,
dialog input,
dialog select,
dialog textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  outline: 0;
}

.search-wrap input {
  height: 3rem;
  padding: 0 2.5rem 0 1rem;
}

.search-wrap span {
  position: absolute;
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
  color: var(--coffee-2);
}

.filter-row {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.filter-row button,
.tabs button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 0.7rem;
  background: #f3e8da;
  color: var(--coffee);
  padding: 0.75rem 0.9rem;
  font-weight: 700;
}

.filter-row .active,
.tabs .active {
  background: linear-gradient(135deg, #8b430b, var(--coffee));
  color: #fff;
}

.client-list {
  display: grid;
  gap: 0.75rem;
}

.client-card {
  padding: 0.75rem;
}

.client-main,
.profile-main,
.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.person {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 0.75rem;
}

.avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffe4bc, var(--caramel));
  color: var(--coffee);
  font-weight: 900;
}

.person strong,
.person span {
  display: block;
}

.person span,
.balance small {
  color: var(--muted);
  font-size: 0.8rem;
}

.balance {
  flex: 0 0 auto;
  text-align: right;
}

.balance strong {
  color: var(--red);
}

.balance.clear strong {
  color: var(--green);
}

.client-actions {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.35rem;
  margin-top: 0.75rem;
}

.client-actions button,
.secondary {
  min-height: 2.45rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: #fffaf4;
  color: var(--coffee);
  font-size: 0.78rem;
  font-weight: 700;
}

.selected-client,
.profile-card {
  padding: 0.8rem;
}

.credit-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0.8rem -0.8rem -0.8rem;
  border-top: 1px solid var(--line);
}

.credit-grid div {
  padding: 0.8rem 0.4rem;
  text-align: center;
  border-right: 1px solid var(--line);
}

.credit-grid div:last-child {
  border-right: 0;
}

.credit-grid span,
.credit-grid strong {
  display: block;
}

.credit-grid span {
  color: var(--muted);
  font-size: 0.76rem;
}

.category-grid button {
  min-height: 4.8rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #fff5e9;
  color: var(--coffee);
  font-size: 1.7rem;
}

.category-grid span {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.82rem;
}

.cart-card footer,
.statement-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.cart-card footer strong,
.statement-total strong {
  font-size: 1.45rem;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 0.9rem 0;
}

.timeline {
  display: grid;
  gap: 0.75rem;
}

.timeline-day {
  overflow: hidden;
}

.timeline-day h3 {
  margin: 0;
  padding: 0.65rem 0.8rem;
  background: #f4eadf;
  color: var(--coffee);
  font-size: 0.9rem;
}

.timeline-row {
  display: grid;
  grid-template-columns: 3.8rem 1.8rem 1fr auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.8rem;
  border-top: 1px solid var(--line);
}

.timeline-row time {
  color: var(--muted);
  font-size: 0.82rem;
}

.primary {
  border: 0;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, #b15b14, #823a07);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(130, 58, 7, 0.22);
}

.wide {
  width: 100%;
  min-height: 3.2rem;
  margin-top: 0.8rem;
}

.report-card strong {
  display: block;
  margin-top: 0.25rem;
  color: var(--red);
  font-size: 1.8rem;
}

.report-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.report-list article {
  padding: 0.85rem;
}

.report-list strong {
  color: var(--red);
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  display: none;
  grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid rgba(111, 78, 55, 0.18);
  background: linear-gradient(135deg, var(--coffee), #793d0c);
  color: #fff;
}

.bottom-nav button {
  min-height: 4.2rem;
  color: rgba(255, 255, 255, 0.76);
}

.bottom-nav button.active {
  color: #fff;
}

.bottom-nav span {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.72rem;
}

dialog {
  width: min(92vw, 28rem);
  max-height: 88vh;
  border: 0;
  border-radius: 1rem;
  padding: 0;
  background: var(--cream);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(59, 36, 22, 0.42);
}

dialog form {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
}

dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

dialog h2 {
  margin: 0;
}

dialog label {
  display: grid;
  gap: 0.35rem;
  color: var(--coffee);
  font-size: 0.88rem;
  font-weight: 800;
}

dialog input,
dialog select,
dialog textarea {
  padding: 0.8rem;
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
    min-height: 100vh;
    padding: 0 0 4.2rem;
  }

  .sidebar {
    display: none;
  }

  .phone-frame {
    min-height: calc(100vh - 4.2rem);
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .bottom-nav {
    display: grid;
  }
}

@media (max-width: 390px) {
  .client-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .summary-grid,
  .category-grid {
    grid-template-columns: 1fr;
  }
}

.product-list {
  display: grid;
  gap: 0.75rem;
}

.product-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 20px rgba(59, 36, 22, 0.06);
}

.product-info {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 0.75rem;
}

.product-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 0.8rem;
  background: #fff1df;
  font-size: 1.5rem;
}

.product-info strong,
.product-info span {
  display: block;
}

.product-info span {
  color: var(--muted);
  font-size: 0.8rem;
}

.product-price {
  flex: 0 0 auto;
  text-align: right;
}

.product-price strong {
  display: block;
  color: var(--coffee);
}

.product-price span {
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
}

.product-price .inactive {
  color: var(--red);
}


.pdv-products {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0.35rem 0 0.9rem;
}

.pdv-product {
  display: grid;
  gap: 0.25rem;
  min-height: 6rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #fff5e9;
  color: var(--coffee);
  padding: 0.8rem;
  text-align: left;
}

.pdv-product span {
  font-size: 1.5rem;
}

.pdv-product strong,
.pdv-product small {
  display: block;
}

.pdv-product small {
  color: var(--green);
  font-weight: 900;
}

.cart-line {
  display: grid;
  grid-template-columns: 2rem 1fr auto 2rem;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.25rem;
  border-bottom: 1px solid var(--line);
}

.cart-line button {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fffaf4;
  color: var(--coffee);
  font-size: 1.05rem;
  font-weight: 900;
}

.cart-line strong {
  white-space: nowrap;
}

.pdv-actions {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.pdv-actions button {
  min-height: 3rem;
}

.primary:disabled,
.secondary:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

@media (max-width: 390px) {
  .pdv-products {
    grid-template-columns: 1fr;
  }
}
/* Mobile polish */
.icon-button[style*="hidden"] {
  pointer-events: none;
}

.client-card,
.product-card,
.selected-client,
.cart-card,
.profile-card,
.report-card,
.timeline-day {
  backdrop-filter: blur(8px);
}

.client-card:active,
.product-card:active,
.pdv-product:active {
  transform: scale(0.99);
}

.client-actions button,
.secondary,
.primary {
  transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

@media (max-width: 760px) {
  body {
    background: var(--cream);
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 4;
    min-height: 4.5rem;
    padding: 0.8rem 0.9rem;
    box-shadow: 0 10px 25px rgba(59, 36, 22, 0.18);
  }

  .topbar-title strong {
    font-size: 1.05rem;
  }

  .topbar-title span {
    font-size: 0.74rem;
  }

  .icon-button {
    width: 2.75rem;
    height: 2.75rem;
    font-size: 1.7rem;
  }

  .screen {
    padding: 0.85rem;
  }

  .search-wrap {
    margin-bottom: 0.75rem;
  }

  .search-wrap input,
  dialog input,
  dialog select,
  dialog textarea {
    min-height: 3.25rem;
    font-size: 1rem;
  }

  .summary-grid {
    gap: 0.6rem;
  }

  .summary-grid article,
  .client-card,
  .product-card,
  .selected-client,
  .cart-card,
  .profile-card,
  .report-card,
  .timeline-day {
    border-radius: 0.9rem;
  }

  .client-card,
  .product-card {
    padding: 0.9rem;
  }

  .client-main,
  .profile-main,
  .section-row {
    align-items: flex-start;
  }

  .person {
    align-items: flex-start;
  }

  .avatar {
    width: 3rem;
    height: 3rem;
  }

  .person strong {
    font-size: 0.98rem;
  }

  .person span,
  .balance small {
    font-size: 0.78rem;
  }

  .balance strong {
    font-size: 0.95rem;
  }

  .client-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .client-actions button,
  .secondary,
  .primary {
    min-height: 2.9rem;
    font-size: 0.86rem;
  }

  .filter-row {
    padding: 0.1rem 0 0.65rem;
    scrollbar-width: none;
  }

  .filter-row::-webkit-scrollbar {
    display: none;
  }

  .filter-row button {
    min-height: 2.65rem;
    padding: 0.7rem 0.85rem;
  }

  .pdv-products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
  }

  .pdv-product {
    min-height: 6.4rem;
    padding: 0.75rem;
  }

  .cart-line {
    grid-template-columns: 2.25rem 1fr auto 2.25rem;
    gap: 0.45rem;
  }

  .cart-line button {
    width: 2.25rem;
    height: 2.25rem;
  }

  .pdv-actions {
    grid-template-columns: 1fr;
  }

  dialog {
    width: 100vw;
    max-width: none;
    height: min(92vh, 48rem);
    max-height: 92vh;
    margin: auto 0 0;
    border-radius: 1.2rem 1.2rem 0 0;
  }

  dialog form {
    gap: 0.8rem;
    padding: 1rem 1rem 1.25rem;
  }

  dialog header {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: -1rem -1rem 0;
    padding: 1rem;
    background: var(--cream);
    border-bottom: 1px solid var(--line);
  }

  dialog h2 {
    font-size: 1.15rem;
  }

  dialog label {
    font-size: 0.9rem;
  }

  .bottom-nav {
    min-height: 4.5rem;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .bottom-nav button {
    min-height: 4.5rem;
    font-size: 1.05rem;
  }

  .bottom-nav span {
    font-size: 0.68rem;
  }
}

@media (max-width: 360px) {
  .pdv-products,
  .summary-grid,
  .category-grid {
    grid-template-columns: 1fr;
  }

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

  .credit-grid div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .credit-grid div:last-child {
    border-bottom: 0;
  }
}
.client-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.payment-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: rgba(255, 255, 255, 0.72);
}

.payment-summary span {
  color: var(--muted);
  font-size: 0.82rem;
}

.payment-summary strong {
  text-align: right;
  color: var(--coffee);
}

.payment-shortcuts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.payment-shortcuts button {
  min-height: 2.8rem;
}