:root {
  color-scheme: light;
  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --surface-3: #eef4f2;
  --text: #14201d;
  --muted: #66736f;
  --muted-2: #8a9692;
  --line: #dfe8e5;
  --brand: #0f766e;
  --brand-strong: #0b5f59;
  --brand-soft: #dff6f1;
  --accent: #f59e0b;
  --danger: #c4322b;
  --danger-soft: #fff0ef;
  --success: #15803d;
  --shadow-sm: 0 1px 2px rgb(15 35 30 / 0.06), 0 3px 10px rgb(15 35 30 / 0.04);
  --shadow-md: 0 12px 34px rgb(15 35 30 / 0.14);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1513;
  --surface: #14201d;
  --surface-2: #182723;
  --surface-3: #22342f;
  --text: #f2f7f5;
  --muted: #a7b5b0;
  --muted-2: #7f918b;
  --line: #2d403a;
  --brand: #2dd4bf;
  --brand-strong: #5eead4;
  --brand-soft: #173a34;
  --danger: #ff8a82;
  --danger-soft: #3c2220;
  --success: #4ade80;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.28), 0 4px 12px rgb(0 0 0 / 0.15);
  --shadow-md: 0 18px 46px rgb(0 0 0 / 0.45);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% 5%, rgb(45 212 191 / 0.08), transparent 34rem),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button,
label,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgb(45 212 191 / 0.34);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: calc(92px + var(--safe-bottom));
}

.topbar {
  position: relative;
  overflow: hidden;
  padding: calc(18px + var(--safe-top)) 16px 18px;
  color: #ffffff;
  background:
    radial-gradient(circle at 85% 10%, rgb(255 255 255 / 0.20), transparent 12rem),
    linear-gradient(145deg, #0b5f59 0%, #0f766e 48%, #14a596 100%);
  border-radius: 0 0 28px 28px;
  box-shadow: 0 12px 28px rgb(15 118 110 / 0.18);
}

.topbar::after {
  position: absolute;
  right: -36px;
  bottom: -72px;
  width: 180px;
  height: 180px;
  content: "";
  border: 1px solid rgb(255 255 255 / 0.16);
  border-radius: 50%;
  box-shadow:
    0 0 0 28px rgb(255 255 255 / 0.05),
    0 0 0 58px rgb(255 255 255 / 0.03);
  pointer-events: none;
}

.topbar-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.trip-heading {
  min-width: 0;
}

.eyebrow {
  display: block;
  margin-bottom: 4px;
  font-size: 0.69rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  opacity: 0.78;
}

.eyebrow.dark {
  color: var(--muted);
  opacity: 1;
}

.trip-heading h1 {
  margin: 0;
  overflow: hidden;
  font-size: clamp(1.45rem, 6vw, 2rem);
  line-height: 1.12;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trip-heading p {
  margin: 6px 0 0;
  font-size: 0.9rem;
  opacity: 0.88;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.icon-button.glass {
  color: #ffffff;
  border-color: rgb(255 255 255 / 0.20);
  background: rgb(255 255 255 / 0.13);
  box-shadow: none;
  backdrop-filter: blur(8px);
}

.progress-card {
  position: relative;
  z-index: 1;
  margin-top: 17px;
  padding: 13px 14px 12px;
  border: 1px solid rgb(255 255 255 / 0.16);
  border-radius: 18px;
  background: rgb(255 255 255 / 0.11);
  backdrop-filter: blur(10px);
}

.progress-labels,
.progress-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.progress-labels {
  margin-bottom: 8px;
  font-size: 0.87rem;
}

.progress-labels strong {
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.24);
}

.progress-track > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #ffffff;
  transition: width 220ms ease;
}

.progress-footer {
  margin-top: 8px;
  font-size: 0.73rem;
  opacity: 0.88;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgb(255 255 255 / 0.12);
}

.sync-status.offline {
  color: #ffe6a7;
}

.sync-status.error {
  color: #ffc3be;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  max-width: 860px;
  margin: 0 auto;
  padding: 12px 12px 10px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px);
}

.search-box {
  display: flex;
  min-width: 0;
  height: 44px;
  align-items: center;
  gap: 9px;
  padding: 0 11px 0 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.search-box input {
  min-width: 0;
  flex: 1;
  padding: 0;
  color: var(--text);
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 0.94rem;
}

.search-box input::placeholder {
  color: var(--muted-2);
}

.clear-search {
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--muted);
  border: 0;
  border-radius: 50%;
  background: var(--surface-3);
  cursor: pointer;
}

.filter-panel {
  max-width: 836px;
  margin: 0 auto 6px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.toggle-row {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: flex-start;
  gap: 11px;
  color: var(--text);
  cursor: pointer;
}

.toggle-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  accent-color: var(--brand);
}

.toggle-row.compact {
  min-height: 32px;
}

.text-button {
  padding: 7px 0 2px;
  color: var(--brand-strong);
  border: 0;
  background: transparent;
  font-weight: 750;
  cursor: pointer;
}

.view-head {
  display: flex;
  max-width: 836px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 14px auto 10px;
  padding: 0 14px;
}

