:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --card-soft: #eef4f2;
  --text: #15202b;
  --muted: #6f7b86;
  --line: #dbe2e8;
  --accent: #0f766e;
  --accent-2: #1f9d8b;
  --ok: #2f9a66;
  --danger: #b63a3a;
  --shadow: 0 8px 28px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top right, #fbfffd 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "SF Pro Text", "Inter", "Segoe UI", sans-serif;
  line-height: 1.35;
  scroll-behavior: smooth;
}

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

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.app-hero {
  padding: max(12px, env(safe-area-inset-top)) 14px 12px;
}

.hero-content {
  max-width: 880px;
  margin: 0 auto;
}

.app-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

h1 {
  margin-bottom: 3px;
  font-size: 2rem;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.subline {
  color: var(--muted);
  font-size: 1rem;
}

.save-status {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.utility-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.utility-actions .ghost-button {
  min-height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 0.8rem;
}

.utility-actions .ghost-button.danger {
  color: var(--danger);
}

.save-button,
.primary-button,
.icon-button,
.square-button,
.ghost-button,
.secondary-button {
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 700;
}

.save-button,
.primary-button {
  color: #fff;
  border: 0;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
}

.icon-button,
.secondary-button,
.ghost-button,
.square-button {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.stats-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #dbe9e3;
  border-radius: 16px;
  background: linear-gradient(160deg, #eef8f4, #f8fcfb);
}

.stats-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: inline-grid;
  place-items: center;
  background: #d4ebe3;
  font-size: 1.35rem;
}

.stats-main .stats-title {
  margin: 0;
  color: var(--muted);
}

.stats-main .stats-date {
  margin: 2px 0 0;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.stats-progress {
  grid-column: 1 / -1;
}

.stats-progress strong {
  color: var(--accent);
  font-size: 1.4rem;
}

.stats-progress span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.92rem;
}

.progress-track {
  margin-top: 8px;
  height: 8px;
  border-radius: 999px;
  background: #dbe3e1;
  overflow: hidden;
}

#completionBar {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #0d8e7f, #3cb69f);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-top: 10px;
}

.stats-grid article {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.stats-grid span {
  display: block;
  font-weight: 900;
  font-size: 1.15rem;
}

.stats-grid p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.73rem;
}

.app-shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 8px 10px calc(96px + env(safe-area-inset-bottom));
}

.toolbar,
.panel,
.category-block {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.toolbar {
  padding: 10px;
  display: grid;
  gap: 9px;
}

.quick-tabs {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding-bottom: 2px;
}

.quick-tabs::-webkit-scrollbar {
  display: none;
}

.tab-pill {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.tab-pill.is-active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
}

label,
.person-picker {
  display: grid;
  gap: 6px;
}

label > span,
.person-picker legend {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  padding: 8px 11px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #63b9a9;
  box-shadow: 0 0 0 3px rgba(46, 160, 144, 0.18);
}

.workspace,
.side-panel,
.main-panel {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 11px 12px 0;
}

.panel-heading h2 {
  margin-bottom: 0;
  font-size: 1.02rem;
}

.panel-heading span {
  color: var(--muted);
  font-size: 0.84rem;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
  padding: 10px 12px;
}

.person-list,
.progress-list,
.items-list {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.person-row,
.progress-row,
.item-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.person-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: center;
  padding: 8px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #117d71, #34af95);
  font-size: 0.84rem;
  font-weight: 800;
}

.item-form,
.edit-form {
  display: grid;
  gap: 10px;
  padding: 10px 12px 12px;
}

.wide-field,
.person-picker {
  grid-column: 1 / -1;
}

.person-picker {
  margin: 0;
  padding: 10px;
  border: 1px dashed #c4d6d0;
  border-radius: 12px;
  background: #f4faf8;
}

.person-picker[hidden] {
  display: none;
}

#personPickerOptions,
.edit-form .person-picker div {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.check-pill,
.person-checks label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 6px 9px;
  font-size: 0.84rem;
}

.check-pill input,
.person-checks input,
.item-title input {
  min-height: auto;
  width: 17px;
  height: 17px;
}

.category-block {
  padding: 10px;
  background: #f9fbfc;
}

.category-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.category-head h3 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.category-head span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.category-list {
  display: grid;
  gap: 8px;
}

.item-card {
  padding: 10px;
}

.item-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.item-title {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 0;
  font-size: 1rem;
}

.item-actions {
  display: flex;
  gap: 6px;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 0.74rem;
  font-weight: 800;
  color: #fff;
  background: #6b7b88;
}

.tag.group {
  background: #2d9b88;
}

.tag.individual {
  background: #6f7f8f;
}

.tag.owner {
  background: #3368a2;
}

.item-note {
  margin: 8px 0 0;
  color: #4a5760;
  font-size: 0.89rem;
}

.person-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.progress-row {
  padding: 9px;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.83rem;
}

.progress-bar {
  margin-top: 8px;
  height: 7px;
  border-radius: 999px;
  background: #dce7e3;
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), #52bf8f);
}

.editing-card {
  border-color: #69baab;
}

.edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.empty-state {
  margin: 0;
  padding: 16px 10px;
  color: var(--muted);
  text-align: center;
}

.mobile-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
}

.mobile-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 39px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.82rem;
  border: 1px solid var(--line);
  background: #fff;
}

.mobile-nav a:active {
  color: #fff;
  background: var(--accent);
}

.toast {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(62px + env(safe-area-inset-bottom));
  z-index: 25;
  max-width: 620px;
  margin: 0 auto;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #2f404f;
  background: #1d2d3b;
  color: #fff;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 140ms ease, opacity 140ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 980px) {
  .hero-content {
    padding-top: 10px;
  }

  .stats-card {
    grid-template-columns: 58px minmax(0, 1fr) minmax(210px, 0.8fr);
  }

  .stats-progress {
    grid-column: auto;
  }

  .app-shell {
    padding-bottom: 36px;
  }

  .toolbar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .workspace {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .item-form,
  .edit-form {
    grid-template-columns: minmax(210px, 1.2fr) minmax(150px, 0.8fr) minmax(130px, 0.6fr) minmax(95px, 0.35fr);
  }

  .mobile-nav {
    display: none;
  }
}

@media print {
  .mobile-nav,
  .toolbar,
  .add-panel,
  .toast {
    display: none !important;
  }
}
