:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --card: #ffffff;
  --text: #17202a;
  --muted: #5e6a75;
  --line: #e3e8ee;
  --accent: #0c6b4d;
  --danger: #9b2c2c;
  --shadow: 0 8px 24px rgba(23, 32, 42, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

h1 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.2;
}

.sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

#app.screen-orders {
  padding: 12px 12px calc(18px + env(safe-area-inset-bottom));
}

#app.screen-orders .topbar {
  margin-bottom: 8px;
}

#app.screen-orders h1 {
  font-size: 1.28rem;
}

.date-bar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 6px;
  margin-top: 2px;
}

.date-nav,
.date-chip {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.date-nav {
  font-size: 1.2rem;
  color: var(--text);
}

.date-chip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  overflow: hidden;
  font-size: 0.9rem;
  font-weight: 650;
}

.date-face {
  pointer-events: none;
}

.date-chip input[type="date"] {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0.02;
  background: transparent;
  color: transparent;
  font-size: 16px;
  cursor: pointer;
}

.date-chip input[type="date"]::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  cursor: pointer;
  background: transparent;
}

#app.screen-orders .search {
  min-height: 44px;
  margin: 8px 0;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.92rem;
}

.search {
  width: 100%;
  min-height: 52px;
  margin: 14px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  font-size: 1.05rem;
}

#app.screen-orders .list {
  gap: 6px;
}

.list {
  display: grid;
  gap: 10px;
}

.order,
.back {
  width: 100%;
  border: 0;
  background: var(--card);
  text-align: left;
  box-shadow: var(--shadow);
}

#app.screen-orders .order {
  min-height: 64px;
  padding: 10px 12px;
  border-radius: 12px;
}

.order {
  min-height: 84px;
  padding: 14px;
  border-radius: 16px;
}

#app.screen-orders .order-name {
  font-size: 0.95rem;
}

.order-name {
  font-size: 1.12rem;
  font-weight: 650;
}

.order-meta,
.muted {
  color: var(--muted);
}

#app.screen-orders .order-foot {
  margin-top: 4px;
  font-size: 0.86rem;
}

.order-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  font-size: 1rem;
}

.amount {
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.back {
  width: auto;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 12px;
  color: var(--accent);
  font-weight: 650;
}

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.customer-name {
  margin: 0 0 8px;
  font-size: 1.45rem;
  line-height: 1.25;
}

.address,
.contact {
  margin: 0;
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.45;
}

.contact {
  margin-top: 8px;
}

.invoice-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.value {
  display: block;
  margin-top: 3px;
  font-size: 1.05rem;
  font-weight: 650;
}

.items {
  margin-top: 14px;
}

.item {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.item-name {
  font-size: 1.08rem;
  font-weight: 650;
}

.item-code {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.92rem;
}

.item-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.item-grid span {
  display: block;
}

.total-bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 8px;
  padding: 16px;
  border-radius: 16px;
  background: #e7f4ee;
  font-size: 1.15rem;
}

.total-bar strong {
  font-size: 1.45rem;
}

.status {
  padding: 28px 8px;
  color: var(--muted);
  text-align: center;
  font-size: 1.05rem;
}

.status.error {
  color: var(--danger);
}

#app.screen-detail {
  padding: 12px 12px calc(20px + env(safe-area-inset-bottom));
}

#app.screen-detail .topbar {
  gap: 8px;
  margin-bottom: 10px;
}

#app.screen-detail h1 {
  font-size: 1.35rem;
}

#app.screen-detail .back {
  min-height: 40px;
  padding: 8px 12px;
  font-size: 0.92rem;
}

#app.screen-detail .card {
  padding: 12px;
  border-radius: 14px;
}

#app.screen-detail .customer-name {
  margin-bottom: 6px;
  font-size: 1.2rem;
  font-weight: 750;
  line-height: 1.2;
}

#app.screen-detail .address,
#app.screen-detail .contact {
  font-size: 0.92rem;
  line-height: 1.35;
}

#app.screen-detail .address a,
#app.screen-detail .contact a {
  color: var(--accent);
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}

#app.screen-detail .contact {
  margin-top: 6px;
}

#app.screen-detail .invoice-meta {
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
}

#app.screen-detail .invoice-meta > div:last-child {
  text-align: right;
}

#app.screen-detail .label {
  font-size: 0.72rem;
}

#app.screen-detail .value {
  margin-top: 2px;
  font-size: 0.92rem;
}

#app.screen-detail .items {
  margin-top: 10px;
}

#app.screen-detail .copy-whatsapp {
  width: 100%;
  min-height: 42px;
  margin-top: 8px;
  border: 0;
  border-radius: 12px;
  background: #128c7e;
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 650;
}

#app.screen-detail .item-head,
#app.screen-detail .item-figures {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1fr;
  gap: 6px;
  align-items: baseline;
}

#app.screen-detail .item-head {
  padding-bottom: 6px;
  padding-left: calc(1.7rem + 2px);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

#app.screen-detail .item-head span:nth-child(n + 2),
#app.screen-detail .item-price,
#app.screen-detail .item-amount {
  text-align: right;
}

#app.screen-detail .item {
  display: grid;
  grid-template-columns: 1.7rem minmax(0, 1fr);
  column-gap: 2px;
  padding: 7px 0 6px;
  border-top: 1px solid var(--line);
}

#app.screen-detail .item-title {
  display: contents;
}

#app.screen-detail .item-seq {
  grid-column: 1;
  grid-row: 1;
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

#app.screen-detail .item-name {
  grid-column: 2;
  grid-row: 1;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.25;
}

#app.screen-detail .item-code {
  grid-column: 2;
  grid-row: 2;
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.78rem;
}

#app.screen-detail .item-figures {
  grid-column: 2;
  grid-row: 3;
  margin-top: 3px;
}

#app.screen-detail .item-qty,
#app.screen-detail .item-price,
#app.screen-detail .item-amount {
  font-size: 0.86rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

#app.screen-detail .total-bar {
  margin-top: 6px;
  padding: 12px;
  border-radius: 14px;
  font-size: 1rem;
}

#app.screen-detail .total-bar strong {
  font-size: 1.2rem;
  font-weight: 750;
}

#app.screen-detail .status {
  padding: 20px 8px;
  font-size: 0.92rem;
}
