/* Shared look for all pages: warm cream, gingerbread brown, fir green, red accent. Design tokens first, components below. */
:root {
  --cream: #fbf3e4;
  --paper: #fffaf0;
  --brown: #6b3b1e;
  --brown-dark: #43240f;
  --ginger: #a1622f;
  --green: #1f5d3b;
  --green-soft: #e0eee4;
  --red: #b3261e;
  --red-soft: #fbe3e0;
  --gold: #d99a2b;
  --gold-soft: #fbefcf;
  --grey: #7d746a;
  --grey-soft: #efe7d8;
  --line: #e6d8bf;
  --radius: 16px;
  --tap: 48px;
  --shadow: 0 2px 8px rgba(67, 36, 15, 0.12);
  --font: ui-rounded, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-head: ui-rounded, "Arial Rounded MT Bold", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--cream); color: var(--brown-dark); font: 17px/1.45 var(--font); }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.2; margin: 0 0 0.5rem; color: var(--brown); }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
a { color: var(--green); }
p { margin: 0 0 0.75rem; }
.muted { color: var(--grey); }
.small { font-size: 0.9rem; }
.hidden { display: none !important; }

/* Header and navigation */
.app-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.9rem; background: var(--brown); color: #fff; box-shadow: var(--shadow); }
.app-header img { width: 40px; height: 40px; }
.app-header .title { flex: 1; font: 700 1.1rem var(--font-head); }
.icon-btn { position: relative; min-width: var(--tap); height: var(--tap); border: 0; border-radius: 12px; background: rgba(255, 255, 255, 0.14); color: #fff; font-size: 1.3rem; cursor: pointer; }
.icon-btn .count { position: absolute; top: 2px; right: 2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--red); color: #fff; font: 700 0.75rem/20px var(--font); }
.top-nav { position: sticky; top: 56px; z-index: 15; display: flex; gap: 0.4rem; overflow-x: auto; padding: 0.5rem 0.9rem; background: var(--paper); border-bottom: 1px solid var(--line); }
.top-nav a { flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 1rem; border-radius: 22px; background: var(--grey-soft); color: var(--brown); font-weight: 600; text-decoration: none; }
.top-nav a.active { background: var(--green); color: #fff; }
.top-nav .badge { margin-left: 0.4rem; }
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--paper); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 58px; color: var(--grey); font-size: 0.78rem; text-decoration: none; }
.bottom-nav a span { font-size: 1.4rem; line-height: 1.2; }
.bottom-nav a.active { color: var(--green); font-weight: 700; }
.page { max-width: 880px; margin: 0 auto; padding: 1rem 0.9rem 5rem; }
.page.wide { max-width: 1100px; }

/* Cards and rows */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem; margin-bottom: 0.8rem; box-shadow: var(--shadow); }
.card.warn { border-color: var(--gold); background: var(--gold-soft); }
.card.bad { border-color: var(--red); background: var(--red-soft); }
.card.good { border-color: var(--green); background: var(--green-soft); }
.row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 0.6rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.8rem; }
.empty { padding: 1.5rem 1rem; text-align: center; color: var(--grey); background: var(--paper); border: 2px dashed var(--line); border-radius: var(--radius); }

