:root {
  --bg: #f6f4f1; --card: #ffffff; --text: #1d1b19; --muted: #77706a; --line: #e7e2dc;
  --accent: #e8572a; --accent-ink: #ffffff; --accent-soft: #fde9e1;
  --ok: #1f8a4c; --ok-soft: #e3f4ea; --warn: #b26b00; --warn-soft: #fff1d6; --err: #c0362c; --err-soft: #fbe5e3;
  --radius: 16px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141210; --card: #1f1c19; --text: #f3efea; --muted: #a39b93; --line: #34302b;
    --accent: #f06a3e; --accent-soft: #3a2219; --ok: #4cc47f; --ok-soft: #173023; --warn: #e3a440; --warn-soft: #33270f;
    --err: #f0766b; --err-soft: #3a1c19; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; padding: env(safe-area-inset-top) 0 calc(76px + env(safe-area-inset-bottom)); }
.splash { display: grid; place-items: center; height: 80vh; }
.logo { width: 64px; height: 64px; border-radius: 18px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 34px; }

header.top { display: flex; align-items: center; gap: 12px; padding: 16px 16px 8px; }
header.top h1 { font-size: 22px; margin: 0; flex: 1; letter-spacing: -.01em; }
header.top .sub { color: var(--muted); font-size: 14px; }
main { padding: 8px 16px 24px; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; border: 1px solid var(--line); }
.card h2 { font-size: 17px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=tel], input[type=password], input[type=number], input[type=time], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); outline: none; min-height: 46px;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 12px 18px; min-height: 46px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: var(--err-soft); color: var(--err); }
.btn.sm { padding: 6px 12px; min-height: 36px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--accent); padding: 8px 0; cursor: pointer; font-weight: 600; }

.big-btn { width: 100%; aspect-ratio: 1.6; max-height: 220px; border-radius: 24px; border: 0; font-size: 24px; font-weight: 700; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: #fff; background: var(--accent); }
.big-btn.close { background: #3b3632; }
@media (prefers-color-scheme: dark) { .big-btn.close { background: #4a443e; } }
.big-btn small { font-size: 14px; font-weight: 500; opacity: .85; }
.big-btn:disabled { opacity: .6; }

.status { display: flex; gap: 12px; align-items: center; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line); color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.err { background: var(--err-soft); color: var(--err); }
.pill.acc { background: var(--accent-soft); color: var(--accent); }
.note { padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: 14px; margin-bottom: 12px; }
.note.err { background: var(--err-soft); color: var(--err); }
.note.ok { background: var(--ok-soft); color: var(--ok); }

nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
nav.tabs .in { display: flex; width: 100%; max-width: 560px; }
nav.tabs button { flex: 1; background: none; border: 0; padding: 8px 2px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 11px; cursor: pointer; }
nav.tabs button svg { width: 24px; height: 24px; }
nav.tabs button.on { color: var(--accent); }

.seg { display: flex; background: var(--line); border-radius: 12px; padding: 3px; gap: 3px; margin-bottom: 12px; overflow-x: auto; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 10px; border-radius: 9px; font-size: 14px; white-space: nowrap; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.month-nav b { font-size: 17px; text-transform: capitalize; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); cursor: pointer; display: grid; place-items: center; }

.list .item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: center; }
.list .item:last-child { border-bottom: 0; }
.date-box { width: 46px; text-align: center; flex: none; }
.date-box b { display: block; font-size: 20px; line-height: 1.1; }
.date-box span { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.today .date-box b { color: var(--accent); }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .h { font-size: 11px; color: var(--muted); text-align: center; padding: 4px 0; }
.cal button { aspect-ratio: 1; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 2px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 14px; min-width: 0; }
.cal button i { font-style: normal; font-size: 9px; color: var(--muted); line-height: 1.1; overflow: hidden; max-width: 100%; white-space: nowrap; }
.cal button.has { background: var(--accent-soft); border-color: transparent; }
.cal button.off { background: var(--line); }
.cal button.iiko { background: var(--ok-soft); border-color: transparent; }
.cal button.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

.money { font-size: 32px; font-weight: 800; letter-spacing: -.02em; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 15px; }
.kv:last-child { border-bottom: 0; }
details.day { border-bottom: 1px solid var(--line); }
details.day summary { list-style: none; display: flex; justify-content: space-between; padding: 10px 0; cursor: pointer; }
details.day summary::-webkit-details-marker { display: none; }
details.day .body { padding: 0 0 10px; font-size: 14px; }

.u-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.u-item:last-child { border-bottom: 0; }
.picker { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; margin-top: 6px; }
.picker button { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: var(--card); cursor: pointer; }
.picker button:last-child { border-bottom: 0; }
.picker button.sug { background: var(--ok-soft); }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: #2a2623; color: #fff; padding: 12px 18px;
  border-radius: 12px; font-size: 15px; opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px); z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 560px; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 90vh; overflow: auto; }
.sheet h3 { margin: 0 0 12px; }
.spinner { width: 22px; height: 22px; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.auth { padding: 40px 16px; }
.auth .logo { margin: 0 auto 16px; }
.auth h1 { text-align: center; margin: 0 0 4px; }
.auth p.lead { text-align: center; color: var(--muted); margin: 0 0 24px; }
.install-tip { font-size: 14px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t td { padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
