/* 
  Expense Tracker V2 - Premium Auditor Theme (Codex Legacy Restored)
*/

:root {
  --bg: #f4efe7;
  --surface: #fffdf9;
  --surface-soft: #f8f3ea;
  --text: #26231f;
  --muted: #817a70;
  --line: #ddd3c5;
  --line-soft: #eee6da;
  
  --blue: #6f8798;
  --blue-soft: #edf3f8;
  --green: #738a75;
  --green-soft: #eef4ed;
  --sage: #87977f;
  --amber: #b0824b;
  --danger: #b85b50;
  
  --shadow: 0 18px 46px rgba(61, 48, 34, .08);
  --shadow-sm: 0 6px 22px rgba(61, 48, 34, .04);
  --shadow-btn: 0 4px 14px rgba(61, 48, 34, .12);
  
  --radius-card: 16px;
  --radius-btn: 12px;
  --radius-pill: 999px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
  overscroll-behavior-y: none; 
}

/* Tipografia Numerica per Revisori (Numeri allineati) */
.summary-amount, .amount-input, .tx-amount, .currency, .currency-select, .mono-num {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.screen {
  min-height: 100vh;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  padding-bottom: 90px;
}

/* TOPBAR */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px 8px;
  background: rgba(244, 239, 231, 0.94);
  position: sticky; top: 0; z-index: 80;
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.topbar h2 { font-size: 24px; font-weight: 750; letter-spacing: -0.02em; }
.avatar { width: 36px; height: 36px; background: linear-gradient(145deg, #2f342f, #6f8798); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 800; color: white; font-size: 14px; box-shadow: var(--shadow-btn); }
.icon-btn { background: none; border: none; cursor: pointer; }

/* CONTENT */
.content { padding: 20px 16px 24px; }

/* REUSABLE CARDS */
.card { 
  background: var(--surface); 
  border-radius: var(--radius-card); 
  padding: 20px; 
  box-shadow: var(--shadow); 
  margin-bottom: 16px; 
  border: 1px solid var(--line-soft);
}
.card h3 {
  font-size: 15px; font-weight: 780; color: var(--text); margin-bottom: 6px;
}

/* MAGIC BOX */
.magic-box-container { margin: 0 0 20px; }
.magic-box {
  display: flex; align-items: center;
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line-soft);
}
.magic-icon { font-size: 16px; margin-right: 12px; }
.magic-box input {
  flex: 1; border: none; outline: none; font-size: 15px;
  background: transparent; color: var(--text);
}
.magic-box input::placeholder { color: var(--muted); }
.magic-send-btn { 
  background: var(--text); color: white; border: none; border-radius: 10px; width: 32px; height: 32px; 
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: var(--shadow-btn); transition: transform 0.2s;
}
.magic-send-btn:active { transform: scale(0.9); }

/* SUMMARY SECTION */
.summary-section { margin-bottom: 24px; }
.summary-card {
  background: linear-gradient(180deg, #fffdf9, #faf5ed);
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line-soft);
}
.summary-label { font-size: 11px; color: #9b9287; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 800; }
.summary-amount { font-size: 32px; font-weight: 780; margin: 4px 0 14px; letter-spacing: -0.02em; color: var(--text); }
.decimals { font-size: 20px; color: var(--muted); }
.progress-bar { height: 7px; background: #e5e5ea; border-radius: 999px; overflow: hidden; margin-bottom: 8px;}
.progress-fill { height: 100%; background: var(--green); border-radius: 999px; }
.summary-sub { font-size: 12px; color: var(--muted); line-height: 1.35; }

/* SECTIONS */
.section-header { 
  display: flex; justify-content: space-between; align-items: center; 
  margin-bottom: 12px;
}
.section-header h3 { font-size: 15px; font-weight: 780; color: var(--text); }
.text-btn { background: none; border: none; color: var(--blue); font-size: 13px; font-weight: 650; cursor: pointer; }

/* TX LISTS */
.transactions-list, #history-list, #reports-category-list {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.tx-item { 
  display: flex; align-items: flex-start; padding: 14px 16px; 
  border-bottom: 1px solid var(--line-soft);
  background: #fff;
}
.tx-item:last-child { border-bottom: none; }

.tx-date { 
  font-size: 12px; color: var(--muted); width: 44px; text-align: left; font-weight: 600; 
  padding-top: 2px;
}
.tx-details { flex: 1; min-width: 0; padding-right: 10px;}
.tx-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tx-cat-container { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tag { background: var(--surface-soft); padding: 3px 8px; border-radius: var(--radius-pill); font-size: 11px; color: #555d68; font-weight: 600; white-space: nowrap; }
.inst-tag { background: var(--blue-soft); color: #526f86; border: 1px solid #d3e0ea; }

.tx-amount { font-size: 17px; font-weight: 750; text-align: right; white-space: nowrap;}
.tx-amount { font-size: 16px; font-weight: 750; text-align: right; white-space: nowrap;}
.tx-amount.negative { color: #d9480f; }
.tx-amount.positive { color: #2b8a3e; }
.tx-amount.move { color: var(--muted); }

.mono-num {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.usd-equiv {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  margin-left: 8px;
  opacity: 0.6;
}

/* FORMS & INPUTS */
.form-select, textarea, input[type="text"], input[type="month"], input[type="number"], input[type="date"] {
  width: 100%; min-height: 48px; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: 12px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--text);
  outline: none; transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none; appearance: none;
}
.form-select:focus, textarea:focus, input:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(111, 135, 152, .15);
}
label { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; margin-bottom: 6px; display: block; }

/* BOTTOM NAV */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 600px;
  display: flex; justify-content: space-around;
  background: rgba(255, 253, 249, 0.94);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line-soft);
  padding: 12px 0 24px 0; z-index: 90;
}
.nav-item { background: none; border: none; display: flex; flex-direction: column; align-items: center; color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 650; }
.nav-item.active { color: var(--text); }
.nav-icon { margin-bottom: 4px; }

/* FAB */
.fab {
  position: fixed; bottom: 100px; right: 24px;
  width: 60px; height: 60px; border-radius: 30px;
  background: var(--text); color: white; border: none;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px rgba(38, 35, 31, 0.3); cursor: pointer; z-index: 95;
  transition: transform 0.2s;
}
.fab:active { transform: scale(0.9); }
@media (min-width: 600px) {
  .fab { right: calc(50% - 300px + 24px); }
}

/* SMART ADD MODAL */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(38,35,31,0.5); z-index: 100;
  display: none; opacity: 0; transition: opacity 0.3s;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.smart-add-panel {
  position: fixed; bottom: -100%; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 600px;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  z-index: 101;
  transition: bottom 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.05);
  box-shadow: 0 -18px 50px rgba(38,35,31,0.18);
  padding-bottom: 40px;
}
.smart-add-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px; border-bottom: 1px solid var(--line-soft); }
.smart-add-header h3 { font-size: 16px; font-weight: 780; color: var(--text); }
.smart-add-body { padding: 24px; }

.amount-input-group { display: flex; align-items: baseline; justify-content: center; margin-bottom: 24px; border-bottom: 1px solid var(--line-soft); padding-bottom: 12px; }
.currency-select { font-size: 18px; font-weight: 750; color: var(--muted); background: transparent; border: none; outline: none; margin-right: 8px; cursor: pointer; }
.amount-input { font-size: 40px; font-weight: 780; border: none; outline: none; text-align: center; width: 100%; color: var(--text); background: transparent;}
.amount-input::placeholder { color: var(--line); }

.quick-categories { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; justify-content: center; }
.cat-pill {
  background: #fff; border: 1px solid var(--line);
  padding: 8px 14px; border-radius: var(--radius-pill); font-size: 13px; font-weight: 650;
  display: flex; align-items: center; cursor: pointer; color: var(--muted);
  box-shadow: 0 2px 6px rgba(0,0,0,0.02); transition: all 0.2s;
}
.cat-pill.active { background: var(--text); border-color: var(--text); color: #fff; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.form-row { display: flex; flex-direction: column; }
.form-row:nth-child(3) { grid-column: span 2; }
/* VERSIONING & FOOTER */
.version-tag {
  margin-top: 24px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

.app-footer {
  text-align: center;
  padding: 24px 16px 100px 16px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.version-text { font-weight: 700; color: var(--text-muted); }
/* AUTH CARD */
#auth-screen { display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { background: var(--surface); padding: 40px 30px; border-radius: var(--radius-card); box-shadow: var(--shadow); width: 100%; text-align: center; border: 1px solid var(--line-soft); }
.brand-icon { width: 64px; height: 64px; background: linear-gradient(145deg, #2f342f, #6f8798); color: white; border-radius: 18px; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 800; margin: 0 auto 20px auto; box-shadow: var(--shadow-btn); letter-spacing: -0.05em;}
.auth-card h1 { font-size: 28px; font-weight: 780; letter-spacing: -0.02em; line-height: 1.1; margin-bottom: 8px; color: var(--text); }
.auth-card .subtitle { font-size: 14px; color: var(--muted); margin-bottom: 32px; }
.primary-btn { background: var(--text); color: white; border: none; border-radius: 14px; padding: 16px; font-size: 16px; font-weight: 750; width: 100%; cursor: pointer; box-shadow: var(--shadow-btn); transition: transform 0.2s; }
.primary-btn:active { transform: scale(0.98); }
