:root {
  --bg: #f3f6f7; --card: #fff; --ink: #11242b; --muted: #5d7279; --line: #dbe4e7;
  --brand: #0e6f8a; --brand-ink: #fff; --head: #0e2a33;
  --ok: #1b8a4b; --soon: #b86e00; --late: #c62f2f; --none: #7a8b91;
  --okbg: #e3f4ea; --soonbg: #fdf0d9; --latebg: #fbe4e4; --nonebg: #eaeff1;
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1519; --card: #14232a; --ink: #e8f0f2; --muted: #93a8af; --line: #25393f;
    --brand: #35b0d2; --brand-ink: #04202a; --head: #0a1a20;
    --ok: #55d088; --soon: #f0b44d; --late: #ff7d7d; --none: #93a8af;
    --okbg: #14372394; --soonbg: #3a2a0e; --latebg: #3d1818; --nonebg: #1c2d33;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.hidden { display: none !important; }

#app { max-width: 720px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; background: var(--head); color: #fff; padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; display: flex; align-items: center; gap: 10px; }
.topbar h1 { font-size: 18px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar button { background: none; border: 0; color: #fff; font-size: 22px; padding: 4px 8px; cursor: pointer; }
.page { flex: 1; padding: 14px 16px calc(90px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); }
.tabs-in { display: flex; width: 100%; max-width: 720px; }
.tab { flex: 1; background: none; border: 0; padding: 8px 2px 7px; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; position: relative; }
.tab .ic { font-size: 22px; line-height: 1; }
.tab.on { color: var(--brand); font-weight: 600; }
.badge { position: absolute; top: 3px; left: calc(50% + 6px); background: var(--late); color: #fff; border-radius: 10px; font-size: 11px; min-width: 18px; height: 18px; line-height: 18px; text-align: center; padding: 0 5px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.card.tap { cursor: pointer; }
.card.tap:active { background: var(--nonebg); }
.row { display: flex; align-items: center; gap: 10px; }
.row.sp { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title { font-weight: 600; }
.sec { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 10px 2px 0; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--okbg); color: var(--ok); }
.pill.soon { background: var(--soonbg); color: var(--soon); }
.pill.overdue { background: var(--latebg); color: var(--late); }
.pill.none { background: var(--nonebg); color: var(--none); }
.pill.open { background: var(--soonbg); color: var(--soon); }
.pill.in_progress { background: var(--nonebg); color: var(--brand); }
.pill.done, .pill.confirmed { background: var(--okbg); color: var(--ok); }
.pill.declined { background: var(--nonebg); color: var(--none); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--ok); } .dot.soon { background: var(--soon); } .dot.overdue { background: var(--late); } .dot.none { background: var(--none); }

.btn { background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 600; cursor: pointer; text-align: center; text-decoration: none; display: inline-block; }
.btn.sec2 { background: var(--nonebg); color: var(--ink); }
.btn.danger { background: var(--latebg); color: var(--late); }
.btn.sm { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns .btn { flex: 1; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; width: 100%; color: var(--ink); font-size: 16px; }
textarea { min-height: 80px; resize: vertical; }
.form { display: flex; flex-direction: column; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; text-align: center; cursor: pointer; }
.stat b { font-size: 26px; display: block; }
.stat span { font-size: 12px; color: var(--muted); }

.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumbs img, .thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--nonebg); cursor: pointer; }
.thumb { position: relative; }
.thumb button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--late); color: #fff; font-size: 14px; line-height: 1; }
.addphoto { width: 72px; height: 72px; border-radius: 10px; border: 2px dashed var(--line); background: none; font-size: 26px; color: var(--muted); cursor: pointer; }

.chat { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 82%; padding: 9px 12px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); align-self: flex-start; white-space: pre-wrap; word-break: break-word; }
.msg.mine { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.msg .who { font-size: 12px; opacity: .75; }
.msg .thumbs { margin-top: 6px; }
.sysmsg { align-self: center; font-size: 13px; color: var(--muted); background: var(--nonebg); border-radius: 99px; padding: 4px 12px; text-align: center; }
.composer { position: sticky; bottom: calc(60px + env(safe-area-inset-bottom)); background: var(--bg); padding: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.composer .row { align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 120px; }

.login { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px; gap: 18px; }
.login h1 { font-size: 28px; text-align: center; }
.logo { width: 76px; height: 76px; border-radius: 18px; margin: 0 auto; display: block; }
.err { color: var(--late); font-size: 14px; min-height: 18px; }
.notice { background: var(--soonbg); color: var(--soon); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.cred { font: 600 17px ui-monospace, Menlo, monospace; background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; padding: 10px; user-select: all; }

#toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: #11242b; color: #fff; padding: 10px 16px; border-radius: 99px; opacity: 0; transition: .2s; pointer-events: none; z-index: 30; max-width: 90vw; font-size: 14px; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.viewer { position: fixed; inset: 0; background: rgba(0, 0, 0, .92); z-index: 40; display: flex; align-items: center; justify-content: center; }
.viewer img { max-width: 100%; max-height: 100%; }
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 35; display: flex; align-items: flex-end; justify-content: center; }
.modal > div { background: var(--card); width: 100%; max-width: 720px; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 90dvh; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.day { border-left: 3px solid var(--brand); padding-left: 12px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
