html {
  /* Site-wide text is ~30% bigger by scaling the root font-size: every
     rem-based size in this file (and Jinja-authored inline rem/em sizes)
     cascades from this one token instead of hunting each declaration.
     16px * 1.3 = ~20.8px. */
  font-size: 130%;
}
:root {
  --bg: #f7f5f2;
  --card: #ffffff;
  --text: #23201c;
  --muted: #766f66;
  --accent: #7a4f2b;
  --accent2: #2e6b57;
  --border: #e4ddd3;
  --good: #2e6b57;
  --warn: #b5892b;
  --bad: #b1443a;
  --font-head: 'Frank Ruhl Libre', serif;
  --font-body: 'Rubik', sans-serif;
}
[data-theme="dark"] {
  --bg: #1a1815;
  --card: #242019;
  --text: #efe9e1;
  --muted: #a99f92;
  --accent: #d3a26b;
  --accent2: #6bbfa2;
  --border: #3a352c;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-body); direction: rtl; padding-bottom: 40px;
}
h1, h2, h3 { font-family: var(--font-head); }
.container { max-width: 940px; margin: 0 auto; padding: 12px 16px 60px; }
.topnav {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 10px 16px; position: sticky; top: 0; z-index: 10;
}
.brand { font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; color: var(--accent); text-decoration: none; }
.navlinks { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 0.85rem; }
.navlinks a { color: var(--text); text-decoration: none; padding: 4px 6px; border-radius: 6px; }
.navlinks a:hover { background: var(--border); }
#themeToggle { background: none; border: none; font-size: 1rem; cursor: pointer; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 14px; }
.week-strip { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; }
.week-day { flex: 1; min-width: 44px; text-align: center; padding: 8px 4px; border-radius: 10px; background: var(--card); border: 1px solid var(--border); cursor: pointer; text-decoration: none; color: var(--text); }
.week-day.today { border-color: var(--accent); font-weight: 700; }
.week-day .score { display: block; font-size: 1.1rem; font-weight: 700; color: var(--accent2); }

.score-big { font-size: 3rem; font-weight: 700; font-family: var(--font-head); color: var(--accent2); text-align: center; }
.bonus-line { text-align: center; color: var(--warn); font-size: 0.9rem; margin-bottom: 8px; }

.window-block { margin-bottom: 18px; }
.window-title { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; margin-bottom: 6px; }
.window-title .wscore { color: var(--accent2); font-size: 0.95rem; }

.item-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.item-row:last-child { border-bottom: none; }
.item-name { flex: 1; }
.item-name small { display: block; color: var(--muted); font-size: 0.75rem; }
.chip { font-size: 0.72rem; padding: 2px 7px; border-radius: 999px; background: var(--border); color: var(--muted); margin-inline-start: 6px; }
.chip.good { background: rgba(46,107,87,0.15); color: var(--good); }
.chip.warn { background: rgba(181,137,43,0.15); color: var(--warn); }

.checkbtn { width: 34px; height: 34px; border-radius: 10px; border: 2px solid var(--border); background: var(--card); font-size: 1rem; cursor: pointer; }
.checkbtn.on { background: var(--good); border-color: var(--good); color: white; }

.qty-control { display: flex; align-items: center; gap: 6px; }
.qty-control button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); font-size: 1rem; cursor: pointer; }
.qty-control input { width: 56px; text-align: center; border: 1px solid var(--border); border-radius: 8px; padding: 4px; background: var(--bg); color: var(--text); }
.quick-add { font-size: 0.72rem; padding: 3px 8px; border-radius: 8px; border: 1px dashed var(--accent); background: none; color: var(--accent); cursor: pointer; }

textarea, input[type=text], input[type=date], input[type=number], select {
  width: 100%; padding: 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-family: var(--font-body);
}
button.primary { background: var(--accent); color: white; border: none; padding: 10px 16px; border-radius: 10px; font-weight: 600; cursor: pointer; }
button.secondary { background: none; border: 1px solid var(--border); color: var(--text); padding: 8px 12px; border-radius: 10px; cursor: pointer; }

.save-status { text-align: center; font-size: 0.8rem; color: var(--muted); min-height: 1.2em; }
.weeknav { display: flex; justify-content: space-between; margin-bottom: 8px; }

/* Tables: wider + roomier cells, but still safe on a phone screen — the
   wrapper scrolls horizontally instead of squeezing columns or breaking the
   page layout (primary use case is marking items from a phone). */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; min-width: 480px; border-collapse: collapse; font-size: 0.85rem; }
table th, table td { border: 1px solid var(--border); padding: 8px 10px; min-width: 52px; text-align: center; }

@media (max-width: 480px) {
  /* Keep the increased text from overwhelming a phone width: tables stay
     legible via horizontal scroll instead of shrinking further. */
  table { font-size: 0.78rem; }
  table th, table td { padding: 6px 8px; min-width: 44px; }
}
.badge-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.badge { font-size: 0.75rem; padding: 4px 8px; border-radius: 999px; }
.badge.overdue { background: rgba(177,68,58,0.15); color: var(--bad); }
.badge.due { background: rgba(181,137,43,0.15); color: var(--warn); }
.badge.ok { background: rgba(46,107,87,0.15); color: var(--good); }

.periodic-row { display: flex; flex-direction: column; gap: 6px; }
.periodic-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.periodic-name { font-family: var(--font-head); font-size: 1.05rem; }
.periodic-meta { color: var(--muted); }
.periodic-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.admin-form label { display: flex; flex-direction: column; gap: 4px; }

.heatmap { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.heat-cell { aspect-ratio: 1; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 0.65rem; color: white; }

form.admin-form { display: grid; gap: 8px; margin-bottom: 10px; }
.admin-item-row { border-bottom: 1px solid var(--border); padding: 8px 0; }
.error { color: var(--bad); }
.small { font-size: 0.8rem; color: var(--muted); }
