/* Dukan design system
   Indigo header band with a large number, white cards that overlap it, tinted icon squares,
   area charts and category bars. Mobile: bottom nav with a centre + button. Desktop (>=1024px):
   left sidebar and a multi-column dashboard. Red/green are kept for money (lena/dena) only. */
:root {
  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e7e9f0;
  --border-strong: #d5d9e4;

  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;

  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-soft: #eef0ff;
  --primary-ring: rgba(79, 70, 229, .18);
  --hero: linear-gradient(155deg, #3730a3 0%, #4f46e5 48%, #6d6af5 100%);

  --lena: #e5484d;          /* party owes the shop */
  --lena-soft: #fff0f0;
  --dena: #12a150;          /* paid / shop owes the party */
  --dena-soft: #e9f9ef;
  --warn: #c2620a;
  --warn-soft: #fff6e8;

  /* tinted icon squares */
  --t-indigo: #eef0ff;  --i-indigo: #4f46e5;
  --t-green: #e6f7ee;   --i-green: #15924a;
  --t-orange: #fff1e6;  --i-orange: #e2620f;
  --t-pink: #ffeef3;    --i-pink: #d6336c;
  --t-sky: #e7f3ff;     --i-sky: #1c7ed6;
  --t-violet: #f3edff;  --i-violet: #7048e8;
  --t-amber: #fff7e0;   --i-amber: #c48a00;
  --t-gray: #f1f2f6;    --i-gray: #4b5563;

  /* names used in templates */
  --brand: var(--primary);
  --brand-soft: var(--primary-soft);

  --radius: 18px;
  --radius-sm: 12px;
  --tap: 52px;
  --shadow-xs: 0 1px 2px rgba(17, 24, 39, .04);
  --shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 8px 24px -12px rgba(17, 24, 39, .12);
  --shadow-lg: 0 18px 40px -16px rgba(55, 48, 163, .45);
  --sidebar: 256px;
  font-size: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Plus Jakarta Sans", "Noto Sans Devanagari", "Noto Sans Gurmukhi", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
body.has-shell { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
a { color: var(--primary); }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 12px; letter-spacing: -.02em; font-weight: 700; color: var(--ink); }
h2 { font-size: 1.05rem; }
small, .muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
[hidden] { display: none !important; }

/* =========================================================
   Header band
   ========================================================= */
.appbar {
  background: var(--hero);
  color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 18px;
  position: relative;
  overflow: hidden;
}
.appbar::before, .appbar::after {
  content: ""; position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255,255,255,.18), transparent);
}
.appbar::before { width: 340px; height: 340px; right: -120px; top: -160px; }
.appbar::after { width: 260px; height: 260px; left: -120px; bottom: -150px; opacity: .6; }
.appbar.has-hero { padding-bottom: 64px; }
.appbar-inner { max-width: 1180px; margin: 0 auto; position: relative; z-index: 1; }
.appbar-row { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.appbar-title { flex: 1; min-width: 0; }
.appbar-title h1 { color: #fff; font-size: 1.2rem; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-title small { color: rgba(255,255,255,.72); font-size: .8rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.glass-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; height: 44px; padding: 0 12px; border-radius: 14px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22);
  color: #fff; text-decoration: none; font-weight: 600; font-size: .85rem;
  backdrop-filter: blur(6px);
}
.glass-btn.back { padding: 0; width: 44px; border-radius: 50%; }
.glass-btn svg { width: 20px; height: 20px; }
.glass-btn.lang svg { width: 18px; height: 18px; }
.appbar-row.home { justify-content: space-between; }
.avatar.ring { box-shadow: 0 0 0 3px rgba(255,255,255,.35); }
.shop-pill {
  display: inline-flex; align-items: center; gap: 6px; max-width: 56vw;
  padding: 8px 14px; border-radius: 999px; background: rgba(255,255,255,.16);
  color: #fff; text-decoration: none; font-weight: 600; font-size: .92rem;
}
.shop-pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shop-pill svg { width: 16px; height: 16px; opacity: .8; }

/* big number inside the band */
.hero-stat { text-align: center; padding: 18px 0 4px; }
.hero-stat .label { color: rgba(255,255,255,.82); font-size: .95rem; font-weight: 500; }
.hero-stat .big { font-size: 2.6rem; font-weight: 800; letter-spacing: -.035em; line-height: 1.15; margin: 4px 0; font-variant-numeric: tabular-nums; }
.hero-stat .big .dec { opacity: .6; }
.hero-stat .meta { color: rgba(255,255,255,.75); font-size: .85rem; }
.hero-stat .meta b { color: #fff; font-weight: 600; }
.hero-chip { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.16); font-size: .78rem; font-weight: 600; }
.hero-chip.good { background: rgba(18,161,80,.28); }
.hero-chip.bad { background: rgba(229,72,77,.32); }

/* frosted stats strip */
.hero-strip {
  margin-top: 16px; display: grid; grid-template-columns: repeat(3, 1fr);
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18);
  border-radius: 18px; backdrop-filter: blur(8px);
}
.hero-strip.two { grid-template-columns: repeat(2, 1fr); }
.hero-strip > * { padding: 12px 8px; text-align: center; color: #fff; text-decoration: none; min-width: 0; }
.hero-strip > * + * { border-left: 1px solid rgba(255,255,255,.16); }
.hero-strip .k { display: block; font-size: .72rem; color: rgba(255,255,255,.75); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-strip .v { display: block; font-size: 1.15rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hero-strip .s { display: block; font-size: .72rem; color: rgba(255,255,255,.7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* party / bill identity inside band */
.hero-id { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.hero-id .grow { flex: 1; min-width: 0; }
.hero-id strong { display: block; font-size: 1.2rem; font-weight: 700; }
.hero-id small { color: rgba(255,255,255,.75); }

/* =========================================================
   Page content
   ========================================================= */
.offline-bar { background: var(--warn); color: #fff; text-align: center; padding: 6px; font-size: .9rem; }
.content { max-width: 880px; margin: 0 auto; padding: 16px; position: relative; z-index: 2; }
.content.wide { max-width: 1180px; }
.content.overlap { margin-top: -48px; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; border: 1px solid rgba(231,233,240,.7); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 1.02rem; }
.card-head .aside { font-size: .82rem; color: var(--primary); font-weight: 600; text-decoration: none; white-space: nowrap; }
.card-head .aside.muted { color: var(--muted); font-weight: 500; }
.card > h2:first-child { display: flex; align-items: center; gap: 8px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 20px 2px 10px; }
.section-head h2 { margin: 0; }
.section-head a { font-weight: 600; text-decoration: none; font-size: .86rem; }

/* dashboard grid */
.dash { display: grid; gap: 14px; }
.dash > * { margin-bottom: 0; min-width: 0; }
.span-2 { }

/* range filter row */
.ranges { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-xs); border: 1px solid var(--border); }
.ranges a { padding: 7px 14px; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .85rem; }
.ranges a.on { background: var(--primary); color: #fff; box-shadow: 0 4px 10px -4px var(--primary); }
.filter-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-row .hint { margin: 0; }

/* quick actions (icon grid) */
.qa { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.qa a { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 4px; border-radius: 14px; text-decoration: none; color: var(--ink-2); font-size: .82rem; font-weight: 600; text-align: center; }
.qa a:hover { background: var(--surface-2); }

.ic { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.ic svg { width: 23px; height: 23px; }
.ic.sm { width: 40px; height: 40px; border-radius: 12px; }
.ic.sm svg { width: 20px; height: 20px; }
.ic.indigo, .ic.green-brand { background: var(--t-indigo); color: var(--i-indigo); }
.ic.green { background: var(--t-green); color: var(--i-green); }
.ic.orange { background: var(--t-orange); color: var(--i-orange); }
.ic.pink, .ic.red { background: var(--t-pink); color: var(--i-pink); }
.ic.sky, .ic.blue { background: var(--t-sky); color: var(--i-sky); }
.ic.violet, .ic.purple { background: var(--t-violet); color: var(--i-violet); }
.ic.amber { background: var(--t-amber); color: var(--i-amber); }
.ic.gray { background: var(--t-gray); color: var(--i-gray); }

/* action rows like "16 New orders  Worth ₹5,243  >" */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li + li { border-top: 1px solid var(--border); }
.rows a { display: flex; align-items: center; gap: 14px; padding: 12px 2px; text-decoration: none; color: var(--ink); }
.rows .grow { flex: 1; min-width: 0; }
.rows .grow strong { display: block; font-weight: 600; }
.rows .grow small { display: block; }
.rows .chev { color: var(--muted); width: 18px; height: 18px; }

/* =========================================================
   Charts
   ========================================================= */
.chart { margin: 0; color: var(--primary); outline: none; }
.chart:focus-visible { box-shadow: 0 0 0 3px var(--primary-ring); border-radius: 10px; }
.chart-plot { position: relative; height: 150px; touch-action: pan-y; cursor: crosshair; }
.chart-plot svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart-plot .line { stroke-width: 2.25; }
.chart-plot .grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; }
.chart-plot .base { stroke: var(--border-strong); stroke-width: 1; }
.chart-dot { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px var(--surface), 0 2px 6px rgba(0,0,0,.2); pointer-events: none; }
.chart.active .chart-dot:not(.hover), .chart.active .chart-flag { opacity: 0; }
.chart-flag { position: absolute; transform: translate(-100%, -150%); margin-left: 6px; background: var(--ink); color: #fff; font-size: .7rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; pointer-events: none; }
.chart-hair { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px dashed var(--muted); pointer-events: none; }
.chart-tip { position: absolute; top: -6px; transform: translate(-50%, -100%); background: var(--ink); color: #fff; padding: 6px 10px; border-radius: 10px; font-size: .78rem; white-space: nowrap; pointer-events: none; box-shadow: 0 6px 16px rgba(0,0,0,.2); }
.chart-tip.flip { transform: translate(-100%, -100%); }
.chart-tip.flip-left { transform: translate(0, -100%); }
.chart-tip strong { display: block; font-size: .92rem; }
.chart-tip small { color: rgba(255,255,255,.7); }
.chart-x { position: relative; height: 22px; margin-top: 8px; font-size: .72rem; color: var(--muted); }
.chart-x span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.chart-x span:first-child { transform: none; }
.chart-x span:last-child { transform: translateX(-100%); }
.chart-table { margin-top: 6px; font-size: .8rem; }
.chart-table summary { color: var(--muted); cursor: pointer; width: max-content; }
.chart-table table { margin-top: 8px; }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.bars li { display: grid; grid-template-columns: 34px minmax(70px, 1fr) 2fr auto; align-items: center; gap: 10px; }
.bar-key { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: .85rem; color: var(--c); background: color-mix(in srgb, var(--c) 14%, white); }
.bar-name { font-size: .9rem; font-weight: 600; color: var(--ink-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-name small { display: block; font-weight: 500; font-size: .74rem; }
.bar-track { height: 8px; border-radius: 99px; background: #eef0f5; overflow: hidden; }
.bar-track span { display: block; height: 100%; border-radius: 99px; }
.bar-val { font-weight: 700; font-size: .9rem; text-align: right; min-width: 72px; }

/* =========================================================
   Balance card, stats, alerts
   ========================================================= */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.stat { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; text-decoration: none; color: var(--ink); display: block; }
.stat .label { font-size: .8rem; color: var(--muted); display: block; font-weight: 500; }
.stat .value { font-size: 1.3rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.35; }
.stat.lena .value { color: var(--lena); }
.stat.dena .value { color: var(--dena); }
.stat.warn { background: var(--warn-soft); box-shadow: none; border: 1px solid #fde1b8; }
.alert-strip { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--radius); background: var(--warn-soft); border: 1px solid #fde1b8; color: #8a3d00; text-decoration: none; margin-bottom: 14px; font-weight: 600; font-size: .9rem; }
.alert-strip svg { color: var(--warn); }
.limit-bar { height: 6px; border-radius: 99px; background: rgba(255,255,255,.25); margin: 12px auto 6px; overflow: hidden; max-width: 320px; }
.limit-bar span { display: block; height: 100%; background: #fff; border-radius: 99px; }

/* =========================================================
   Lists
   ========================================================= */
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: .85rem; flex: none; letter-spacing: .02em; }
.avatar.lg { width: 52px; height: 52px; font-size: 1.05rem; }
.list { list-style: none; margin: 0 0 14px; padding: 4px 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card .list { box-shadow: none; padding: 0; margin: 0 -6px; }
.list li + li { border-top: 1px solid var(--border); }
.list a.row, .list .row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 66px; color: var(--ink); text-decoration: none; }
.card .list a.row, .card .list .row { padding: 12px 6px; }
.list a.row:hover { background: var(--surface-2); }
.list a.row::after { content: ""; width: 7px; height: 7px; border-right: 2px solid #b8bdc9; border-bottom: 2px solid #b8bdc9; transform: rotate(-45deg); flex: none; margin-left: 2px; }
.list .row > svg { color: var(--muted); }
.row .grow { flex: 1; min-width: 110px; }
.row .grow strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .grow small { display: block; font-size: .8rem; }
.list .row .num.right { flex: none; display: flex; flex-direction: column; align-items: flex-end; font-weight: 700; }
.list .row .num.right small { font-weight: 600; font-size: .76rem; }
.list .row form .btn { min-width: 40px; min-height: 40px; padding: 0 8px; }
.amt-lena { color: var(--lena); font-weight: 700; }
.amt-dena { color: var(--dena); font-weight: 700; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: .7rem; background: var(--t-gray); color: var(--ink-2); font-weight: 600; vertical-align: 1px; }
.badge.gst { background: var(--t-indigo); color: var(--i-indigo); }
.badge.cash { background: var(--t-amber); color: #8a6100; }
.badge.bad { background: var(--lena-soft); color: #c4262c; }
.badge.contractor { background: var(--t-orange); color: #b14c0b; }
.badge.supplier { background: var(--t-sky); color: #1863b0; }
.badge.match { background: var(--t-violet); color: var(--i-violet); }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); margin: 0 0 14px; font-size: .9rem; }
.empty::before { content: ""; display: block; width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%; background: var(--primary-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234f46e5' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 2h9l5 5v15H6z'/%3E%3Cpath d='M14 2v6h6M9 13h8M9 17h5'/%3E%3C/svg%3E") center / 30px no-repeat; }
.card .empty { box-shadow: none; padding: 16px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar form { flex: 1; display: flex; gap: 8px; min-width: 220px; }
.searchfield { position: relative; flex: 1; }
.searchfield > svg { position: absolute; left: 14px; top: 26px; transform: translateY(-50%); color: var(--muted); pointer-events: none; width: 20px; height: 20px; }
.searchfield input { padding-left: 44px; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 14px; padding: 2px 16px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 999px; background: var(--surface); color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .85rem; box-shadow: var(--shadow-xs); border: 1px solid var(--border); }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* =========================================================
   Buttons & forms
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink-2); font: inherit; font-weight: 700; font-size: .95rem; text-decoration: none; cursor: pointer;
  transition: background .15s, transform .08s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn svg { width: 20px; height: 20px; }
.btn.big { min-height: var(--tap); font-size: 1rem; width: 100%; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 8px 18px -8px var(--primary); }
.btn.primary:hover { background: var(--primary-600); }
.btn.wa { background: #1fa855; border-color: #1fa855; color: #fff; }
.btn.danger { color: #c4262c; border-color: #f7c2c4; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.lena { background: var(--lena); border-color: var(--lena); color: #fff; }
.btn.dena { background: var(--dena); border-color: var(--dena); color: #fff; box-shadow: 0 8px 18px -8px var(--dena); }
.btn:disabled { opacity: .5; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 40px; border: 0; background: none; color: var(--muted); border-radius: 10px; cursor: pointer; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: grid; gap: 10px; margin: 14px 0; }
.actions.two { grid-template-columns: 1fr 1fr; }

label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: .86rem; color: var(--ink-2); }
label.inline { display: flex; align-items: center; gap: 10px; margin: 10px 0; min-height: 44px; font-size: .92rem; font-weight: 500; }
input, select, textarea {
  width: 100%; min-height: 50px; padding: 10px 14px; font: inherit; font-size: 1rem; color: var(--ink);
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: #9aa1ae; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px var(--primary-ring); }
input.invalid { border-color: #f3a3a6; background: #fff8f8; box-shadow: 0 0 0 4px rgba(229,72,77,.1); }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; min-height: 0; accent-color: var(--primary); flex: none; }
textarea { min-height: 84px; }
.hint { font-size: .82rem; color: var(--muted); margin: 6px 0 0; }
.field-msg { font-size: .78rem; margin: 6px 2px 0; color: var(--muted); font-weight: 500; }
.field-msg:empty { display: none; }
.field-msg.bad { color: #c4262c; }
.field-msg.good { color: var(--dena); }
.error, .flash { padding: 12px 14px; border-radius: 14px; margin-bottom: 14px; font-weight: 600; font-size: .9rem; }
.error, .flash.error { background: var(--lena-soft); color: #c4262c; }
.flash.ok { background: var(--dena-soft); color: #0b7a3b; }
.content.overlap > .flash:first-child { box-shadow: var(--shadow); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #eef0f5; border-radius: 14px; padding: 4px; gap: 4px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { margin: 0; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; cursor: pointer; color: var(--muted); text-align: center; padding: 0 6px; border-radius: 11px; font-weight: 700; font-size: .92rem; }
.seg input:checked + label { background: var(--surface); color: var(--ink); box-shadow: 0 2px 8px rgba(17,24,39,.08); }
.types { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

/* =========================================================
   Bill builder
   ========================================================= */
.step { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 1rem; font-weight: 700; color: var(--ink); }
.step label { font: inherit; color: inherit; margin: 0; }
.step .n { width: 26px; height: 26px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: .8rem; font-weight: 800; flex: none; }
.searchbox { position: relative; }
.results { list-style: none; margin: 6px 0 0; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; max-height: 50vh; overflow: auto; box-shadow: 0 20px 40px -12px rgba(17,24,39,.25); }
.results li { padding: 10px 12px; display: flex; gap: 12px; align-items: center; cursor: pointer; min-height: var(--tap); border-radius: 12px; }
.results li:hover, .results li.active { background: var(--primary-soft); }
.results li > svg { color: var(--primary); }
.results .grow { flex: 1; min-width: 0; }
.results .grow strong { font-weight: 600; }
.results .grow small { display: block; font-size: .78rem; }
.line { background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px; padding: 12px; margin-top: 10px; }
#party-picked.line { background: var(--primary-soft); border-color: #d9dcff; }
.line-head { display: flex; align-items: flex-start; gap: 8px; }
.line-head strong { flex: 1; font-weight: 700; }
.line-grid { display: grid; grid-template-columns: 1.1fr 1fr 1.2fr; gap: 8px; margin-top: 8px; }
.line-grid label { margin: 0 0 4px; font-size: .74rem; color: var(--muted); }
.line-grid input, .line-grid select { background: #fff; }
.line-amt { text-align: right; margin-top: 8px; font-size: 1.05rem; font-weight: 800; }
.totals { width: 100%; border-collapse: collapse; font-size: .94rem; }
.totals td { padding: 6px 0; color: var(--ink-2); }
.totals td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.totals tr.grand td { font-size: 1.4rem; font-weight: 800; color: var(--ink); border-top: 1px dashed var(--border-strong); padding-top: 12px; letter-spacing: -.02em; }
.sticky-save { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 5; padding: 10px 0 0; }
.sticky-save .btn { min-height: 58px; font-size: 1.05rem; border-radius: 18px; box-shadow: var(--shadow-lg); }
body.searching .sticky-save { display: none; }
.searchbox input { scroll-margin-top: 80px; }
.bill-layout { display: grid; gap: 0; }

/* =========================================================
   Tables
   ========================================================= */
.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .88rem; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.data th { background: var(--surface-2); font-size: .72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
table.data td.num, table.data th.num { text-align: right; }

/* =========================================================
   Mobile bottom nav
   ========================================================= */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -8px 24px -12px rgba(17,24,39,.12);
}
.bottomnav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 64px; color: #9aa1ae; text-decoration: none; font-size: .7rem; font-weight: 600; text-align: center; padding: 0 2px; }
.bottomnav a.on { color: var(--primary); }
.bottomnav svg { width: 24px; height: 24px; }
.bottomnav a.fab { justify-content: flex-end; padding-bottom: 8px; color: var(--ink-2); }
.bottomnav a.fab .bubble {
  width: 56px; height: 56px; border-radius: 50%; margin-top: -26px;
  display: grid; place-items: center; color: #fff; background: var(--hero);
  box-shadow: 0 10px 22px -6px rgba(79,70,229,.6); border: 4px solid var(--surface);
}
.bottomnav a.fab .bubble svg { width: 26px; height: 26px; stroke-width: 2.4; }

/* =========================================================
   Desktop sidebar (hidden on phones)
   ========================================================= */
.sidebar { display: none; }

/* confirm dialog */
dialog.confirm { border: 0; border-radius: 22px; padding: 24px; width: min(92vw, 400px); box-shadow: 0 30px 60px -20px rgba(17,24,39,.4); }
dialog.confirm::backdrop { background: rgba(17,24,39,.5); backdrop-filter: blur(2px); }
dialog.confirm p { font-size: 1.1rem; font-weight: 700; margin: 0 0 18px; }

/* =========================================================
   Welcome screens (language, login, register)
   ========================================================= */
body.welcome { background: var(--bg); min-height: 100vh; }
body.welcome .main::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 300px; background: var(--hero); border-radius: 0 0 36px 36px; z-index: 0; }
body.welcome .content { max-width: 440px; padding-top: 24px; }
.brand-hero { text-align: center; padding: 20px 0 22px; color: #fff; position: relative; }
.brand-hero .logo { width: 72px; height: 72px; border-radius: 22px; margin: 0 auto 12px; display: grid; place-items: center; background: #fff; box-shadow: 0 12px 30px -10px rgba(0,0,0,.35); }
.brand-hero .logo img { width: 56px; height: 56px; border-radius: 16px; }
.brand-hero h1 { font-size: 1.7rem; margin: 0; color: #fff; }
.brand-hero p { margin: 4px 0 0; color: rgba(255,255,255,.8); font-size: .92rem; }
.brand-hero .chip { display: inline-flex; gap: 6px; align-items: center; margin-top: 12px; background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.25); color: #fff; box-shadow: none; }
.brand-hero .chip svg { width: 16px; height: 16px; }
.welcome .card { border-radius: 24px; padding: 22px; box-shadow: 0 24px 48px -24px rgba(17,24,39,.3); }
.langs { display: grid; gap: 10px; }
.langs button { display: flex; align-items: center; gap: 14px; min-height: 68px; padding: 0 16px; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); font: inherit; font-size: 1.1rem; font-weight: 700; color: var(--ink); cursor: pointer; }
.langs button small { display: block; font-size: .78rem; color: var(--muted); font-weight: 500; }
.langs button .flag { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-size: 1rem; font-weight: 800; flex: none; }
.langs button:hover { border-color: var(--primary); }
.trust { display: flex; gap: 10px; align-items: flex-start; font-size: .8rem; color: var(--muted); margin-top: 16px; }
.trust svg { color: var(--dena); width: 18px; height: 18px; margin-top: 2px; }

/* =========================================================
   Printable bill
   ========================================================= */
.invoice { background: #fff; color: #000; padding: 20px; max-width: 800px; margin: 0 auto; font-size: 14px; }
.invoice h1 { font-size: 22px; margin: 0; }
.invoice .inv-head { display: flex; justify-content: space-between; gap: 16px; border-bottom: 2px solid #4f46e5; padding-bottom: 10px; margin-bottom: 10px; }
.invoice .inv-title { text-align: center; font-weight: 800; letter-spacing: .1em; margin: 8px 0; color: #3730a3; }
.invoice table { width: 100%; border-collapse: collapse; }
.invoice th, .invoice td { border: 1px solid #c3c7d4; padding: 5px 6px; text-align: left; }
.invoice th { background: #eef0ff; }
.invoice td.num, .invoice th.num { text-align: right; }
.invoice .inv-foot { display: flex; justify-content: space-between; gap: 16px; margin-top: 10px; }
.invoice .inv-sum td { border: 0; padding: 3px 6px; }
.invoice .powered { margin-top: 18px; text-align: center; font-size: 12px; color: #4b5563; border-top: 1px dashed #c3c7d4; padding-top: 8px; }
.noprint { margin: 16px auto; max-width: 800px; padding: 0 16px; }
@media print {
  body { background: #fff; padding: 0; }
  .noprint, .appbar, .bottomnav, .sidebar { display: none !important; }
  .invoice { padding: 0; }
}

/* =========================================================
   Tablet
   ========================================================= */
@media (min-width: 680px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .dash.two { grid-template-columns: 1fr 1fr; }
  .hero-stat .big { font-size: 3rem; }
  .qa { grid-template-columns: repeat(6, 1fr); }
}

/* =========================================================
   Desktop
   ========================================================= */
@media (min-width: 1024px) {
  body.has-shell { padding: 0 0 0 var(--sidebar); }
  .bottomnav { display: none; }
  .glass-btn.back.top-level { display: none; }

  .sidebar {
    display: flex; flex-direction: column; gap: 6px;
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 30;
    background: var(--surface); border-right: 1px solid var(--border); padding: 18px 14px;
  }
  .side-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 16px; text-decoration: none; color: var(--ink); }
  .side-brand img { width: 40px; height: 40px; border-radius: 12px; }
  .side-brand strong { display: block; font-size: 1.05rem; }
  .side-brand small { display: block; font-size: .78rem; max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-cta { margin: 0 4px 12px; }
  .side-nav, .side-foot { display: grid; gap: 2px; }
  .side-nav a, .side-foot > a {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
    color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .92rem;
  }
  .side-nav a svg, .side-foot > a svg { color: #9aa1ae; width: 21px; height: 21px; }
  .side-nav a:hover, .side-foot > a:hover { background: var(--surface-2); }
  .side-nav a.on, .side-foot > a.on { background: var(--primary-soft); color: var(--primary); }
  .side-nav a.on svg, .side-foot > a.on svg { color: var(--primary); }
  .side-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 10px; }
  .side-user { display: flex; align-items: center; gap: 10px; padding: 10px 8px 0; }
  .side-user .avatar { width: 36px; height: 36px; font-size: .78rem; }
  .side-user .grow { flex: 1; min-width: 0; }
  .side-user strong { display: block; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-user small { display: block; font-size: .74rem; }

  .appbar { padding: 18px 32px 22px; }
  .appbar.has-hero { padding-bottom: 76px; }
  .appbar-title h1 { font-size: 1.45rem; }
  .content { padding: 20px 32px 40px; }
  .content.overlap { margin-top: -56px; }
  .shop-pill { max-width: 420px; }

  /* hero: number on the left, strip on the right */
  .hero-split { display: grid; grid-template-columns: 1fr 1.1fr; align-items: end; gap: 32px; }
  .hero-split .hero-stat { text-align: left; }
  .hero-split .hero-strip { margin-top: 0; }

  .dash { grid-template-columns: repeat(12, 1fr); gap: 18px; }
  .dash > * { grid-column: span 12; }
  .dash > .c8 { grid-column: span 8; }
  .dash > .c7 { grid-column: span 7; }
  .dash > .c6 { grid-column: span 6; }
  .dash > .c5 { grid-column: span 5; }
  .dash > .c4 { grid-column: span 4; }
  .dash.two { grid-template-columns: 1fr 1fr; }
  .dash.two > * { grid-column: auto; }
  .chart-plot { height: 220px; }
  .qa { grid-template-columns: repeat(3, 1fr); }
  .tall .chart-plot { height: 260px; }

  /* bill builder: items on the left, totals + save on the right */
  .bill-layout { grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
  .bill-side { position: sticky; top: 20px; }
  .sticky-save { position: static; padding: 0; }
  .sticky-save .btn { box-shadow: 0 10px 22px -10px var(--primary); }

  .list a.row, .list .row { padding-left: 20px; padding-right: 20px; }
}
.main { position: relative; }

/* stat tiles with a sparkline (home) */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  display: flex; flex-direction: column; gap: 6px; padding: 14px 14px 10px;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  text-decoration: none; color: var(--ink); min-width: 0; border: 1px solid rgba(231,233,240,.7);
}
.tile:hover { box-shadow: 0 1px 2px rgba(17,24,39,.04), 0 14px 30px -14px rgba(17,24,39,.22); }
.tile-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile-top .chev { width: 18px; height: 18px; color: #b8bdc9; }
.tile strong { font-size: .95rem; font-weight: 700; margin-top: 4px; }
.tile .val { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: .76rem; color: var(--muted); font-weight: 600; }
.tile .sub.lena { color: var(--lena); }
.tile .sub.dena { color: var(--dena); }
.tile .sub.warn { color: var(--warn); }
.tile .spark { margin: 4px -4px 0; }
.tile .spark .chart-plot { height: 44px; cursor: default; }
.tile .spark .chart-dot { width: 8px; height: 8px; margin: -4px 0 0 -4px; box-shadow: 0 0 0 2px var(--surface); }
.tile .spark .chart-tip { font-size: .72rem; padding: 4px 8px; }
.tile .spark .chart-tip strong { font-size: .8rem; }
.tile.t-red { --tc: var(--i-pink); } .tile.t-orange { --tc: var(--i-orange); } .tile.t-sky { --tc: var(--i-sky); }
.tile.t-violet { --tc: var(--i-violet); } .tile.t-green { --tc: var(--i-green); } .tile.t-indigo { --tc: var(--i-indigo); }
.tile .spark { color: var(--tc, var(--primary)); }
.tile-links { display: grid; gap: 2px; margin-top: 2px; }
.tile-links span { font-size: .8rem; color: var(--ink-2); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.tile-links span::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--i-indigo); }
@media (min-width: 680px) { .tiles { grid-template-columns: repeat(3, 1fr); } }

/* charts: only the line is stroked (the global icon stroke must not outline fills) */
.chart-plot svg { stroke: none; stroke-width: 0; }
.chart-plot svg path.line { stroke: currentColor; stroke-width: 2.25; }
.tile .spark svg path.line { stroke-width: 2; }

/* controls that sit on the purple band at the top of an overlapping page */
.content.overlap > .chips:first-child .chip,
.content.overlap > .flash + .chips .chip { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.25); color: #fff; box-shadow: none; }
.content.overlap > .chips:first-child .chip.on,
.content.overlap > .flash + .chips .chip.on { background: #fff; color: var(--primary); border-color: #fff; }
.content.overlap > .filter-row .hint { color: rgba(255,255,255,.8); }
.content.overlap > .filter-row .hint strong { color: #fff; }
.content.overlap > .filter-row .ranges { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.22); box-shadow: none; }
.content.overlap > .filter-row .ranges a { color: rgba(255,255,255,.85); }
.content.overlap > .filter-row .ranges a.on { background: #fff; color: var(--primary); box-shadow: none; }
.toolbar input[type=month] { max-width: 260px; }

/* =========================================================
   v4: shop menu, range control, combobox, toggles, bill builder polish
   ========================================================= */
.avatar.sm { width: 34px; height: 34px; font-size: .74rem; }

/* header: bell */
.glass-btn.bell { position: relative; width: 44px; padding: 0; border-radius: 50%; }
.bell-dot { position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; background: #ff5a5f; color: #fff; font-size: .68rem; font-weight: 800; display: grid; place-items: center; border: 2px solid #4f46e5; }

/* shop menu (header pill + sidebar) */
details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; user-select: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu.pill > summary {
  display: inline-flex; align-items: center; gap: 8px; max-width: min(60vw, 420px);
  padding: 8px 12px 8px 10px; border-radius: 999px;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.22); color: #fff; font-weight: 700; font-size: .9rem;
}
details.menu.pill > summary .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shop-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.25); flex: none; }
details.menu .caret { width: 16px; height: 16px; flex: none; transition: transform .2s; }
details.menu[open] .caret { transform: rotate(180deg); }
.menu-panel {
  position: absolute; z-index: 50; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  width: min(320px, calc(100vw - 24px)); max-height: 70vh; overflow: auto;
  background: var(--surface); color: var(--ink); border-radius: 18px; padding: 8px;
  box-shadow: 0 24px 48px -12px rgba(17,24,39,.35), 0 0 0 1px rgba(17,24,39,.05);
  animation: pop .14s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateX(-50%) translateY(-6px); } }
.menu-label { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px 6px; }
.menu-panel hr { border: 0; border-top: 1px solid var(--border); margin: 6px 4px; }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; border-radius: 12px; border: 0; background: none; font: inherit; color: var(--ink); text-align: left; text-decoration: none; cursor: pointer; }
.menu-item:hover { background: var(--surface-2); }
.menu-item.on { background: var(--primary-soft); }
.menu-item .grow { flex: 1; min-width: 0; }
.menu-item strong { display: block; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-item small { display: block; font-size: .74rem; }
.menu-item .tick { width: 18px; height: 18px; color: var(--primary); }
.menu-item.danger strong { color: #c4262c; }

/* range control inside the home band */
.hero-range { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.seg-range { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; flex: 1; max-width: 420px; padding: 4px; border-radius: 14px; background: rgba(15, 10, 80, .28); border: 1px solid rgba(255,255,255,.14); }
.seg-range a { text-align: center; padding: 9px 10px; border-radius: 10px; color: rgba(255,255,255,.82); text-decoration: none; font-weight: 700; font-size: .86rem; white-space: nowrap; transition: background .15s, color .15s; }
.seg-range a:hover { color: #fff; background: rgba(255,255,255,.08); }
.seg-range a.on { background: #fff; color: var(--primary); box-shadow: 0 6px 14px -6px rgba(0,0,0,.35); }
.range-meta { display: inline-flex; align-items: center; gap: 8px; color: rgba(255,255,255,.82); font-size: .84rem; }
.range-meta svg { width: 17px; height: 17px; }
.range-meta b { color: #fff; }
@media (max-width: 679px) { .seg-range { max-width: none; flex-basis: 100%; } .range-meta { width: 100%; justify-content: center; } }

/* combobox (searchable select) */
.combo-native { position: absolute !important; opacity: 0; pointer-events: none; width: 1px !important; height: 1px !important; min-height: 0 !important; padding: 0 !important; border: 0 !important; }
.combo { position: relative; }
.combo-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 50px;
  padding: 10px 12px 10px 14px; font: inherit; font-size: 1rem; color: var(--ink); text-align: left;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); cursor: pointer;
}
.combo-btn.placeholder .combo-val { color: #9aa1ae; }
.combo-val { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-caret { width: 18px; height: 18px; color: var(--muted); transition: transform .15s; }
.combo.open .combo-btn, .combo-btn:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px var(--primary-ring); }
.combo.open .combo-caret { transform: rotate(180deg); }
.combo-panel {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 6px); min-width: 180px;
  background: var(--surface); border-radius: 14px; padding: 6px; box-shadow: 0 20px 40px -12px rgba(17,24,39,.3), 0 0 0 1px rgba(17,24,39,.06);
}
.combo.up .combo-panel { top: auto; bottom: calc(100% + 6px); }
.combo-search { min-height: 42px; margin-bottom: 6px; font-size: .92rem; }
.combo-list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow: auto; }
.combo-list li { padding: 10px 12px; border-radius: 10px; cursor: pointer; font-size: .94rem; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.combo-list li.active { background: var(--surface-2); }
.combo-list li.sel { color: var(--primary); font-weight: 700; }
.combo-list li.sel::after { content: "✓"; }
.combo-list li.none { color: var(--muted); cursor: default; }
.line-grid .combo-btn { min-height: 46px; background: #fff; padding: 8px 10px; }

/* pills (radio buttons that look like chips) */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pills input { position: absolute; opacity: 0; pointer-events: none; }
.pills label { margin: 0; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-weight: 600; font-size: .9rem; color: var(--ink-2); cursor: pointer; transition: all .15s; }
.pills input:checked + label { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.pills input:focus-visible + label { box-shadow: 0 0 0 4px var(--primary-ring); }

/* toggle buttons (can be switched off) */
.toggle-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.toggle {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 64px; padding: 8px 6px;
  border-radius: 14px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink-2);
  font: inherit; font-weight: 700; font-size: .84rem; cursor: pointer; text-align: center; line-height: 1.2; transition: all .15s;
}
.toggle svg { width: 20px; height: 20px; color: var(--muted); }
.toggle:hover { border-color: var(--primary); }
.toggle[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 8px 18px -8px var(--primary); }
.toggle[aria-pressed="true"] svg { color: #fff; }
.toggle[data-pay="none"][aria-pressed="true"] { background: var(--lena); border-color: var(--lena); box-shadow: 0 8px 18px -8px var(--lena); }
.toggle[data-pay="full"][aria-pressed="true"] { background: var(--dena); border-color: var(--dena); box-shadow: 0 8px 18px -8px var(--dena); }
.toggle:disabled { opacity: .4; cursor: not-allowed; border-style: dashed; }
.toggle:active { transform: scale(.97); }
.baaki { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-weight: 600; font-size: .9rem; }
.baaki.due { background: var(--lena-soft); color: #c4262c; }
.baaki.clear { background: var(--dena-soft); color: #0b7a3b; }
.baaki strong { font-size: 1.1rem; }

/* bill builder */
.step .step-ic { width: 22px; height: 22px; color: var(--primary); }
.note { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); color: var(--ink-2); font-size: .82rem; line-height: 1.45; }
.note svg { width: 18px; height: 18px; color: var(--primary); margin-top: 1px; }
.seg label svg { width: 18px; height: 18px; }
.search-row { display: flex; gap: 8px; align-items: flex-start; }
.search-row .searchfield { flex: 1; }
.btn.icon-text { min-height: 50px; padding: 0 14px; white-space: nowrap; color: var(--primary); border-color: #d9dcff; background: var(--primary-soft); }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: .85rem; }
.picked { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: var(--primary-soft); border: 1px solid #d9dcff; }
.picked .grow { flex: 1; min-width: 0; }
.picked strong { display: block; font-size: 1rem; }
.picked small { display: block; font-size: .8rem; }
.picked .badge { margin-top: 4px; }
#site-wrap { margin-top: 4px; }
.results li.add-row { color: var(--primary); }
.results li .num small { color: var(--muted); font-weight: 500; }
.quick { margin-top: 12px; }
.quick-label { display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.quick-label svg { width: 14px; height: 14px; color: var(--i-amber); }
.quick-list { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.quick-list::-webkit-scrollbar { display: none; }
.qchip { flex: none; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font: inherit; font-size: .84rem; font-weight: 700; color: var(--ink); cursor: pointer; text-align: left; }
.qchip small { font-weight: 600; font-size: .74rem; color: var(--muted); }
.qchip:hover { border-color: var(--primary); background: var(--primary-soft); }
.qchip:active { transform: scale(.97); }
.line-head strong small { display: block; font-weight: 500; font-size: .74rem; color: var(--muted); margin-top: 2px; }
.iconbtn.danger { color: #c4262c; }
.iconbtn.danger:hover { background: var(--lena-soft); }
.stepper { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 14px; background: #fff; overflow: hidden; }
.stepper input { border: 0; border-radius: 0; text-align: center; min-height: 44px; padding: 6px 2px; background: transparent; box-shadow: none !important; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper button { width: 38px; flex: none; border: 0; background: var(--surface-2); color: var(--ink-2); cursor: pointer; display: grid; place-items: center; }
.stepper button:hover { background: var(--primary-soft); color: var(--primary); }
.stepper button svg { width: 16px; height: 16px; stroke-width: 2.4; }
.stepper:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
.line-grid { grid-template-columns: 1.3fr 1fr 1.1fr; }
.line-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.line-foot .line-amt { margin: 0 0 0 auto; }
.line-warn { font-size: .76rem; font-weight: 700; color: var(--warn); background: var(--warn-soft); padding: 3px 8px; border-radius: 8px; }
.line.flash-in { animation: flashIn .6s ease-out; }
@keyframes flashIn { from { box-shadow: 0 0 0 3px var(--primary-ring); border-color: var(--primary); } }
.card.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.empty.slim { padding: 18px 12px; margin: 12px 0 0; background: var(--surface-2); box-shadow: none; border: 1px dashed var(--border-strong); }
.empty.slim::before { display: none; }
.more-fields { margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 10px; }
.more-fields summary { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--ink-2); list-style: none; padding: 6px 0; }
.more-fields summary::-webkit-details-marker { display: none; }
.more-fields summary svg { width: 18px; height: 18px; color: var(--muted); }
.more-fields summary .muted { margin-left: auto; font-weight: 500; font-size: .84rem; }

/* bottom-sheet dialog (quick add party) */
dialog.sheet { border: 0; padding: 20px; width: min(100vw, 480px); max-width: 100vw; border-radius: 24px; box-shadow: 0 30px 60px -20px rgba(17,24,39,.45); }
dialog.sheet::backdrop { background: rgba(17,24,39,.5); }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.sheet-head h2 { flex: 1; margin: 0; }
@media (max-width: 679px) {
  dialog.sheet { margin: auto 0 0; border-radius: 24px 24px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); animation: up .2s ease-out; }
  @keyframes up { from { transform: translateY(40px); opacity: .5; } }
}

/* toasts */
.toasts { position: fixed; z-index: 100; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; border-radius: 14px; background: var(--ink); color: #fff; font-weight: 600; font-size: .9rem; box-shadow: 0 16px 32px -12px rgba(0,0,0,.45); pointer-events: auto; opacity: 0; transform: translateY(-10px); transition: all .25s; }
.toast.in { opacity: 1; transform: none; }
.toast::before { content: "✓"; width: 22px; height: 22px; border-radius: 50%; background: var(--dena); display: grid; place-items: center; font-size: .75rem; flex: none; }
.toast.error::before { content: "!"; background: var(--lena); }
.toast span { flex: 1; }
.toast-x { border: 0; background: none; color: rgba(255,255,255,.7); font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 0 4px; }

/* loading buttons */
.btn.loading { position: relative; pointer-events: none; opacity: .85; }
.btn.loading::after { content: ""; width: 16px; height: 16px; margin-left: 4px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
#save.loading::after { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* focus that is easy to see for keyboard users */
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid var(--primary-ring); outline-offset: 2px; }

/* shop type choice at sign-up */
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.type-grid input { position: absolute; opacity: 0; pointer-events: none; }
.type-grid label { margin: 0; display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; border: 1px solid var(--border-strong); background: var(--surface); font-weight: 600; font-size: .86rem; cursor: pointer; line-height: 1.25; }
.type-grid label .ic { width: 34px; height: 34px; border-radius: 10px; }
.type-grid label .ic svg { width: 18px; height: 18px; }
.type-grid input:checked + label { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }

@media (min-width: 1024px) {
  details.menu.side { margin: 0 0 12px; }
  details.menu.side > summary { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 14px; }
  details.menu.side > summary:hover { background: var(--surface-2); }
  details.menu.side > summary img { width: 40px; height: 40px; border-radius: 12px; }
  details.menu.side > summary .grow { flex: 1; min-width: 0; }
  details.menu.side > summary strong { display: block; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  details.menu.side > summary small { display: block; font-size: .76rem; }
  details.menu.side .menu-panel { left: 0; transform: none; top: calc(100% + 4px); width: 300px; animation: none; }
  .toasts { top: 20px; left: auto; right: 24px; transform: none; }
}

/* layout safety: grid children may shrink (long chip rows scroll instead of widening the page) */
.bill-layout > *, .dash > *, .card { min-width: 0; }
html, body { overflow-x: clip; }

/* header band: decorations drawn as backgrounds so the band need not clip (menus can drop out of it) */
.appbar {
  overflow: visible;
  background:
    radial-gradient(340px 340px at calc(100% + 40px) -40px, rgba(255,255,255,.16), transparent 70%),
    radial-gradient(260px 260px at -60px calc(100% + 40px), rgba(255,255,255,.10), transparent 70%),
    var(--hero);
}
.appbar::before, .appbar::after { display: none; }
.appbar.menu-open { z-index: 30; }

/* =========================================================
   v5: segmented tabs, filter bar, party header, header actions
   ========================================================= */
/* Tabs (.chips) look like the home range control: a track with a raised selected pill */
.chips {
  display: flex; gap: 4px; width: max-content; max-width: 100%; overflow-x: auto; scrollbar-width: none;
  margin: 0 0 14px; padding: 4px; border-radius: 14px; background: #e6e8f1; border: 1px solid transparent;
}
.chips::-webkit-scrollbar { display: none; }
.chip, .chip.on { flex: none; padding: 9px 16px; border-radius: 10px; border: 0; box-shadow: none; background: transparent; color: var(--muted); font-weight: 700; font-size: .86rem; white-space: nowrap; }
.chip:hover { color: var(--ink); }
.chip.on { background: #fff; color: var(--primary); box-shadow: 0 2px 8px rgba(17,24,39,.08); }
/* on the purple band */
.content.overlap > .chips:first-child, .content.overlap > .flash + .chips, .content.overlap > .error + .chips {
  background: rgba(15, 10, 80, .28); border-color: rgba(255,255,255,.14);
}
.content.overlap > .chips:first-child .chip, .content.overlap > .flash + .chips .chip, .content.overlap > .error + .chips .chip {
  background: transparent; border: 0; color: rgba(255,255,255,.82); box-shadow: none;
}
.content.overlap > .chips:first-child .chip.on, .content.overlap > .flash + .chips .chip.on, .content.overlap > .error + .chips .chip.on {
  background: #fff; color: var(--primary); box-shadow: 0 6px 14px -6px rgba(0,0,0,.35);
}
@media (max-width: 679px) {
  .content.overlap > .chips:first-child { width: 100%; }
  .content.overlap > .chips:first-child .chip { flex: 1; text-align: center; }
}

/* filter bar */
.filters { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; margin-bottom: 14px; display: grid; gap: 10px; }
.filters .searchfield input { background: var(--surface-2); }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fsel { position: relative; flex: 0 1 auto; min-width: 140px; }
.fsel .combo-btn { min-height: 40px; padding: 6px 10px 6px 12px; border-radius: 999px; font-size: .84rem; font-weight: 600; background: var(--surface); border-color: var(--border-strong); }
.fsel.set .combo-btn { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.fsel.date { min-width: 170px; }
.fsel.date > svg { position: absolute; left: 12px; top: 11px; width: 17px; height: 17px; color: var(--primary); z-index: 1; pointer-events: none; }
.fsel.date .combo-btn { padding-left: 36px; }
.fsel .combo-panel { min-width: 220px; right: auto; }
.fdates { display: flex; align-items: center; gap: 6px; }
.fdates input { min-height: 40px; padding: 6px 10px; border-radius: 999px; font-size: .84rem; width: 150px; }
.fclear { display: inline-flex; align-items: center; gap: 4px; padding: 8px 12px; border-radius: 999px; color: #c4262c; text-decoration: none; font-weight: 700; font-size: .82rem; }
.fclear svg { width: 15px; height: 15px; }
.fclear:hover { background: var(--lena-soft); }
@media (max-width: 679px) {
  .filter-bar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px 2px; }
  .filter-bar::-webkit-scrollbar { display: none; }
  .fsel { flex: none; }
  /* the dropdown list must not be cut by the scrolling row */
  .filter-bar .combo-panel { position: fixed; left: 12px !important; right: 12px !important; top: auto; bottom: calc(80px + env(safe-area-inset-bottom)); width: auto; max-width: none; z-index: 60; }
  .fdates input { width: 140px; }
}
.result-summary { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin: 0 4px 10px; font-size: .84rem; color: var(--muted); }
.result-summary b { color: var(--ink); }
.result-summary .amt-lena b { color: var(--lena); }
.result-summary .amt-dena b { color: var(--dena); }
#results { transition: opacity .15s; }
#results.refreshing { opacity: .5; pointer-events: none; }
.dash { margin-bottom: 14px; }

/* header action buttons (Add / Edit) */
.glass-btn.action span { display: none; }
.glass-btn.action { width: 44px; padding: 0; }
@media (min-width: 680px) {
  .glass-btn.action { width: auto; padding: 0 14px; }
  .glass-btn.action span { display: inline; }
}

/* party header: centred identity, then balance */
.avatar.xl { width: 64px; height: 64px; font-size: 1.25rem; margin: 0 auto 10px; }
.party-hero { padding-top: 6px; }
.party-hero .who strong { display: block; font-size: 1.3rem; font-weight: 800; letter-spacing: -.01em; }
.party-hero .who small { display: block; color: rgba(255,255,255,.75); font-size: .85rem; margin-top: 2px; }
.party-hero .tags { display: inline-flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }
.party-hero .tags span { padding: 2px 10px; border-radius: 999px; background: rgba(255,255,255,.16); font-size: .72rem; font-weight: 700; }
.party-hero .label { margin-top: 16px; }
@media (min-width: 1024px) {
  .hero-split .party-hero { display: grid; grid-template-columns: auto 1fr; column-gap: 16px; align-items: center; }
  .hero-split .party-hero .avatar.xl { margin: 0; grid-row: span 1; }
  .hero-split .party-hero .tags { justify-content: flex-start; }
  .hero-split .party-hero .label, .hero-split .party-hero .big, .hero-split .party-hero .limit-bar, .hero-split .party-hero .meta { grid-column: 1 / -1; }
  .hero-split .party-hero .limit-bar { margin-left: 0; }
}

/* tabs on the band: leave room so the whole track sits on the purple */
.appbar.has-hero { padding-bottom: 80px; }
.content.overlap { margin-top: -60px; }
.content.overlap > .chips:first-child { margin-bottom: 18px; }
@media (min-width: 1024px) {
  .appbar.has-hero { padding-bottom: 92px; }
  .content.overlap { margin-top: -68px; }
}
/* party actions: 2 per row on phones, all in one row on wide screens */
.party-actions { grid-template-columns: 1fr 1fr; }
@media (min-width: 1024px) { .party-actions { grid-template-columns: repeat(4, 1fr); } }

/* logo on welcome screens: the icon is already a coloured tile */
.brand-hero .logo { background: none; box-shadow: none; width: 76px; height: 76px; }
.brand-hero .logo img { width: 76px; height: 76px; border-radius: 22px; box-shadow: 0 14px 30px -10px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.18); }
.side-brand img, details.menu.side > summary img { box-shadow: 0 6px 14px -6px rgba(79,70,229,.6); }

/* =========================================================
   Party header (mobile: centred stack; desktop: one row)
   ========================================================= */
.party-head { display: grid; gap: 14px; text-align: center; padding-top: 4px; }
.party-head .who-block { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.party-head .avatar.xl { margin: 0; border: 3px solid rgba(255,255,255,.25); }
.party-head .who strong { display: block; font-size: 1.3rem; font-weight: 800; letter-spacing: -.01em; line-height: 1.2; }
.party-head .who small { display: block; color: rgba(255,255,255,.75); font-size: .85rem; margin-top: 3px; }
.party-head .tags { display: inline-flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }
.party-head .tags span { padding: 3px 10px; border-radius: 999px; background: rgba(255,255,255,.16); font-size: .72rem; font-weight: 700; }
.party-head .tags:empty { display: none; }
.party-head .label { color: rgba(255,255,255,.82); font-size: .9rem; font-weight: 600; }
.party-head .big { font-size: 2.5rem; font-weight: 800; letter-spacing: -.035em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.party-head .limit { max-width: 300px; margin: 8px auto 0; }
.party-head .limit-bar { margin: 0 0 6px; max-width: none; height: 6px; background: rgba(255,255,255,.22); }
.party-head .limit-bar span { background: #fff; }
.party-head .limit-bar.over span { background: #ffb4b6; }
.party-head .meta { color: rgba(255,255,255,.75); font-size: .8rem; }
.party-head .meta b { color: #fff; }
.party-head .hero-strip { margin-top: 4px; }
.hero-strip .v.small { font-size: .98rem; }
.action-card { padding: 12px; }
.action-card .party-actions { margin: 0; }
@media (min-width: 1024px) {
  .party-head { grid-template-columns: minmax(0, 1.15fr) minmax(0, .9fr) minmax(0, 1.35fr); align-items: center; gap: 28px; text-align: left; padding: 8px 0 4px; }
  .party-head .who-block { flex-direction: row; align-items: center; gap: 16px; min-width: 0; }
  .party-head .who { min-width: 0; }
  .party-head .who strong { font-size: 1.45rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .party-head .tags { justify-content: flex-start; }
  .party-head .bal { border-left: 1px solid rgba(255,255,255,.18); padding-left: 28px; }
  .party-head .big { font-size: 2.4rem; }
  .party-head .limit { margin: 8px 0 0; }
  .party-head .hero-strip { margin: 0; }
  .action-card { padding: 14px; }
  .action-card .party-actions .btn.big { min-height: 50px; }
}
@media (min-width: 1024px) { .party-actions { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); } }

/* udhaar options on a walk-in bill: look locked but stay tappable (tap explains + offers to add a party) */
.toggle.locked { opacity: .55; border-style: dashed; background: var(--surface-2); }
.toggle.locked:hover { opacity: .8; border-color: var(--primary); }
.toggle.locked svg { color: var(--muted); }

/* header without the user avatar: shop menu on the left, bell on the right */
.appbar-row.home { justify-content: space-between; }
.appbar-row.home details.menu.pill > summary { max-width: min(72vw, 460px); }
.appbar-row.home .menu-panel { left: 0; transform: none; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } }
.party-head .who-block { gap: 0; }
.side-user { padding-left: 12px; }

/* =========================================================
   Admin (client onboarding)
   ========================================================= */
body.admin { background: var(--bg); }
.admin-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; background: var(--hero); color: #fff; }
.admin-brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.admin-brand img { width: 38px; height: 38px; border-radius: 11px; box-shadow: 0 0 0 1px rgba(255,255,255,.25); }
.admin-brand strong { display: block; font-size: 1rem; }
.admin-brand small { display: block; color: rgba(255,255,255,.75); font-size: .74rem; }
.admin-top nav { display: flex; align-items: center; gap: 8px; }
.admin-top nav > a:not(.btn) { color: rgba(255,255,255,.85); text-decoration: none; font-weight: 600; font-size: .9rem; padding: 8px 12px; border-radius: 10px; }
.admin-top nav > a.on { background: rgba(255,255,255,.16); color: #fff; }
.admin-top .btn.primary { background: #fff; color: var(--primary); border-color: #fff; box-shadow: none; }
.admin-top .btn.ghost { color: #fff; }
.admin-wrap { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
.admin-wrap.narrow { max-width: 760px; }
.admin-wrap h1 { margin: 6px 0 4px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .88rem; text-decoration: none; margin-bottom: 8px; }
.back-link svg { width: 16px; height: 16px; }
.link-row { cursor: pointer; }
.link-row:hover td { background: var(--surface-2); }
.created { border: 2px solid #abefc6; }
.created h2 { color: var(--dena); }
.created h2 svg { width: 22px; height: 22px; }
.cred { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 10px 0; }
.cred div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.cred span { color: var(--muted); font-size: .86rem; }
.cred strong { font-variant-numeric: tabular-nums; word-break: break-all; text-align: right; }
.welcome-text { white-space: pre-wrap; background: var(--surface-2); border-radius: 12px; padding: 12px; font-family: inherit; font-size: .84rem; color: var(--ink-2); margin: 12px 0 0; }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.checklist li { padding: 10px 12px 10px 40px; border-radius: 12px; background: var(--surface-2); position: relative; font-size: .92rem; }
.checklist li::before { content: ""; position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; margin-top: -9px; border-radius: 50%; border: 2px solid var(--border-strong); }
.checklist li.done { color: var(--ink); }
.checklist li.done::before { background: var(--dena); border-color: var(--dena); box-shadow: inset 0 0 0 3px #fff; }
@media (max-width: 679px) { .admin-top nav > a:not(.btn) { display: none; } .admin-brand small { display: none; } }
/* admin pages use their own width (top bar full-bleed) */
body.admin .content { max-width: none; padding: 0; }
body.admin .admin-top { padding: 12px max(20px, calc((100vw - 1100px) / 2 + 16px)); }

/* home: custom date range in the band */
.seg-range a svg { width: 15px; height: 15px; vertical-align: -2px; margin-right: 4px; }
.seg-range { max-width: 560px; }
.custom-range {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-top: 12px; padding: 12px;
  border-radius: 16px; background: rgba(15, 10, 80, .28); border: 1px solid rgba(255,255,255,.14);
}
.custom-range label { margin: 0; flex: 1; min-width: 140px; color: rgba(255,255,255,.82); font-size: .78rem; font-weight: 600; }
.custom-range label span { display: block; margin-bottom: 4px; }
.custom-range input { min-height: 44px; background: #fff; border-color: transparent; font-size: .95rem; }
.custom-range .btn { min-height: 44px; background: #fff; color: var(--primary); border-color: #fff; }
@media (max-width: 679px) {
  .seg-range a { padding: 9px 6px; font-size: .8rem; }
  .seg-range a svg { display: none; }
  .custom-range .btn { flex-basis: 100%; }
}
@media (min-width: 680px) { .custom-range { max-width: 560px; } }

/* settings: language choice */
.lang-card h2 svg { width: 20px; height: 20px; color: var(--primary); }
.lang-pills { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.lang-pills input { position: absolute; opacity: 0; pointer-events: none; }
.lang-pills label { margin: 0; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; transition: all .15s; }
.lang-pills label strong { font-size: 1.05rem; color: var(--ink); }
.lang-pills label small { font-size: .74rem; font-weight: 500; }
.lang-pills label:hover { border-color: var(--primary); }
.lang-pills input:checked + label { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.lang-pills input:checked + label strong { color: var(--primary); }
.lang-pills input:focus-visible + label { box-shadow: 0 0 0 4px var(--primary-ring); }

/* =========================================================
   Bill preview / print
   ========================================================= */
body.print-page { background: #e9ebf2; padding: 0 0 40px; }
.print-bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  max-width: none; margin: 0 0 24px; padding: 10px max(16px, calc((100vw - 820px) / 2));
  background: rgba(255,255,255,.96); border-bottom: 1px solid var(--border);
}
.print-bar .print-title { flex: 1; font-weight: 700; color: var(--ink-2); }
.print-bar .btn { min-height: 44px; }
body.print-page .invoice { background: #fff; border-radius: 6px; box-shadow: 0 10px 30px -12px rgba(17,24,39,.25); padding: 32px; margin: 0 auto; max-width: 800px; font-family: "Plus Jakarta Sans", "Noto Sans Devanagari", "Noto Sans Gurmukhi", system-ui, sans-serif; }
@media (max-width: 679px) { body.print-page .invoice { margin: 0 12px; padding: 18px; font-size: 13px; } }
@media print {
  body.print-page { background: #fff; padding: 0; }
  body.print-page .invoice { box-shadow: none; border-radius: 0; margin: 0; max-width: none; padding: 0; }
}
@media (max-width: 679px) {
  body.print-page .invoice .inv-head { flex-direction: column; gap: 8px; }
  body.print-page .invoice .inv-head > div:last-child { text-align: left !important; display: flex; gap: 14px; flex-wrap: wrap; }
  body.print-page .invoice .inv-head > div:last-child > div { white-space: nowrap; }
}

/* GSTIN check result */
.gst-info { margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: .84rem; display: grid; gap: 2px; }
.gst-info .gst-title { font-weight: 700; color: var(--ink-2); }
.gst-info .gst-name { font-weight: 700; font-size: .95rem; color: var(--ink); }
.gst-info .gst-sub { color: var(--muted); }
.gst-info .gst-note { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.gst-info .gst-warn { color: var(--warn); font-weight: 700; }
.gst-info a { font-weight: 700; text-decoration: none; }
.gst-info.good { background: var(--dena-soft); border-color: #abefc6; }
.gst-info.good .gst-title { color: #0b7a3b; }
.gst-info.bad { background: var(--lena-soft); border-color: #f7c2c4; }
.gst-info.bad .gst-title { color: #c4262c; }
.gst-info.warn { background: var(--warn-soft); border-color: #fde1b8; }
.gst-info.warn .gst-title { color: #8a3d00; }
.results li.gst-row { align-items: flex-start; }
.results li.gst-row .gst-info { margin: 0; flex: 1; }
.items-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* return form */
.ret-line { padding: 12px; border: 1px solid var(--border); border-radius: 14px; margin-top: 10px; background: var(--surface-2); transition: border-color .15s, background .15s; }
.ret-line.picked-line { border-color: var(--primary); background: var(--primary-soft); }
.ret-line.done { opacity: .55; }
.ret-head { display: flex; justify-content: space-between; gap: 10px; }
.ret-head strong { font-size: .95rem; }
.ret-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; font-size: .78rem; color: var(--muted); }
.ret-meta b { color: var(--ink-2); }
.ret-qty { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.ret-qty .stepper { width: 150px; flex: none; }
.ret-qty .ret-amt { margin-left: auto; font-weight: 800; }

/* =========================================================
   Bill lines: compact cards, round + / − buttons
   ========================================================= */
#lines .line { padding: 10px 12px; margin-top: 8px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-xs); }
.line-top { display: flex; align-items: flex-start; gap: 10px; }
.line-name { flex: 1; min-width: 0; }
.line-name strong { display: block; font-size: .95rem; font-weight: 700; line-height: 1.3; }
.line-name small { display: block; font-size: .72rem; color: var(--muted); margin-top: 1px; }
.line-top .line-amt { margin: 0; font-size: 1rem; font-weight: 800; white-space: nowrap; padding-top: 1px; }
.line-del { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.line-del svg { width: 15px; height: 15px; stroke-width: 2.4; }
.line-del:hover { background: var(--lena-soft); color: #c4262c; }
.line-ctrl { display: grid; grid-template-columns: auto minmax(86px, 1fr) minmax(96px, 1.2fr); gap: 8px; margin-top: 8px; align-items: center; }
.qty-step { display: flex; align-items: center; gap: 6px; }
.qty-step button { width: 36px; height: 36px; flex: none; border-radius: 50%; border: 0; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; cursor: pointer; transition: transform .08s, background .15s; }
.qty-step button:hover { background: #dfe2ff; }
.qty-step button:active { transform: scale(.92); }
.qty-step button[data-act="inc"] { background: var(--primary); color: #fff; }
.qty-step button svg { width: 17px; height: 17px; stroke-width: 2.6; }
.qty-step input { width: 58px; min-height: 38px; padding: 4px; text-align: center; font-weight: 800; font-size: 1rem; border-radius: 10px; -moz-appearance: textfield; }
.qty-step input::-webkit-outer-spin-button, .qty-step input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.unit-f .combo-btn { min-height: 38px; padding: 4px 10px; border-radius: 10px; font-size: .86rem; font-weight: 700; background: var(--surface-2); }
.rate-f { position: relative; margin: 0; display: block; }
.rate-f span { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; font-size: .9rem; pointer-events: none; }
.rate-f input { min-height: 38px; padding: 4px 10px 4px 24px; border-radius: 10px; font-weight: 700; }
#lines .line-warn { display: inline-block; margin-top: 6px; }
#lines .line-warn[hidden] { display: none; }
/* search results and quick buttons: obvious + */
.results li .add-plus { width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; }
.results li .add-plus svg { width: 16px; height: 16px; stroke-width: 2.6; }
.qchip { flex-direction: row; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; }
.qchip .qplus { width: 26px; height: 26px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; }
.qchip .qplus svg { width: 14px; height: 14px; stroke-width: 2.8; }
.qchip .qtext { display: flex; flex-direction: column; line-height: 1.2; }
/* stock form: units as capital-letter buttons */
.unit-pills label { padding: 8px 14px; font-weight: 800; letter-spacing: .04em; font-size: .82rem; }
.unit-other, .unit-text { text-transform: uppercase; }

/* bill lines: fit any card width (phone, and the narrow left column on desktop) */
.line-ctrl { grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); }
.qty-step { gap: 4px; }
.qty-step button { width: 34px; height: 34px; }
.qty-step input { width: 48px; }
.rate-f input, .unit-f .combo-btn { width: 100%; min-width: 0; }
.unit-f, .rate-f { min-width: 0; }
/* return form */
.ret-qty .stepper { width: 128px; }
.ret-qty .btn.sm { white-space: nowrap; padding: 0 10px; }
.ret-qty .ret-amt { font-size: .92rem; }
.edit-banner { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,.95); color: var(--ink); font-weight: 600; font-size: .9rem; box-shadow: var(--shadow); }
.edit-banner svg { width: 18px; height: 18px; color: var(--primary); flex: none; }
.edit-banner span { flex: 1; }
.edit-banner a { font-weight: 700; text-decoration: none; }

/* =========================================================
   Reports
   ========================================================= */
.report-tabs .chip svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: 6px; }
.bt-switch { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; font-size: .84rem; }
.bt-switch a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); text-decoration: none; font-weight: 600; }
.bt-switch a.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.bt-switch .cmp-note { margin-left: auto; font-size: .78rem; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 14px; }
@media (min-width: 680px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); text-decoration: none; color: var(--ink); min-width: 0; border: 1px solid rgba(231,233,240,.7); }
a.kpi:hover { box-shadow: 0 1px 2px rgba(17,24,39,.04), 0 14px 30px -14px rgba(17,24,39,.22); }
.kpi.warn { background: var(--warn-soft); border-color: #fde1b8; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.kpi-top .chev { width: 16px; height: 16px; color: #b8bdc9; }
.kpi-label { font-size: .78rem; color: var(--muted); font-weight: 600; line-height: 1.3; }
.kpi-value { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.kpi-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .74rem; color: var(--muted); font-weight: 600; }
.delta { padding: 1px 7px; border-radius: 999px; font-weight: 800; font-size: .72rem; }
.delta.good { background: var(--dena-soft); color: #0b7a3b; }
.delta.bad { background: var(--lena-soft); color: #c4262c; }
.h-ic { width: 18px; height: 18px; color: var(--primary); vertical-align: -3px; margin-right: 6px; }
.insights { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.insights a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); text-decoration: none; color: var(--ink); font-size: .9rem; font-weight: 600; line-height: 1.35; }
.insights .ins-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--t-indigo); color: var(--i-indigo); }
.insights .ins-ic svg { width: 18px; height: 18px; }
.insights li.good .ins-ic { background: var(--t-green); color: var(--i-green); }
.insights li.bad .ins-ic { background: var(--t-pink); color: var(--i-pink); }
.insights li.warn .ins-ic { background: var(--t-amber); color: var(--i-amber); }
.insights .chev { width: 16px; height: 16px; color: #b8bdc9; flex: none; }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.rank a { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-radius: 10px; text-decoration: none; color: var(--ink); }
.rank a:hover { background: var(--surface-2); }
.rank-n { width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; font-size: .78rem; font-weight: 800; flex: none; }
.rank li:nth-child(-n+3) .rank-n { background: var(--primary-soft); color: var(--primary); }
.rank .grow { flex: 1; min-width: 0; }
.rank .grow strong { display: block; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank .grow small { display: block; font-size: .74rem; color: var(--muted); }
.rank-bar { display: block; height: 5px; border-radius: 99px; background: #eef0f5; margin-top: 5px; overflow: hidden; }
.rank-bar span { display: block; height: 100%; border-radius: 99px; background: #2a78d6; }
.rank-bar span.neg { background: var(--lena); }
.rank .num.right { display: flex; flex-direction: column; align-items: flex-end; flex: none; font-size: .9rem; }
.rank .num.right small { font-size: .72rem; color: var(--muted); }
.actions.four { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 680px) { .actions.four { grid-template-columns: repeat(4, 1fr); } }
.alert-strip a { margin-left: auto; font-weight: 700; white-space: nowrap; }
.bar-key:empty { width: 14px; height: 14px; border-radius: 4px; background: var(--c); margin: 0 10px; }
.bar-name { white-space: normal; line-height: 1.25; }
/* range buttons: scroll sideways on phones instead of spilling off screen */
@media (max-width: 679px) {
  .seg-range { display: flex; overflow-x: auto; scrollbar-width: none; }
  .seg-range::-webkit-scrollbar { display: none; }
  .seg-range a { flex: 1 0 auto; }
}
