:root {
  --bg: #f4f3f0;
  --card-bg: #ffffff;
  --text: #1c1b19;
  --muted: #6b6862;
  --accent: #2f6f4f;
  --border: #e3e0da;
  --overdue: #c1442e;
  --urgent: #d9822b;
  --soon: #c9a227;
  --ok: #2f6f4f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 3rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.2rem 1rem 0.8rem;
  gap: 0.75rem;
}

.topbar h1 { margin: 0; font-size: 1.4rem; }
.subtitle { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.9rem; }

.banner {
  margin: 0 1rem 0.5rem;
  background: #fff4e0;
  border: 1px solid #e8c78a;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.85rem;
}

.last-synced {
  margin: 0 1rem 1rem;
  color: var(--muted);
  font-size: 0.8rem;
}

main { padding: 0 1rem; max-width: 640px; margin: 0 auto; }

.stop { margin-bottom: 1.8rem; }

.stop-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.05rem;
  margin: 0 0 0.7rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--border);
}

.badge {
  background: var(--text);
  color: white;
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: 0.8rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 5px solid var(--ok);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.8rem;
}

.card.urgency-overdue { border-left-color: var(--overdue); }
.card.urgency-urgent { border-left-color: var(--urgent); }
.card.urgency-soon { border-left-color: var(--soon); }
.card.urgency-unknown { border-left-color: var(--muted); }

.review-flag {
  background: #fff4e0;
  color: #7a4a00;
  font-size: 0.8rem;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.carrier { font-weight: 600; }
.deadline { color: var(--muted); }
.deadline.unknown { font-style: italic; }

.item-name { color: var(--muted); font-size: 0.85rem; margin-top: 0.2rem; }

.code-block {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  background: #f0efe9;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  margin: 0.6rem 0 0.4rem;
}

.code-label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.code-value { font-size: 1.4rem; font-weight: 700; font-family: "SF Mono", Menlo, monospace; letter-spacing: 0.04em; }

.parcel-number { font-size: 0.8rem; color: var(--muted); font-family: "SF Mono", Menlo, monospace; }

.card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.7rem;
}

.collect-btn {
  flex: 1;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.7rem;
  font-size: 0.9rem;
  min-height: 44px;
}

.edit-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  min-height: 44px;
  font-size: 0.85rem;
  color: var(--muted);
}

.edit-form {
  display: none;
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px dashed var(--border);
}

.edit-form.open { display: block; }

.edit-form label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.edit-form input {
  display: block;
  width: 100%;
  padding: 0.5rem;
  margin-top: 0.2rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}

.edit-form button {
  margin-top: 0.4rem;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  border: none;
  background: var(--text);
  color: white;
}

.edit-form pre {
  white-space: pre-wrap;
  font-size: 0.75rem;
  color: var(--muted);
  max-height: 200px;
  overflow-y: auto;
}

.delete-btn {
  background: transparent !important;
  color: var(--overdue) !important;
  border: 1px solid var(--overdue) !important;
}

.collected-section {
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.collected-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.collected-row form button {
  border: none;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
}
