/* ===== Brand + sync pill ===== */
.brand { font: 600 20px/1 var(--font-ui); letter-spacing: -.02em; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--muted);
  font: 400 11px var(--font-num);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill[data-state="synced"] { color: var(--ok); }
.pill[data-state="syncing"] { color: var(--canada); }
.pill[data-state="offline"] { color: var(--over); }

/* ===== Budget ===== */
.budget { display: grid; gap: 8px; min-width: 0; }
.budget__row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.budget__main { font-size: 24px; font-weight: 500; letter-spacing: -.02em; }
.budget__sub { color: var(--muted); font-size: 12px; }
.bar { position: relative; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; transition: width .9s var(--ease); }
.bar__plan { background: rgba(111, 211, 255, .28); }
.bar__spent { background: linear-gradient(90deg, var(--india), var(--canada)); }
.bar[data-over] .bar__spent { background: var(--over); }

/* ===== Category chips ===== */
.cat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
  transition: color var(--t), background var(--t), border-color var(--t);
}
.cat small { margin-left: auto; font: 400 12px var(--font-num); opacity: .6; }
.cat[aria-pressed="true"] { color: var(--text); background: var(--surface-2); border-color: rgba(255, 255, 255, .22); }
@media (min-width: 900px) {
  .cat { border-color: transparent; background: none; }
  .cat[aria-pressed="true"] { border-color: var(--line); }
}

/* ===== Country switch ===== */
.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: rgba(19, 19, 26, .88);
  backdrop-filter: blur(16px);
}
.seg button { padding: 9px 20px; border-radius: 99px; color: var(--muted); transition: background var(--t), color var(--t); }
.seg button[aria-pressed="true"] { background: var(--text); color: #000; font-weight: 500; }
.seg button[data-v="india"][aria-pressed="true"] { background: var(--india); }
.seg button[data-v="canada"][aria-pressed="true"] { background: var(--canada); }

/* ===== Add form ===== */
.add { display: flex; gap: 8px; margin-bottom: 20px; }
.add input {
  flex: 1;
  min-width: 0;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.add input::placeholder { color: var(--muted); }
.btn { padding: 0 22px; border-radius: var(--r-sm); background: var(--text); color: #000; font-weight: 500; }

/* ===== Item groups ===== */
.group { margin-bottom: 26px; }
.group h2 { display: flex; justify-content: space-between; margin-bottom: 8px; padding: 0 4px; color: var(--muted); font-size: 14px; font-weight: 500; }
.group ul { display: grid; gap: 8px; }

/* ===== Item card ===== */
.item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); transition: opacity var(--t), border-color var(--t); }
.item:hover { border-color: rgba(255, 255, 255, .16); }
.item[data-done] { opacity: .55; }
.item[data-done] .item__name { color: var(--muted); text-decoration: line-through; }
.item__main { display: flex; align-items: center; gap: 12px; min-width: 0; cursor: pointer; }
.tile { flex: none; display: grid; place-items: center; width: 48px; height: 48px; overflow: hidden; border-radius: 12px; background: var(--surface-2); font-size: 22px; object-fit: cover; }
.item__name { display: block; font-weight: 500; overflow-wrap: anywhere; }
.item__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 3px; color: var(--muted); font-size: 12px; }
.item__meta a { color: var(--canada); text-decoration: none; }
.item__meta a:hover { text-decoration: underline; }
.tag { padding: 1px 8px; border: 1px solid var(--line); border-radius: 99px; font-size: 11px; }
.tag--qty { background: var(--surface-2); color: var(--text); }
.tag--opt { border-style: dashed; }
.item__side { display: grid; justify-items: end; gap: 6px; }
.item__price { text-align: right; line-height: 1.35; }
.item__price small { display: block; color: var(--muted); font-size: 11px; }
.p-main { display: block; font-size: 16px; }
.p-main.muted { color: var(--muted); font-size: 12px; }
.p-main[data-d="under"] { color: var(--ok); }
.p-main[data-d="over"] { color: var(--over); }

.flag { padding: 3px 8px; border: 1px solid currentColor; border-radius: 99px; font: 400 10px var(--font-num); letter-spacing: .04em; }
.flag[data-c="india"] { color: var(--india); }
.flag[data-c="canada"] { color: var(--canada); }
.flag[data-c="either"] { color: var(--muted); }

/* ===== Check ===== */
.check { display: grid; place-items: center; width: 28px; height: 28px; border: 1.5px solid rgba(255, 255, 255, .25); border-radius: 50%; transition: background var(--t), border-color var(--t); }
.check svg { width: 16px; height: 16px; fill: none; stroke: #000; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .3s var(--ease) .05s; }
.check[aria-checked="true"] { background: var(--ok); border-color: var(--ok); }
.check[aria-checked="true"] svg { stroke-dashoffset: 0; }
.empty { padding: 56px 0; color: var(--muted); text-align: center; }

/* ===== Header tools ===== */
.top__tools { display: flex; align-items: center; gap: 10px; }
.gear { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); font-size: 16px; transition: color var(--t); }
.gear:hover { color: var(--text); }

