/* ============================================================
   HD Budget — Style global (Auth + App)
   ============================================================ */
:root {
  --green:        #1D9E75;
  --green-dark:   #0F6E56;
  --green-light:  #EAF3DE;
  --green-text:   #3B6D11;
  --red:          #E24B4A;
  --red-light:    #FCEBEB;
  --red-text:     #A32D2D;
  --amber:        #EF9F27;
  --amber-light:  #FAEEDA;
  --amber-text:   #854F0B;
  --blue:         #3266ad;
  --blue-light:   #E6F1FB;
  --blue-text:    #185FA5;

  --bg:           #f6f5f1;
  --surface:      #ffffff;
  --surface-2:    #f0efe9;
  --border:       rgba(0,0,0,0.08);
  --border-med:   rgba(0,0,0,0.14);
  --text:         #1a1a18;
  --text-2:       #5c5c58;
  --text-3:       #9a9a96;

  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    14px;
  --font:         'DM Sans', system-ui, sans-serif;
  --font-mono:    'DM Mono', monospace;
}

[data-theme="dark"] {
  --bg:       #141413;
  --surface:  #1e1e1c;
  --surface-2:#272725;
  --border:   rgba(255,255,255,0.08);
  --border-med:rgba(255,255,255,0.14);
  --text:     #f0f0ec;
  --text-2:   #a0a09c;
  --text-3:   #666662;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }

/* ---- Splash / écran de démarrage ---- */
#loading-screen {
  position: fixed; inset: 0; z-index: 9999;
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: linear-gradient(158deg, #0E7A56 0%, #1D9E75 60%, #24B587 100%);
  transition: opacity .5s ease;
}
#loading-screen::after { /* halo décoratif discret */
  content: ""; position: absolute; top: -20%; right: -10%;
  width: 70vmax; height: 70vmax; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.14), rgba(255,255,255,0) 60%);
  pointer-events: none;
}
#loading-screen.splash-out { opacity: 0; pointer-events: none; }
.load-box { text-align: center; position: relative; z-index: 1; animation: splashIn .7s cubic-bezier(.2,.75,.25,1) both; }
.load-mark {
  width: 52px; height: 52px; background: rgba(255,255,255,.18);
  border-radius: 14px; display: inline-flex;
  align-items: center; justify-content: center;
  color: #fff; font-size: 18px; font-weight: 600;
  margin-bottom: 12px;
}
.load-logo {
  width: 96px; height: 96px; object-fit: contain;
  background: rgba(255,255,255,.16); border-radius: 24px; padding: 15px;
  box-shadow: 0 16px 44px rgba(0,0,0,.28);
  animation: splashPop .8s cubic-bezier(.18,.9,.25,1.15) both;
}
.load-title { font-size: 25px; font-weight: 700; margin-bottom: 4px; color: #fff; letter-spacing: -.3px; }
.load-sub   { font-size: 13.5px; color: rgba(255,255,255,.85); margin-bottom: 22px; }
.load-bar   { width: 170px; height: 4px; background: rgba(255,255,255,.25); border-radius: 3px; margin: 0 auto; overflow: hidden; }
.load-fill  { height: 100%; background: #fff; border-radius: 3px; animation: loadAnim 1.4s ease-in-out forwards; }
@keyframes loadAnim  { from { width: 0 } to { width: 100% } }
@keyframes splashIn  { from { opacity: 0; transform: translateY(14px) } to { opacity: 1; transform: none } }
@keyframes splashPop { 0% { opacity: 0; transform: scale(.7) } 60% { opacity: 1 } 100% { opacity: 1; transform: scale(1) } }
@media (prefers-reduced-motion: reduce) {
  .load-box, .load-logo { animation: none; }
  .load-fill { animation: loadAnim .6s linear forwards; }
}

/* ---- Auth screen ---- */
#auth-screen {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  padding: 1rem;
}
.auth-wrap {
  background: var(--surface);
  border: 0.5px solid var(--border-med);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem;
  width: 100%; max-width: 400px;
}
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 1.75rem; }
.logo-mark {
  width: 42px; height: 42px; background: var(--green);
  border-radius: 11px; display: flex; align-items: center;
  justify-content: center; color: #fff; font-size: 15px; font-weight: 600;
}
.logo-img {
  width: 42px; height: 42px; object-fit: contain; border-radius: 12px;
}
.load-logo {
  width: 48px; height: 48px; object-fit: contain; margin-bottom: 12px;
}
.app-footer {
  text-align: center; font-size: 12px; color: var(--text-3); margin: 20px 0 40px; letter-spacing: .02em;
}
.app-footer strong { color: var(--text); }
.auth-title { font-size: 20px; font-weight: 600; }
.auth-sub   { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.auth-tabs {
  display: flex; gap: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 3px; margin-bottom: 1.25rem;
}
.auth-tab {
  flex: 1; padding: 7px; border: none; cursor: pointer;
  font-size: 13px; font-weight: 500; font-family: var(--font);
  color: var(--text-2); background: none;
  border-radius: calc(var(--radius-sm) - 2px);
  transition: background .15s, color .15s;
}
.auth-tab.on { background: var(--surface); color: var(--text); }

.auth-error {
  background: var(--red-light); color: var(--red-text);
  border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: 13px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.auth-success {
  background: var(--green-light); color: var(--green-text);
  border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: 13px; margin-bottom: 12px;
}

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 500; color: var(--text-2); }

input[type="text"], input[type="email"],
input[type="password"], input[type="number"],
input[type="date"], input[type="month"], select, textarea {
  height: 38px; padding: 0 12px;
  border: 0.5px solid var(--border-med);
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 13px;
  background: var(--surface); color: var(--text);
  width: 100%; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(29,158,117,.1); }

.pass-toggle {
  position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--text-3); font-size: 16px; padding: 4px;
}
.pass-toggle:hover { color: var(--text); }