/* Buttons and inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; min-height: var(--tap); padding: 0 1.1rem; border: 2px solid var(--green); border-radius: 14px; background: var(--green); color: #fff; font: 700 1rem var(--font); cursor: pointer; text-decoration: none; }
.btn.secondary { background: transparent; color: var(--green); }
.btn.danger { background: var(--red); border-color: var(--red); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--brown); }
.btn.small { min-height: 40px; padding: 0 0.8rem; font-size: 0.9rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }
input, select, textarea { width: 100%; min-height: var(--tap); padding: 0.5rem 0.8rem; border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--brown-dark); font: 1rem var(--font); }
input[type="checkbox"] { width: 28px; min-height: 28px; height: 28px; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 1px; }
label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.field { margin-bottom: 0.8rem; }
.inline { display: flex; gap: 0.5rem; align-items: end; flex-wrap: wrap; }
.inline > * { flex: 1 1 140px; }

/* Chips, badges, state buttons */
.chip { display: inline-flex; align-items: center; gap: 0.3rem; min-height: 34px; padding: 0 0.7rem; border-radius: 17px; background: var(--grey-soft); font-weight: 600; font-size: 0.95rem; }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.gold { background: var(--gold-soft); color: #7a4f00; }
.chip.struck { text-decoration: line-through; }
.chip button { border: 0; background: transparent; font-size: 1.1rem; color: inherit; cursor: pointer; min-width: 30px; min-height: 30px; }
.badge { display: inline-block; min-width: 24px; padding: 0 7px; border-radius: 12px; background: var(--red); color: #fff; font: 700 0.8rem/24px var(--font); text-align: center; }
.badge.green { background: var(--green); }
.badge.gold { background: var(--gold); color: #fff; }
.seg { display: flex; gap: 0.35rem; }
.seg button { flex: 1; min-height: var(--tap); border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--grey); font: 700 0.95rem var(--font); cursor: pointer; }
.seg button.on-can { background: var(--green); border-color: var(--green); color: #fff; }
.seg button.on-cannot { background: var(--red); border-color: var(--red); color: #fff; }
.seg button.on-any { background: var(--grey); border-color: var(--grey); color: #fff; }
.seg button.on-neutral { background: var(--brown); border-color: var(--brown); color: #fff; }

/* Shifts in the plan */
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.shift { padding: 0.6rem; margin-top: 0.5rem; border-radius: 12px; border: 2px solid var(--line); background: #fff; }
.shift.gap { border-color: var(--red); background: var(--red-soft); }
.shift.full { border-color: var(--green); }
.count-pill { padding: 2px 10px; border-radius: 12px; font-weight: 700; background: var(--green-soft); color: var(--green); }
.shift.gap .count-pill { background: var(--red); color: #fff; }
.overlay { margin-top: 0.4rem; font-size: 0.85rem; color: var(--grey); }
.overlay .yes { color: var(--green); font-weight: 600; }
.overlay .no { color: var(--red); font-weight: 600; }
.hint-yellow { color: #7a4f00; background: var(--gold-soft); border-radius: 8px; padding: 2px 8px; font-size: 0.85rem; }
.hint-red { color: var(--red); background: var(--red-soft); border-radius: 8px; padding: 2px 8px; font-size: 0.85rem; font-weight: 600; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--paper); }
th, td { padding: 0.5rem 0.6rem; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
td input { min-height: 40px; padding: 0.2rem 0.4rem; min-width: 84px; }
th { font-size: 0.85rem; color: var(--grey); }
td.num, th.num { text-align: right; }

/* Dialog and toast */
.overlay-bg { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(67, 36, 15, 0.5); }
.dialog { width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; padding: 1rem; border-radius: 20px 20px 0 0; background: var(--cream); }
@media (min-width: 700px) { .overlay-bg { align-items: center; } .dialog { border-radius: 20px; } }
.toast { position: fixed; left: 50%; bottom: 80px; z-index: 60; transform: translateX(-50%); max-width: 92vw; padding: 0.7rem 1.1rem; border-radius: 14px; background: var(--brown-dark); color: #fff; box-shadow: var(--shadow); }
.toast.error { background: var(--red); }
.copy-box { padding: 0.6rem; border: 2px dashed var(--line); border-radius: 12px; background: #fff; font-size: 0.9rem; word-break: break-all; white-space: pre-wrap; }
.login-box { max-width: 420px; margin: 8vh auto; padding: 0 1rem; text-align: center; }
.login-box img { width: 96px; height: 96px; }
.login-box form { text-align: left; }
.badge:empty { display: none; }
button.card { display: block; font: inherit; color: inherit; }
