/* KinKeeper — Grandfamilies Support — senior-friendly, offline-first */

:root {
  --accent: #2B6B5A;
  --accent-hover: #215446;
  --accent-soft: #D9EBE4;
  --accent-ink: #1A4338;
  --amber: #D4883B;
  --amber-soft: #F8E8D4;
  --bg: #FAF8F5;
  --surface: #FFFFFF;
  --surface-2: #F0EDE8;
  --text: #1C1917;
  --text-muted: #57534E;
  --border: #D6D3D1;
  --danger: #B91C1C;
  --danger-soft: #FEE2E2;
  --success: #166534;
  --success-soft: #DCFCE7;
  --warn: #92400E;
  --warn-soft: #FEF3C7;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(28, 25, 23, 0.08), 0 4px 16px rgba(28, 25, 23, 0.06);
  --shadow-lg: 0 8px 30px rgba(28, 25, 23, 0.12);
  --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --touch: 48px;
  --max: 920px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

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

button {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.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;
}

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -100px;
  z-index: 1000;
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  top: 0.75rem;
}

/* Header */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 0 rgba(28, 25, 23, 0.04);
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1rem 1.25rem 0.75rem;
}

.brand {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--accent-soft);
  font-size: 1.55rem;
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.2;
  color: var(--accent-ink);
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.main-nav {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.nav-btn {
  flex: 0 0 auto;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0.55rem 0.9rem;
  border: 2px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
}

.nav-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: var(--accent);
}

/* Main */
.main {
  flex: 1;
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2.5rem;
}

.view[hidden] {
  display: none !important;
}

.view-header {
  margin-bottom: 1.25rem;
}

.view-header.compact {
  margin-bottom: 0.75rem;
}

.view-header.row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
}

.view-header h2 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  color: var(--accent-ink);
  letter-spacing: -0.02em;
}

.view-header h3 {
  margin: 0 0 0.25rem;
  font-size: 1.2rem;
  color: var(--accent-ink);
}

.view-lead {
  margin: 0;
  color: var(--text-muted);
  max-width: 42rem;
}

/* Cards & stats */
.state-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.state-banner-label {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.state-banner-name {
  margin: 0;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent-ink);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 700px) {
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow);
}

