:root {
  --primary: #1a5276;
  --primary-light: #2980b9;
  --primary-bg: #eaf2f8;
  --accent: #e67e22;
  --accent-light: #f39c12;
  --success: #27ae60;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #dce1e6;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 28px;
}

header h1 {
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: 4px;
}

.subtitle {
  color: var(--text-light);
  font-size: 0.95rem;
}

/* Accordion panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.panel-header:hover {
  background: var(--primary-bg);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.panel-title h2 {
  font-size: 1.15rem;
  color: var(--primary);
  margin: 0;
}

.panel-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.panel.collapsed .panel-number {
  background: var(--success);
}

.panel-summary {
  flex: 1;
  text-align: right;
  font-size: 0.85rem;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.panel-chevron {
  font-size: 1.2rem;
  color: var(--text-light);
  transition: transform 0.3s;
  flex-shrink: 0;
}

.panel.collapsed .panel-chevron {
  transform: rotate(-90deg);
}

.panel-body {
  padding: 0 20px 20px;
  transition: all 0.3s ease;
}

.panel-body > p {
  color: var(--text-light);
  margin-bottom: 20px;
}

.panel.collapsed .panel-body {
  display: none;
}

/* Form grid */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.form-card label {
  display: block;
  font-weight: 600;
  margin-bottom: 10px;
  font-size: 0.95rem;
}

/* Stepper */
.stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.stepper-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--surface);
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s;
}

.stepper-btn:hover {
  background: var(--primary-bg);
}

.stepper input {
  width: 56px;
  height: 44px;
  border: none;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  -moz-appearance: textfield;
}

.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

/* Toggle */
.toggle-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toggle-btn {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-light);
  transition: all 0.2s;
  min-width: 0;
}

.toggle-btn:hover {
  border-color: var(--primary-light);
}

.toggle-btn.active {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
}

.toggle-btn small {
  display: block;
  font-weight: 400;
  font-size: 0.75rem;
  margin-top: 2px;
}

/* Custom days */
.custom-days {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.custom-days.hidden {
  display: none;
}

.custom-days .stepper {
  flex: 0 0 auto;
}

.custom-days-label {
  font-size: 0.9rem;
  color: var(--text-light);
  font-weight: 600;
}

/* Scenario grid */
.scenario-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.scenario-card {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.scenario-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-lg);
}

.scenario-card.selected {
  border-color: var(--accent);
  background: #fef5e7;
}

.scenario-card .icon {
  font-size: 2rem;
  margin-bottom: 8px;
  display: block;
}

.scenario-card .name {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.scenario-card .desc {
  font-size: 0.8rem;
  color: var(--text-light);
  line-height: 1.4;
}

/* Buttons */
.btn {
  padding: 12px 28px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn.primary {
  background: var(--primary);
  color: white;
}

.btn.primary:hover {
  background: var(--primary-light);
}

.btn.danger {
  background: var(--surface);
  color: #c0392b;
  border: 1px solid #e6b0aa;
}

.btn.danger:hover {
  background: #fdedec;
  border-color: #c0392b;
}

/* Panel actions */
.panel-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

/* Preparedness overview */
.preparedness-overview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.prep-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  transition: border-color 0.3s;
}

.prep-card.complete {
  border-color: var(--success);
  background: #eafaf1;
}

.prep-card .prep-icon {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.prep-card .prep-label {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prep-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}

.prep-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
  background: var(--primary-light);
}

.prep-bar-fill.high { background: var(--success); }
.prep-bar-fill.mid { background: var(--accent); }
.prep-bar-fill.low { background: #e74c3c; }

.prep-pct {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

/* Shopping list */
.category-group {
  margin-bottom: 24px;
  break-inside: avoid;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--primary-bg);
}

.category-pct {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 10px;
  background: var(--primary-bg);
  color: var(--primary);
}

.category-pct.complete {
  background: #eafaf1;
  color: var(--success);
}

.list-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  transition: background 0.15s;
}

.list-item.checked {
  background: #eee;
}

.list-item.checked .item-name {
  text-decoration: line-through;
  color: var(--text-light);
}

.list-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--success);
  cursor: pointer;
  flex-shrink: 0;
}

.list-item .item-name {
  flex: 1;
  font-size: 0.95rem;
}

