:root {
  --bg: #f3f2f0; --card: #ffffff; --ink: #111111; --muted: #5f5f5f; --line: #e5e4e1; --line2: #eeedea;
  --accent: #ce0404; --accent-ink: #a30303; --accent-soft: #fbe3e3;
  --ok: #15803d; --ok-soft: #e3efe7; --warn: #9a3412; --warn-soft: #fff4e5; --danger: #a30303; --danger-soft: #fbe3e3;
  --info-soft: #eef2ff;
  --radius: 20px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0b0b; --card: #1a1a1a; --ink: #f2f2f2; --muted: #a8a8a8; --line: #2c2c2c; --line2: #262626;
  --accent: #e8261f; --accent-ink: #ff5a4f; --accent-soft: #3a1414;
  --ok: #4ade80; --ok-soft: #173322; --warn: #fdba74; --warn-soft: #3a2a16; --danger: #fca5a5; --danger-soft: #3a1414;
  --info-soft: #1e2236;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, system-ui, -apple-system, sans-serif; font-size: 15px; -webkit-text-size-adjust: 100%; }
body { padding: env(safe-area-inset-top) 0 calc(90px + env(safe-area-inset-bottom)); }
#app { max-width: 640px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
a { color: var(--accent-ink); text-decoration: none; }
h1 { font-family: Oswald, sans-serif; font-weight: 700; font-size: 28px; letter-spacing: .5px; text-transform: uppercase; margin: 0; }
h3 { margin: 4px 0 8px; font-size: 15px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.pad { padding: 40px 16px; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .danger { color: var(--danger); }

.top { display: flex; align-items: center; gap: 8px; padding-top: 8px; }
.home-top { display: flex; justify-content: space-between; align-items: center; padding-top: 6px; }
.home-top > div { display: flex; flex-direction: column; gap: 6px; }
.logo { width: 126px; height: 48px; object-fit: cover; border-radius: 10px; display: block; }
.logo-big { width: 240px; border-radius: 14px; display: block; margin: 40px auto 24px; }
.login { max-width: 420px; margin: 0 auto; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-head a { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; font-weight: 600; }
.card-head a svg { width: 16px; height: 16px; }
.big { font-family: Oswald, sans-serif; font-size: 34px; font-weight: 700; }

.add-big { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; background: var(--accent); color: #fff; border-radius: var(--radius); padding: 16px 18px; }
.add-big svg { grid-row: span 2; width: 30px; height: 30px; }
.add-big span { font-weight: 700; font-size: 17px; }
.add-big small { opacity: .85; }

.add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.add-btn { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); min-height: 120px; padding: 16px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; cursor: pointer; font-weight: 700; }
.add-btn.primary { background: var(--accent); color: #fff; border: none; }
.add-btn svg { width: 28px; height: 28px; }
.add-btn small { font-weight: 400; opacity: .8; }

.rings { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ring-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ring { position: relative; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-center b { font-family: Oswald, sans-serif; font-size: 30px; font-weight: 700; }
.ring-center b.sm { font-size: 20px; }
.ring-center small { color: var(--muted); font-size: 11px; }
.ring-center svg { color: var(--muted); }
.ring-label { display: flex; flex-direction: column; align-items: center; text-align: center; }
.ring-label span { color: var(--muted); font-size: 12px; }
.pace { margin: 4px 0 0; border-top: 1px solid var(--line2); padding-top: 10px; line-height: 1.5; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { background: var(--card); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 4px; color: var(--ink); }
.tile span, .tile small { color: var(--muted); font-size: 12px; }
.tile b { font-family: Oswald, sans-serif; font-size: 22px; font-weight: 600; }

.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line2); color: var(--ink); }
.row:last-child { border-bottom: none; }
.row.off { opacity: .5; }
.row-main { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; color: var(--ink); }
.row-main strong { font-size: 14px; overflow-wrap: anywhere; }
.row-main span { font-size: 12px; color: var(--muted); }
.row-main span.danger { color: var(--danger); } .row-main span.warn { color: var(--warn); } .row-main span.ok { color: var(--ok); }
.row-amount { font-weight: 600; font-size: 14px; white-space: nowrap; }
.row > svg { color: var(--muted); width: 18px; height: 18px; }
.badge { width: 44px; height: 44px; border-radius: 12px; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; }
.badge span { font-size: 10px; font-weight: 600; color: var(--muted); }
.badge strong { font-size: 15px; }
.badge.danger { background: var(--danger-soft); } .badge.danger span, .badge.danger strong { color: var(--danger); }
.badge.warn { background: var(--warn-soft); } .badge.warn span, .badge.warn strong { color: var(--warn); }
.tag { font-style: normal; font-size: 10px; font-weight: 600; background: var(--warn-soft); color: var(--warn); padding: 2px 6px; border-radius: 6px; margin-left: 4px; }
.day { border-bottom: 1px solid var(--line2); padding-bottom: 6px; }
.day:last-child { border-bottom: none; }

.alert { border-radius: 14px; padding: 12px 14px; font-size: 13px; line-height: 1.45; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink); }
.alert svg { width: 16px; height: 16px; }
.alert.warn { background: var(--warn-soft); } .alert.danger { background: var(--danger-soft); } .alert.ok { background: var(--ok-soft); } .alert.info { background: var(--info-soft); }
div.alert { display: block; }

.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
input, select { font: inherit; font-size: 16px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; width: 100%; min-height: 44px; }
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.kv { display: flex; flex-direction: column; gap: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line2); }
.kv > div:last-child { border-bottom: none; }
.kv span { color: var(--muted); font-size: 13px; }

.btn { font: inherit; font-weight: 600; font-size: 15px; min-height: 46px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; }
.btn.block { width: 100%; }
.btn.primary { background: var(--ink); color: var(--bg); border: none; }
.btn.sm { min-height: 34px; font-size: 12px; padding: 0 10px; border-radius: 10px; }
.btn.danger-outline { color: var(--danger); border-color: var(--danger-soft); background: transparent; }
.btn:disabled { opacity: .5; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: var(--card); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 20px; flex-shrink: 0; }
.icon-btn.sm { width: 32px; height: 32px; font-size: 16px; }

.seg { display: flex; gap: 4px; background: var(--line); border-radius: 14px; padding: 4px; }
.seg button { flex: 1; min-height: 38px; border: none; border-radius: 10px; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 500; }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 600; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); z-index: 10; }
.nav[hidden] { display: none; }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 500; padding: 6px 0; }
.nav a.on { color: var(--accent-ink); font-weight: 600; }
.nav .nav-add { width: 54px; height: 54px; border-radius: 27px; background: var(--accent); color: #fff; justify-self: center; justify-content: center; }
.nav .nav-add svg { width: 28px; height: 28px; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px; font-weight: 600; text-align: center; opacity: 0; transform: translateY(10px); transition: all .2s; pointer-events: none; z-index: 20; max-width: 600px; margin: 0 auto; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--accent); color: #fff; }
.ring > svg { width: 100%; height: 100%; }
.ring-center svg { width: 22px; height: 22px; }
.grid2 > *, .grid3 > * { min-width: 0; }
input[type="date"], input[type="time"] { -webkit-appearance: none; appearance: none; min-width: 0; }
.items { display: flex; flex-direction: column; gap: 10px; }
.item-row { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: 14px; background: var(--bg); }
.item-row input { background: var(--card); padding: 8px 10px; min-height: 40px; font-size: 15px; }
.it-nums { display: grid; grid-template-columns: 1fr 0.8fr 1.2fr 1.2fr auto; gap: 6px; align-items: center; }
.it-nums > * { min-width: 0; }
.it-head { display: grid; grid-template-columns: 1fr 0.8fr 1.2fr 1.2fr 32px; gap: 6px; padding: 0 10px; font-size: 11px; color: var(--muted); }
.it-pack { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.it-pack .it-psize { width: 80px; }
.it-pack select { width: 74px; padding: 8px; min-height: 40px; background: var(--card); font-size: 15px; }
.it-pack .it-base { color: var(--ink); }
.tag.ok-tag { background: var(--ok-soft); color: var(--ok); }
.pay-alert { display: flex !important; align-items: center; gap: 10px; }
.pay-alert .btn { flex-shrink: 0; }
.step-row { align-items: end; }
.row-amount small { font-weight: 400; font-size: 11px; }
.proof-box { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 14px; border: 1px dashed var(--line); }
.proof-box strong { font-size: 14px; }
.proof-box .btn svg { width: 18px; height: 18px; }
.if-paid { display: none; flex-direction: column; gap: 10px; }
form:has(input[name="paid"]:checked) .if-paid { display: flex; }
.search { position: relative; display: block; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.search input { padding-left: 38px; background: var(--card); }
label.btn { cursor: pointer; }
.seg-wrap { flex-wrap: wrap; }
.seg-wrap button { flex: 1 1 30%; }
.alert label.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--ink); }
