/* Farewell Planner — senior-friendly, offline-first UI
   Accent: deep sage green (#2E6B62) — calm, dignified */

:root {
  --accent: #2e6b62;
  --accent-hover: #24564f;
  --accent-soft: #e8f2ef;
  --accent-mid: #3d857a;
  --danger: #a32020;
  --danger-soft: #fdecec;
  --warn: #8a5a00;
  --warn-soft: #fff4db;
  --ok: #1a6b4a;
  --ok-soft: #e6f4ed;
  --text: #1a1a1a;
  --text-muted: #4a5568;
  --border: #c8c4bc;
  --surface: #ffffff;
  --bg: #fafaf8;
  --cream: #f5ede3;
  --shadow: 0 2px 10px rgba(26, 26, 26, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --touch: 48px;
  --max: 720px;
}

*,
*::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;
}

.visually-hidden {
  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: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1rem;
  z-index: 1000;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

/* Header */
.app-header {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.85rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-mark {
  font-size: 1.75rem;
  line-height: 1;
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

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

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* Tab nav */
.tab-nav {
  max-width: var(--max);
  margin: 0 auto;
  width: 100%;
  display: flex;
  gap: 0.25rem;
  padding: 0.65rem 0.75rem 0;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 40;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-bottom: 2px solid var(--border);
}

.tab {
  flex: 1 1 auto;
  min-height: var(--touch);
  min-width: 4.25rem;
  padding: 0.5rem 0.55rem;
  border: 2px solid transparent;
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

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

.tab.active {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--border);
  border-bottom: 2px solid var(--surface);
  margin-bottom: -2px;
}

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

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.panel-title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  color: var(--text);
}

.panel-lead {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 1rem;
}

.panel-head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.panel-head-row .panel-lead {
  margin-bottom: 0.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0.6rem 1.1rem;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

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

.btn:disabled {
  opacity: 0.55;
  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);
  border-color: var(--accent);
}

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

.btn-text {
  background: transparent;
  color: var(--accent);
  border-color: transparent;
  min-width: auto;
  padding-left: 0.65rem;
  padding-right: 0.65rem;
}

.btn-text:hover:not(:disabled) {
  background: var(--accent-soft);
}

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

.btn-danger:hover:not(:disabled) {
  background: #861a1a;
}

.btn-icon {
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  min-width: var(--touch);
  min-height: var(--touch);
  padding: 0;
}

.btn-icon:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.75rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.35rem;
  margin-left: 0.25rem;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* Stats */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

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

  .budget-stats {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

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

.stat-card.stat-primary {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.stat-card.stat-warn {
  border-color: #e0b84a;
  background: var(--warn-soft);
}

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

.stat-value {
  margin: 0.2rem 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
}

.stat-link {
  display: inline;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  min-height: auto;
}

.stat-link:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Pills */
.location-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.location-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.location-pill strong {
  color: var(--text);
  font-weight: 700;
}

.loc-icon {
  font-size: 1rem;
}

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

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

.card h3 {
  margin: 0 0 0.65rem;
  font-size: 1.1rem;
  color: var(--text);
}

.card-head h3 {
  margin: 0;
}

.card-note {
  margin: 0 0 0.85rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.sample-card {
  border-style: dashed;
  border-color: var(--accent-mid);
  background: var(--accent-soft);
}

.ref-card {
  background: var(--cream);
  border-color: #d4c8b8;
}

/* Progress */
.progress-wrap {
  height: 12px;
  background: #e5e2dc;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.4rem;
}

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

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

/* Wish grid */
.wish-grid {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.wish-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  min-height: var(--touch);
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.wish-row:hover {
  border-color: var(--accent-mid);
  background: var(--accent-soft);
}

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

.wish-row.complete {
  border-color: var(--accent);
}

.wish-icon {
  font-size: 1.35rem;
  line-height: 1;
  width: 2rem;
  text-align: center;
  flex-shrink: 0;
}

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

.wish-name {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}

.wish-selection {
  margin: 0.15rem 0 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.wish-row.complete .wish-selection {
  color: var(--accent);
  font-weight: 600;
}

.wish-chevron {
  color: var(--text-muted);
  font-size: 1.25rem;
  flex-shrink: 0;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #c5cdd9;
  flex-shrink: 0;
}

.wish-row.complete .status-dot {
  background: var(--accent);
}

/* Item lists */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.item-card {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
}

.item-card.sample-tag {
  border-style: dashed;
}

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

.item-title {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
}

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

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
  margin-right: 0.35rem;
}

.chip-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.chip-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.chip-muted {
  background: #eceff3;
  color: var(--text-muted);
}

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

.empty-msg {
  margin: 0.5rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.empty-state {
  text-align: center;
  padding: 2rem 1.25rem;
}

.empty-title {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
  font-weight: 700;
}

.obit-snippet {
  margin: 0 0 0.5rem;
  color: var(--text);
  font-size: 1rem;
}

.budget-mini {
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.budget-mini strong {
  color: var(--text);
}

/* Tips */
.tip-list {
  margin: 0;
  padding-left: 1.25rem;
}

.tip-list li {
  margin-bottom: 0.5rem;
  color: var(--text);
}

.tip-banner {
  background: var(--warn-soft);
  border: 2px solid #e0b84a;
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  color: var(--text);
  font-weight: 500;
}

/* Fields */
.field {
  margin-bottom: 0.85rem;
}

.field:last-child {
  margin-bottom: 0;
}

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

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

.field-hint {
  margin: -0.15rem 0 0.4rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
}

.field input[type="text"],
.field input[type="search"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="number"],
.field select,
.field textarea,
.filters select {
  display: block;
  width: 100%;
  min-height: var(--touch);
  padding: 0.65rem 0.85rem;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
}

.field textarea {
  min-height: 5.5rem;
  resize: vertical;
  line-height: 1.45;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.filters select:focus {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.filters {
  margin-bottom: 1rem;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.toggle {
  width: 2.75rem;
  height: 1.6rem;
  min-height: auto;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

/* Option list (wish choices) */
.option-fieldset {
  border: none;
  margin: 0 0 1rem;
  padding: 0;
}

.option-fieldset legend {
  font-weight: 700;
  margin-bottom: 0.5rem;
  padding: 0;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--touch);
  padding: 0.65rem 0.85rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font: inherit;
}

.option-row:hover {
  border-color: var(--accent-mid);
  background: var(--accent-soft);
}

.option-row:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option-row input {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.option-row span {
  font-weight: 500;
}

/* Dialogs */
.dialog {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 560px) {
  .dialog {
    align-items: center;
    padding: 1.5rem;
  }
}

.dialog[hidden] {
  display: none;
}

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

.dialog-panel {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: min(92vh, 900px);
  overflow: auto;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.15rem 1.15rem 1.35rem;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
  z-index: 1;
}

@media (min-width: 560px) {
  .dialog-panel {
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
  }
}

.dialog-wide {
  max-width: 640px;
}

.dialog-sm {
  max-width: 420px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.dialog-head h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--text);
  padding-top: 0.35rem;
}

.dialog-lead {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.15rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

/* Documents */
.obit-document,
.plan-document {
  background: var(--cream);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  line-height: 1.6;
}

.obit-document h3,
.plan-document h3 {
  margin: 0 0 0.75rem;
  color: var(--accent);
  font-size: 1.35rem;
}

.obit-document p,
.plan-document p {
  margin: 0 0 0.85rem;
}

.plan-document h4 {
  margin: 1.15rem 0 0.4rem;
  font-size: 1.05rem;
  color: var(--text);
}

.plan-document ul {
  margin: 0 0 0.75rem;
  padding-left: 1.25rem;
}

.cost-table-wrap {
  overflow-x: auto;
}

.cost-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.cost-table th,
.cost-table td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.cost-table th {
  font-weight: 700;
  color: var(--text);
  background: var(--accent-soft);
}

.cost-table td:last-child,
.cost-table th:last-child {
  text-align: right;
  white-space: nowrap;
  font-weight: 600;
}

/* Footer */
.app-footer {
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
}

.app-footer p {
  margin: 0;
}

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

.toast[hidden] {
  display: none;
}

/* Print */
.print-root {
  display: none;
}

@media print {
  body * {
    visibility: hidden;
  }

  .print-root,
  .print-root * {
    visibility: visible;
  }

  .print-root {
    display: block;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    padding: 1rem;
    background: #fff;
    color: #000;
  }

  .print-root h1 {
    font-size: 1.5rem;
    margin: 0 0 0.5rem;
  }

  .print-root h2 {
    font-size: 1.15rem;
    margin: 1.25rem 0 0.4rem;
    border-bottom: 1px solid #ccc;
    padding-bottom: 0.25rem;
  }

  .print-root p,
  .print-root li {
    font-size: 12pt;
    line-height: 1.45;
  }
}

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