[hidden] { display: none !important; }
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #16202e;
  --muted: #5b6675;
  --line: #e2e6eb;
  --accent: #1f6f5c;
  --accent-soft: #e6f2ee;
  --warn: #a15c07;
  --warn-soft: #fdf3e2;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #15803d;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line); padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; font-weight: 600; font-size: 17px; }
main { max-width: 760px; margin: 0 auto; padding: 14px 14px calc(env(safe-area-inset-bottom) + 96px); }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; text-align: center; padding: 11px 0 12px; color: var(--muted); font-size: 13px; font-weight: 500; }
.tabs a.on { color: var(--accent); font-weight: 650; }

h2 { font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 22px 4px 8px; font-weight: 600; }
h2:first-child { margin-top: 4px; }
h3 { font-size: 17px; margin: 0 0 6px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stats > .stat:nth-child(odd):last-child { grid-column: 1 / -1; }
.stat { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 12px 14px; }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; min-height: 2.9em; }
.stat .value { font-size: 24px; font-weight: 650; margin-top: 2px; }
.stat .sub { font-size: 13px; color: var(--muted); }

.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 10px; }
.row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row.tap { cursor: pointer; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 550; }
.row .sub { font-size: 13px; color: var(--muted); }
.row .amt { font-weight: 600; text-align: right; }
.row.overdue { background: var(--danger-soft); }
.row.done .title { color: var(--muted); text-decoration: line-through; }
.empty { padding: 14px; color: var(--muted); }

.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--line); color: var(--muted); margin-left: 6px; vertical-align: 1px; }
.tag.ok { background: #e3f4e8; color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }

.btn { border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 10px; padding: 9px 14px; font-weight: 600; cursor: pointer; }
.btn.ghost { background: var(--card); color: var(--accent); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { border-color: var(--danger); background: var(--card); color: var(--danger); }
.btn:disabled { opacity: .5; }
.check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); flex: none; cursor: pointer; padding: 0; }
.check.on { background: var(--ok); border-color: var(--ok); }
.bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.bar .grow { flex: 1; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.seg button { border: 0; background: none; padding: 7px 12px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.fab { position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 70px); z-index: 6; width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 28px; line-height: 1; cursor: pointer; box-shadow: 0 4px 14px rgba(22, 32, 46, .18); }

.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.form input, .form select, .form textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; background: #fff; font-size: 16px; color: var(--ink); }
.form textarea { min-height: 84px; resize: vertical; }
.form .inline { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 15px; }
.form .inline input { width: auto; }
.form .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.form .actions .left { margin-right: auto; }
.preview { max-width: 100%; max-height: 260px; border-radius: 10px; border: 1px solid var(--line); }
.note { background: var(--accent-soft); border-radius: 10px; padding: 9px 11px; font-size: 13px; }
.error { background: var(--danger-soft); color: var(--danger); border-radius: 10px; padding: 9px 11px; font-size: 14px; }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 20px)); max-height: calc(100vh - 40px); color: var(--ink); }
dialog::backdrop { background: rgba(22, 32, 46, .35); }
dialog .sheet { padding: 18px; }
dialog h3 { margin-bottom: 12px; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { font-size: 11px; color: var(--muted); text-align: center; padding: 2px 0; }
.cal .day { background: var(--card); border: 1px solid var(--line); border-radius: 8px; min-height: 54px; padding: 4px; cursor: pointer; }
.cal .day.out { opacity: .4; }
.cal .day.today { border-color: var(--accent); border-width: 2px; }
.cal .day.sel { background: var(--accent-soft); }
.cal .num { font-size: 12px; font-weight: 600; }
.dots { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.dot.paid { background: #aab4be; }
.dot.todo { background: var(--warn); }
.dot.warranty { background: var(--danger); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 8px 2px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }

.chat { display: grid; gap: 10px; }
.msg { padding: 10px 12px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.me { background: var(--accent); color: #fff; justify-self: end; max-width: 88%; }
.msg.ai { background: var(--card); border: 1px solid var(--line); max-width: 100%; }
.msg .src { margin-top: 8px; font-size: 12px; color: var(--muted); }
.askbar { position: sticky; bottom: calc(env(safe-area-inset-bottom) + 58px); display: flex; gap: 8px; background: var(--bg); padding: 10px 0; }
.askbar textarea { flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-height: 44px; max-height: 160px; resize: none; font-size: 16px; }

.kv { display: grid; grid-template-columns: minmax(96px, 30%) 1fr; gap: 6px 12px; }
.kv dt { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); line-height: 20px; }
.kv dd { margin: 0; line-height: 20px; overflow-wrap: anywhere; }
.menu a { display: flex; justify-content: space-between; padding: 14px; border-top: 1px solid var(--line); color: var(--ink); }
.menu a:first-child { border-top: 0; }
.menu a span { color: var(--muted); }
.login { max-width: 380px; margin: 12vh auto 0; text-align: center; }
.login .form { text-align: left; margin-top: 16px; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; background: var(--accent); }
.progress.over > div { background: var(--danger); }