.list-item .item-name a {
  color: var(--primary-light);
  text-decoration: none;
  border-bottom: 1px dotted var(--primary-light);
  transition: color 0.15s;
}

.list-item .item-name a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.list-item .item-qty {
  font-weight: 600;
  color: var(--primary);
  font-size: 0.9rem;
  white-space: nowrap;
}

/* Info button */
.item-info-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: var(--text-light);
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
  line-height: 24px;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
}

.item-info-btn:hover,
.item-info-btn.active {
  color: var(--primary);
  background: var(--primary-bg);
}

/* Shop button */
.item-shop-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
  line-height: 24px;
  border-radius: 50%;
  transition: background 0.15s;
}

.item-shop-btn:hover,
.item-shop-btn.active {
  background: var(--primary-bg);
}

/* Info box (help text + links) */
.item-info-box {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-top: 6px;
  order: 99;
}

.item-info-help {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-light);
  margin: 0;
}

.item-info-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.item-info-help + .item-info-links {
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.item-info-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--primary-light);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  transition: border-color 0.15s, color 0.15s;
}

.item-info-link:hover {
  border-color: var(--primary-light);
  color: var(--primary);
}

.item-info-link::before {
  content: "\1F6D2";
  font-size: 0.75rem;
}

.list-item .item-scenario {
  font-size: 0.7rem;
  background: #fef5e7;
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  order: 98;
  width: 100%;
}

/* List actions */
.list-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.copy-feedback {
  color: var(--success);
  font-weight: 600;
  font-size: 0.9rem;
  transition: opacity 0.3s;
}

.copy-feedback.hidden {
  opacity: 0;
}

/* Footer */
.site-footer {
  max-width: 720px;
  margin: 48px auto 0;
  padding: 32px 16px 48px;
  border-top: 1px solid var(--border);
}

.site-footer h2 {
  font-size: 1.1rem;
  color: var(--primary);
  margin-bottom: 12px;
}

.site-footer p {
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text-light);
  margin-bottom: 10px;
}

.site-footer p:last-child {
  margin-bottom: 0;
}

/* Wide screens */
@media (min-width: 900px) {
  .app {
    max-width: 1280px;
  }

  #shopping-list {
    columns: 2;
    column-gap: 24px;
  }

  .scenario-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1400px) {
  .app {
    max-width: 1400px;
  }

  #shopping-list {
    columns: 3;
  }
}

/* Responsive */
@media (max-width: 600px) {
  .app {
    padding: 16px 12px 32px;
  }

  header h1 {
    font-size: 1.5rem;
  }

  .panel-header {
    padding: 14px 16px;
  }

  .panel-body {
    padding: 0 16px 16px;
  }

  .panel-title h2 {
    font-size: 1rem;
  }

  .panel-summary {
    font-size: 0.78rem;
  }

  .form-grid,
  .scenario-grid {
    grid-template-columns: 1fr;
  }

  .preparedness-overview {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }

  .btn {
    width: 100%;
    text-align: center;
  }
}

/* Print */
@media print {
  body {
    background: white;
  }

  .app {
    max-width: none;
    padding: 0;
  }

  /* Hide everything except the shopping list panel */
  #panel-1,
  #panel-2,
  .list-actions,
  .preparedness-overview,
  .item-info-btn,
  .item-shop-btn,
  .item-info-box,
  .site-footer {
    display: none !important;
  }

  #panel-3 {
    border: none;
    box-shadow: none;
  }

  #panel-3 .panel-header {
    padding: 0 0 8px;
  }

  #panel-3 .panel-chevron {
    display: none;
  }

  /* Always show the body even if collapsed */
  #panel-3.collapsed .panel-body {
    display: block !important;
  }

  #panel-3 .panel-body {
    padding: 0;
  }

  #shopping-list {
    columns: 2;
    column-gap: 20px;
  }

  .category-group {
    break-inside: avoid;
    margin-bottom: 16px;
  }

  .list-item {
    padding: 4px 8px;
    margin-bottom: 3px;
    border: 1px solid #ccc;
    font-size: 0.85rem;
  }

  .list-item input[type="checkbox"] {
    width: 14px;
    height: 14px;
  }

  .list-item.checked .item-name {
    text-decoration: line-through;
    color: #999;
  }

  .list-item .item-name a {
    color: inherit;
    text-decoration: none;
    border: none;
  }
}