/* ===== Sheet ===== */
.sheet { width: 100%; max-width: 100%; max-height: 92dvh; margin: auto 0 0; padding: 0; overflow: auto; border: 1px solid var(--line); border-radius: 20px 20px 0 0; background: var(--surface); color: var(--text); scrollbar-width: thin; }
.sheet::backdrop { background: rgba(0, 0, 0, .72); backdrop-filter: blur(4px); }
.sheet[open] { animation: sheet .3s var(--ease); }
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
.sheet form { display: grid; gap: 18px; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); }
.sheet h3 { font-size: 18px; font-weight: 600; }
.fld { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
.fld > input, .fld > textarea { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); color: var(--text); font-size: 16px; resize: vertical; }
.fld > input:focus, .fld > textarea:focus { border-color: var(--canada); outline: none; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.hint { min-height: 1.2em; color: var(--muted); font: 400 12px var(--font-num); }

input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { appearance: none; margin: 0; }

/* ===== Segmented + chips ===== */
.opts { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.opts label { flex: 1; }
.opts input, .chips input { position: absolute; opacity: 0; pointer-events: none; }
.opts span { display: block; padding: 10px; border-radius: 9px; color: var(--muted); text-align: center; cursor: pointer; transition: background var(--t), color var(--t); }
.opts input:checked + span { background: var(--text); color: #000; font-weight: 500; }
.opts input[value="india"]:checked + span, .opts input[value="INR"]:checked + span { background: var(--india); }
.opts input[value="canada"]:checked + span, .opts input[value="CAD"]:checked + span { background: var(--canada); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips span { display: block; padding: 9px 14px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface-2); color: var(--muted); cursor: pointer; transition: background var(--t), color var(--t); }
.chips input:checked + span { background: var(--text); color: #000; font-weight: 500; }
.opts label:focus-within span, .chips label:focus-within span { outline: 2px solid var(--canada); }

/* ===== Money, stepper, switch ===== */
.money { display: flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.money:focus-within { border-color: var(--canada); }
.money b { padding-left: 14px; color: var(--muted); font-weight: 400; }
.money input { flex: 1; min-width: 0; padding: 12px 14px 12px 8px; border: 0; background: none; color: var(--text); font: 400 16px var(--font-num); outline: none; }
.step { display: flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.step button { flex: none; width: 44px; height: 46px; color: var(--text); font-size: 20px; }
.step input { flex: 1; min-width: 0; width: 100%; border: 0; background: none; color: var(--text); font: 400 16px var(--font-num); text-align: center; outline: none; }
.sw { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); color: var(--text); cursor: pointer; }
.sw small { display: block; color: var(--muted); font-size: 12px; }
.sw input { position: absolute; opacity: 0; pointer-events: none; }
.sw i { position: relative; flex: none; width: 44px; height: 26px; border-radius: 99px; background: #2a2a35; transition: background var(--t); }
.sw i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform var(--t) var(--ease); }
.sw input:checked + i { background: var(--ok); }
.sw input:checked + i::after { transform: translateX(18px); }
.sw input:focus-visible + i { outline: 2px solid var(--canada); }

/* ===== Photo ===== */
.pickrow { display: flex; align-items: stretch; gap: 8px; }
.pick { display: flex; flex: 1; align-items: center; gap: 12px; padding: 10px; border: 1px dashed rgba(255, 255, 255, .22); border-radius: var(--r-sm); color: var(--text); cursor: pointer; }
.pick input { display: none; }
.pick img, .pick .ph { flex: none; width: 56px; height: 56px; border-radius: 10px; object-fit: cover; }
.pick .ph { display: grid; place-items: center; background: var(--surface-2); font-size: 22px; }
.x { padding: 0 12px; color: var(--over); font-size: 13px; }

/* ===== Actions ===== */
.acts { display: flex; gap: 10px; }
.acts .btn { flex: 1; padding: 14px; }
.btn--ghost { border: 1px solid var(--line); background: var(--surface-2); color: var(--text); }
.btn--danger { color: var(--over); }
@media (min-width: 900px) { .sheet { max-width: 520px; margin: auto; border-radius: 20px; } }

/* ===== Toolbar ===== */
.toolbar { display: grid; gap: 12px; margin-bottom: 20px; }
.toolbar .add { margin: 0; }
.fchips { display: flex; gap: 6px; }
.fchips button { padding: 8px 16px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); transition: background var(--t), color var(--t); }
.fchips button[aria-pressed="true"] { background: var(--text); color: #000; font-weight: 500; }
.fchips button[data-v="india"][aria-pressed="true"] { background: var(--india); }
.fchips button[data-v="canada"][aria-pressed="true"] { background: var(--canada); }
body[data-mode="pack"] #country { display: none; }
.cat--edit { border-style: dashed; }
.flag[data-c="own"] { color: var(--ok); }

/* ===== Category editor ===== */
.clist { display: grid; gap: 8px; }
.crow { display: flex; gap: 8px; }
.crow input { min-width: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); color: var(--text); font-size: 16px; outline: none; }
.crow input:focus { border-color: var(--canada); }
.emo { width: 68px; text-align: center; }
.cname { flex: 1; }
.strip { display: flex; flex-wrap: wrap; gap: 6px; }
.strip button { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-2); font-size: 20px; }
.strip button:hover { background: #1d1d27; }

/* ===== Sheet layout ===== */
.cols, .col, .buy { display: grid; gap: 18px; }
.col { align-content: start; }
.is-owned .buy { display: none; }
.fld .btn { padding: 14px; }
.filebtn { display: grid; place-items: center; padding: 14px; cursor: pointer; }

/* ===== Landscape (desktop) ===== */
@media (min-width: 900px) {
  .main { max-width: 1200px; }
  .toolbar { grid-template-columns: auto 1fr; align-items: center; gap: 20px; }
  .toolbar .add { justify-self: end; width: 100%; max-width: 460px; }
  .group ul { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
  .sheet--wide { max-width: 920px; }
  .sheet--wide .cols { grid-template-columns: 1fr 1fr; gap: 32px; }
  .sheet--wide .acts { justify-content: flex-end; }
  .sheet--wide .acts .btn { flex: none; min-width: 150px; }
}

/* ===== Column balance ===== */
.fld.buy { gap: 7px; }
.step, .fld > input { min-height: 50px; }
