:root {
  --bg: #F4F7F6; --card: #FFFFFF; --text: #13201D; --muted: #5F6F6B; --line: #DDE5E3;
  --brand: #0E7C66; --brand-dark: #0B3D33; --waste: #D9480F; --over: #C92A2A; --need: #2B8A3E; --unk: #7048E8;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0D1513; --card: #16211E; --text: #E7EFEC; --muted: #9AABA6; --line: #26332F; --brand: #20A386; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
.top { position: sticky; top: 0; z-index: 5; background: var(--brand-dark); color: #fff; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.site-card { display: block; margin: 20px 0 8px; padding: 14px; border-radius: 14px; text-decoration: none; color: #fff; background: linear-gradient(135deg, var(--brand-dark), var(--brand)); }
.site-card span, .site-card small { display: block; font-size: 12px; opacity: .85; }
.site-card b { display: block; font-size: 17px; margin: 2px 0; }
.brand small { display: block; opacity: .8; font-size: 12px; }
.logo { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 20px; }
main { padding: 12px 16px; max-width: 640px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; }
h2 { font-size: 15px; margin: 20px 0 8px; color: var(--muted); text-transform: none; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-width: 0; }
.card span { display: block; font-size: 12px; color: var(--muted); }
.card b { display: block; font-size: 20px; overflow-wrap: anywhere; }
.card small { display: block; font-size: 12px; color: var(--muted); }
.card.big { grid-column: 1 / -1; }
.card.big b { font-size: 28px; }
.card.waste b { color: var(--waste); }
.card.need b { color: var(--need); }
.card.unk b { color: var(--unk); }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 6px 0 2px; }
.bar i { display: block; height: 100%; width: 0; background: var(--brand); }
.bar i.warn { background: #F08C00; }
.bar i.over { background: var(--over); }
.list { display: flex; flex-direction: column; gap: 8px; }
.row-item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.row-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.row-top b { overflow-wrap: anywhere; }
.row-sub { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--muted); }
.amt { font-weight: 700; white-space: nowrap; }
.amt.waste { color: var(--waste); }
.amt.unk { color: var(--unk); }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); }
.tag.waste { color: var(--waste); border-color: var(--waste); }
.tag.need { color: var(--need); border-color: var(--need); }
select, input, textarea { width: 100%; font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.row-sub select { width: auto; max-width: 60%; padding: 4px 6px; font-size: 12px; }
.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
button { font: inherit; border-radius: 10px; padding: 10px 14px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; width: 100%; margin-top: 12px; }
button.secondary { margin-top: 8px; }
button.danger { color: var(--over); border-color: var(--over); margin-top: 8px; }
button.x { padding: 2px 8px; font-size: 12px; }
.hint { font-size: 12px; color: var(--muted); }
.banner { background: #FFF4E6; color: #7A3E00; border: 1px solid #FFD8A8; border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; font-size: 13px; }
.banner button { margin-top: 6px; }
@media (prefers-color-scheme: dark) { .banner { background: #3A2A12; color: #FFD8A8; border-color: #6B4A1A; } }
.cat-edit { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cat-edit .full { grid-column: 1 / -1; }
.cat-edit label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); min-width: 0; }
.status { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 6px 0; }
.status button { margin: 0; white-space: nowrap; }
.ok { color: var(--need); font-weight: 700; }
.bad { color: var(--over); font-weight: 700; }
.links { display: flex; flex-direction: column; gap: 8px; }
.links a { color: var(--brand); font-weight: 700; text-decoration: none; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
ul.plain { padding-left: 18px; }
details { margin: 8px 0; }
summary { cursor: pointer; color: var(--brand); }
code { font-size: 12px; overflow-wrap: anywhere; }
nav.bottom { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
nav.bottom button { border: 0; border-radius: 0; background: none; padding: 8px 0 10px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
nav.bottom button span { font-size: 20px; }
nav.bottom button.active { color: var(--brand); font-weight: 700; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.modal[hidden], .toast[hidden] { display: none; }
.sheet { background: var(--card); width: 100%; max-width: 640px; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.sheet h3 { margin: 0 0 8px; }
.sheet p { white-space: pre-line; margin: 0 0 12px; }
.row { display: flex; gap: 8px; }
.row button { flex: 1; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); background: var(--brand-dark); color: #fff; padding: 10px 14px; border-radius: 12px; z-index: 11; text-align: center; }
.empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

/* v1.6 карт холбох */
#btnCards { width: 100%; margin-top: 8px; }
#btnCardsBack { margin: 4px 0 0; }
.cardrow .row-top b small { font-weight: 400; color: var(--muted); }
.unk-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.unk-actions button { margin: 0; font-size: 12px; padding: 6px 10px; }

/* 2.0: доош татаж шинэчлэх, үлдэгдэл */
#ptr { height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; transition: height .15s; }
.amt.muted { color: var(--muted); font-weight: 400; font-size: 13px; }
.cardrow { cursor: pointer; }
#mInput { width: 100%; box-sizing: border-box; font-size: 20px; padding: 10px 12px; margin: 4px 0 12px; border: 1px solid var(--muted); border-radius: 10px; }
#mInput[hidden] { display: none; }
