/* DownsizeWise — senior-friendly, offline-first downsizing companion */

:root {
  --accent: #2c5530;
  --accent-hover: #1f3d23;
  --accent-soft: #e8f0e9;
  --accent-mid: #3d7042;
  --warm: #b8860b;
  --warm-soft: #f8f0de;
  --danger: #a32020;
  --danger-hover: #8a1a1a;
  --danger-soft: #fdecec;
  --ok: #2c5530;
  --ok-soft: #e8f0e9;
  --text: #1a1f28;
  --text-muted: #4a5568;
  --border: #c8d0dc;
  --surface: #ffffff;
  --bg: #f7f5f1;
  --shadow: 0 2px 12px rgba(44, 85, 48, 0.1);
  --radius: 12px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --touch: 48px;
  --max: 720px;

  /* Decision colors — always paired with text labels */
  --keep: #2c5530;
  --keep-bg: #e8f0e9;
  --sell: #8b6914;
  --sell-bg: #f8f0de;
  --donate: #1b4f72;
  --donate-bg: #e8f1f8;
  --family: #6b3fa0;
  --family-bg: #f3eef9;
  --trash: #5c5c5c;
  --trash-bg: #f0f0f0;
  --undecided: #8a5a00;
  --undecided-bg: #fff4e0;
}

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

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Skip link */
.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 {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: var(--accent);
  color: #f8f0de;
  font-size: 1.25rem;
  border-radius: 10px;
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
}

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

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

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

.tab {
  flex: 1 0 auto;
  min-height: var(--touch);
  min-width: 4.5rem;
  padding: 0.6rem 0.75rem;
  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.95rem;
  cursor: pointer;
  white-space: nowrap;
}

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

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

.tab.active,
.tab[aria-selected="true"] {
  color: var(--accent);
  background: var(--surface);
  border-color: var(--border);
  border-bottom-color: var(--surface);
  margin-bottom: -2px;
  padding-bottom: calc(0.6rem + 2px);
}

/* Sub-tabs (Act panel) */
.sub-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}

.sub-tab {
  min-height: var(--touch);
  padding: 0.55rem 1rem;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

.sub-tab:hover {
  border-color: var(--accent-mid);
  color: var(--accent);
}

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

.sub-tab.active,
.sub-tab[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.sub-panel {
  display: none;
}

.sub-panel.active {
  display: block;
}

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

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.panel-title {
  margin: 0 0 0.35rem;
  font-size: 1.4rem;
  color: var(--accent);
  font-weight: 700;
}

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

.back-btn {
  margin: 0 0 0.75rem;
  padding-left: 0;
}

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

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

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

.card-head h3 {
  margin: 0;
}

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

.danger-zone {
  border-color: #e0b4b4;
  background: #fffafa;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0.65rem 1.15rem;
  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 ease, border-color 0.15s ease, color 0.15s ease;
}

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

.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(--surface);
  color: var(--accent);
  border-color: var(--accent);
}

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

.btn-text {
  background: transparent;
  color: var(--accent);
  border-color: transparent;
  min-width: auto;
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

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

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

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

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

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

.btn-row.stacked {
  flex-direction: column;
  align-items: stretch;
}

.btn-row.stacked .btn {
  width: 100%;
}

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

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

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

.req {
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--danger);
  text-transform: lowercase;
}

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

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

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

.field-error {
  margin: 0.35rem 0 0;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 600;
}

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

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

.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-top: 0.75rem;
}

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

.filters .field {
  margin-bottom: 0;
}

.helper-text {
  margin: 0.35rem 0 0.65rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.status-msg {
  margin: 0.65rem 0 0;
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 600;
  min-height: 1.4em;
}

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

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

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

.stat-grid.tight {
  margin-bottom: 0.85rem;
}

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

.stat-label {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-value {
  margin: 0.25rem 0 0;
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.15;
  word-break: break-word;
}

.stat-value.gold,
.gold {
  color: var(--warm);
}

.stat-value-card {
  background: var(--warm-soft);
  border-color: #e0c98a;
}

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

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

@media (prefers-reduced-motion: reduce) {
  .progress-bar,
  .btn {
    transition: none;
  }
}

/* Item / room lists */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.item-list.compact {
  gap: 0.5rem;
}

.item-card {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  width: 100%;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  min-height: var(--touch);
}

button.item-card {
  appearance: none;
}

.item-card:hover {
  border-color: var(--accent-mid);
  background: #fbfcfe;
}

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

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

.item-card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  word-break: break-word;
}

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

.item-card-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  flex-shrink: 0;
}

