/* ItsGoodThru — calm, simple, easy to the eyes. */

:root {
  --accent: #2e7d6b;
  --accent-dark: #256557;
  --ink: #22302c;
  --muted: #6b7a75;
  --line: #e2e8e5;
  --bg: #f7f9f8;
  --card: #ffffff;
  --red-bg: #fdecea;
  --red-ink: #9c2b21;
  --overdue-bg: #f8cfc7;
  --overdue-border: #e08a7c;
  --overdue-ink: #8a1a0e;
  --orange-bg: #ffedd6;
  --orange-border: #f0cd96;
  --orange-ink: #8a5200;
  --yellow-bg: #fff6da;
  --yellow-ink: #7a5c00;
  --green-bg: #edf6ee;
  --green-border: #cfe4d2;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.app-header {
  /* The top term keeps the title clear of the phone's status bar,
     including Android edge-to-edge where the inset can be 0 but the
     base 20px still applies. */
  padding: calc(20px + env(safe-area-inset-top)) 20px 8px;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.app-header h1 {
  font-size: 24px;
  font-weight: 700;
  margin: 0;
  color: var(--accent-dark);
  flex: 1;
  min-width: 0;
}

.bell-btn {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--accent-dark);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  width: 42px;
  height: 42px;
  cursor: pointer;
}

.bell-btn img { display: block; border-radius: 8px; }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 16px 150px;
}

h2 { font-size: 20px; margin: 12px 0 14px; }
h3 { font-size: 16px; margin: 0 0 10px; }

.hidden { display: none !important; }

/* ---------- filter / reminder chips ---------- */

.chips { display: flex; gap: 8px; margin: 6px 0 14px; }
.chips.wrap { flex-wrap: wrap; margin: 8px 0 0; }

