:root {
  color-scheme: light;
  --page: #f6f6f0;
  --paper: #ffffff;
  --ink: #202a23;
  --muted: #7a837c;
  --line: #e8ebe3;
  --green: #246344;
  --green-dark: #184a31;
  --green-soft: #eaf3ed;
  --gold: #d8a847;
  --gold-soft: #fbf3df;
  --red: #c94f40;
  --red-dark: #a93b30;
  --shadow: 0 12px 32px rgba(27, 50, 36, 0.055);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(ellipse at 85% 6%, rgba(218, 187, 108, 0.10), transparent 31rem),
    var(--page);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid rgba(36, 99, 68, 0.32);
  outline-offset: 3px;
}

.page-shell {
  width: min(100% - 40px, 800px);
  margin: 0 auto;
  padding: 0 0 154px;
}

.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(55, 75, 59, 0.09);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark { width: 40px; height: 40px; color: var(--green); flex: 0 0 auto; }
.brand-mark svg { display: block; width: 100%; height: 100%; }
.brand-copy { display: grid; gap: 1px; }
.brand-copy strong { font-size: 16px; letter-spacing: -0.03em; }
.brand-copy small { color: var(--muted); font-size: 10px; letter-spacing: 0.015em; }

.date-chip {
  flex: 0 0 auto;
  border: 1px solid #e5e8df;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  padding: 9px 12px;
  color: #4e5b50;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.intro { padding: 34px 0 23px; }
.eyebrow, .section-kicker {
  margin: 0 0 9px;
  color: #7b857c;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.13em;
}
.eyebrow { display: flex; align-items: center; gap: 8px; }
.eyebrow-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 8px;
  font-size: clamp(28px, 6vw, 39px);
  line-height: 1.12;
  letter-spacing: -0.055em;
  font-weight: 760;
}
h1 span, h2 span { color: #7d877f; font-weight: 500; }
h1 span { font-size: 0.73em; letter-spacing: -0.04em; }
.intro-copy { margin: 0; color: #778078; font-size: 13px; line-height: 1.6; }
.intro-copy [lang="ha"] { color: #59665c; }

.panel {
  border: 1px solid rgba(33, 67, 45, 0.07);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.quick-add { padding: 22px 23px 17px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.035em;
  line-height: 1.25;
}
.section-heading h2 span { font-size: 0.78em; letter-spacing: -0.02em; }
.section-kicker { margin-bottom: 5px; font-size: 8px; letter-spacing: 0.15em; }
.pencil-badge {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 21px;
  font-weight: 450;
}

#sale-form { margin-top: 20px; }
.field-label { display: block; margin-bottom: 8px; color: #3b473e; font-size: 12px; font-weight: 700; }
.field-label [lang="ha"] { padding-left: 3px; color: #839087; font-weight: 500; }
#sale-input {
  width: 100%;
  min-height: 58px;
  padding: 0 16px;
  border: 1px solid #dfe4dc;
  border-radius: 12px;
  background: #fcfdfa;
  color: var(--ink);
  font-size: 15px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
#sale-input::placeholder { color: #a0a8a1; opacity: 1; }
#sale-input:focus { border-color: #79a18a; background: #fff; box-shadow: 0 0 0 4px rgba(36, 99, 68, 0.08); outline: 0; }
.input-hint { margin: 8px 0 16px; color: #929a93; font-size: 10px; line-height: 1.5; }
.input-hint [lang="ha"] { color: #7b887f; }
.add-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.add-button {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 750;
  transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease;
}
.add-button:active, .close-button:active, .paid-button:active { transform: scale(0.985); }
.add-button:disabled, .close-button:disabled, .paid-button:disabled { cursor: not-allowed; opacity: 0.52; }
.cash-button { background: var(--green); color: #fff; }
.cash-button:hover:not(:disabled) { background: var(--green-dark); box-shadow: 0 5px 14px rgba(24, 74, 49, 0.13); }
.bashi-button { border-color: #eedcae; background: var(--gold-soft); color: #72551c; }
.bashi-button:hover:not(:disabled) { background: #f7ebcc; }
.add-button small { display: block; margin-top: 4px; font-size: 9px; font-weight: 550; opacity: 0.77; }
.button-icon { display: grid; width: 25px; height: 25px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, 0.2); font-size: 18px; font-weight: 450; }
.bashi-button .button-icon { background: rgba(114, 85, 28, 0.08); }
.feedback { min-height: 16px; margin: 12px 0 0; color: var(--green); font-size: 11px; font-weight: 650; }
.feedback.error { color: #ad4035; }
.feedback.info { color: #69776c; }

.summary-section { padding-top: 25px; }
.compact-heading { margin-bottom: 11px; }
.compact-heading .section-kicker { margin-bottom: 4px; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.summary-card {
  position: relative;
  display: flex;
  min-height: 112px;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  padding: 13px 14px 12px;
  border: 1px solid rgba(33, 67, 45, 0.06);
  border-radius: 15px;
  background: #fff;
}
.summary-card::before { position: absolute; top: 0; left: 0; width: 100%; height: 3px; content: ""; background: #8ab39a; }
.bashi-summary::before { background: #e0b856; }
.sales-summary::before { background: #6b987a; }
.summary-label { display: block; color: #68736a; font-size: 10px; font-weight: 700; line-height: 1.3; }
.summary-label small { display: block; margin-top: 2px; color: #939d94; font-size: 9px; font-weight: 500; }
.summary-amount { display: block; margin-top: 8px; color: #21382a; font-size: clamp(18px, 4vw, 24px); letter-spacing: -0.05em; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bashi-summary .summary-amount { color: #80601e; }
.summary-note { display: block; margin-top: 5px; color: #9aa29b; font-size: 8px; line-height: 1.35; }

.content-section { margin-top: 16px; padding: 19px 20px 6px; }
.list-heading { align-items: flex-start; min-height: 43px; }
.list-heading .section-heading h2, .list-heading h2 { font-size: 16px; }
.list-heading h2 span { display: inline-block; margin-left: 3px; font-size: 0.73em; }
.count-badge { display: grid; min-width: 25px; height: 25px; padding: 0 6px; place-items: center; border-radius: 9px; background: var(--gold-soft); color: #795c24; font-size: 10px; font-weight: 750; font-variant-numeric: tabular-nums; }
.neutral-badge { background: #f0f2ee; color: #738077; }
.list-wrap { min-height: 43px; }
.empty-state { display: flex; align-items: center; gap: 11px; padding: 11px 0 14px; color: #8a948c; font-size: 11px; line-height: 1.45; }
.empty-icon { display: grid; width: 32px; height: 32px; flex: 0 0 auto; place-items: center; border-radius: 10px; background: #f5f7f3; color: #88958a; font-size: 15px; }
.empty-state strong { display: block; color: #576359; font-size: 11px; font-weight: 650; }
.empty-state span:last-child { display: block; }

.debt-row, .sale-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid #eef0ec; }
.debt-main, .sale-main { display: flex; min-width: 0; align-items: center; gap: 11px; }
.person-mark, .sale-mark { display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; border-radius: 12px; background: #fbf3df; color: #87651e; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.sale-mark { background: #edf4ef; color: var(--green); font-size: 15px; }
.debt-detail, .sale-detail { min-width: 0; }
.debt-name, .sale-name { display: block; overflow: hidden; color: #354139; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.debt-meta, .sale-meta { display: block; margin-top: 3px; color: #929a93; font-size: 9px; }
.debt-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 10px; }
.debt-amount, .sale-amount { color: #815f1e; font-size: 13px; font-weight: 780; font-variant-numeric: tabular-nums; white-space: nowrap; }
.paid-button { min-height: 34px; padding: 0 10px; border: 1px solid #dce9df; border-radius: 10px; background: #f0f7f1; color: #326243; cursor: pointer; font-size: 10px; font-weight: 750; white-space: nowrap; transition: background 120ms ease, transform 120ms ease; }
.paid-button:hover:not(:disabled) { background: #e4f0e7; }
.sale-amount { color: #344b3b; }
.sale-meta .type-tag { display: inline-block; margin-right: 4px; color: #526c59; font-weight: 700; }
.sale-meta .paid-tag { color: #738078; }
.sale-row:last-child, .debt-row:last-child { padding-bottom: 14px; }

.close-dock {
  position: fixed;
  z-index: 5;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 12px max(20px, calc((100vw - 800px) / 2)) calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(33, 67, 45, 0.08);
  background: rgba(246, 246, 240, 0.94);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.close-dock-inner { display: flex; width: 100%; max-width: 800px; align-items: center; justify-content: space-between; gap: 18px; margin: 0 auto; }
.close-copy { display: grid; gap: 4px; }
.close-copy strong { color: #465149; font-size: 11px; }
.close-copy strong [lang="ha"] { color: #758078; font-weight: 550; }
.close-copy > span { color: #8d968e; font-size: 9px; line-height: 1.35; }
.close-button {
  display: inline-flex;
  min-height: 54px;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
  padding: 8px 15px;
  border: 0;
  border-radius: 13px;
  background: var(--red);
  box-shadow: 0 5px 15px rgba(201, 79, 64, 0.18);
  color: #fff;
  cursor: pointer;
  text-align: left;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.15;
  transition: transform 120ms ease, background 120ms ease;
}
.close-button:hover:not(:disabled) { background: var(--red-dark); }
.close-button small { display: block; margin-top: 4px; font-size: 9px; font-weight: 550; opacity: 0.8; }
.close-icon { display: grid; width: 25px; height: 25px; place-items: center; border-radius: 8px; background: rgba(255, 255, 255, 0.16); font-size: 16px; }

@media (max-width: 560px) {
  .page-shell { width: min(100% - 28px, 800px); padding-bottom: 164px; }
  .topbar { min-height: 70px; }
  .brand-mark { width: 35px; height: 35px; }
  .brand-copy strong { font-size: 15px; }
  .brand-copy small { font-size: 9px; }
  .date-chip { max-width: 45vw; overflow: hidden; padding: 8px 9px; font-size: 9px; text-overflow: ellipsis; }
  .intro { padding: 28px 0 19px; }
  .eyebrow { gap: 6px; font-size: 8px; letter-spacing: 0.1em; }
  h1 { font-size: 30px; }
  h1 span { font-size: 0.65em; }
  .intro-copy { font-size: 12px; }
  .quick-add { padding: 18px 15px 12px; border-radius: 16px; }
  .section-heading h2 { font-size: 16px; }
  .section-heading h2 span { font-size: 0.72em; }
  .pencil-badge { width: 31px; height: 31px; }
  #sale-form { margin-top: 17px; }
  #sale-input { min-height: 56px; padding: 0 12px; font-size: 13px; }
  #sale-input::placeholder { font-size: 11px; }
  .input-hint { font-size: 9px; }
  .add-buttons { gap: 8px; }
  .add-button { min-height: 58px; gap: 7px; padding: 8px 9px; font-size: 10px; }
  .add-button small { font-size: 8px; }
  .button-icon { width: 22px; height: 22px; font-size: 16px; }
  .summary-section { padding-top: 22px; }
  .summary-grid { gap: 7px; }
  .summary-card { min-height: 101px; padding: 11px 9px 10px; border-radius: 13px; }
  .summary-label { font-size: 9px; }
  .summary-label small { font-size: 8px; }
  .summary-amount { margin-top: 7px; font-size: clamp(16px, 5vw, 21px); }
  .summary-note { font-size: 7px; }
  .content-section { margin-top: 12px; padding: 16px 13px 4px; border-radius: 16px; }
  .list-heading h2, .list-heading .section-heading h2 { max-width: 300px; font-size: 14px; }
  .list-heading h2 span { margin-left: 0; font-size: 0.67em; }
  .section-kicker { font-size: 7px; }
  .debt-row, .sale-row { gap: 7px; }
  .debt-main, .sale-main { gap: 8px; }
  .person-mark, .sale-mark { width: 32px; height: 32px; border-radius: 10px; }
  .debt-name, .sale-name { font-size: 11px; }
  .debt-meta, .sale-meta { font-size: 8px; }
  .debt-actions { gap: 6px; }
  .debt-amount, .sale-amount { font-size: 11px; }
  .paid-button { min-height: 32px; padding: 0 8px; font-size: 9px; }
  .close-dock { padding-right: 14px; padding-left: 14px; }
  .close-dock-inner { align-items: center; gap: 9px; }
  .close-copy { max-width: 44%; gap: 5px; }
  .close-copy strong { font-size: 10px; line-height: 1.35; }
  .close-copy > span { font-size: 8px; }
  .close-button { min-height: 52px; gap: 7px; padding: 7px 10px; font-size: 10px; }
  .close-button small { font-size: 8px; }
  .close-icon { width: 23px; height: 23px; }
}

@media (max-width: 370px) {
  .page-shell { width: calc(100% - 22px); }
  .date-chip { max-width: 42vw; font-size: 8px; }
  .brand-copy small { font-size: 8px; }
  .add-button { font-size: 9px; }
  .add-button small { font-size: 7px; }
  .summary-card { padding-right: 7px; padding-left: 7px; }
  .summary-label { font-size: 8px; }
  .summary-amount { font-size: 16px; }
  .close-copy { max-width: 40%; }
  .close-button { gap: 6px; padding-right: 8px; padding-left: 8px; font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}


/* Local-only PIN gate and optional local controls */
[hidden] { display: none !important; }
.pin-screen {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: 24px max(18px, env(safe-area-inset-left));
  background: var(--page);
}
.pin-card {
  width: min(100%, 430px);
  padding: 27px 24px 23px;
}
.pin-lock-mark {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 19px;
  place-items: center;
  border-radius: 14px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 16px;
}
.pin-card h1 { margin: 0 0 10px; font-size: clamp(24px, 6vw, 31px); }
.pin-card h1 span { display: block; margin-top: 4px; font-size: .72em; }
.pin-copy { margin: 0 0 20px; color: #69756c; font-size: 13px; line-height: 1.6; }
#pin-form { display: grid; gap: 10px; }
#pin-entry, #pin-confirm {
  width: 100%;
  min-height: 58px;
  padding: 0 16px;
  border: 1px solid #dfe4dc;
  border-radius: 12px;
  background: #fcfdfa;
  color: var(--ink);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .38em;
  text-align: center;
}
.primary-button {
  display: block;
  width: 100%;
  min-height: 54px;
  margin-top: 5px;
  border: 0;
  border-radius: 12px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 750;
}
.primary-button:disabled { opacity: .58; cursor: progress; }
.forgot-pin {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: #a23f34;
  cursor: pointer;
  font-size: 11px;
  line-height: 1.45;
}
.forgot-pin [lang="ha"] { display: block; color: #87655f; }
.local-note {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: #828c84;
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.lock-now {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #dce6de;
  border-radius: 10px;
  background: #fff;
  color: var(--green-dark);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.search-label { display: block; margin: 2px 0 7px; color: #536056; font-size: 10px; font-weight: 700; }
.search-label [lang="ha"] { color: #8b958d; font-weight: 500; }
.search-input {
  width: 100%;
  min-height: 42px;
  margin-bottom: 6px;
  padding: 0 12px;
  border: 1px solid #e2e7df;
  border-radius: 10px;
  background: #fcfdfa;
  color: var(--ink);
  font-size: 12px;
}
.search-input:focus { border-color: #79a18a; outline: 3px solid rgba(36, 99, 68, .10); }
.share-panel {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 18px 20px;
}
.share-panel h2 { margin: 0; font-size: 16px; letter-spacing: -.03em; }
.share-panel h2 span { color: #7d877f; font-size: .78em; font-weight: 500; }
.share-panel p:not(.section-kicker):not(.feedback) { margin: 6px 0 0; color: #828c84; font-size: 10px; line-height: 1.5; }
.whatsapp-button {
  display: flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  padding: 9px 13px;
  border-radius: 12px;
  background: #286b48;
  color: #fff;
  text-align: center;
  text-decoration: none;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
}
.whatsapp-button small { display: block; margin-left: 5px; font-size: 9px; font-weight: 550; opacity: .8; }
.whatsapp-button:active { transform: scale(.99); }
.share-panel .feedback { min-height: 0; margin: 0; }

@media (max-width: 560px) {
  .pin-card { padding: 23px 18px 19px; }
  .topbar-actions { gap: 5px; }
  .lock-now { padding: 0 8px; font-size: 9px; }
  .share-panel { padding: 16px 14px; }
  .whatsapp-button { flex-direction: column; gap: 2px; }
  .whatsapp-button small { margin-left: 0; }
}
