:root {
  --bg: #f3efe6;
  --paper: #fffdf8;
  --ink: #222;
  --muted: #6a6257;
  --primary: #0b6e4f;
  --primary-light: #e5f4ee;
  --secondary: #d27a3a;
  --danger: #b23a48;
  --border: #d7cfc4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  padding: 1rem;
}

header, main {
  width: min(720px, 100%);
  margin: 0 auto;
}

/* ---- Header ---- */

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.1rem;
}

.header-row h1 {
  margin: 0;
  font-size: 1.25rem;
  text-align: center;
}

.nav-link {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
  min-width: 5rem;
}

.nav-link:last-child { text-align: right; }
.nav-link:hover { text-decoration: underline; }

.status-bar {
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  min-height: 1.2em;
  margin: 0.2rem 0 0.85rem;
}

/* ---- Layout ---- */

main {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem 1.2rem;
  box-shadow: 0 4px 14px #0000000a;
}

.panel > h2 {
  margin: 0 0 0.8rem;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
}

/* ---- Kid cards ---- */

.kids-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.kid-card {
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem 0.8rem;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
  box-shadow: 0 3px 10px #0000000a;
}

.kid-card:hover { border-color: #7abfa0; }

.kid-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 3px 14px #0b6e4f1a;
}

.kid-name {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

.balance {
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--primary);
}

.balance.negative {
  color: var(--danger);
}

/* ---- Daily entry panel ---- */

.daily-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.daily-header h2 { margin: 0; }

.date-label input[type="date"] {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.6rem;
  font: inherit;
  font-size: 0.875rem;
  background: #fff;
  color: var(--ink);
}

/* ---- Assignment rows ---- */

.assignment-rows {
  display: flex;
  flex-direction: column;
}

.assignment-row {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.assignment-row:last-child { border-bottom: none; }

.asgn-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.45rem;
}

.asgn-name {
  font-weight: 600;
  font-size: 0.97rem;
}

.asgn-earned {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--primary);
  min-width: 3.5rem;
  text-align: right;
}

.asgn-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.pct-slider {
  -webkit-appearance: none;
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.pct-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 1px 4px #0002;
}

.pct-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 4px #0002;
}

.pct-label {
  flex-shrink: 0;
  width: 2.8rem;
  text-align: right;
  font-size: 0.83rem;
  color: var(--muted);
}

.asgn-max-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.entry-mode-badge {
  margin: 0.3rem 0 0;
  padding: 0.35rem 0.7rem;
  background: #fff8e1;
  border: 1px solid #f0c040;
  border-radius: 8px;
  color: #7a5c00;
  font-size: 0.82rem;
  font-weight: 600;
}

/* ---- Daily footer ---- */

.daily-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-top: 0.85rem;
  gap: 0.8rem;
}

.daily-total-row {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.daily-total-row span {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.daily-total-row strong,
#daily-total {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
}

.daily-note-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.daily-note {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font: inherit;
  font-size: 0.875rem;
  resize: vertical;
  color: inherit;
  background: #fff;
}

.daily-note:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

.entry-note {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- Buttons ---- */

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  white-space: nowrap;
}

button:hover { filter: brightness(1.07); }

.btn-danger, .delete-kid, .delete-assignment { background: var(--danger); }
.btn-secondary { background: var(--muted); font-weight: 600; }

/* ---- Inputs ---- */

input:not([type="range"]):not([type="checkbox"]):not([type="date"]),
select {
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 0.5rem 0.7rem;
  font: inherit;
  background: #fff;
  width: 100%;
}

input:not([type="range"]):not([type="checkbox"]):not([type="date"]):focus,
select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

/* ---- Transaction list ---- */

.txns {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.txns li {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  background: #fff;
}

.txns-empty { color: var(--muted); font-size: 0.9rem; border: none !important; background: transparent !important; }

.txn-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  font-size: 0.95rem;
}

.txn-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.txn-detail {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.negative { color: var(--danger); font-weight: 700; }
.positive { color: var(--primary); font-weight: 700; }

/* ---- Photo attachments ---- */

.photo-file-input { display: none; }

.photo-picker-row { display: flex; align-items: center; gap: 0.5rem; }

.photo-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  cursor: pointer;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  transition: border-color 0.15s, color 0.15s;
  user-select: none;
}

.photo-picker-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.photo-preview:empty { display: none; }

.photo-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
}

.existing-photos {
  margin-top: 0.1rem;
}