.chip {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 15px;
  min-height: 40px;
  cursor: pointer;
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chip-check { display: inline-flex; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check input:checked + .chip {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- item rows ---------- */

.list { display: flex; flex-direction: column; gap: 10px; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-height: 64px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

/* Urgency bands — four clearly distinct looks:
   overdue = strong red; today / within 7 days = light orange;
   within 30 days = yellow; beyond 30 days = very light green. */
.row.band-expired {
  background: var(--overdue-bg);
  border-color: var(--overdue-border);
}
.row.band-today, .row.band-soon {
  background: var(--orange-bg);
  border-color: var(--orange-border);
}
.row.band-month {
  background: var(--yellow-bg);
  border-color: #ecd98f;
}
.row.band-later {
  background: var(--green-bg);
  border-color: var(--green-border);
}

.thumb {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  flex: none;
  background: #e6efec;
}

.thumb-initial {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  font-weight: 700;
  color: var(--accent-dark);
}

.thumb-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
}

.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-name { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 13px; color: var(--muted); }
.row-days { font-size: 14px; font-weight: 600; white-space: nowrap; }
.band-expired .row-days { color: var(--overdue-ink); font-weight: 700; }
.band-today .row-days, .band-soon .row-days { color: var(--orange-ink); }
.band-month .row-days { color: var(--yellow-ink); }

.empty { color: var(--muted); font-size: 15px; padding: 18px 4px; }

/* ---------- quantities ---------- */

.qty-badge {
  flex: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-dark);
  background: #e6efec;
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}

.stepper { display: inline-flex; align-items: center; gap: 14px; }

.stepper-btn {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.stepper-value {
  font-size: 18px;
  font-weight: 700;
  min-width: 2ch;
  text-align: center;
}

.merge-note {
  background: #eef4f2;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.round-banner {
  background: #eef4f2;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 600;
}

/* ---------- forms ---------- */

.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="date"],
.field select,
.newplace input[type="text"],
.newplace select,
.renew-custom input[type="date"] {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  min-height: 48px;
}

.newplace {
  display: flex;
  gap: 8px;
  margin: -6px 0 16px;
}
.newplace input { flex: 1; }
.newplace select { width: auto; }

.stack { margin-top: 22px; }

.note { font-size: 14px; color: var(--accent-dark); margin: 8px 0 14px; }
.field .hint { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.error { font-size: 14px; color: var(--red-ink); margin: 0 0 12px; }

.photo-preview {
  display: block;
  max-width: 180px;
  border-radius: 10px;
  margin: 10px 0;
}

/* ---------- category creator ---------- */

.cat-creator {
  margin-top: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.cat-creator .error { margin: 8px 0 0; }

.icon-palette .chip {
  font-size: 20px;
  line-height: 1;
  padding: 10px 13px;
}

.cat-creator-actions { display: flex; gap: 8px; margin-top: 12px; }

.cat-manage-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  border-top: 1px solid var(--line);
  font-size: 16px;
}
.cat-manage-row .cm-name { flex: 1; min-width: 0; }

.cat-del {
  flex: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--red-ink);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

/* ---------- buttons ---------- */

.btn {
  font: inherit;
  font-size: 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: 13px 18px;
  min-height: 50px;
  cursor: pointer;
  width: 100%;
  margin-bottom: 10px;
}

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-secondary { background: #eef4f2; }
.btn-quiet { background: transparent; border-color: transparent; color: var(--accent-dark); }
.btn-danger { background: transparent; border-color: #f3c6c0; color: var(--red-ink); }
.btn-small { width: auto; min-height: 48px; padding: 10px 14px; margin-bottom: 0; white-space: nowrap; }
.btn.back { width: auto; padding-left: 0; margin-bottom: 4px; }

/* ---------- places ---------- */

.place-row .row-sub { font-size: 13px; }
.month-line { font-size: 15px; font-weight: 600; color: var(--yellow-ink); margin: 0 0 12px; }

/* ---------- detail ---------- */

.detail-photo { width: 100%; max-height: 260px; object-fit: cover; border-radius: var(--radius); margin-bottom: 12px; }
.days-big { font-size: 22px; font-weight: 700; margin: 4px 0 14px; }
.days-big.band-expired { color: var(--overdue-ink); }
.days-big.band-today, .days-big.band-soon { color: var(--orange-ink); }
.days-big.band-month { color: var(--yellow-ink); }
.days-big.band-later { color: var(--accent-dark); }

.detail-facts { margin: 0 0 20px; }
.detail-facts > div {
  display: flex;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.detail-facts dt { color: var(--muted); font-size: 15px; }
.detail-facts dd { margin: 0; font-size: 15px; font-weight: 600; }

.action-grid { display: flex; gap: 10px; }
.action-grid .btn { flex: 1; }

.renew-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin: 6px 0 16px;
}
.renew-custom { display: flex; gap: 8px; align-items: center; }
.renew-custom input { flex: 1; }

/* ---------- replaced ---------- */

.replace-box .note { margin-top: 0; }
.replace-qty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.replace-qty .rq-label { color: var(--muted); font-size: 15px; }
.btn-block { width: 100%; }

/* ---------- overdue actions ---------- */

.overdue-box {
  background: var(--red-bg);
  border: 1px solid var(--overdue-border);
  border-radius: var(--radius);
  padding: 14px;
  margin: 6px 0 16px;
}
.overdue-box h3 { color: var(--overdue-ink); }
.overdue-box .note { margin-bottom: 0; }

/* ---------- expiring list tools ---------- */

.attention-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--orange-ink);
  background: var(--orange-bg);
  border: 1px solid var(--orange-border);
  border-radius: 10px;
  padding: 11px 12px;
  margin: 0 0 14px;
  cursor: pointer;
}
.attention-banner span:first-child { flex: 1; }
.attention-banner.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.attention-close { font-size: 20px; font-weight: 700; line-height: 1; }

.search-row { display: flex; gap: 8px; margin: 0 0 14px; }
.search-row input[type="search"],
.search-row select {
  font: inherit;
  font-size: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  min-height: 48px;
}
.search-row input[type="search"] { flex: 1; min-width: 0; }
.search-row select { flex: none; }

/* ---------- floating add button ---------- */

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 11;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 14px 22px;
  min-height: 52px;
  box-shadow: 0 4px 14px rgba(34, 48, 44, 0.28);
  cursor: pointer;
}
.fab:active { background: var(--accent-dark); }

/* ---------- tab bar ---------- */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}

.tab {
  flex: 1;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  background: none;
  border: none;
  color: var(--muted);
  min-height: 58px;
  cursor: pointer;
}

.tab.active { color: var(--accent-dark); box-shadow: inset 0 3px 0 var(--accent); }
