/* Colours follow HisabBD's "Padma Teal" palette (hisabbd/src/app/globals.css) so both apps read as one brand. */
:root {
  --bg: #f8fafc; --card: #ffffff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #0b6e6e; --brand-ink: #ffffff; --brand-soft: #eef5f5; --brand-strong: #074646;
  --accent: #ef8a00; --sun: #ffd66b; --danger: #dc2626;
  --bar: #237d7d; --bar-bg: #dae9e9; --grid: rgb(11 110 110 / 0.07);
  --shadow: 0 10px 24px -12px rgb(15 23 42 / 0.18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121b1c; --card: #172324; --ink: #ebf0f0; --muted: #8a9c9e; --line: #283a3c;
    --brand: #11a6a6; --brand-ink: #121b1c; --brand-soft: #162d2d; --brand-strong: #62dddd;
    --accent: #ecb851; --sun: #7a5a12; --danger: #f0675a;
    --bar: #11a6a6; --bar-bg: #1f3d3d; --grid: rgb(128 180 180 / 0.06);
    --shadow: 0 10px 24px -12px rgb(0 0 0 / 0.7); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121b1c; --card: #172324; --ink: #ebf0f0; --muted: #8a9c9e; --line: #283a3c;
  --brand: #11a6a6; --brand-ink: #121b1c; --brand-soft: #162d2d; --brand-strong: #62dddd;
  --accent: #ecb851; --sun: #7a5a12; --danger: #f0675a;
  --bar: #11a6a6; --bar-bg: #1f3d3d; --grid: rgb(128 180 180 / 0.06);
  --shadow: 0 10px 24px -12px rgb(0 0 0 / 0.7); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Bengali', sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
h1, h2 { margin: 0; font-weight: 700; font-family: 'Anek Bangla', system-ui, sans-serif; font-variation-settings: 'wdth' 110; letter-spacing: -.01em; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
::selection { background: var(--sun); }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.05rem; margin-bottom: .5rem; }
.muted { color: var(--muted); font-size: .9rem; margin: .25rem 0 .75rem; }
.hidden { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: .6rem 16px; min-height: 60px; color: var(--ink); border-bottom: 1px solid var(--line);
  background-color: var(--card);
  background-image: linear-gradient(to right, var(--grid) 1px, transparent 1px), linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand svg { flex: none; width: 36px; height: 36px; }
.brand h1 { font-size: 1.35rem; line-height: 1.1; }
.brand h1 em { font-style: normal; color: var(--brand); }
.brand .by { display: block; font-size: .72rem; color: var(--muted); font-weight: 500; letter-spacing: .01em; text-decoration: none; }
.brand .by:hover { color: var(--brand); text-decoration: underline; }
.sync { font-size: .78rem; color: var(--muted); cursor: pointer; white-space: nowrap; }
.lang-btn { font: inherit; font-size: .8rem; font-weight: 600; margin-left: 10px; padding: .15rem .6rem; border-radius: 999px;
  border: 2px solid var(--ink); background: var(--card); color: var(--ink); cursor: pointer; min-width: 44px; min-height: 36px; }
.lang-btn:hover { background: var(--sun); }
.seg { display: inline-flex; margin-top: 6px; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { font: inherit; font-size: .78rem; border: 0; background: transparent; color: var(--muted); padding: .15rem .7rem; cursor: pointer; }
.seg button.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
#micState.err { color: var(--danger); font-weight: 500; }
.tabs button b { font-weight: inherit; }
main { max-width: 760px; margin: 0 auto; padding: 12px 16px; }
.tab { display: none; }
.tab.active { display: block; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card.danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; margin-top: 0; }
.spacer { flex: 1; }

.btn {
  font: inherit; border-radius: 10px; padding: .55rem .9rem; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer; min-height: 44px; font-weight: 600;
}
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.file { display: inline-flex; align-items: center; }
.btn:disabled { opacity: .5; }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: .55rem .7rem; min-height: 48px; width: 100%;
}
textarea { resize: vertical; margin-top: 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; }
.field { display: block; font-size: .9rem; color: var(--muted); }
.field input { margin-top: 4px; }
.chk { display: inline-flex; gap: 6px; align-items: center; font-size: .9rem; white-space: nowrap; }
.chk input { width: auto; min-height: 0; }

/* mic */
.mic-row { display: flex; gap: 14px; align-items: center; }
.mic {
  flex: none; width: 76px; height: 76px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); display: grid; place-items: center;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 35%, transparent);
}
.mic.on { background: var(--danger); }
@media (prefers-reduced-motion: no-preference) { .mic.on { animation: pulse 1.2s infinite; } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.07); } }
.mic { position: relative; }
.mic-help strong { font-family: 'Anek Bangla', system-ui, sans-serif; font-variation-settings: 'wdth' 105; }
.mic-help small { display: block; color: var(--muted); }