.stat-card.stat-warn {
  border-color: #E7C28A;
  background: linear-gradient(180deg, #FFFBF5 0%, var(--surface) 100%);
}

.stat-card.stat-ok {
  border-color: #A8D4C4;
  background: linear-gradient(180deg, #F4FBF8 0%, var(--surface) 100%);
}

.stat-label {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value {
  margin: 0.25rem 0 0.5rem;
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--accent-ink);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.stat-link {
  min-height: 44px;
  padding: 0.35rem 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  margin-bottom: 1.15rem;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.85rem;
}

.card-head h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--accent-ink);
}

.card > h3 {
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
  color: var(--accent-ink);
}

.muted {
  color: var(--text-muted);
  margin: 0 0 0.85rem;
}

.muted-sm {
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: #B5D6C9;
}

.btn-secondary:hover:not(:disabled) {
  background: #c8e0d6;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn-text {
  min-height: 44px;
  padding: 0.25rem 0.35rem;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: #991B1B;
}

.btn-block {
  width: 100%;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0.5rem 0 0.85rem;
}

.btn-sm {
  min-height: 44px;
  padding: 0.45rem 0.85rem;
  font-size: 0.95rem;
}

/* Forms */
.field {
  margin-bottom: 0.9rem;
}

.field.grow {
  flex: 1 1 12rem;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 1rem;
}

@media (min-width: 560px) {
  .field-row {
    grid-template-columns: 1fr 1fr;
  }
}

input[type="text"],
input[type="search"],
input[type="date"],
input[type="number"],
input[type="tel"],
select,
textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 0.6rem 0.8rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

textarea {
  min-height: 6rem;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.check-field {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.check-field input[type="checkbox"] {
  width: 1.35rem;
  height: 1.35rem;
  min-height: 1.35rem;
  margin-top: 0.2rem;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.check-field label {
  margin: 0;
  font-weight: 500;
}

.req {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.85rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  align-items: flex-end;
}

.results-count {
  margin: 0 0 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
}

/* Lists & items */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.item-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.95rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.item-card.is-past {
  opacity: 0.78;
}

.item-card.is-overdue {
  border-color: #E8A0A0;
  background: #FFF8F8;
}

.item-card.is-soon {
  border-color: #E7C28A;
  background: #FFFBF5;
}

.item-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem 0.85rem;
}

.item-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.item-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.item-notes {
  margin: 0.15rem 0 0;
  color: var(--text);
  font-size: 0.95rem;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.45rem;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: var(--amber-soft);
  color: var(--warn);
  text-transform: none;
}

.badge-type {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.badge-national {
  background: var(--surface-2);
  color: var(--text-muted);
}

.badge-done {
  background: var(--success-soft);
  color: var(--success);
}

.badge-sample {
  background: #E0E7FF;
  color: #3730A3;
}

.empty-state {
  text-align: center;
  padding: 1.75rem 1rem;
  color: var(--text-muted);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.empty-state h3,
.empty-state p {
  margin: 0 0 0.65rem;
}

.empty-state h3 {
  color: var(--accent-ink);
  font-size: 1.15rem;
}

/* Checklist categories */
.category-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

@media (min-width: 640px) {
  .category-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.category-card {
  text-align: left;
  width: 100%;
  min-height: var(--touch);
  padding: 1.1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  cursor: pointer;
}

.category-card:hover {
  border-color: var(--accent);
  background: #F7FCFA;
}

.category-card .cat-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.category-card .cat-name {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-ink);
}

.category-card .cat-count {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.progress-track {
  height: 10px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.progress-block {
  margin-bottom: 1rem;
}

.progress-text {
  margin: 0.45rem 0 0;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.checklist-item {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  padding: 1rem 1.05rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.checklist-item.is-done {
  background: #F4FBF8;
  border-color: #A8D4C4;
}

.checklist-item input[type="checkbox"] {
  width: 1.5rem;
  height: 1.5rem;
  min-width: 1.5rem;
  margin-top: 0.15rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.checklist-item .item-body {
  flex: 1;
  min-width: 0;
}

.checklist-item .item-title {
  font-size: 1.05rem;
}

.checklist-item.is-done .item-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.tip-box {
  margin-top: 0.5rem;
  padding: 0.65rem 0.8rem;
  background: var(--amber-soft);
  border-radius: var(--radius-sm);
  color: var(--warn);
  font-size: 0.95rem;
}

.checklist-detail[hidden],
.resource-detail[hidden] {
  display: none !important;
}

.resource-detail h3 {
  margin: 0.35rem 0 0.25rem;
  font-size: 1.3rem;
  color: var(--accent-ink);
}

.resource-scope {
  margin: 0 0 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.disclaimer {
  margin: 1rem 0 0;
  padding: 0.75rem 0.9rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.profile-block p {
  margin: 0.25rem 0;
}

.profile-block .profile-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-ink);
}

/* Onboarding */
.onboarding {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(28, 25, 23, 0.45);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.onboarding[hidden] {
  display: none !important;
}

.onboarding-card {
  width: min(100%, 520px);
  max-height: min(92vh, 720px);
  overflow: auto;
  background: var(--surface);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.6rem 1.4rem 1.4rem;
  box-shadow: var(--shadow-lg);
}

.onboard-mark {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  font-size: 2.2rem;
  margin: 0 auto 1rem;
}

.onboarding-card h1,
.onboarding-card h2 {
  margin: 0 0 0.5rem;
  text-align: center;
  color: var(--accent-ink);
  font-size: 1.55rem;
}

.onboard-lead {
  text-align: center;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

.onboard-bullets {
  margin: 0 0 1.25rem;
  padding-left: 1.25rem;
  color: var(--text);
}

.onboard-bullets li {
  margin-bottom: 0.4rem;
}

.state-list {
  max-height: 240px;
  overflow: auto;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.state-option {
  display: block;
  width: 100%;
  min-height: var(--touch);
  text-align: left;
  padding: 0.7rem 0.9rem;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-weight: 500;
}

.state-option:last-child {
  border-bottom: 0;
}

.state-option:hover {
  background: var(--surface-2);
}

.state-option.is-selected {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
}

/* Dialogs */
.dialog {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.dialog[hidden] {
  display: none !important;
}

.dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 25, 23, 0.45);
}

.dialog-panel {
  position: relative;
  width: min(100%, 520px);
  max-height: min(92vh, 760px);
  overflow: auto;
  background: var(--surface);
  border-radius: calc(var(--radius) + 2px);
  padding: 1.35rem 1.25rem 1.2rem;
  box-shadow: var(--shadow-lg);
}

.dialog-panel.dialog-sm {
  width: min(100%, 420px);
}

.dialog-panel h2 {
  margin: 0 0 1rem;
  font-size: 1.3rem;
  color: var(--accent-ink);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  z-index: 300;
  max-width: min(92vw, 420px);
  padding: 0.85rem 1.15rem;
  background: var(--accent-ink);
  color: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-weight: 600;
  text-align: center;
}

.toast[hidden] {
  display: none !important;
}

/* Export */
.export-box {
  margin-top: 0.85rem;
  padding: 0.85rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8rem;
  max-height: 200px;
  overflow: auto;
}

/* Footer */
.app-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 1rem 1.25rem;
  text-align: center;
}

.app-footer p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  max-width: var(--max);
  margin-inline: auto;
}

/* Utility links that look like buttons for tel: */
a.btn {
  color: inherit;
}

a.btn-primary {
  color: #fff;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
