/* ============================================================
   Dakan — prototype styles
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { min-height: 100dvh; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; border: 0; background: none; color: inherit; cursor: pointer; }
input, select { font-family: inherit; color: inherit; }

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}

/* ---------- header ---------- */
header.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px var(--gutter) 12px;
  padding-top: calc(14px + env(safe-area-inset-top));
}
.logo {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: linear-gradient(145deg, var(--brand-2), var(--brand));
  display: grid; place-items: center;
  box-shadow: var(--shadow-brand);
  flex: 0 0 auto;
}
.brand-name { font-weight: 800; font-size: 18px; line-height: 1.1; }
.brand-name small { display: block; font-weight: 500; font-size: var(--fs-tiny); color: var(--muted); margin-top: 2px; }
.bell {
  margin-inline-start: auto;
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  position: relative;
}
.bell .dot {
  position: absolute; top: 7px; inset-inline-start: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  border: 1.5px solid var(--surface);
}

header.sub {
  display: flex; align-items: center; gap: 8px;
  padding: 14px var(--gutter) 10px;
  padding-top: calc(14px + env(safe-area-inset-top));
}
.icon-btn {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  background: var(--brand-soft);
  display: grid; place-items: center; flex: 0 0 auto;
}
.icon-btn.ghost { background: var(--surface); border: 1px solid var(--line); }
header.sub h1 { font-size: 16px; font-weight: 800; }
header.sub .sub2 { font-size: var(--fs-tiny); color: var(--muted); margin-top: 2px; }
header.sub .spacer { margin-inline-start: auto; }

/* ---------- layout ---------- */
main {
  flex: 1;
  padding: 0 var(--gutter);
  padding-bottom: calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
}

.h1 { font-size: var(--fs-h1); font-weight: 800; }
.h2 { font-size: var(--fs-title); font-weight: 800; }
.mut { color: var(--muted); }
.tiny { font-size: var(--fs-tiny); }
.small { font-size: var(--fs-small); }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; }
.sp { justify-content: space-between; }
.gap3 { gap: 8px; }
.mt2 { margin-top: 8px; }
.mt3 { margin-top: 12px; }
.mt4 { margin-top: 16px; }
.sec-title { display: flex; align-items: center; justify-content: space-between; margin: 16px 2px 8px; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-card);
}
.card.flush { padding: 4px var(--sp-5); }
.card.grad {
  background: linear-gradient(140deg, var(--brand), var(--brand) 55%, var(--brand-deep));
  border: 0;
  color: #fff;
  box-shadow: var(--shadow-brand);
}
.card.grad .lbl { color: rgba(255,255,255,.82); }
.card.grad .chip-ghost { background: rgba(0,0,0,.16); color: #fff; }
.hero-num { display: flex; align-items: baseline; gap: 6px; margin-top: 2px; }
.hero-num b { font-size: 32px; font-weight: 800; letter-spacing: -.5px; }
.hero-num span { font-size: 14px; font-weight: 700; opacity: .85; }
.hero-foot { display: flex; justify-content: space-between; margin-top: 12px; font-size: var(--fs-small); font-weight: 600; }
.hero-foot > div { display: flex; flex-direction: column; gap: 2px; }
.hero-foot b { font-size: var(--fs-base); font-weight: 800; }

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mini { padding: 11px 10px; border-radius: var(--r-md); }
.mini .lbl { font-size: var(--fs-tiny); color: var(--muted); }
.mini b { display: block; margin-top: 3px; font-size: 16px; font-weight: 800; }

/* ---------- pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-tiny); font-weight: 700;
  border-radius: var(--r-pill);
  padding: 3px 9px;
  white-space: nowrap;
}
.pill.ok   { background: var(--ok-soft); color: var(--ok); }
.pill.cred { background: var(--accent-soft); color: var(--accent-ink); }
.pill.bad  { background: var(--danger-soft); color: var(--danger); font-weight: 800; }
.pill.soft { background: var(--brand-soft); color: var(--brand); }
.chip-ghost { background: rgba(0,0,0,.16); color: #fff; border-radius: var(--r-pill); padding: 3px 9px; font-size: var(--fs-tiny); font-weight: 700; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 7px 12px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text-2); font-size: var(--fs-small); font-weight: 700;
  white-space: nowrap;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- rows ---------- */
.list { display: flex; flex-direction: column; }
.item-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 11px 0;
  border-bottom: 1px solid var(--line-2);
  width: 100%; text-align: start;
}
.item-row:last-child { border-bottom: 0; }
.item-row .t { font-size: var(--fs-base); font-weight: 700; }
.item-row .s { font-size: var(--fs-tiny); color: var(--muted); margin-top: 3px; }
.item-row .end { text-align: end; flex: 0 0 auto; }
.item-row .price { font-size: 14px; font-weight: 800; }

/* ---------- search ---------- */
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 12px;
  margin-top: 10px;
}
.search input {
  border: 0; outline: 0; background: none;
  font-size: var(--fs-body); width: 100%;
}
.search input::placeholder { color: var(--muted); }

/* ---------- charts ---------- */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 92px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; }
.bars .bar > i {
  display: block; width: 100%;
  border-radius: 6px 6px 3px 3px;
  background: var(--brand-tint);
}
.bars .bar.on > i { background: var(--brand); }
.bar-labels { display: flex; gap: 8px; margin-top: 6px; font-size: 9.5px; color: var(--inactive); }
.bar-labels > div { flex: 1; text-align: center; }

