/* ═══════════════════════════════════════════════════════════
   SPENDLY — RIGID UI SYSTEM
   Regola fondamentale: il contenuto si adatta al box, MAI il contrario
   ═══════════════════════════════════════════════════════════ */

/* ───────── RESET & BASE ───────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  min-width: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: Inter, sans-serif;
  background: #f4f4f1;
  color: #111;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* ───────── TOP BAR ───────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 70px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  /* NO overflow:hidden: il logo è più alto della topbar by design */
}

.topbar-logo {
  height: 130px;
  width: auto;
  flex-shrink: 0;
  display: block;
}

/* ───────── BUDGET BUTTON ───────── */
.btn-budget-set {
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 50px;
  border: none;
  background: #FACC15;
  color: #1c2b3a;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 3px 0px #CA8A04, 0 6px 16px rgba(250,204,21,0.3);
  transition: transform 0.1s, box-shadow 0.1s;
  animation: coinBounce 1.8s ease-in-out infinite;
  letter-spacing: -0.01em;
}
.btn-budget-set:hover  { animation: none; transform: translateY(-3px); box-shadow: 0 6px 0px #CA8A04, 0 12px 24px rgba(250,204,21,0.4); }
.btn-budget-set:active { transform: translateY(2px); box-shadow: 0 1px 0px #CA8A04; animation: none; }

@keyframes coinBounce {
  0%, 100% { transform: translateY(0); }
  30%       { transform: translateY(-6px); }
  50%       { transform: translateY(-3px); }
  70%       { transform: translateY(-5px); }
}

/* ───────── PAGES ───────── */
.pages {
  position: fixed;
  top: 70px;
  bottom: 72px;
  left: 0; right: 0;
  overflow: hidden;
}

.page {
  display: none;
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.page.active { display: block; }

.page-scroll {
  height: 100%;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scroll-behavior: smooth;
  padding: 20px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ───────── SECTION ───────── */
.section-title {
  font-size: 17px;
  font-weight: 600;
  color: #111;
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.section-block {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ───────── METRICS ───────── */
.metrics { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.metrics-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.card {
  background: #fff;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  border: 1px solid transparent;
  transition: 0.2s;
  overflow: hidden;
  min-width: 0;
}

.card span {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #aaa;
  text-transform: uppercase;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card h2 {
  font-family: 'Playfair Display';
  font-size: 34px;
  margin-top: 6px;
  color: #1c2b3a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card h3 {
  font-family: 'Playfair Display';
  font-size: 22px;
  margin-top: 6px;
  color: #1c2b3a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.budget-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #aaa;
  text-transform: uppercase;
  display: block;
  white-space: nowrap;
}

.budget-hint { font-size: 13px; color: #aaa; margin-top: 8px; }

/* ───────── BUDGET CARD DINAMICA ───────── */
.budget-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.budget-pct-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-green  { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-red    { background: #fee2e2; color: #991b1b; }

.budget-secondary {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(0,0,0,0.06);
}
.budget-initial-label {
  font-size: 11px;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.budget-daily-label {
  font-size: 12px;
  font-weight: 600;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hero amount — cambia colore se in rosso */
#budget-bar.over-budget #hero-amount { color: #e74c3c; }
#budget-bar.ok-budget   #hero-amount { color: #166534; }
#budget-bar.near-budget #hero-amount { color: #92601a; }

.budget-progress-wrap { margin-top: 14px; }
.budget-progress-track { width: 100%; height: 6px; background: #eee; border-radius: 99px; overflow: hidden; margin-bottom: 8px; }
.budget-progress-fill { height: 100%; border-radius: 99px; background: #f5c518; transition: width 0.5s ease, background 0.3s; }
.budget-status-text { font-size: 13px; color: #666; }
.budget-status-text strong { color: #111; }

.card.over-budget { background: linear-gradient(135deg,#fff8f8,#fff); border-color: #fbd5d5; }
.card.near-budget { background: linear-gradient(135deg,#fffdf0,#fff); border-color: #fde9a0; }
.card.ok-budget   { background: linear-gradient(135deg,#f3fbf6,#fff); border-color: #b8e8cc; }

/* ───────── CTA ───────── */
.cta {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 16px;
  background: #1c2b3a;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
  box-shadow: 0 4px 14px rgba(28,43,58,0.25);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cta:active { transform: scale(0.98); }

/* ═══════════════════════════════════════════════════════════
   LISTA ABBONAMENTI — layout rigido
   ═══════════════════════════════════════════════════════════ */
.item {
  display: flex;
  align-items: flex-start;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 16px;
  margin-bottom: 10px;
  transition: 0.15s;
  overflow: hidden;
  min-width: 0;
}
.item:active { background: #fafaf8; }

.item-left {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.item-right {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-shrink: 0;
  margin-left: 12px;
  padding-top: 1px;
}

.item-name {
  font-size: 15px;
  font-weight: 600;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.item-meta {
  font-size: 12px;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.item-price {
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  color: #1c2b3a;
  max-width: 90px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
}


.item-edit {
  border: none;
  background: #f0f4ff;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
  line-height: 1;
  transition: background 0.15s;
}
.item-edit:active { background: #dde6ff; }

.item-remove {
  border: none;
  background: #f3f3f0;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
  line-height: 1;
}

/* ═══════════════════════════════════════════════════════════
   DETTAGLI — layout rigido
   ═══════════════════════════════════════════════════════════ */
#details-grid { display: flex; flex-direction: column; gap: 12px; }

.detail-card {
  background: #fff;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.05);
  border: 1px solid #f0f0ee;
  overflow: hidden;
  min-width: 0;
}

.detail-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #f0f0ee;
  overflow: hidden;
}

.detail-name {
  font-family: 'Playfair Display';
  font-size: 18px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-price {
  font-family: 'Playfair Display';
  font-size: 20px;
  font-weight: 700;
  color: #1c2b3a;
  flex-shrink: 0;
  white-space: nowrap;
}
.detail-price span { font-family: Inter; font-size: 11px; color: #aaa; font-weight: 400; }

.detail-rows { display: flex; flex-direction: column; gap: 10px; }
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  gap: 8px;
}
.dr-label { color: #888; flex-shrink: 0; white-space: nowrap; }
.dr-value { font-weight: 500; color: #333; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dr-value.highlight { color: #1c2b3a; font-weight: 700; }

/* ═══════════════════════════════════════════════════════════
   CALENDARIO — completamente isolato
   ═══════════════════════════════════════════════════════════ */
.calendar-section {
  background: #fff;
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.05);
  contain: layout style;
  overflow: hidden;
  width: 100%;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 8px;
  overflow: visible;
}

.calendar-header .section-title {
  flex-shrink: 1;
  min-width: 0;
  margin-bottom: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-nav { display: flex; align-items: center; gap: 4px; flex-shrink: 0; flex-wrap: nowrap; }
.calendar-nav button {
  background: #f1f1ee; border: none; border-radius: 8px;
  width: 30px; height: 30px; font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

#cal-month-label {
  font-size: 12px; font-weight: 600; color: #444;
  min-width: 0;
  text-align: center; text-transform: capitalize;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex-shrink: 1;
}

.cal-view-toggle {
  background: #f1f1ee; border: none; border-radius: 8px;
  padding: 5px 8px; font-size: 11px; font-weight: 600;
  color: #444; cursor: pointer; white-space: nowrap;
  flex-shrink: 0;
  min-width: fit-content;
}
.cal-view-toggle:active { background: #e0e0dc; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  width: 100%;
  overflow: hidden;
}

.cal-day-name {
  text-align: center; font-size: 9px; font-weight: 600;
  color: #bbb; letter-spacing: 0.04em; padding-bottom: 6px; overflow: hidden;
}

.cal-cell {
  border-radius: 6px;
  padding: 3px;
  height: 62px;
  max-height: 62px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #fafaf8;
  border: 1px solid transparent;
  overflow: hidden;
  contain: strict;
}

.cal-empty { background: transparent; border: none; contain: strict; }
.cal-today { border-color: #ddd; background: #fff; }
.cal-today .cal-day-num { background: #1c2b3a; color: #fff; border-radius: 50%; }
.cal-has-payment { background: #fff; border-color: #eee; box-shadow: 0 1px 6px rgba(0,0,0,0.05); }

.cal-day-num {
  font-size: 10px; font-weight: 500; color: #bbb;
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; border-radius: 50%;
}
.cal-has-payment .cal-day-num { color: #111; font-weight: 700; }

.cal-chips { display: flex; flex-direction: column; gap: 2px; overflow: hidden; flex: 1; min-width: 0; }

.cal-chip {
  border-radius: 3px; padding: 1px 3px; border: 1px solid;
  display: flex; flex-direction: column;
  overflow: hidden; min-width: 0; max-width: 100%; flex-shrink: 0;
}

.cal-chip-name {
  font-size: 7px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: block; line-height: 1.3;
}

.cal-chip-price {
  font-size: 7px; font-weight: 600; opacity: 0.8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: block; line-height: 1.3;
}

.calendar-legend {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid #f0f0ee;
  display: flex; flex-direction: column; gap: 7px; overflow: hidden;
}

.cal-legend-summary { font-size: 13px; color: #888; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-legend-summary strong { color: #1c2b3a; }

.cal-legend-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: #444; overflow: hidden; min-width: 0;
}

.cal-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.cal-legend-text {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0; flex: 1;
}

.cal-no-payments { font-size: 13px; color: #aaa; }

/* ── Vista lista Apple ── */
.apple-cal-group { margin-bottom: 18px; overflow: hidden; }

.apple-cal-date {
  font-size: 13px; font-weight: 500; color: #888;
  padding: 0 0 8px 0; border-bottom: 1px solid #f0f0ee; margin-bottom: 6px;
  text-transform: capitalize; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.apple-cal-date.apple-cal-today { color: #1c2b3a; font-weight: 700; }

.apple-cal-event {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid #f5f5f3;
  overflow: hidden; min-width: 0;
}
.apple-cal-event:last-child { border-bottom: none; }
.apple-cal-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.apple-cal-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow: hidden; }
.apple-cal-name { font-size: 15px; font-weight: 500; color: #111; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apple-cal-time { font-size: 12px; color: #aaa; white-space: nowrap; }
.apple-cal-amount { font-size: 14px; font-weight: 600; color: #1c2b3a; flex-shrink: 0; white-space: nowrap; }

/* ═══════════════════════════════════════════════════════════
   INSIGHTS
   ═══════════════════════════════════════════════════════════ */
#insights-grid, #insights-grid-full { display: flex; flex-direction: column; gap: 10px; }

.insight-card {
  background: #fff;
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
  border: 1px solid #f0f0ee;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  overflow: hidden;
  min-width: 0;
  transition: transform 0.15s;
}
.insight-card:active { transform: scale(0.99); }

/* Stili varianti */
.insight-card.insight-alert {
  background: linear-gradient(135deg, #fff8f8, #fff);
  border-color: #fbd5d5;
}
.insight-card.insight-highlight {
  background: linear-gradient(135deg, #f0fdf4, #fff);
  border-color: #b8e8cc;
}

.insight-icon {
  font-size: 22px;
  flex-shrink: 0;
  margin-top: 1px;
  line-height: 1;
  width: 28px;
  text-align: center;
}

.insight-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.insight-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: #aaa;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.insight-value {
  font-size: 13px;
  color: #333;
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.insight-value strong { color: #1c2b3a; font-weight: 600; }

.insights-empty { font-size: 14px; color: #aaa; }

/* ───────── BOTTOM NAV ───────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 72px;
  background: rgba(250,247,242,0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid #EDE8DF;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
  box-shadow: 0 -2px 20px rgba(28,43,58,0.06);
  overflow: hidden;
}

.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  background: none; border: none; cursor: pointer;
  color: #CBD5E1; padding: 8px 0;
  transition: color 0.2s, transform 0.15s;
  font-size: 10px; font-weight: 700; font-family: Inter, sans-serif;
  letter-spacing: 0.03em; min-height: 56px;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden; min-width: 0;
}
.nav-item svg { width: 22px; height: 22px; transition: transform 0.2s; flex-shrink: 0; }
.nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.nav-item.active { color: #1c2b3a; }
.nav-item.active svg { transform: scale(1.15); stroke-width: 2.5; }
.nav-item:active { transform: scale(0.85); }
.nav-item.active::after {
  content: ''; width: 4px; height: 4px; background: #FACC15;
  border-radius: 50%; display: block; margin-top: -2px;
  box-shadow: 0 0 6px rgba(250,204,21,0.9);
}

.nav-add {
  width: 54px; height: 54px; background: #1c2b3a;
  border: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 0 #0a1020, 0 8px 20px rgba(28,43,58,0.4);
  flex-shrink: 0; transition: transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.nav-add svg { width: 24px; height: 24px; stroke: #fff; }
.nav-add:active { transform: scale(0.9) translateY(3px); box-shadow: 0 1px 0 #0a1020, 0 4px 10px rgba(28,43,58,0.2); }

/* ───────── MODAL ───────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(8px);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 200;
}
.modal-box {
  background: #fff; border-radius: 28px 28px 0 0;
  padding: 28px 24px 40px; width: 100%; max-height: 92vh;
  overflow-y: auto; animation: slideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-box h3 { font-family: 'Playfair Display'; font-size: 22px; margin-bottom: 6px; }
.modal-sub { font-size: 13px; color: #888; margin-bottom: 18px; }
.modal-box input {
  width: 100%; padding: 14px 16px; border-radius: 14px;
  border: 1px solid #e5e5e2; background: #fafaf8;
  margin-bottom: 12px; font-size: 16px; transition: 0.2s; font-family: Inter, sans-serif;
}
.modal-box input:focus { outline: none; border-color: #1c2b3a; box-shadow: 0 0 0 3px rgba(28,43,58,0.08); background: #fff; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.btn-light { flex: 1; background: #f1f1ee; border: none; padding: 14px; border-radius: 14px; cursor: pointer; font-size: 15px; font-weight: 500; }
.btn-dark  { flex: 2; background: #1c2b3a; color: #fff; border: none; padding: 14px; border-radius: 14px; cursor: pointer; font-size: 15px; font-weight: 600; }
.btn-outline-red { flex: 1; background: #fff0f0; border: 1px solid #f5b8b8; color: #c0392b; padding: 14px; border-radius: 14px; cursor: pointer; font-size: 15px; }




/* ───────── FILTRO LISTA ───────── */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  min-width: 0;
  overflow: hidden;
}

.filter-select {
  flex-shrink: 0;
  padding: 7px 30px 7px 12px;
  border-radius: 20px;
  border: 1px solid #e5e5e2;
  background: #fafaf8;
  font-size: 12px;
  font-weight: 600;
  font-family: Inter, sans-serif;
  color: #1c2b3a;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color 0.2s;
}
.filter-select:focus { outline: none; border-color: #1c2b3a; }

.filter-select-sub {
  width: 100%;
  max-width: 100%;
  margin-bottom: 10px;
  border-radius: 12px;
}


/* ───────── GRUPPO CATEGORIA NEL MODAL ───────── */
.cat-group {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid #e5e5e2;
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 12px;
  background: #fafaf8;
}

.cat-group-row {
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid #eee;
  min-height: 50px;
}
.cat-group-row:last-child { border-bottom: none; }

.cat-group-label {
  font-size: 11px;
  font-weight: 600;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  width: 90px;
  flex-shrink: 0;
}

.cat-group select {
  flex: 1;
  border: none;
  background: transparent;
  padding: 14px 28px 14px 0;
  font-size: 15px;
  font-family: Inter, sans-serif;
  color: #111;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0 center;
  cursor: pointer;
  margin-bottom: 0 !important;
  width: 100%;
}
.cat-group select:focus { outline: none; }

/* Nasconde il vecchio stile standalone per i select categoria */
#input-macro.modal-box select,
#input-sub.modal-box select,
#edit-macro.modal-box select,
#edit-sub.modal-box select { margin-bottom: 0; }


/* ───────── MODAL SECTION LABEL ───────── */
.modal-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #aaa;
  text-transform: uppercase;
  margin-bottom: 8px;
  margin-top: 4px;
}

/* ───────── PRESET DESELECTABLE ───────── */
.preset {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.preset:not(.active) { opacity: 0.85; }
.preset:not(.active):hover { opacity: 1; border-color: #ccc; }

/* ───────── BADGE CATEGORIA ───────── */
.cat-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  letter-spacing: 0.02em;
  margin-top: 1px;
}

/* ───────── SELECT (frequenza) ───────── */
.modal-box select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid #e5e5e2;
  background: #fafaf8;
  margin-bottom: 12px;
  font-size: 16px;
  font-family: Inter, sans-serif;
  color: #111;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  cursor: pointer;
  transition: 0.2s;
}
.modal-box select:focus {
  outline: none;
  border-color: #1c2b3a;
  box-shadow: 0 0 0 3px rgba(28,43,58,0.08);
  background-color: #fff;
}

#recurrence-limit-wrap { margin-bottom: 0; }
#recurrence-limit-wrap select { margin-bottom: 0; }

/* ───────── PRESETS ───────── */
.preset-buttons {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px; margin: 4px 0 16px;
}
.preset {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 12px 8px; border-radius: 14px; background: #f4f4f2;
  cursor: pointer; border: 1.5px solid transparent;
  font-size: 12px; font-weight: 600; transition: all 0.15s; min-height: 64px; overflow: hidden;
}
.preset span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.preset img { width: 24px; height: 24px; flex-shrink: 0; }
.preset:active { background: #eaeae7; }
.preset.active { background: #1c2b3a; color: #fff; border-color: #1c2b3a; }




/* ───────── UTILS ───────── */
.hidden { display: none !important; }
.budget-bar { display: none; }

/* ───────── DESKTOP FALLBACK ───────── */
@media (min-width: 500px) {
  html, body { overflow: auto; background: #E5E0D8; }
  .topbar { max-width: 480px; left: 50%; transform: translateX(-50%); }
  .pages  { max-width: 480px; left: 50%; transform: translateX(-50%); }
  .bottom-nav { max-width: 480px; left: 50%; transform: translateX(-50%); border-left: 1px solid #EDE8DF; border-right: 1px solid #EDE8DF; }
  .modal-box { border-radius: 28px; max-width: 480px; margin-bottom: 80px; }
  .modal { align-items: center; }
}