/* PackRight — Senior Travel Packing
   Base font >= 18px, 48px touch targets, WCAG AA contrast
   Accent: deep teal green
*/

:root {
  --accent: #1a5f4a;
  --accent-hover: #144a3a;
  --accent-soft: #e6f2ed;
  --accent-mid: #2d8a6e;
  --bg: #f6f4f0;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #3d3d3d;
  --muted: #5c5c5c;
  --border: #c8c4bc;
  --border-light: #e0dcd4;
  --danger: #9b1c1c;
  --danger-hover: #7a1616;
  --danger-soft: #fce8e8;
  --warning: #8a5a00;
  --warning-soft: #fff4d6;
  --success: #1a5f4a;
  --success-soft: #e6f2ed;
  --shadow: 0 2px 8px rgba(26, 26, 26, 0.08);
  --shadow-lg: 0 8px 28px rgba(26, 26, 26, 0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --space: 1rem;
  --touch: 48px;
  --max: 760px;
}

*,
*::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);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

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

.skip-link:focus {
  left: 0;
}

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

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

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

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  border-radius: 12px;
  flex-shrink: 0;
}

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

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

.main-nav {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0;
  scrollbar-width: none;
}

.main-nav::-webkit-scrollbar {
  display: none;
}

.nav-btn {
  flex: 1 0 auto;
  min-height: var(--touch);
  min-width: 5.5rem;
  padding: 0.6rem 0.85rem;
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

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

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

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

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

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

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

.view-header h2 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.view-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.row-between {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.wrap-gap {
  flex-wrap: wrap;
}

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

.stat-grid.compact {
  grid-template-columns: repeat(2, 1fr);
}

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

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

.stat-card .stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

.stat-card .stat-label {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}

.stat-card.warn .stat-value {
  color: var(--warning);
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  overflow: hidden;
}

.card-header {
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border-light);
  background: #faf9f7;
}

.card-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.card-body {
  padding: 1.1rem;
}

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

.empty-state {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--muted);
}

.empty-state p {
  margin: 0 0 1rem;
}

/* 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: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

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

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

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

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

.btn-secondary:hover {
  background: #d0e8df;
}

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

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

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

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

.btn-sm {
  min-height: var(--touch);
  padding: 0.5rem 0.9rem;
  font-size: 0.95rem;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch);
  height: var(--touch);
  min-width: var(--touch);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.btn-icon:hover {
  background: var(--border-light);
  color: var(--text);
}

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

.btn-back {
  margin-bottom: 0.5rem;
  padding-left: 0.5rem;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

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

.field label,
.field .label-text,
fieldset.field legend {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
  color: var(--text);
  font-size: 1rem;
}

.req {
  color: var(--danger);
}

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

.field select,
.field-inline select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%233d3d3d' d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2.5rem;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.field-inline input:focus,
.field-inline select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 95, 74, 0.2);
}

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

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

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

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--touch);
  margin-bottom: 1rem;
  cursor: pointer;
  font-weight: 500;
}

.checkbox-row input[type="checkbox"],
.checkbox-inline input[type="checkbox"],
.item-check input[type="checkbox"],
.chip input[type="checkbox"],
.suggest-item input[type="checkbox"] {
  width: 1.4rem;
  height: 1.4rem;
  min-width: 1.4rem;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.form-error {
  color: var(--danger);
  background: var(--danger-soft);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin: 0 0 1rem;
  font-weight: 600;
}

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

.toolbar.tight {
  margin-bottom: 1rem;
}

.field-inline {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 8rem;
}

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

.field-inline .label-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.checkbox-inline {
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  min-height: var(--touch);
  font-weight: 500;
  cursor: pointer;
}

/* Chips */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: var(--touch);
  padding: 0.4rem 0.85rem;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.95rem;
}

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

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

/* Trip list */
.trip-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.trip-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.trip-card:hover,
.trip-card:focus-within {
  border-color: var(--accent-mid);
  box-shadow: var(--shadow-lg);
}

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

.trip-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

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

.trip-card .dest {
  color: var(--accent);
  font-weight: 600;
  margin: 0.2rem 0 0;
}

.trip-card .dates {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0.35rem 0 0;
}

.trip-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}

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

.badge.neutral {
  background: var(--border-light);
  color: var(--text-secondary);
}

.trip-progress-mini {
  margin-top: 0.85rem;
}

.trip-progress-mini .mini-bar {
  height: 8px;
  background: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
}

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

.trip-progress-mini .mini-text {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

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

.item-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.item-row.is-packed {
  background: #f0f7f4;
  border-color: #b8d9cc;
}

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

.item-check {
  display: flex;
  align-items: center;
  min-height: var(--touch);
  padding-top: 0.1rem;
  cursor: pointer;
}

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

.item-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  word-break: break-word;
}

.item-meta {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
}

.item-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex-shrink: 0;
}

.item-actions .btn {
  min-height: var(--touch);
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
}

.category-group {
  margin-bottom: 1.25rem;
}

.category-group h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}

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

.progress-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.progress-bar {
  height: 14px;
  background: var(--border-light);
  border-radius: 7px;
  overflow: hidden;
}

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

/* Next trip / attention */
.next-trip-card h4 {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
}

.attention-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.attention-list li {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.attention-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.attention-list li:first-child {
  padding-top: 0;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  min-height: var(--touch);
  padding: 0.4rem 0;
}

.link-btn:hover {
  color: var(--accent-hover);
}

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

/* Suggest list */
.suggest-list {
  max-height: 50vh;
  overflow-y: auto;
  margin: 0.75rem 0 1rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}

.suggest-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--touch);
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
}

.suggest-item:last-child {
  border-bottom: none;
}

.suggest-item:hover {
  background: var(--accent-soft);
}

.suggest-item span.cat {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

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

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

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

.modal-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow-lg);
}

@media (min-width: 560px) {
  .modal-panel {
    border-radius: var(--radius);
  }
}

.modal-panel-sm {
  max-width: 420px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.5rem 0.75rem 1.15rem;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.modal-body {
  padding: 1.15rem;
}

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

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  max-width: min(90vw, 420px);
  padding: 0.9rem 1.25rem;
  background: var(--text);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

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

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

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

/* Utility */
.grow {
  flex: 1 1 auto;
}

/* Print */
@media print {
  .app-header,
  .app-footer,
  .toolbar,
  .action-row,
  .btn,
  .nav-btn,
  .skip-link {
    display: none !important;
  }

  body {
    background: #fff;
  }

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