* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --text: #1C1C1E;
  --text2: #8E8E93;
  --sep: #E5E5EA;
  --blue: #0A84FF;
  --vale: #FF375F;
  --max: #0A84FF;
  --green: #30D158;
  --orange: #FF9F0A;
  --red: #FF3B30;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- login ---------- */
.login-screen {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-box { width: 100%; max-width: 320px; text-align: center; }
.login-icon { width: 84px; height: 84px; border-radius: 20px; margin-bottom: 12px; }
.login-box h1 { font-size: 28px; margin-bottom: 24px; }
.login-box input {
  width: 100%; padding: 14px; font-size: 17px; border: none; border-radius: 12px;
  background: var(--card); margin-bottom: 12px; outline: none; text-align: center;
}
.login-err { color: var(--red); margin-top: 12px; min-height: 20px; }

/* ---------- nav ---------- */
.screen {
  min-height: 100vh;
  padding-top: env(safe-area-inset-top);
  display: flex; flex-direction: column;
}
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 8px;
}
.nav-title-large { font-size: 34px; font-weight: 700; }
.nav-title { font-size: 17px; font-weight: 600; flex: 1; text-align: center; }
.nav-btn {
  border: none; background: none; color: var(--blue); font-size: 24px;
  padding: 4px 8px; cursor: pointer;
}
.nav-back { font-size: 17px; }
.nav-spacer { width: 60px; }

/* ---------- home ---------- */
.content { flex: 1; padding: 8px 16px calc(24px + env(safe-area-inset-bottom)); }
.content-fab { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }

.list-card {
  background: var(--card); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px;
  cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.list-card-top { display: flex; align-items: center; justify-content: space-between; }
.list-card-name { font-size: 20px; font-weight: 600; text-transform: capitalize; }
.list-card-chev { color: var(--text2); font-size: 20px; }
.list-card-sums { margin-top: 6px; font-size: 15px; color: var(--text2); }
.list-card-sums b { font-weight: 600; }
.badge-pending {
  display: inline-block; margin-top: 8px; font-size: 13px; font-weight: 600;
  color: #fff; background: var(--orange); border-radius: 20px; padding: 3px 10px;
}

.overall-card {
  background: var(--card); border-radius: 14px; padding: 14px 16px; margin-top: 20px;
  border: 1px dashed var(--sep);
}
.overall-title { font-size: 13px; text-transform: uppercase; color: var(--text2); letter-spacing: 0.4px; }
.overall-net { margin-top: 6px; font-size: 16px; }

.name-vale { color: var(--vale); font-weight: 600; }
.name-max { color: var(--max); font-weight: 600; }

/* ---------- month nav ---------- */
.month-nav {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  padding: 4px 0 10px; font-size: 17px; font-weight: 600;
}
.month-arrow {
  border: none; background: var(--card); color: var(--blue); font-size: 22px;
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
}
.month-arrow:disabled { color: var(--sep); }

/* ---------- list detail ---------- */
.sum-card {
  background: var(--card); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px;
}
.sum-row { display: flex; justify-content: space-between; font-size: 17px; padding: 3px 0; }
.sum-diff { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--sep); font-size: 15px; color: var(--text2); }

.pending-card {
  background: #FFF4E0; border-radius: 14px; padding: 12px 16px; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.pending-text { font-size: 15px; }
.pending-text b { font-weight: 700; }
.btn-settle {
  border: none; background: var(--green); color: #fff; font-size: 15px; font-weight: 600;
  padding: 8px 14px; border-radius: 10px; cursor: pointer; white-space: nowrap;
}
.settled-note {
  font-size: 14px; color: var(--green); font-weight: 600; margin-bottom: 12px; text-align: center;
}

.exp-group { background: var(--card); border-radius: 14px; overflow: hidden; margin-bottom: 12px; }
.exp-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--sep); cursor: pointer;
}
.exp-row:last-child { border-bottom: none; }
.exp-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.exp-dot.vale { background: var(--vale); }
.exp-dot.max { background: var(--max); }
.exp-main { flex: 1; min-width: 0; }
.exp-desc { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-sub { font-size: 13px; color: var(--text2); margin-top: 2px; }
.exp-amount { font-size: 17px; font-weight: 600; white-space: nowrap; }

.empty-note { text-align: center; color: var(--text2); padding: 40px 20px; font-size: 16px; }

/* ---------- FAB ---------- */
#fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom));
  width: 64px; height: 64px; border-radius: 50%;
  border: none; background: var(--blue); color: #fff; font-size: 36px; line-height: 1;
  box-shadow: 0 4px 14px rgba(10,132,255,0.4); cursor: pointer;
}
#fab:active { transform: translateX(-50%) scale(0.94); }

/* ---------- sheets ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 10;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11;
  background: var(--bg); border-radius: 18px 18px 0 0;
  padding: 8px 20px calc(24px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
}
.sheet-handle {
  width: 40px; height: 5px; border-radius: 3px; background: var(--sep);
  margin: 4px auto 14px;
}
.sheet h2 { font-size: 20px; margin-bottom: 16px; text-align: center; }

.who-row { display: flex; gap: 12px; margin-bottom: 16px; }
.who-btn {
  flex: 1; padding: 18px 0; font-size: 20px; font-weight: 700;
  border-radius: 14px; border: 2px solid var(--sep); background: var(--card);
  color: var(--text2); cursor: pointer;
}
.who-btn.who-vale.sel { border-color: var(--vale); color: var(--vale); background: #FFF0F3; }
.who-btn.who-max.sel { border-color: var(--max); color: var(--max); background: #EAF4FF; }

.amount-row {
  display: flex; align-items: center; background: var(--card); border-radius: 14px;
  padding: 6px 16px; margin-bottom: 12px;
}
#exp-amount {
  flex: 1; border: none; background: none; outline: none;
  font-size: 34px; font-weight: 700; padding: 8px 0; min-width: 0;
}
.amount-euro { font-size: 28px; color: var(--text2); }

.field-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); border-radius: 14px; padding: 12px 16px; margin-bottom: 12px;
}
.field-row label { font-size: 16px; color: var(--text2); flex-shrink: 0; }
.field-row input {
  border: none; background: none; outline: none; font-size: 17px;
  text-align: right; flex: 1; min-width: 0; color: var(--text);
  font-family: inherit;
}

.btn-primary {
  width: 100%; padding: 16px; font-size: 18px; font-weight: 600;
  border: none; border-radius: 14px; background: var(--blue); color: #fff;
  cursor: pointer; margin-top: 4px;
}
.btn-primary:disabled { opacity: 0.5; }
.btn-secondary {
  width: 100%; padding: 14px; font-size: 17px;
  border: none; border-radius: 14px; background: var(--card); color: var(--blue);
  cursor: pointer; margin-top: 10px;
}
.btn-danger {
  width: 100%; padding: 14px; font-size: 17px;
  border: none; border-radius: 14px; background: var(--card); color: var(--red);
  cursor: pointer; margin-top: 10px;
}

.menu-list-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border-radius: 12px; padding: 12px 16px; margin-bottom: 8px;
}
.menu-list-name { font-size: 17px; text-transform: capitalize; }
.menu-list-actions button {
  border: none; background: none; font-size: 18px; cursor: pointer; padding: 4px 8px;
}
