:root {
  --sand: #FBF7F0;
  --sand-2: #F2EADB;
  --marine: #0E7C86;
  --marine-light: #11A5B3;
  --ink: #1F2933;
  --ink-soft: #5B6770;
  --red: #C0392B;
  --card: #FFFFFF;
  --line: #E7DECF;
  --ok: #2E8B57;
  --shadow: 0 2px 10px rgba(31, 41, 51, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }

/* Atributul `hidden` trebuie să învingă regulile noastre de `display` (flex/block) */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--sand);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body { max-width: 540px; margin: 0 auto; }

button { font-family: inherit; }

a { color: var(--marine); }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--sand);
  border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top) + 10px) 14px 8px;
  box-shadow: 0 4px 12px rgba(31, 41, 51, 0.05);
}

.head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.app-title {
  font-size: 1.18rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.02em;
  color: var(--marine);
}
.app-title .dot { color: var(--marine-light); font-weight: 600; }

.sync {
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--sand-2);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.sync.is-synced { color: var(--ok); }
.sync.is-syncing { color: var(--marine-light); }
.sync.is-offline { color: var(--red); background: #FBEAE8; border-color: #F0C7C2; }

/* Quick actions */
.quick {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.quick-btn {
  flex: 1 1 auto;
  min-height: 44px;
  border: 1px solid var(--marine);
  background: #fff;
  color: var(--marine);
  font-weight: 600;
  font-size: 0.86rem;
  border-radius: 999px;
  padding: 0 12px;
  cursor: pointer;
}
.quick-btn:active { background: var(--sand-2); }
.quick-hint {
  margin: 8px 2px 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 0 auto;
  min-width: 56px;
  min-height: 48px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 6px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  color: var(--ink-soft);
}
.tab .tab-day { font-weight: 800; font-size: 0.95rem; }
.tab .tab-date { font-size: 0.68rem; margin-top: 2px; }
.tab.active {
  background: var(--marine);
  border-color: var(--marine);
  color: #fff;
}
.tab { position: relative; }
.tab.complete .tab-day::after { content: " ✓"; color: var(--ok); font-size: 0.7rem; }
.tab.active.complete .tab-day::after { color: #CDEEDE; }

/* Progress */
.progress-wrap { margin-top: 10px; }
.progress-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 5px;
}
.progress-label { font-weight: 700; font-size: 0.84rem; color: var(--ink); }
.progress-total { font-size: 0.74rem; color: var(--ink-soft); }
.progress-track {
  height: 7px;
  background: var(--sand-2);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--marine), var(--marine-light));
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* ---------- Main ---------- */
#main { padding: 12px 14px 40px; }

.banner {
  background: #FBEAE8;
  border: 1px solid #F0C7C2;
  border-left: 4px solid var(--red);
  border-radius: 12px;
  padding: 12px 12px 12px 14px;
  margin-bottom: 14px;
  font-size: 0.88rem;
}
.banner h3 { margin: 0 0 6px; font-size: 0.92rem; color: var(--red); }
.banner ul { margin: 6px 0 0; padding-left: 18px; }
.banner li { margin: 3px 0; }
.banner a { color: var(--red); font-weight: 600; }
.banner .banner-dismiss {
  float: right;
  border: none;
  background: transparent;
  color: var(--red);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
}

.day-head { margin: 2px 0 12px; }
.day-head h2 { margin: 0; font-size: 1.15rem; }
.day-head p { margin: 3px 0 0; color: var(--ink-soft); font-size: 0.85rem; }

/* Cards container fade */
.cards.fade { animation: fadeIn 0.25s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Card ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 14px;
  margin-bottom: 12px;
  transition: opacity 0.25s ease;
}
.card.done { opacity: 0.55; }
.card.done .card-name { text-decoration: line-through; }

.card-head { display: flex; gap: 10px; align-items: flex-start; }
.card-name {
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.25;
}
.card-meta {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.card-meta .star { color: #E08A1E; font-weight: 700; }

.card-note { margin: 9px 0 0; font-size: 0.9rem; line-height: 1.4; }

/* Făcut checkbox */
.done-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.done-toggle input {
  width: 24px;
  height: 24px;
  accent-color: var(--marine);
  cursor: pointer;
}

/* Reservation badge */
.resv {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 999px;
  min-height: 32px;
}

/* Nearby */
.nearby {
  margin-top: 11px;
  border-top: 1px dashed var(--line);
  padding-top: 9px;
}
.nearby-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  font-weight: 700;
  margin-bottom: 6px;
}
.nearby-item { margin-bottom: 9px; }
.nearby-item:last-child { margin-bottom: 0; }
.nearby-name { font-weight: 600; font-size: 0.9rem; }
.nearby-blurb { font-size: 0.83rem; color: var(--ink-soft); margin: 2px 0 4px; line-height: 1.35; }
.nearby-links { display: flex; gap: 12px; flex-wrap: wrap; }
.nearby-links a { font-size: 0.82rem; font-weight: 600; text-decoration: none; }

/* Action buttons */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}
.act {
  flex: 1 1 calc(50% - 4px);
  min-height: 42px;
  border: 1px solid var(--line);
  background: var(--sand);
  border-radius: 10px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 8px;
}
.act:active { background: var(--sand-2); }
.act.primary { background: var(--marine); border-color: var(--marine); color: #fff; }

/* Reset day */
.reset-day {
  display: block;
  margin: 8px auto 0;
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-size: 0.82rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 8px;
}
.foot-note {
  text-align: center;
  font-size: 0.74rem;
  color: var(--ink-soft);
  margin: 18px 6px 0;
  line-height: 1.4;
}

.empty { text-align: center; color: var(--ink-soft); padding: 30px 10px; }

/* ---------- Category headers ---------- */
.cat-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.8rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--marine); margin: 18px 2px 8px;
}
.cat-head:first-child { margin-top: 4px; }
.cat-count {
  font-size: 0.7rem; background: var(--sand-2); color: var(--ink-soft);
  border-radius: 999px; padding: 1px 8px; font-weight: 700;
}