/* preview lines */
.preview-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-field { display: flex; align-items: center; gap: 6px; font-size: .9rem; }
.date-field input { width: auto; }
.pv-line { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-top: 10px; position: relative; }
.pv-line.unknown { border-color: var(--accent); }
.pv-line .raw { font-size: .8rem; color: var(--muted); margin-bottom: 6px; padding-right: 30px; }
.pv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pv-grid .full { grid-column: 1 / -1; }
.pv-grid label { font-size: .78rem; color: var(--muted); display: block; }
.pv-grid .qty { display: grid; grid-template-columns: 1fr 84px; gap: 6px; }
.pv-line .x { position: absolute; top: 6px; right: 6px; border: 0; background: none; font-size: 1.2rem; color: var(--muted); cursor: pointer; }
.tag { display: inline-block; font-size: .72rem; padding: 0 .45rem; border-radius: 99px; background: var(--brand-soft); color: var(--brand); }
.tag.warn { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }

/* lists */
.list .li, .hs-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list .li:last-child { border-bottom: 0; }
.li .grow, .hs-row .grow { flex: 1; min-width: 0; }
.li .path, .hs-row .path { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amt { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.icon-btn { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 4px 6px; }
.hs-day { margin: 14px 0 4px; display: flex; justify-content: space-between; font-weight: 600; color: var(--muted); font-size: .9rem; }
.hs-group { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0 12px; }
.hs-row { cursor: pointer; }
.hs-row:last-child { border-bottom: 0; }

/* report */
.controls { display: flex; gap: 10px; align-items: center; }
.controls > select, .controls > input { flex: 1; min-width: 0; width: auto; }
.controls .chk { flex: none; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow); }
.kpi:first-child { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.kpi:first-child span { color: inherit; opacity: .85; }
.kpi b { display: block; font-size: 1.4rem; font-variant-numeric: tabular-nums; font-family: 'Anek Bangla', system-ui, sans-serif; font-variation-settings: 'wdth' 110; }
.kpi span { font-size: .82rem; color: var(--muted); }
.kpi .up { color: var(--danger); } .kpi .down { color: var(--brand); }
.kpi:first-child .up, .kpi:first-child .down { color: inherit; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(4, 1fr); } }

.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 8px; font-size: .95rem; }
.crumbs button { font: inherit; border: 0; background: none; color: var(--brand); cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.crumbs button:last-child { color: var(--ink); font-weight: 600; cursor: default; }
.crumbs .sep { color: var(--muted); }
.bar-row { display: block; width: 100%; text-align: left; font: inherit; color: inherit; border: 0; background: none; padding: 7px 0; cursor: pointer; }
.bar-row[disabled] { cursor: default; }
.bar-top { display: flex; justify-content: space-between; gap: 8px; }
.bar-top .name { font-weight: 500; }
.bar-top .name small { color: var(--muted); font-weight: 400; }
.bar-track { height: 10px; background: var(--bar-bg); border-radius: 6px; margin-top: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--bar); border-radius: 6px; }
.bar-row:not([disabled]) .name::after { content: ' ›'; color: var(--muted); }

.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl th:first-child, .tbl td:first-child { text-align: left; white-space: normal; }
.tbl th { color: var(--muted); font-weight: 500; font-size: .82rem; }
.tbl td small { color: var(--muted); display: block; }

.daily { display: flex; align-items: flex-end; gap: 2px; height: 120px; }
.daily .d { flex: 1; background: var(--bar); border-radius: 3px 3px 0 0; min-height: 1px; position: relative; }
.daily .d.zero { background: var(--bar-bg); }
.daily-axis { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-top: 4px; }

.staples { display: grid; gap: 10px; }
.staple { border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.staple .head { display: flex; justify-content: space-between; gap: 8px; }
.staple .meta { font-size: .85rem; color: var(--muted); }
.staple .soon { color: var(--accent); font-weight: 600; }

/* tree in settings */
.tree ul { list-style: none; margin: 0; padding-left: 18px; border-left: 1px dashed var(--line); }
.tree > ul { padding-left: 0; border: 0; }
.tree li { margin: 2px 0; }
.tree button { font: inherit; background: none; border: 0; color: var(--ink); cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.tree button:hover { background: var(--brand-soft); }
.tree small { color: var(--muted); }

/* nav */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 10;
}
.tabs button { flex: 1; font: inherit; font-size: .8rem; border: 0; background: none; color: var(--muted); padding: 8px 0 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; }
.tabs button span { font-size: 1.25rem; line-height: 1.2; }
.tabs button.active { color: var(--brand); font-weight: 700; }
.tabs button.active span { transform: translateY(-1px); }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink); width: min(520px, calc(100% - 32px)); padding: 16px; }
dialog::backdrop { background: rgba(0,0,0,.4); }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: .55rem 1rem; border-radius: 10px; transition: .25s; z-index: 20; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.empty { text-align: center; color: var(--muted); padding: 18px 0; }

/* chips, welcome, budgets */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; font: inherit; font-size: .88rem; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 99px; padding: .25rem .75rem; cursor: pointer; }
.chip:hover { background: var(--brand-soft); border-color: var(--brand); }
.welcome { border-color: var(--brand); background: linear-gradient(135deg, var(--brand-soft), var(--card)); }
.budgets { display: grid; gap: 8px; }
.budget-row { display: grid; grid-template-columns: 1fr 140px; align-items: center; gap: 10px; }
.input-card textarea { font-size: 1.05rem; }
#hsMonth { flex: 0 0 44%; }
.setup { border: 1px dashed var(--line); border-radius: 10px; padding: 8px 10px; }
.setup summary { cursor: pointer; color: var(--brand); font-weight: 500; }
.setup[open] summary { margin-bottom: 4px; }
