:root {
  --bg: #f7f5ef;
  --card: #ffffff;
  --fg: #1f2a22;
  --muted: #6b7568;
  --line: #e4e1d6;
  --accent: #2f7d4a;
  --accent-soft: #e3f0e6;
  --gold: #c99a1e;
  --danger: #b3261e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem;
}

h1 { color: var(--accent); }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
ul { list-style: none; margin: 0; padding: 0; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.big { font-size: 1.6rem; font-weight: 700; margin: 0 0 0.5rem; }

button {
  font: inherit;
  padding: 0.6rem 1rem;
  border: 0;
  border-radius: 0.6rem;
  background: var(--accent);
  color: white;
  cursor: pointer;
}
button:disabled { opacity: 0.45; cursor: default; }
button.secondary { background: var(--line); color: var(--fg); }
button.small { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
button.primary { width: 100%; margin-top: 0.5rem; }

input {
  font: inherit;
  padding: 0.55rem 0.7rem;
  border: 2px solid var(--line);
  border-radius: 0.6rem;
  width: 100%;
}

.card {
  background: var(--card);
  border-radius: 1rem;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}

/* --- Header --- */
.top { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.who { display: flex; align-items: center; gap: 0.4rem; }
.who .avatar { font-size: 1.8rem; }
.stats { display: flex; gap: 1rem; margin-left: auto; }
.stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.stat .value { font-weight: 700; }
.stat .label { font-size: 0.75rem; color: var(--muted); }

/* --- Checklista --- */
.tasks li + li { margin-top: 0.4rem; }
.task {
  display: flex; align-items: center; gap: 0.75rem;
  width: 100%; text-align: left;
  background: var(--bg); color: var(--fg);
  padding: 0.75rem;
}
.task .check {
  flex: none; display: grid; place-items: center;
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  border: 2px solid var(--accent); font-size: 0.9rem;
}
.task .title { flex: 1; display: flex; flex-direction: column; }
.task .note { font-size: 0.8rem; color: var(--danger); }
.task .note.muted { color: var(--muted); }
.task .due, .task .xp { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.task.done .check { border-color: var(--gold); }
.task.approved { background: var(--accent-soft); }
.task.approved .check { background: var(--accent); color: white; }
.task.approved .title { color: var(--muted); text-decoration: line-through; }

/* --- Progress --- */
.progress { height: 0.6rem; background: var(--line); border-radius: 1rem; overflow: hidden; margin: 0.5rem 0; }
.progress .bar { height: 100%; background: var(--accent); transition: width 0.4s; }

/* --- Extrajobb --- */
.extras li + li { margin-top: 0.4rem; }
.extra-head {
  display: flex; justify-content: space-between; gap: 0.5rem;
  width: 100%; text-align: left;
  background: var(--bg); color: var(--fg); padding: 0.75rem;
}
.extra-head .price { font-weight: 700; color: var(--accent); white-space: nowrap; }
.extra-panel { padding: 0.5rem 0.25rem; }
.qty { display: flex; align-items: center; justify-content: center; gap: 1rem; }
.qty span { min-width: 6rem; text-align: center; font-weight: 600; }
.recent li { display: flex; justify-content: space-between; padding: 0.3rem 0; }
.plus { color: var(--accent); font-weight: 700; }

/* --- Förälder --- */
.badge {
  background: var(--danger); color: white; border-radius: 1rem;
  padding: 0.1rem 0.5rem; font-size: 0.8rem; vertical-align: middle;
}
.review { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0; }
.review + .review { border-top: 1px solid var(--line); }
.review .what { flex: 1; display: flex; align-items: center; gap: 0.5rem; }
.review .what div { display: flex; flex-direction: column; }
.review .avatar { font-size: 1.5rem; }
.actions { display: flex; gap: 0.3rem; }
.actions button { padding: 0.5rem 0.7rem; }
.actions .bonus { background: var(--gold); }
.actions .reject { background: var(--line); color: var(--danger); }
.child + .child { border-top: 1px solid var(--line); margin-top: 0.75rem; padding-top: 0.75rem; }
.child-head { display: flex; align-items: center; gap: 0.4rem; }
.child-head .avatar { font-size: 1.5rem; }
.child-head .balance { margin-left: auto; font-weight: 700; }
.payout { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.payout .primary { width: auto; margin: 0; }

/* --- Inloggning --- */
.profiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.profile {
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  padding: 1.25rem 0.5rem; background: white; color: var(--fg);
  border: 3px solid var(--c, var(--accent));
}
.profile .avatar { font-size: 2.5rem; }
.pinpad { text-align: center; }
.dots { display: flex; justify-content: center; gap: 0.75rem; margin: 1rem 0; }
.dot { width: 1rem; height: 1rem; border-radius: 50%; border: 2px solid var(--accent); }
.dot.filled { background: var(--accent); }
.error { color: var(--danger); min-height: 1.5em; }
.keys { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; max-width: 18rem; margin: 0 auto; }
.key { font-size: 1.5rem; padding: 0.9rem 0; }

/* --- Butik --- */
.reward { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.5rem 0; }
.reward + .reward { border-top: 1px solid var(--line); }
.reward div { display: flex; flex-direction: column; }

/* --- Flikar --- */
main:has(.tabs) { padding-bottom: 5rem; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center; gap: 0.5rem;
  padding: 0.5rem 1rem calc(0.5rem + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line);
}
.tabs a {
  flex: 0 1 10rem; display: flex; flex-direction: column; align-items: center;
  padding: 0.3rem; border-radius: 0.6rem; color: var(--muted);
  text-decoration: none; font-size: 0.8rem;
}
.tabs a span { font-size: 1.3rem; }
.tabs a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* --- Admin --- */
.subtabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; }
.subtabs a {
  padding: 0.4rem 0.9rem; border-radius: 2rem; background: var(--line);
  color: var(--fg); text-decoration: none; font-size: 0.9rem;
}
.subtabs a.active { background: var(--accent); color: white; }
.flash { background: var(--accent-soft); color: var(--accent); padding: 0.6rem 0.9rem; border-radius: 0.6rem; }
.item { border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item summary {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.5rem;
  padding: 0.7rem 0; cursor: pointer; list-style: none;
}
.item summary::-webkit-details-marker { display: none; }
.item summary::after { content: "›"; margin-left: auto; color: var(--muted); transition: transform 0.2s; }
.item[open] summary::after { transform: rotate(90deg); }
.item summary .avatar { font-size: 1.3rem; }
.item.new summary { color: var(--accent); }
.edit { display: flex; flex-direction: column; gap: 0.6rem; padding: 0 0 1rem; }
.edit h3 { font-size: 1rem; margin: 0.5rem 0 0; }
.field { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; min-width: 0; }
.field > span { font-size: 0.8rem; color: var(--muted); }
.row { display: flex; gap: 0.6rem; }
select { font: inherit; padding: 0.5rem; border: 2px solid var(--line); border-radius: 0.6rem; background: white; }
input[type=color] { padding: 0.2rem; height: 2.6rem; }
input[type=checkbox] { width: auto; margin: 0; }
fieldset { border: 2px solid var(--line); border-radius: 0.6rem; padding: 0.4rem 0.6rem 0.6rem; margin: 0;
           display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; }
legend { font-size: 0.8rem; color: var(--muted); padding: 0 0.3rem; }
.check-label { display: inline-flex; align-items: center; gap: 0.35rem; }
.item-actions { padding-bottom: 1rem; }