.pass-strength { font-size: 11px; margin-top: 3px; }

.btn-auth {
  width: 100%; padding: 11px; margin-bottom: 8px;
  background: var(--green); color: #fff; border: none;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  font-family: var(--font); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  transition: background .15s;
}
.btn-auth:hover { background: var(--green-dark); }
.btn-auth:disabled { background: var(--text-3); cursor: not-allowed; }

.btn-auth-google {
  width: 100%; padding: 10px; margin-bottom: 8px;
  background: var(--surface); color: var(--text);
  border: 0.5px solid var(--border-med);
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  font-family: var(--font); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s;
}
.btn-auth-google:hover { background: var(--surface-2); }

/* ---- Tour de bienvenue (onboarding) ---- */
#tour-track::-webkit-scrollbar { display: none; }
#tour-modal.tour-bg {
  background: radial-gradient(135% 80% at 50% -8%, rgba(29,158,117,.16), transparent 55%), var(--bg);
}
.tour-slide {
  min-width: 100%; scroll-snap-align: center; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px 28px; box-sizing: border-box;
}
.tour-badge {
  width: 112px; height: 112px; border-radius: 32px; margin-bottom: 24px;
  background: linear-gradient(150deg, #28B485, #0E7A56);
  display: grid; place-items: center; font-size: 56px; line-height: 1;
  box-shadow: 0 20px 46px rgba(14,122,86,.38);
  animation: tourPop .6s cubic-bezier(.2,.8,.25,1.25) both;
}
.tour-title { font-size: 23px; font-weight: 800; letter-spacing: -.4px; margin-bottom: 12px; max-width: 340px; }
.tour-text  { font-size: 15px; color: var(--text-2); line-height: 1.65; max-width: 330px; }
.tour-text strong { color: var(--green); font-weight: 700; }
.tdot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); cursor: pointer; transition: width .25s, border-radius .25s, background .25s; }
.tdot.on { width: 24px; border-radius: 5px; background: var(--green); }
@keyframes tourPop { from { transform: scale(.6); opacity: 0 } 70% { opacity: 1 } to { transform: scale(1); opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .tour-badge { animation: none } }

.auth-forgot { text-align: center; margin-top: 8px; }
.auth-forgot button {
  background: none; border: none; cursor: pointer;
  font-size: 12px; color: var(--text-3); font-family: var(--font);
}
.auth-forgot button:hover { color: var(--green); }

.auth-footer { text-align: center; font-size: 11px; color: var(--text-3); margin-top: 1.5rem; }

/* ---- App layout ---- */
#app-root { max-width: 780px; margin: 0 auto; padding: 0 16px 80px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0 14px; gap: 12px;
}
.topbar-logo { display: flex; align-items: center; gap: 10px; }
.logo-name { font-size: 18px; font-weight: 600; line-height: 1.2; }
.logo-sub  { font-size: 11px; color: var(--text-3); }

