:root {
  --bg: #f4f6f5;
  --card: #fff;
  --ink: #16211e;
  --muted: #64716d;
  --line: #dde3e1;
  --brand: #0f766e;
  --brand-ink: #fff;
  --brand-soft: #e3f2ef;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --radius: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 720px; margin: 0 auto; padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 17px; margin: 24px 0 10px; }
h3 { font-size: 16px; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; padding: 48px 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.grow { flex: 1; }
.stack > * + * { margin-top: 10px; }

/* top bar */
.top {
  position: sticky; top: 0; z-index: 5;
  margin: 0 -16px 12px; padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--brand); color: var(--brand-ink);
  display: flex; align-items: center; gap: 10px;
}
.top h1 { flex: 1; font-size: 18px; }
.top button, .top a { color: var(--brand-ink); background: rgba(255,255,255,.14); border: 0; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.room-card { display: flex; flex-direction: column; gap: 8px; }
.room-card .who { font-size: 18px; font-weight: 600; }
.room-card .who.vacant { color: var(--muted); font-weight: 500; }

/* buttons */
button, .btn {
  font: inherit; font-size: 15px; font-weight: 600;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 9px 14px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; min-height: 40px;
}
button:disabled { opacity: .55; cursor: default; }
.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.danger { color: var(--bad); border-color: #f3c2c2; }
.ghost { background: transparent; border-color: transparent; }
.wa { background: #25d366; border-color: #25d366; color: #fff; }
.block { width: 100%; }
.icon-btn { padding: 6px 10px; min-height: 36px; }

/* badges */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.grey { background: #eceff0; color: var(--muted); }

/* forms */
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
input[type=checkbox] { width: auto; }
.check { display: flex; gap: 8px; align-items: center; font-size: 15px; color: var(--ink); font-weight: 500; }
.grid2 { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }
.field + .field, .grid2 + .field, .field + .grid2, .grid2 + .grid2 { margin-top: 10px; }
textarea.tpl { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; min-height: 200px; resize: vertical; }

/* month nav */
.month-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.month-nav .label { flex: 1; text-align: center; font-weight: 700; font-size: 18px; }

/* lists */
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list .item { padding: 12px 14px; display: flex; gap: 10px; align-items: center; }
.list .item + .item { border-top: 1px solid var(--line); }
.list .item .grow { min-width: 0; }
.empty { padding: 14px; color: var(--muted); }

/* IC */
.ic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ic-slot { border: 1px dashed var(--line); border-radius: 10px; aspect-ratio: 1.58; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #fafbfb; }
.ic-slot img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(10,20,18,.5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
@media (min-width: 600px) { .modal-bg { align-items: center; } .modal { border-radius: 18px; } }
.modal h3 { margin-bottom: 12px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

/* signature pad */
.sigpad { border: 1px solid var(--line); border-radius: 10px; background: #fff; touch-action: none; width: 100%; height: 200px; display: block; }

/* toast */
#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #16211e; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 99; font-size: 14px; max-width: calc(100% - 32px); }
#toast.err { background: var(--bad); }

/* login */
.login { max-width: 360px; margin: 12vh auto 0; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; display: block; margin: 0 auto 16px; }

/* banner */
.banner { padding: 12px 14px; border-radius: var(--radius); background: var(--warn-soft); color: #78350f; display: flex; gap: 10px; align-items: center; }

/* agreement document */
.doc { background: #fff; color: #000; border: 1px solid var(--line); border-radius: 6px; padding: 28px 22px; font-family: "Times New Roman", Georgia, serif; font-size: 15px; line-height: 1.5; }
.doc h1 { text-align: center; font-size: 22px; letter-spacing: .5px; }
.doc .sub { text-align: center; font-weight: 700; }
.doc .parties { margin: 18px 0; }
.doc .parties div { display: grid; grid-template-columns: 90px 1fr; }
.doc h4 { margin: 16px 0 4px; font-size: 15px; text-decoration: underline; }
.doc table.money { border-collapse: collapse; margin: 6px 0; }
.doc table.money td { padding: 2px 16px 2px 0; }
.doc table.money tr.total td { font-weight: 700; border-top: 1px solid #000; }
.doc .sigs { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 28px; }
.doc .sigbox { height: 90px; border-bottom: 1px dotted #000; display: flex; align-items: flex-end; }
.doc .sigbox img { max-height: 86px; max-width: 100%; }
.doc .signed-at { font-size: 11px; color: #555; }

@media print {
  body { background: #fff; }
  #app { max-width: none; padding: 0; }
  .no-print, .top, #toast { display: none !important; }
  .doc { border: 0; padding: 0; font-size: 13px; }
}