.room-card-progress {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
}

/* Decision badges — color + text, never color alone */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.3;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-keep {
  background: var(--keep-bg);
  color: var(--keep);
  border-color: #a8c9ab;
}

.badge-sell {
  background: var(--sell-bg);
  color: var(--sell);
  border-color: #e0c98a;
}

.badge-donate {
  background: var(--donate-bg);
  color: var(--donate);
  border-color: #a8c5dc;
}

.badge-family {
  background: var(--family-bg);
  color: var(--family);
  border-color: #c9b5e0;
}

.badge-trash {
  background: var(--trash-bg);
  color: var(--trash);
  border-color: #c8c8c8;
}

.badge-undecided {
  background: var(--undecided-bg);
  color: var(--undecided);
  border-color: #e8c98a;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 2rem 1.25rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.1rem;
}

.empty-icon {
  font-size: 2rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.empty-state h3 {
  margin: 0 0 0.4rem;
  color: var(--accent);
  font-size: 1.2rem;
}

.empty-state p {
  margin: 0 0 1rem;
  color: var(--text-muted);
}

/* Breakdown lists */
.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.breakdown-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.75rem;
  align-items: center;
}

.breakdown-label {
  font-weight: 600;
  color: var(--text);
}

.breakdown-meta {
  font-size: 0.9rem;
  color: var(--text-muted);
  grid-column: 1 / -1;
}

.breakdown-bar-track {
  grid-column: 1 / -1;
  height: 10px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.breakdown-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  min-width: 0;
}

.breakdown-count {
  font-weight: 700;
  color: var(--accent);
}

/* Tips */
.tips-list {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text);
}

.tips-list li {
  margin-bottom: 0.5rem;
}

.tips-list li:last-child {
  margin-bottom: 0;
}

/* Donation centers */
.centers-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.center-card {
  padding: 0.9rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.center-card h4 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  color: var(--accent);
}

.center-card p {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.center-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

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

/* Action rows for compact lists */
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

.action-row .btn {
  min-height: 44px;
  padding: 0.45rem 0.85rem;
  font-size: 0.9rem;
}

.inline-select {
  min-height: 44px;
  padding: 0.4rem 0.65rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
  max-width: 100%;
}

.inline-select:focus {
  outline: 3px solid var(--warm);
  border-color: var(--accent);
}

/* Decision helper */
.decide-question {
  margin: 0.75rem 0 1rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.decide-options {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.decide-option {
  width: 100%;
  min-height: var(--touch);
  padding: 0.85rem 1rem;
  text-align: left;
  font: inherit;
  font-weight: 600;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
}

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

.decide-option:focus-visible {
  outline: 3px solid var(--warm);
  outline-offset: 2px;
}

.progress-dots {
  display: flex;
  gap: 0.4rem;
  margin: 0.5rem 0;
}

.progress-dots .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
}

.progress-dots .dot.active {
  background: var(--accent);
}

.decide-result {
  margin: 0.5rem 0 1rem;
  padding: 1rem;
  background: var(--accent-soft);
  border-radius: var(--radius);
  border: 1px solid #a8c9ab;
}

.suggestion-badge {
  margin: 0.35rem 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.override-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  width: 100%;
}

.override-grid .btn {
  width: 100%;
  font-size: 0.9rem;
  padding: 0.55rem 0.5rem;
}

@media (max-width: 400px) {
  .override-grid {
    grid-template-columns: 1fr;
  }
}

/* Detail view */
.detail-grid {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.detail-row dt {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.detail-row dd {
  margin: 0.15rem 0 0;
  font-size: 1.05rem;
  color: var(--text);
  word-break: break-word;
}

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

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

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

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

.dialog-panel-sm {
  max-width: 440px;
  margin: auto 1rem 1rem;
  border-radius: var(--radius);
}

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

  .dialog-panel {
    border-radius: var(--radius);
    max-height: 90vh;
  }
}

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

.dialog-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--accent);
}

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

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

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

.app-footer p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Print estate list */
@media print {
  .app-header,
  .tab-nav,
  .app-footer,
  .skip-link,
  .btn,
  .sub-tabs,
  .dialog {
    display: none !important;
  }

  body {
    background: #fff;
  }

  main {
    max-width: none;
    padding: 0;
  }

  .panel {
    display: none !important;
  }

  .panel.active {
    display: block !important;
  }

  .sub-panel {
    display: none !important;
  }

  .sub-panel.active {
    display: block !important;
  }

  .card {
    box-shadow: none;
    break-inside: avoid;
  }
}