.view-head h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.15;
}

.view-counter {
  padding: 7px 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.entity-tabs {
  display: flex;
  max-width: 860px;
  gap: 8px;
  margin: 0 auto 12px;
  padding: 0 12px 4px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}

.entity-tabs::-webkit-scrollbar {
  display: none;
}

.entity-tab {
  display: inline-flex;
  min-height: 38px;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.84rem;
  font-weight: 780;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  scroll-snap-align: start;
}

.entity-tab.active {
  color: #ffffff;
  border-color: var(--brand);
  background: var(--brand);
}

.entity-tab .tab-count {
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.entity-tab.active .tab-count {
  color: var(--brand-strong);
  background: #ffffff;
}

.item-list {
  display: grid;
  max-width: 836px;
  gap: 9px;
  margin: 0 auto;
  padding: 0 12px;
}

.item-card {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 11px 10px 11px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 120ms ease, opacity 160ms ease, border-color 160ms ease;
}

.item-card:active {
  transform: scale(0.993);
}

.item-card.packed {
  opacity: 0.64;
  background: var(--surface-2);
}

.item-card.packed .item-label {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.item-card.suggested:not(.packed) {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--line));
}

.pack-button {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  padding: 0;
  place-items: center;
  color: transparent;
  border: 2px solid color-mix(in srgb, var(--brand) 42%, var(--line));
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  transition: all 150ms ease;
}

.pack-button::before {
  content: "✓";
  font-size: 1rem;
  font-weight: 900;
}

.item-card.packed .pack-button {
  color: #ffffff;
  border-color: var(--brand);
  background: var(--brand);
}

.item-content {
  min-width: 0;
}

.item-mainline {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 8px;
}

.item-label {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.96rem;
  font-weight: 760;
  line-height: 1.25;
}

.quantity-badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  color: var(--brand-strong);
  border-radius: 999px;
  background: var(--brand-soft);
  font-size: 0.72rem;
  font-weight: 850;
  white-space: nowrap;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
}

.meta-chip.bag-chip {
  color: var(--brand-strong);
}

.meta-chip.suggestion-chip {
  color: #975a00;
  border-color: #f6cf82;
  background: #fff6dd;
}

:root[data-theme="dark"] .meta-chip.suggestion-chip {
  color: #ffd58a;
  border-color: #6c5222;
  background: #372d17;
}

.item-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.edit-button {
  display: grid;
  width: 35px;
  height: 35px;
  flex: 0 0 35px;
  padding: 0;
  place-items: center;
  color: var(--muted);
  border: 0;
  border-radius: 11px;
  background: transparent;
  cursor: pointer;
}

.edit-button:active {
  background: var(--surface-3);
}

.empty-state {
  max-width: 520px;
  margin: 28px auto;
  padding: 28px 22px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.empty-icon {
  margin-bottom: 8px;
  font-size: 2.2rem;
}

.empty-state h2 {
  margin: 0;
  font-size: 1.15rem;
}

.empty-state p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.bulk-actions {
  display: flex;
  max-width: 836px;
  gap: 8px;
  margin: 15px auto 0;
  padding: 0 12px;
}

.bulk-actions .button {
  flex: 1;
}

.button {
  min-height: 43px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 13px;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
}

.button.primary {
  color: #ffffff;
  border-color: var(--brand);
  background: var(--brand);
}

.button.primary:active {
  background: var(--brand-strong);
}

.button.secondary {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface);
}

.button.danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 32%, var(--line));
  background: var(--danger-soft);
}

.button.wide {
  width: 100%;
}

.page-footer {
  max-width: 836px;
  margin: 18px auto 0;
  padding: 0 18px 16px;
  color: var(--muted-2);
  text-align: center;
  font-size: 0.74rem;
  line-height: 1.4;
}

