/* Mandi Munim — app styles. Mobile first, large touch targets, Hindi-friendly fonts. */
:root {
  --green: #1B7A3D;
  --green-dark: #135C2D;
  --green-soft: #E3F1E7;
  --saffron: #F4A300;
  --saffron-soft: #FFF3D6;
  --red: #D93025;
  --red-soft: #FCE8E6;
  --ink: #23262A;
  --muted: #5F6670;
  --line: #DDD8CC;
  --bg: #F7F5EF;
  --card: #FFFFFF;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 14px rgba(0, 0, 0, .05);
  --font: "Noto Sans Devanagari", "Noto Sans", "Mangal", "Nirmala UI", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 17px; line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}
h1 { font-size: 1.35rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
p { margin: .25rem 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.hi { color: var(--muted); }

/* Environment banner: demo orange, practice blue, staging grey */
.env-banner { position: sticky; top: 0; z-index: 30; padding: .45rem 1rem; text-align: center; font-weight: 700; color: #fff; letter-spacing: .02em; }
.env-demo .env-banner { background: #E65100; }
.env-practice .env-banner { background: #1565C0; }
.env-staging .env-banner { background: #455A64; }
body.env-demo { background: #FFF6EC; }
body.env-practice { background: #EEF4FC; }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .7rem 1rem; background: var(--green); color: #fff; }
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 800; font-size: 1.2rem; }
.brand-by { font-size: .72rem; opacity: .85; }
.top-actions { display: flex; gap: .5rem; }
.top .chip { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .35); }

main { max-width: 760px; margin: 0 auto; padding: 1rem; outline: none; }
.loading { text-align: center; color: var(--muted); padding: 3rem 0; }

/* Cards and notices */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; margin-bottom: 1rem; }
.notice { background: var(--saffron-soft); border: 1px solid #F1D48A; padding: .6rem .9rem; border-radius: 10px; margin-bottom: 1rem; }
.notice.bad { background: var(--red-soft); border-color: #F3B7B1; color: #8A1C14; }
.note { background: var(--green-soft); padding: .55rem .8rem; border-radius: 8px; font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 48px; padding: .6rem 1.1rem; border-radius: 12px; border: 2px solid transparent;
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; color: inherit; background: none;
}
.btn.block { width: 100%; margin-top: .6rem; }
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:active { background: var(--green-dark); }
.btn.accent { background: var(--saffron); color: #2B1D00; }
.btn.ghost { background: var(--card); border-color: var(--line); }
.btn.link { background: none; color: var(--green); padding-left: 0; padding-right: 0; text-decoration: underline; }
.btn.whatsapp { background: #25D366; color: #06371A; }
.btn:disabled, .btn.busy { opacity: .6; cursor: progress; }
.btn:focus-visible, .chip:focus-visible, .tile:focus-visible, .list-row:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--saffron); outline-offset: 2px;
}
.row { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }

.chip { min-height: 40px; padding: .35rem .9rem; border-radius: 999px; border: 2px solid var(--line); background: var(--card); font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer; color: var(--ink); }
.chip.on { background: var(--green); border-color: var(--green); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin: .5rem 0 .9rem; }

/* Forms */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.field label, .field .label { font-weight: 700; font-size: .95rem; }
input, select, textarea {
  font: inherit; font-size: 1.05rem; min-height: 50px; padding: .6rem .8rem;
  border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); width: 100%;
}
textarea { min-height: 80px; }
.big-input { font-size: 1.4rem; letter-spacing: .08em; text-align: center; }
.big-input.pin { letter-spacing: .5em; }
.upper { text-transform: uppercase; }
.hint { color: var(--muted); }
.field.invalid input, .field.invalid select, .field.invalid textarea, .field.invalid .chips { border-color: var(--red); }
.field-error { color: var(--red); font-weight: 700; font-size: .9rem; }
details.more { border-top: 1px solid var(--line); padding-top: .6rem; margin: .6rem 0; }
details.more > summary { cursor: pointer; font-weight: 700; color: var(--green); min-height: 44px; display: flex; align-items: center; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.seg-btn { min-height: 48px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.seg-btn.on.dr { background: var(--green-soft); border-color: var(--green); color: var(--green-dark); }
.seg-btn.on.cr { background: var(--red-soft); border-color: var(--red); color: #8A1C14; }
.photo-field { flex-direction: row; align-items: center; gap: 1rem; }

/* Login */
.login { max-width: 440px; margin: 1rem auto; }
.login-extras { max-width: 440px; margin: 0 auto; }
.demo-card p { margin-bottom: .4rem; }

/* Dashboard */
.hello h1 { margin-bottom: 0; }
.hello .firm { color: var(--muted); font-weight: 600; margin-bottom: 1rem; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; margin-bottom: 1.1rem; }
.stat { background: var(--card); border-radius: 12px; padding: .7rem .85rem; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.stat-label { font-size: .85rem; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 1.25rem; font-weight: 800; }
.stat.dr .stat-value { color: var(--green); }
.stat.cr .stat-value { color: var(--red); }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem;
  min-height: 108px; padding: .6rem; border: 0; border-radius: 16px; background: var(--card); box-shadow: var(--shadow);
  font: inherit; font-weight: 700; color: var(--ink); cursor: pointer;
}
.tile:active { transform: scale(.98); background: var(--green-soft); }
.tile-icon { font-size: 2.3rem; line-height: 1; }
.tile-label { font-size: 1rem; text-align: center; }

/* Lists */
.bar { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.bar h1 { margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { min-height: 44px; padding: .4rem .8rem; }
.search { margin-bottom: .2rem; }
.list { display: flex; flex-direction: column; gap: .45rem; }
.list-row {
  display: flex; align-items: center; gap: .8rem; width: 100%; min-height: 64px; padding: .6rem .8rem;
  border: 0; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); font: inherit; text-align: left; cursor: pointer; color: var(--ink);
}
.row-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.row-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--muted); font-size: .9rem; }
.row-amt { font-weight: 800; white-space: nowrap; }
.dr { color: var(--green); }
.cr { color: var(--red); }
.avatar {
  flex: none; width: 46px; height: 46px; border-radius: 50%; background: var(--green-soft); color: var(--green-dark);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800; object-fit: cover;
}
.avatar.big { width: 84px; height: 84px; font-size: 1.6rem; }
.fab {
  position: fixed; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom)); z-index: 20;
  min-height: 56px; padding: .8rem 1.3rem; border-radius: 999px; border: 0; background: var(--saffron); color: #2B1D00;
  font: inherit; font-weight: 800; box-shadow: 0 6px 18px rgba(0, 0, 0, .2); cursor: pointer;
}

/* Party view */
.party-head { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; align-items: center; }
.party-head > .balance, .party-head > .muted, .party-head > .actions { grid-column: 1 / -1; }
.party-head h2 { margin: 0; }
.types { font-size: .9rem; color: var(--muted); }
.balance { font-size: 1.5rem; font-weight: 800; margin-top: .5rem; }
table.ledger { width: 100%; border-collapse: collapse; font-size: .95rem; }
.ledger th, .ledger td { padding: .5rem .35rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.ledger .num { text-align: right; white-space: nowrap; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.details dt { color: var(--muted); font-weight: 600; }
.details dd { margin: 0; word-break: break-word; }

/* Modal and toast */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 50; }
.modal .card { width: 100%; max-width: 420px; }
.preview { white-space: pre-wrap; word-break: break-word; background: #F3F3F3; padding: .7rem; border-radius: 8px; }
#toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translate(-50%, 150%); max-width: 92vw; z-index: 60;
  padding: .75rem 1.1rem; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 700;
  transition: transform .25s ease; pointer-events: none;
}
#toast.show { transform: translate(-50%, 0); }
#toast.bad { background: var(--red); }
#toast.good { background: var(--green); }
.noscript { padding: 2rem; text-align: center; }

@media (min-width: 640px) {
  .stats { grid-template-columns: repeat(5, 1fr); }
  .tiles { grid-template-columns: repeat(5, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