.topbar-right { display: flex; align-items: center; gap: 8px; }
.avatar-chip {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; cursor: pointer;
  position: relative;
}
.user-menu {
  position: absolute; top: 44px; right: 0; z-index: 50;
  background: var(--surface); border: 0.5px solid var(--border-med);
  border-radius: var(--radius); padding: 6px;
  min-width: 200px; box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
.user-menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  font-size: 13px; cursor: pointer; color: var(--text);
}
.user-menu-item:hover { background: var(--surface-2); }
.user-menu-item.danger { color: var(--red-text); }
.user-menu-item.danger:hover { background: var(--red-light); }

.score-chip {
  padding: 5px 14px; background: var(--surface);
  border: 0.5px solid var(--border-med);
  border-radius: var(--radius); text-align: center;
}
.score-chip .n { font-size: 18px; font-weight: 600; }
.score-chip .l { font-size: 10px; color: var(--text-3); }

.icon-btn {
  width: 34px; height: 34px; border: 0.5px solid var(--border-med);
  border-radius: var(--radius-sm); background: var(--surface);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text-2); font-size: 17px; transition: background .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---- Tabs ---- */
.tab-nav {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px; overflow-x: auto;
  scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tb {
  background: none; border: none; padding: 9px 14px;
  cursor: pointer; font-size: 13px; font-family: var(--font);
  color: var(--text-2); border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap;
  display: flex; align-items: center; gap: 5px;
  transition: color .15s;
}
.tb.on { color: var(--text); border-bottom-color: var(--green); font-weight: 500; }
.tb:hover:not(.on) { color: var(--text); }
.panel { display: none; }
.panel.on { display: block; }

/* ---- Cards & metrics ---- */
.mg { display: grid; grid-template-columns: repeat(auto-fit,minmax(130px,1fr)); gap: 10px; margin-bottom: 18px; }
.mc { background: var(--surface-2); border-radius: var(--radius); padding: 12px 14px; }
.mc .lb { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.mc .vl { font-size: 20px; font-weight: 600; }
.mc .sb { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.card {
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px; margin-bottom: 10px;
}
.sl {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px;
}

/* ---- Buttons ---- */
.btn {
  background: var(--green); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 9px 18px;
  cursor: pointer; font-size: 13px; font-weight: 500; font-family: var(--font);
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s;
}
.btn:hover { background: var(--green-dark); }
.btn-ghost {
  background: none; border: 0.5px solid var(--border-med);
  color: var(--text-2); border-radius: var(--radius-sm);
  padding: 7px 14px; cursor: pointer; font-size: 12px;
  font-family: var(--font); display: inline-flex; align-items: center; gap: 5px;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm {
  padding: 5px 10px; font-size: 12px; cursor: pointer;
  border-radius: var(--radius-sm); border: 0.5px solid var(--border-med);
  background: none; color: var(--text-2); font-family: var(--font);
  display: inline-flex; align-items: center; gap: 4px;
}
.btn-sm:hover { background: var(--surface-2); color: var(--text); }
.btn-danger {
  border: 0.5px solid rgba(226,75,74,.3); color: var(--red-text);
  border-radius: var(--radius-sm); padding: 5px 10px; cursor: pointer;
  font-size: 12px; background: none; font-family: var(--font);
}
.btn-danger:hover { background: var(--red-light); }

/* ---- Row / field ---- */
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.field-inline { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 100px; }
.field-inline label { font-size: 12px; font-weight: 500; color: var(--text-2); }

/* ---- Progress ---- */
.prog-row { padding: 11px 14px; background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); margin-bottom: 6px; }
.prog-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; font-size: 13px; flex-wrap: wrap; gap: 6px; }
.prog-bar-bg { height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.prog-bar { height: 100%; border-radius: 3px; transition: width .5s ease; }

/* ---- Tags ---- */
.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 500; }
.tag-ok   { background: var(--green-light); color: var(--green-text); }
.tag-warn { background: var(--amber-light); color: var(--amber-text); }
.tag-over { background: var(--red-light);   color: var(--red-text);   }
.tag-info { background: var(--blue-light);  color: var(--blue-text);  }

/* ---- Dep / list items ---- */
.dep-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); margin-bottom: 6px; }
.dep-dot  { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dep-info { flex: 1; min-width: 0; }
.dep-name { font-size: 13px; font-weight: 500; }
.dep-meta { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.dep-amt  { font-size: 13px; font-weight: 600; color: var(--red); font-family: var(--font-mono); white-space: nowrap; }

/* ---- Épargne history ---- */
.ep-row { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 0.5px solid var(--border); font-size: 13px; }
.ep-row:last-child { border-bottom: none; }
.ep-month { min-width: 76px; color: var(--text-2); font-size: 12px; }
.ep-bar-bg { flex: 1; height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.ep-bar   { height: 100%; border-radius: 3px; background: var(--green); }
.ep-amt   { min-width: 90px; text-align: right; font-weight: 500; font-family: var(--font-mono); font-size: 12px; }

/* ---- Bank cards ---- */
.bank-card { border-radius: 12px; padding: 16px 18px; margin-bottom: 10px; color: #fff; min-height: 90px; }
.bank-card .card-num { font-family: monospace; font-size: 13px; letter-spacing: .12em; margin: 8px 0 4px; opacity: .85; }
.card-badge { font-size: 11px; background: rgba(255,255,255,.2); padding: 3px 8px; border-radius: 20px; }

/* ---- Tx rows ---- */
.tx-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 0.5px solid var(--border); font-size: 13px; }
.tx-row:last-child { border-bottom: none; }
.tx-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 15px; }
.tx-info { flex: 1; }
.tx-desc { font-weight: 500; font-size: 13px; }
.tx-meta { font-size: 11px; color: var(--text-3); }

/* ---- Toast ---- */
.toast { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.toast-ok  { background: var(--green-light); color: var(--green-text); }
.toast-err { background: var(--red-light); color: var(--red-text); }

/* ---- Alert ---- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 8px; line-height: 1.5; }
.alert-ok   { background: var(--green-light); color: #173404; }
.alert-warn { background: var(--amber-light); color: #412402; }
.alert-danger { background: var(--red-light); color: #501313; }

/* ---- Filter ---- */
.filter-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-btn { font-size: 12px; padding: 5px 12px; border-radius: 20px; border: 0.5px solid var(--border-med); background: none; cursor: pointer; color: var(--text-2); font-family: var(--font); transition: all .15s; }
.filter-btn.on { background: var(--green); color: #fff; border-color: var(--green); }

/* ---- Color picker ---- */
.color-opt { width: 26px; height: 26px; border-radius: 6px; cursor: pointer; border: 2px solid transparent; transition: transform .1s; display: inline-block; }
.color-opt:hover { transform: scale(1.1); }
.color-opt.sel { border-color: var(--text); }

/* ---- Sync indicator ---- */
.sync-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.sync-ok   { background: var(--green); }
.sync-wait { background: var(--amber); }
.sync-err  { background: var(--red); }

/* ---- Responsive ---- */
@media(max-width:480px) {
  .mg { grid-template-columns: 1fr 1fr; }
  .row { flex-direction: column; }
  .auth-wrap { padding: 1.5rem 1.25rem; }
}
