:root {
  --red: #ea3129;
  --blue: #031d8c;
  --yellow: #f7d823;
  --ink: #232323;
  --muted: #6b6b76;
  --line: #e7e3d9;
  --bg: #faf8f3;
  --card: #ffffff;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(35, 35, 35, 0.08);
  --shadow-sm: 0 2px 10px rgba(35, 35, 35, 0.06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: calc(92px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}

body.no-scroll { overflow: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--blue); }

/* ---------- Layout ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(250, 248, 243, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: conic-gradient(from 210deg, var(--red) 0 33%, var(--yellow) 33% 66%, var(--blue) 66% 100%);
  box-shadow: inset 0 0 0 3px #fff, var(--shadow-sm);
}

.brand { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand strong { font-size: 15px; letter-spacing: 0.2px; }
.brand span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.saved {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 22px 18px 10px;
}

/* ---------- Typography ---------- */
h1 { font-size: 24px; line-height: 1.15; margin: 0 0 6px; letter-spacing: -0.4px; }
h2 { font-size: 18px; margin: 0 0 12px; letter-spacing: -0.2px; }
h3 { font-size: 15px; margin: 0 0 4px; }
p { margin: 0 0 10px; line-height: 1.5; }
.lead { color: var(--muted); font-size: 14.5px; }
.eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 6px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.card.flat { box-shadow: none; }

.hero {
  background: linear-gradient(135deg, #fff 0%, #fffdf4 100%);
  border-top: 4px solid var(--red);
}

.hint {
  background: #fffbe8;
  border: 1px solid #f2e6a8;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.45;
  color: #5c4b05;
}

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 14px 0 4px;
}

.stat {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.stat b { display: block; font-size: 24px; line-height: 1.1; letter-spacing: -0.5px; }
.stat span { font-size: 11.5px; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 6px 16px rgba(234, 49, 41, 0.28); }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 6px 16px rgba(3, 29, 140, 0.22); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 38px; padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.block { display: flex; width: 100%; }
.btn.danger { color: #b3241d; border-color: #f0c3c0; background: #fff7f6; }

.row { display: flex; flex-wrap: wrap; gap: 8px; }
.row.between { justify-content: space-between; align-items: center; }

.actions { display: grid; gap: 8px; margin-top: 12px; }

/* ---------- Chips ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef0fb;
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.badge.red { background: #fdeceb; color: #b3241d; }
.badge.yellow { background: #fdf7d5; color: #7a6500; }
.badge.green { background: #e8f5ec; color: #1c6b37; }
.badge.grey { background: #f0efe9; color: var(--muted); }

/* ---------- Lists ---------- */
.list { display: grid; gap: 10px; }

.item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
}
.item-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.item-head h3 { font-size: 15.5px; }
.meta { font-size: 12px; color: var(--muted); }
.item p { font-size: 13.5px; margin: 6px 0 0; }
.item .row { margin-top: 10px; }

.quote {
  border-left: 3px solid var(--yellow);
  padding: 4px 0 4px 10px;
  margin: 8px 0;
  font-size: 13.5px;
  color: #4b4b52;
}

.empty {
  text-align: center;
  padding: 26px 16px;
  color: var(--muted);
  border: 1px dashed #d9d4c7;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
}

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 6px; letter-spacing: 0.1px; }
.field .help { font-size: 11.5px; color: var(--muted); font-weight: 400; margin-top: 4px; display: block; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
select,
textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid #d8d4c8;
  border-radius: 11px;
  background: #fff;
  font-size: 16px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(3, 29, 140, 0.1); }
textarea { min-height: 84px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; gap: 9px; align-items: flex-start; font-size: 13.5px; line-height: 1.4; }
.check input { width: 18px; height: 18px; margin-top: 2px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(20, 20, 24, 0.45);
  backdrop-filter: blur(3px);
  padding: 0;
}
.modal.open { display: flex; }
.sheet {
  width: 100%;
  max-width: 620px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(22px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  position: sticky;
  top: -18px;
  background: var(--bg);
  padding: 6px 0 10px;
  z-index: 2;
}
.sheet-head h2 { margin: 0; font-size: 18px; }
.icon-btn {
  margin-left: auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

/* ---------- Bottom nav ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: space-around;
  gap: 2px;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: 0;
  background: none;
  color: #8b8b94;
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 2px;
  cursor: pointer;
  border-radius: 10px;
}
.tab svg { width: 21px; height: 21px; }
.tab.active { color: var(--red); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.small { font-size: 12px; color: var(--muted); line-height: 1.5; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (min-width: 720px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  main { padding: 28px 26px 20px; }
  .modal { align-items: center; padding: 24px; }
  .sheet { border-radius: 22px; }
  .actions { grid-template-columns: 1fr 1fr; }
  .actions .block:first-child { grid-column: 1 / -1; }
}

@media print {
  .tabbar, .topbar, .btn, .modal { display: none !important; }
}