.track { height: 7px; border-radius: var(--r-pill); background: var(--brand-soft); overflow: hidden; }
.track > i { display: block; height: 100%; border-radius: var(--r-pill); background: var(--brand); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 16px; border-radius: var(--r-md);
  font-size: var(--fs-base); font-weight: 800;
}
.btn.primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-brand); }
.btn.soft { background: var(--brand-soft); color: var(--brand); }
.btn.outline { background: var(--surface); border: 1px solid var(--line); color: var(--brand); }
.btn.block { width: 100%; }
.btn.sm { padding: 10px 14px; font-size: var(--fs-body); }

/* ---------- bottom nav ---------- */
nav.tabs {
  position: fixed; inset-inline: 0; bottom: 0;
  z-index: 30;
  max-width: 520px; margin: 0 auto;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-around;
}
nav.tabs a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 700; color: var(--inactive);
  min-width: 56px;
}
nav.tabs a.on { color: var(--brand); }
nav.tabs .fab {
  width: 50px; height: 50px; border-radius: 17px;
  background: linear-gradient(145deg, var(--brand-2), var(--brand));
  display: grid; place-items: center;
  box-shadow: var(--shadow-brand);
  margin-top: -18px;
}

/* ---------- sheets ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(5, 41, 26, .34);
  display: flex; align-items: flex-end;
  animation: fade .16s ease-out;
}
.sheet {
  width: 100%; max-width: 520px; margin: 0 auto;
  background: var(--bg);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 14px var(--gutter) calc(18px + env(safe-area-inset-bottom));
  max-height: 86dvh; overflow: auto;
  animation: rise .2s ease-out;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-close { width: 30px; height: 30px; border-radius: var(--r-xs); background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; }
@keyframes rise { from { transform: translateY(18px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.field {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 11px 12px; margin-top: 8px;
}
.field input, .field select {
  border: 0; outline: 0; background: none; text-align: end;
  font-size: var(--fs-base); font-weight: 700; width: 100%;
  -moz-appearance: textfield;
}
.field input::-webkit-outer-spin-button, .field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field label { font-size: var(--fs-body); color: var(--text-2); flex: 0 0 auto; }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 90;
  inset-inline: 0; bottom: calc(var(--nav-h) + 16px);
  margin: 0 auto; width: max-content; max-width: 88%;
  background: var(--brand-deep); color: #fff;
  font-size: var(--fs-body); font-weight: 700;
  padding: 11px 16px; border-radius: var(--r-pill);
  box-shadow: 0 10px 24px rgba(5,41,26,.3);
  animation: fade .15s ease-out;
}

/* ---------- sale screen ---------- */
.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; text-align: center; padding: 10px 6px;
  border-radius: var(--r-sm); background: var(--surface);
  border: 1px solid var(--line); color: var(--text-2);
  font-size: var(--fs-body); font-weight: 700;
}
.seg button.on { background: var(--brand); border-color: var(--brand); color: #fff; }

.qty {
  display: inline-flex; align-items: center; gap: 0;
  border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden;
  background: var(--surface);
}
.qty button { width: 26px; height: 26px; display: grid; place-items: center; color: var(--brand); }
.qty span { min-width: 26px; text-align: center; font-size: var(--fs-body); font-weight: 800; }

.sticky-foot {
  position: fixed; inset-inline: 0;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 6px);
  z-index: 25;
  max-width: 520px; margin: 0 auto;
  padding: 10px var(--gutter) 0;
  background: linear-gradient(to top, var(--bg) 62%, rgba(231, 237, 232, 0));
}
/* the sale screen lays out as a column: scrollable body + save bar in flow above the nav,
   so the bar can never cover the totals or the payment switch */
body[data-route="sale"] { overflow: hidden; }
body[data-route="sale"] .app {
  height: calc(100dvh - var(--nav-h) - env(safe-area-inset-bottom));
  min-height: 0; overflow: hidden;
}
body[data-route="sale"] main {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  padding-bottom: 14px;
}
.item-row.compact { padding: 8px 0; }
.item-row.compact .t { font-size: 13px; }
.item-row.compact .s { font-size: 10.5px; }
.hint-row { padding: 12px 2px; text-align: center; color: var(--muted); font-size: 11.5px; }
.app > .sale-foot {
  position: static; inset: auto; z-index: 1;
  flex: 0 0 auto; width: 100%; max-width: 520px; margin: 0 auto;
  padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 20px rgba(5, 41, 26, .06);
  display: flex; flex-direction: column; gap: 8px;
}
.sale-foot .card { padding: 11px 14px; border-radius: 15px; }
.sale-foot .kv { padding: 2px 0; }
.sale-foot .seg { margin-top: 6px; }
.sale-foot .btn.primary { padding: 13px 16px; }

/* ---------- misc ---------- */
.empty { text-align: center; color: var(--muted); font-size: var(--fs-body); padding: 22px 0; }
.divider { height: 1px; background: var(--line); margin: 10px 0; }
.dashed { border-top: 1px dashed var(--line); margin: 9px 0; padding-top: 9px; }
.kv { display: flex; align-items: center; justify-content: space-between; font-size: var(--fs-body); color: var(--text-2); }
.kv + .kv { margin-top: 7px; }
.kv b { font-weight: 800; color: var(--text); }
.warn-card {
  display: flex; align-items: center; gap: 9px;
  background: var(--accent-soft); border: 1px solid #eccfa6;
  border-radius: var(--r-md); padding: 12px;
}
.warn-card .ic { width: 28px; height: 28px; border-radius: 9px; background: #f7e0c6; display: grid; place-items: center; flex: 0 0 auto; }
