:root {
  --teal: #0f766e; --teal-dark: #115e59; --teal-light: #f0fdfa; --teal-border: #99f6e4; --teal-text: #134e4a;
  --bg: #f9fafb; --card: #fff; --text: #1f2937; --muted: #6b7280; --line: #e5e7eb;
  --green: #15803d; --green-bg: #dcfce7; --amber: #92400e; --amber-bg: #fef3c7; --red: #b91c1c;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh;
       font-family: system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, p { margin: 0; }
button { font: inherit; cursor: pointer; border: 0; }
input { font: inherit; }

.center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.center { text-align: center; }

/* Header (extends under the iOS status bar when installed) */
.app-header { background: var(--teal); color: #fff; text-align: center; box-shadow: 0 2px 6px rgba(0,0,0,.15);
              padding: max(22px, env(safe-area-inset-top)) 16px 22px; }
.app-header h1 { font-size: 22px; letter-spacing: .3px; }
.app-header p { margin-top: 4px; font-size: 12px; color: #ccfbf1; }

/* --install-space is set by app.js to the install banner's height while it is showing. */
main { max-width: 480px; margin: 20px auto 0; padding: 0 16px calc(48px + var(--install-space, 0px) + env(safe-area-inset-bottom)); display: grid; gap: 16px; }
main.narrow { max-width: 400px; margin-top: 28px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.pad { padding: 16px; }
.card h2 { font-size: 16px; }
.card-head { padding: 12px 16px; background: #f3f4f6; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 15px; color: #374151; }

.label { display: block; font-size: 11px; text-transform: uppercase; font-weight: 700; color: var(--muted); letter-spacing: .5px; }
.label.teal, .teal { color: var(--teal-dark); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hint { font-size: 12px; color: var(--muted); text-align: center; }
.error { background: #fef2f2; color: #b91c1c; font-size: 14px; padding: 8px 12px; border-radius: 8px; }

.stack-16 { display: grid; gap: 16px; }
.stack-10 { display: grid; gap: 10px; }
label input { width: 100%; margin-top: 4px; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; font-size: 16px; outline: none; }
label input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px #ccfbf1; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.big { font-size: 30px; font-weight: 800; margin-top: 4px; line-height: 1.1; }
.recipient-card { background: var(--teal-light); border-color: var(--teal-border); }
.recipient-name { font-size: 20px; font-weight: 700; margin-top: 4px; color: var(--teal-text); line-height: 1.2; word-break: break-word; }
.recipient-card .small { margin-top: 4px; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--teal); transition: width .3s; }
#progress-text { margin-top: 6px; }

/* Due date */
.due-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.due-date { font-size: 18px; font-weight: 700; margin-top: 4px; }
.chip { flex: none; font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 99px; background: #f3f4f6; color: #374151; white-space: nowrap; }
.chip.ok { background: var(--green-bg); color: var(--green); }
.chip.soon { background: var(--teal-light); color: var(--teal-dark); }
.chip.today { background: var(--amber-bg); color: var(--amber); }
.chip.late { background: #fee2e2; color: var(--red); }
.note { margin: -6px 2px 0; font-size: 13px; color: var(--teal-text); background: var(--teal-light); border: 1px solid var(--teal-border);
        border-radius: 10px; padding: 8px 12px; }

/* Members */
ul { list-style: none; margin: 0; padding: 0; }
li.member { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid #f3f4f6; }
li.member:last-child { border-bottom: 0; }
li.is-recipient { background: #fffbeb; }
.mleft { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pos { flex: none; width: 28px; height: 28px; border-radius: 50%; background: #f3f4f6; color: #4b5563;
       font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.mtext { min-width: 0; display: grid; gap: 2px; }
.mline { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mname { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msub { font-size: 12px; color: var(--muted); }
.tag { flex: none; font-size: 10px; font-weight: 700; background: var(--amber-bg); color: var(--amber); padding: 2px 6px; border-radius: 4px; }
.status { flex: none; padding: 7px 14px; border-radius: 8px; font-size: 12px; font-weight: 700; background: #f3f4f6; color: var(--muted); }
.status.paid { background: var(--green-bg); color: var(--green); }
.status.late { background: #fee2e2; color: var(--red); }

/* Payout history */
li.payout { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #f3f4f6; }
li.payout:last-child { border-bottom: 0; }
.payout .pname { font-weight: 600; }
.payout .pmeta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.payout .pamount { text-align: right; font-weight: 700; white-space: nowrap; }
.payout .pamount small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.history-more { display: block; width: 100%; border-top: 1px solid #f3f4f6; padding: 12px; }

/* Treasurer settings */
.hint-left { font-size: 12px; color: var(--muted); margin-top: -8px; line-height: 1.45; }
.row-actions { display: flex; justify-content: flex-end; gap: 8px; }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 4px; }
button.status:hover { filter: brightness(.96); }
button.status:disabled { opacity: .5; }
.empty { padding: 24px 16px; text-align: center; font-size: 14px; color: var(--muted); }

/* Buttons */
.btn { padding: 12px 16px; border-radius: 12px; font-weight: 600; font-size: 15px; }
.btn-block { width: 100%; }
.btn-teal { background: var(--teal); color: #fff; }
.btn-teal:hover { background: var(--teal-dark); }
.btn-green { background: #059669; color: #fff; }
.btn-green:hover { background: #047857; }
.btn-outline { background: #fff; color: var(--teal-dark); border: 1px solid var(--teal-border); }
.btn-outline:hover:not(:disabled) { background: var(--teal-light); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-link { background: none; font-size: 13px; font-weight: 500; padding: 6px 10px; }
.btn-link:hover { color: var(--text); }

/* Toast */
#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
         background: #111827; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0;
         pointer-events: none; transition: .25s; max-width: 90%; text-align: center; z-index: 60; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Install banner */
#install { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); }
.install-card { max-width: 448px; margin: 0 auto; background: #fff; border: 1px solid var(--teal-border); border-radius: 18px;
                padding: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.install-row { display: flex; gap: 12px; align-items: flex-start; }
.install-row img { border-radius: 12px; flex: none; }
.install-row p { margin-top: 2px; font-size: 14px; color: #4b5563; }
.install-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 12px; }

a.btn-link { text-decoration: none; display: inline-block; }

input[type=date] { min-height: 46px; background: #fff; color: var(--text); }
