:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #637083;
  --line: #d9dee7;
  --line-strong: #b9c1ce;
  --brand: #2878d7;
  --brand-dark: #1d5eab;
  --chip: #e6eaf0;
  --danger: #ba3a3a;
  --shadow: 0 8px 24px rgba(20, 31, 48, 0.14);
  --nav: 64px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

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

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 44px 1fr auto auto;
  align-items: center;
  min-height: 61px;
  padding: 0 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.content {
  position: relative;
  min-height: 0;
  padding-bottom: var(--nav);
}

.view {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 0 92px;
}

.wide {
  max-width: 1180px;
}

.filter-label,
.table-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 12px 14px;
  min-height: 43px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  color: #0b1830;
  font-size: 14px;
}

.group-row,
.person-row,
.report-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 38px;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.person-row {
  grid-template-columns: 56px 1fr 42px 42px auto;
  min-height: 43px;
  padding: 0 10px;
}

.thumb {
  width: 48px;
  height: 40px;
  object-fit: cover;
  background: #cdd5df;
}

.thumb-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 18px;
}

.count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 5px;
  background: var(--chip);
  color: #425067;
  font-size: 13px;
}

.chevron {
  font-size: 28px;
  color: #1b2433;
}

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(var(--nav) + 12px);
  z-index: 30;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: #428fe3;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 38px;
  line-height: 1;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  min-height: var(--nav);
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -3px 12px rgba(21, 30, 45, 0.08);
}

.nav-item {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  border: 0;
  background: transparent;
  color: #555f70;
  font-size: 11px;
  border-bottom: 4px solid transparent;
}

.nav-item.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.nav-icon {
  font-size: 20px;
  line-height: 1;
}

.form-page {
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 22px 160px;
  background: var(--surface);
  min-height: calc(100vh - 61px);
}

.form-page h2 {
  margin: 0 0 18px;
  font-size: 24px;
  font-weight: 500;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
}

.field label {
  color: #11203a;
  font-size: 16px;
}

.required::after {
  content: "*";
  color: var(--brand);
}

.input,
.textarea,
.select {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: #0f1b2d;
  padding: 10px 12px;
}

.textarea {
  min-height: 86px;
  resize: vertical;
}

.number-stepper {
  display: grid;
  grid-template-columns: 1fr 52px 52px;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  min-height: 48px;
  overflow: hidden;
}

.number-stepper input {
  min-width: 0;
  border: 0;
  padding: 8px 14px;
}

.step-button {
  height: 48px;
  border: 0;
  background: #fff;
  color: #5c6572;
  font-size: 32px;
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(var(--segments, 2), 1fr);
  gap: 6px;
}

.segment {
  min-height: 54px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: #3f4a5c;
}

.segment.active {
  background: #438ada;
  color: #fff;
  border-color: #438ada;
}

.photo-button {
  display: grid;
  place-items: center;
  min-height: 70px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: #55616f;
  font-size: 28px;
}

.form-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 35;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  min-height: 62px;
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--line);
  box-shadow: 0 -3px 16px rgba(21, 30, 45, 0.12);
}

.form-actions button {
  border: 0;
  background: transparent;
  color: #141a24;
  font-size: 17px;
}

.form-actions .primary {
  color: var(--brand);
  font-weight: 600;
}

.pattern-band {
  height: 220px;
  margin: 26px -22px -10px;
  background:
    repeating-linear-gradient(45deg, transparent 0 24px, rgba(47, 117, 186, 0.6) 25px 27px, transparent 28px 52px),
    repeating-linear-gradient(135deg, transparent 0 18px, rgba(42, 104, 168, 0.78) 19px 21px, transparent 22px 48px),
    #08101a;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  padding: 16px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.metric h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}

.metric strong {
  font-size: 34px;
  font-weight: 650;
}

.chart {
  display: grid;
  gap: 10px;
  padding: 16px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.bar {
  display: grid;
  grid-template-columns: 120px 1fr 48px;
  gap: 10px;
  align-items: center;
}

.bar-track {
  height: 12px;
  background: #e8edf4;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--brand);
}

.empty {
  padding: 30px 18px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--nav) + 20px);
  z-index: 50;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 7px;
  background: #172033;
  color: #fff;
  box-shadow: var(--shadow);
}

@media (min-width: 720px) {
  body {
    background: linear-gradient(90deg, #f0f3f7, #ffffff 22%, #ffffff 78%, #f0f3f7);
  }

  .bottom-nav,
  .form-actions {
    max-width: 600px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }

  .topbar {
    max-width: 600px;
    margin: 0 auto;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }

  .topbar.wide-top {
    max-width: 1180px;
  }

  .fab {
    right: calc((100vw - min(600px, 100vw)) / 2 + 18px);
  }
}