.existing-photos::before {
  content: "Saved photos:";
  display: block;
  width: 100%;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.entry-photo-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0 0.25rem;
}

.entry-photo-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: opacity 0.15s;
  display: block;
}

.entry-photo-thumb:hover { opacity: 0.82; }

/* ---- Spend / Deduction forms ---- */

.txn-forms {
  display: flex;
  gap: 1.2rem;
  align-items: flex-start;
}

.txn-form-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.txn-form-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.spend-title     { color: #a05a1a; }
.deduction-title { color: var(--danger); }

.txn-form-desc {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.txn-form-row {
  display: flex;
  gap: 0.5rem;
}

.txn-amount-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font: inherit;
  font-size: 0.875rem;
}

.txn-date-input {
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font: inherit;
  font-size: 0.875rem;
  background: #fff;
}

.txn-form-divider {
  width: 1px;
  align-self: stretch;
  background: var(--border);
  flex-shrink: 0;
}

.btn-spend {
  background: #d27a3a;
}

.btn-deduction {
  background: var(--danger);
}

/* ---- Settings page ---- */

.kid-manager-list,
.assignment-manager-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.kid-manager-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
}

.assignment-manager-row {
  display: grid;
  grid-template-columns: 1fr 6rem auto auto;
  gap: 0.5rem;
  align-items: center;
}

.add-row-form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.add-row-form input { flex: 1; }

.add-assignment-form input:last-of-type { flex: 0; }

/* ---- Notifications ---- */

.notif-fields {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.95rem;
  cursor: pointer;
}

.toggle-label input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--primary);
  cursor: pointer;
}

.inline-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
}

.inline-label input { width: auto; flex: 0; }

label:not(.toggle-label):not(.inline-label):not(.date-label) {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.88rem;
}

.notif-status {
  font-weight: 600;
  margin-top: -0.3rem;
}

/* ---- GitHub config ---- */

.config-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.7rem;
  margin-bottom: 0.85rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.hint {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.87rem;
}

.hint.center, .center { text-align: center; padding: 1rem 0; }

/* ---- Responsive ---- */

@media (max-width: 540px) {
  .assignment-manager-row {
    grid-template-columns: 1fr 5rem auto auto;
  }
  .config-grid {
    grid-template-columns: 1fr;
  }
  .daily-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .daily-footer button {
    width: 100%;
  }
  .txn-forms {
    flex-direction: column;
  }
  .txn-form-divider {
    width: auto;
    height: 1px;
    align-self: stretch;
  }
  .txn-amount-input,
  .txn-date-input,
  .btn-spend,
  .btn-deduction {
    width: 100%;
  }
}

/* ---- Header multi-link nav ---- */

.header-nav {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: flex-end;
  min-width: 8rem;
}

/* ---- Balances section (home page) ---- */

.balances-section {
  padding: 0;
}

.section-label {
  margin: 0 0 0.55rem;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
}

/* ---- Daily panel (home page) ---- */

.daily-panel {
  margin-top: 0.15rem;
}

/* ---- Entries page ---- */

.entries-filter-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.filter-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

.filter-label select {
  width: auto;
  min-width: 9rem;
}

.entry-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.entry-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  background: #fff;
}

.entry-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.entry-card-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.txn-type-badge {
  display: inline-block;
  border-radius: 4px;
  padding: 0 0.35em;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  align-self: flex-start;
}

.txn-type-daily      { background: var(--primary-light); color: var(--primary); }
.txn-type-spend      { background: #fde8cd; color: #a05a1a; }
.txn-type-deduction  { background: #fce4e7; color: var(--danger); }

.entry-kid-name {
  font-size: 1rem;
  font-weight: 700;
}

.entry-date {
  font-size: 0.83rem;
  color: var(--muted);
}

.entry-card-total {
  font-size: 1.35rem;
  font-weight: 800;
  white-space: nowrap;
}

.entry-detail {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.entry-detail-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.entry-pct {
  font-size: 0.78rem;
  color: var(--muted);
}

.entry-card-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.btn-edit {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 0.45rem 0.9rem;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  text-decoration: none;
  font-size: 0.875rem;
}

.btn-edit:hover { filter: brightness(1.07); }

.btn-delete-entry {
  padding: 0.45rem 0.9rem;
  font-size: 0.875rem;
}

@media (max-width: 540px) {
  .entry-detail-row {
    grid-template-columns: 1fr auto auto;
  }
  .entry-pct { display: none; }
}