/* ---------- Zone suggestions ---------- */
.zone-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 11px; }
.zone-label { font-size: 0.78rem; color: var(--ink-soft); font-weight: 600; width: 100%; margin-bottom: 1px; }
.zone-btn {
  font-size: 0.78rem; font-weight: 600; text-decoration: none; color: var(--marine);
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 11px; min-height: 32px;
  display: inline-flex; align-items: center;
}
.zone-btn:active { background: var(--sand-2); }

/* ---------- Spend input on cards ---------- */
.spend {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 11px; padding-top: 10px; border-top: 1px dashed var(--line);
  font-size: 0.85rem; font-weight: 600; color: var(--ink-soft);
}
.spend-in { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; color: var(--ink); }
.spend-in input {
  width: 88px; text-align: right; font-size: 1rem; font-weight: 700; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; background: var(--sand);
}
.spend-in input:focus { outline: 2px solid var(--marine-light); background: #fff; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- Expenses tab + view ---------- */
.tab-exp.active { background: #E08A1E; border-color: #E08A1E; }
.exp-grand {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(90deg, var(--marine), var(--marine-light)); color: #fff;
  border-radius: var(--radius); padding: 15px 18px; font-size: 1rem; font-weight: 600;
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.exp-grand strong { font-size: 1.55rem; font-weight: 800; }
.exp-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 12px;
}
.exp-card-title {
  font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ink-soft); font-weight: 800; margin-bottom: 8px;
}
.exp-line {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-top: 1px solid var(--line); font-size: 0.92rem;
}
.exp-line:first-of-type { border-top: none; }
.exp-line b { font-weight: 800; }
.exp-empty { font-size: 0.85rem; color: var(--ink-soft); padding: 4px 0; }
.gen-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 0; border-top: 1px solid var(--line); font-size: 0.92rem; font-weight: 600;
}
.gen-row:first-of-type { border-top: none; }

/* ---------- Card photo + category chip ---------- */
.card-photo { border-radius: 12px; overflow: hidden; margin-bottom: 11px; background: var(--sand-2); }
.card-photo-skel {
  height: 150px;
  background: linear-gradient(110deg, var(--sand-2) 30%, #efe6d5 50%, var(--sand-2) 70%);
  background-size: 200% 100%; animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.card-photo-img { display: block; width: 100%; height: 165px; object-fit: cover; }
.cat-chip {
  display: inline-block; font-size: 0.66rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.03em; color: var(--marine); background: var(--sand-2);
  border-radius: 999px; padding: 2px 9px; margin-bottom: 5px;
}
.ai-chip {
  display: inline-block; font-size: 0.62rem; font-weight: 800; color: #fff;
  background: #E08A1E; border-radius: 999px; padding: 2px 8px; margin-bottom: 5px;
}
.card.custom { border-left: 3px solid #E08A1E; }
.act.danger { color: var(--red); border-color: #F0C7C2; background: #FBEAE8; }

/* ---------- AI chat ---------- */
#aiFab {
  position: fixed; right: 16px; bottom: 18px; z-index: 60;
  width: 56px; height: 56px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--marine-light), var(--marine)); color: #fff;
  font-size: 1.55rem; box-shadow: 0 6px 18px rgba(14, 124, 134, 0.42); cursor: pointer;
}
#aiFab:active { transform: scale(0.95); }
@media (min-width: 560px) { #aiFab { right: calc(50% - 270px + 16px); } }

#aiPanel {
  position: fixed; z-index: 61; left: 0; right: 0; bottom: 0;
  margin: 0 auto; width: 100%; max-width: 540px; height: min(74vh, 580px);
  background: var(--sand); border-top-left-radius: 18px; border-top-right-radius: 18px;
  box-shadow: 0 -8px 30px rgba(31, 41, 51, 0.28); display: flex; flex-direction: column;
  animation: sheetUp 0.22s ease;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.ai-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 800; color: var(--marine);
}
.ai-head button { border: none; background: transparent; font-size: 1.5rem; line-height: 1; color: var(--ink-soft); cursor: pointer; }
.ai-msgs { flex: 1 1 auto; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.ai-msg { max-width: 85%; padding: 9px 12px; border-radius: 14px; font-size: 0.9rem; line-height: 1.4; }
.ai-user { align-self: flex-end; background: var(--marine); color: #fff; border-bottom-right-radius: 4px; }
.ai-ai { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.ai-note { align-self: center; background: #E8F5E9; color: #2E7D32; font-size: 0.8rem; font-weight: 700; border-radius: 999px; padding: 5px 12px; }
.ai-typing { opacity: 0.6; }
.ai-input { display: flex; gap: 8px; padding: 10px 12px calc(env(safe-area-inset-bottom) + 12px); border-top: 1px solid var(--line); }
.ai-input input { flex: 1 1 auto; min-width: 0; border: 1px solid var(--line); border-radius: 999px; padding: 11px 14px; font-size: 1rem; background: #fff; }
.ai-input input:focus { outline: 2px solid var(--marine-light); }
.ai-input button { flex: 0 0 auto; width: 46px; border: none; border-radius: 50%; background: var(--marine); color: #fff; font-size: 1.1rem; cursor: pointer; }
.ai-input button:disabled { opacity: 0.5; }