.fab {
  position: fixed;
  right: 17px;
  bottom: calc(74px + var(--safe-bottom));
  z-index: 42;
  display: grid;
  width: 56px;
  height: 56px;
  padding: 0;
  place-items: center;
  color: #ffffff;
  border: 0;
  border-radius: 19px;
  background: var(--brand);
  box-shadow: 0 12px 30px rgb(15 118 110 / 0.35);
  font-size: 1.9rem;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 7px 7px calc(7px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 -8px 24px rgb(15 35 30 / 0.07);
  backdrop-filter: blur(18px);
}

.nav-button {
  display: grid;
  min-height: 51px;
  gap: 2px;
  place-items: center;
  color: var(--muted);
  border: 0;
  border-radius: 13px;
  background: transparent;
  cursor: pointer;
}

.nav-button span {
  font-size: 1.16rem;
  line-height: 1;
}

.nav-button strong {
  font-size: 0.66rem;
  font-weight: 800;
}

.nav-button.active {
  color: var(--brand-strong);
  background: var(--brand-soft);
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-top: var(--safe-top);
  background: rgb(5 15 12 / 0.54);
  backdrop-filter: blur(4px);
}

.sheet {
  width: min(100%, 680px);
  max-height: calc(100vh - var(--safe-top) - 14px);
  padding: 8px 16px calc(18px + var(--safe-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 26px 26px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  animation: sheet-in 180ms ease-out;
}

.settings-sheet {
  width: min(100%, 720px);
}

@keyframes sheet-in {
  from { transform: translateY(24px); opacity: 0.7; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-handle {
  width: 42px;
  height: 5px;
  margin: 1px auto 10px;
  border-radius: 999px;
  background: var(--line);
}

.sheet-head {
  position: sticky;
  top: -8px;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -4px 12px;
  padding: 8px 4px 10px;
  background: var(--surface);
}

.sheet-head h2 {
  margin: 0;
  font-size: 1.25rem;
}

.sheet-close {
  color: var(--muted);
  box-shadow: none;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field > span {
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.field input,
.field select {
  height: 44px;
  padding: 0 11px;
}

.field textarea {
  min-height: 82px;
  padding: 10px 11px;
  resize: vertical;
}

.input-with-suffix {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.input-with-suffix input {
  border: 0;
  background: transparent;
}

.input-with-suffix span {
  padding-right: 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.spacer {
  flex: 1;
}

.settings-section {
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.settings-section + .settings-section {
  margin-top: 12px;
}

.settings-section h3 {
  margin: 0 0 12px;
  font-size: 0.96rem;
}

.settings-row {
  justify-content: space-between;
  padding: 4px 1px;
  font-weight: 750;
}

.settings-action {
  display: flex;
  width: 100%;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 3px;
  text-align: left;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}

.settings-action:first-of-type {
  border-top: 0;
}

.settings-action > span:first-child {
  display: grid;
  gap: 3px;
}

.settings-action strong {
  color: var(--text);
  font-size: 0.88rem;
}

.settings-action small {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.3;
}

.settings-action > span:last-child {
  color: var(--muted);
  font-size: 1.15rem;
}

.settings-action.danger-text strong,
.settings-action.danger-text > span:last-child {
  color: var(--danger);
}

.file-action {
  cursor: pointer;
}

.version-text {
  margin: 11px 0 0;
  color: var(--muted-2);
  text-align: center;
  font-size: 0.72rem;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  min-height: 100vh;
  padding: calc(22px + var(--safe-top)) 18px calc(22px + var(--safe-bottom));
  place-items: center;
  background:
    radial-gradient(circle at 25% 20%, rgb(45 212 191 / 0.22), transparent 22rem),
    linear-gradient(150deg, #0a3e3a, #0f766e 58%, #102822);
}

.login-card {
  width: min(100%, 390px);
  padding: 28px 22px 22px;
  border: 1px solid rgb(255 255 255 / 0.16);
  border-radius: 26px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 30px 80px rgb(0 0 0 / 0.28);
}

.login-icon {
  display: grid;
  width: 62px;
  height: 62px;
  margin: 0 auto 13px;
  place-items: center;
  border-radius: 20px;
  background: var(--brand-soft);
  font-size: 2rem;
}

.login-card h1 {
  margin: 0;
  text-align: center;
  font-size: 1.45rem;
}

.login-card > p {
  margin: 8px 0 18px;
  color: var(--muted);
  text-align: center;
  font-size: 0.88rem;
  line-height: 1.45;
}

.login-card .field {
  margin-bottom: 14px;
}

.login-card input {
  text-align: center;
  font-size: 1.1rem;
  letter-spacing: 0.14em;
}

.form-error {
  min-height: 1.2em;
  margin: 10px 0 0 !important;
  color: var(--danger) !important;
  font-size: 0.78rem !important;
}

.toast-region {
  position: fixed;
  right: 12px;
  bottom: calc(88px + var(--safe-bottom));
  left: 12px;
  z-index: 300;
  display: grid;
  max-width: 440px;
  gap: 8px;
  margin: 0 auto;
  pointer-events: none;
}

.toast {
  padding: 11px 13px;
  color: #ffffff;
  border-radius: 13px;
  background: #1d2c28;
  box-shadow: var(--shadow-md);
  font-size: 0.84rem;
  font-weight: 700;
  animation: toast-in 150ms ease-out;
}

.toast.error {
  background: #8f241f;
}

.toast.success {
  background: #166534;
}

@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

body.sheet-open {
  overflow: hidden;
}

@media (min-width: 700px) {
  .topbar {
    padding-right: max(28px, calc((100vw - 836px) / 2));
    padding-left: max(28px, calc((100vw - 836px) / 2));
  }

  .item-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bottom-nav {
    right: 50%;
    left: auto;
    width: min(520px, calc(100% - 24px));
    bottom: 12px;
    transform: translateX(50%);
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow-md);
  }

  .fab {
    right: max(22px, calc((100vw - 836px) / 2));
    bottom: 25px;
  }

  .app-shell {
    padding-bottom: 104px;
  }
}

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

  .form-grid .full {
    grid-column: auto;
  }

  .sheet-actions .button {
    flex: 1;
  }

  .sheet-actions .spacer {
    display: none;
  }

  .bulk-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
