:root {
  --ink: #21261f;
  --ink-soft: #565f52;
  --paper: #faf8f3;
  --card: #ffffff;
  --line: #e4e0d4;
  --moss: #4a6b52;
  --moss-dark: #38513f;
  --moss-tint: #e9f0e8;
  --clay: #b5643f;
  --clay-tint: #f6e9e1;
  --gold: #b8923a;
  --gold-tint: #f7f0dc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(33,38,31,0.06), 0 4px 16px rgba(33,38,31,0.06);
  font-size: 17px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #eee9dd;
    --ink-soft: #b9b3a2;
    --paper: #1b1d19;
    --card: #24261f;
    --line: #363a30;
    --moss: #86ab8b;
    --moss-dark: #a9c9ac;
    --moss-tint: #26312a;
    --clay: #d99871;
    --clay-tint: #34281f;
    --gold: #d9bb6f;
    --gold-tint: #332c1c;
  }
}
:root[data-theme="dark"] {
  --ink: #eee9dd;
  --ink-soft: #b9b3a2;
  --paper: #1b1d19;
  --card: #24261f;
  --line: #363a30;
  --moss: #86ab8b;
  --moss-dark: #a9c9ac;
  --moss-tint: #26312a;
  --clay: #d99871;
  --clay-tint: #34281f;
  --gold: #d9bb6f;
  --gold-tint: #332c1c;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html {
  scroll-padding-top: env(safe-area-inset-top, 0px);
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 100px;
}

.centered-wrap {
  max-width: 420px;
  margin: 0 auto;
  padding: 48px 20px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

h1, h2, h3 { font-weight: 650; line-height: 1.25; margin: 0 0 4px; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
p { line-height: 1.5; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.85rem; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--moss);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

label { display: block; font-size: 0.85rem; color: var(--ink-soft); margin: 12px 0 4px; }
label:first-child { margin-top: 0; }
input, textarea, select {
  width: 100%;
  font-size: 1rem;
  font-family: inherit;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}
textarea { resize: vertical; min-height: 72px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--moss); outline-offset: 1px; }

button, .btn {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  cursor: pointer;
  background: var(--moss);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}
button:active { transform: translateY(1px); }
button.secondary { background: var(--moss-tint); color: var(--moss-dark); }
button.ghost { background: transparent; color: var(--ink-soft); padding: 8px 10px; }
button.danger { background: var(--clay-tint); color: var(--clay); }
button:disabled { opacity: 0.5; cursor: default; }
button.full { width: 100%; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.error {
  background: var(--clay-tint);
  color: var(--clay);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  margin: 10px 0;
}
.notice {
  background: var(--gold-tint);
  color: var(--gold);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  margin: 10px 0;
}

.pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--moss-tint);
  color: var(--moss-dark);
}
.pill.role-owner { background: var(--gold-tint); color: var(--gold); }
.pill.role-carer { background: var(--clay-tint); color: var(--clay); }

.entry { border-bottom: 1px solid var(--line); padding: 12px 0; }
.entry:last-child { border-bottom: none; }
.entry-meta { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.entry-content { white-space: pre-wrap; }

.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 20;
}
.tabbar button {
  flex: 1;
  background: none;
  color: var(--ink-soft);
  border-radius: 0;
  padding: 12px 4px 10px;
  flex-direction: column;
  font-size: 0.7rem;
  font-weight: 600;
  gap: 2px;
}
.tabbar button.active { color: var(--moss-dark); }
.tabbar .icon { font-size: 1.25rem; line-height: 1; }

header.topbar {
  position: sticky; top: 0;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--paper);
  z-index: 10;
  border-bottom: 1px solid var(--line);
  margin: 0 -16px 16px;
}
header.topbar .inner { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; }

.view { display: none; }
.view.active { display: block; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--ink-soft); font-weight: 600; font-size: 0.8rem; }

a { color: var(--moss-dark); }

.empty-state { text-align: center; padding: 32px 16px; color: var(--ink-soft); }

.rota-subtab {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.82rem;
  padding: 8px 4px;
}
.rota-subtab.active { background: var(--moss); color: #fff; border-color: var(--moss); }
.rota-view { display: none; }
.rota-view.active { display: block; }

.shift-card { border-bottom: 1px solid var(--line); padding: 12px 0; }
.shift-card:last-child { border-bottom: none; }
.shift-card select, .shift-card input { margin-top: 4px; }
.pay-payable { color: var(--moss-dark); font-weight: 700; }
.pay-not-payable { color: var(--ink-soft); }

.copy-box {
  display: flex; gap: 8px; align-items: center;
  background: var(--paper); border: 1px dashed var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 0.85rem; word-break: break-all;
}
