/* ---------- Polices (Playfair Display, local, hors-ligne) ---------- */
@font-face {
  font-family: "Playfair Display";
  font-weight: 600;
  font-display: swap;
  src: url("fonts/playfair-600.woff2") format("woff2");
}
@font-face {
  font-family: "Playfair Display";
  font-weight: 700;
  font-display: swap;
  src: url("fonts/playfair-700.woff2") format("woff2");
}

/* ---------- Charte INOVA ---------- */
:root {
  --bg:          #FAF5EE;   /* ivoire chaud */
  --surface:     #FFFFFF;
  --surface-2:   #F5EEE3;
  --ink:         #2A2422;   /* noir chaud */
  --ink-soft:    #838383;   /* gris du sous-titre logo */
  --line:        #ECE3D6;   /* filet chaud */
  --coral:       #EE5958;   /* coral de marque */
  --coral-2:     #F49E92;   /* coral clair (ponctuel) */
  --coral-soft:  #FBE7E4;   /* fond coral très clair */
  --alert:       #C0342C;   /* dépassement */
  --radius:      16px;
  --pad:         20px;
  --shadow:      0 1px 2px rgba(42,36,34,.04), 0 10px 30px -16px rgba(42,36,34,.20);
  --serif:       "Playfair Display", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Cadre signature à coins marqués ---------- */
.frame {
  position: fixed;
  inset: calc(env(safe-area-inset-top) + 7px) 7px
         calc(env(safe-area-inset-bottom) + 7px) 7px;
  border: 1px solid rgba(238, 89, 88, .28);
  border-radius: 10px;
  pointer-events: none;
  z-index: 40;
}
.frame i {
  position: absolute;
  width: 14px; height: 14px;
  border: 2px solid var(--coral);
}
.frame i.tl { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.frame i.tr { top: -1px; right: -1px; border-left: 0; border-bottom: 0; border-radius: 0 10px 0 0; }
.frame i.bl { bottom: -1px; left: -1px; border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }
.frame i.br { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }

.app {
  max-width: 460px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) calc(var(--pad) + 6px)
           calc(env(safe-area-inset-bottom) + 44px);
}

/* ---------- Sélecteur de mois ---------- */
.monthbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0 4px;
}
.monthbar__label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink);
}
.monthbar__nav {
  width: 40px; height: 40px;
  border: none; background: transparent;
  color: var(--coral);
  font-size: 24px; line-height: 1;
  border-radius: 12px; cursor: pointer;
  transition: background .15s;
}
.monthbar__nav:active { background: var(--coral-soft); }

/* ---------- Héro ---------- */
.hero {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px var(--pad) 20px;
  margin: 14px 0 22px;
}
.hero__eyebrow {
  font-size: 10px;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
}
.hero__amount {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(42px, 13.5vw, 56px);
  letter-spacing: -.01em;
  line-height: 1.02;
  color: var(--coral);
  margin-top: 8px;
}
.hero__amount.is-negative { color: var(--alert); }

.gauge {
  display: flex;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin: 20px 0 12px;
}
.gauge__seg { height: 100%; transition: width .35s ease; }
.gauge__seg--fixed  { background: var(--coral); }
.gauge__seg--oneoff { background: var(--coral-2); }
.gauge.is-over { box-shadow: inset 0 0 0 2px var(--alert); }

.hero__legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--ink-soft);
}
.hero__of { white-space: nowrap; letter-spacing: .01em; }
.hero__income {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: none; background: transparent;
  color: var(--ink-soft);
  font: inherit; cursor: pointer;
  padding: 4px 2px;
}
.hero__income strong { color: var(--ink); font-weight: 600; margin-left: 2px; }
.hero__income .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--coral); }

/* ---------- Blocs ---------- */
.block {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px var(--pad) 10px;
  margin-bottom: 18px;
}
.block__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 0 6px;
}
.block__title {
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 700;
}
.block__total { font-size: 15px; font-weight: 600; }

.list { list-style: none; }
.row {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 13px 0;
  border-top: 1px solid var(--line);
  border-left: none; border-right: none; border-bottom: none;
  background: transparent;
  font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.row__tag {
  flex: none; width: 34px;
  font-size: 11px; font-weight: 700;
  letter-spacing: .04em;
  color: var(--coral);
}
.row__label { flex: 1; font-size: 15px; }
.row__amount { font-size: 15px; font-weight: 600; }

.list__empty {
  color: var(--ink-soft);
  font-size: 14px;
  padding: 14px 0 10px;
  border-top: 1px solid var(--line);
}

.add {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 13px 0 8px;
  border: none; border-top: 1px solid var(--line);
  background: transparent;
  color: var(--coral);
  font: inherit; font-weight: 600; cursor: pointer;
}
.add__plus {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  border-radius: 7px;
  background: var(--coral-soft);
  color: var(--coral);
  font-size: 17px; line-height: 1;
}

/* ---------- Pied ---------- */
.foot { text-align: center; padding-top: 6px; }
.foot__reset {
  border: none; background: transparent;
  color: var(--ink-soft);
  font: inherit; font-size: 12px;
  letter-spacing: .04em;
  padding: 8px 12px; cursor: pointer;
}
.foot__logo {
  display: block;
  width: min(260px, 70%);
  height: auto;
  margin: 26px auto 8px;
  opacity: .96;
}

/* ---------- Feuille modale ---------- */
.sheet {
  position: fixed; inset: 0;
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 50;
}
.sheet[hidden] { display: none; }
.sheet__scrim {
  position: absolute; inset: 0;
  background: rgba(42,36,34,.42);
  animation: fade .2s ease;
}
.sheet__panel {
  position: relative;
  width: 100%; max-width: 460px;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 22px var(--pad) calc(env(safe-area-inset-bottom) + 20px);
  box-shadow: 0 -12px 40px -12px rgba(42,36,34,.35);
  animation: rise .24s cubic-bezier(.2,.7,.2,1);
}
.sheet__title {
  font-family: var(--serif);
  font-size: 22px; font-weight: 700;
  margin-bottom: 18px;
}
.field { display: block; margin-bottom: 14px; }
.field[hidden] { display: none; }
.field__label {
  display: block;
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 7px; font-weight: 700;
}
.field__input {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  font: inherit; font-size: 16px;
  color: var(--ink);
}
.field__input:focus {
  outline: none;
  border-color: var(--coral);
  background: var(--surface);
}

.sheet__actions { display: flex; align-items: center; gap: 8px; margin-top: 20px; }
.sheet__spacer { flex: 1; }
.btn {
  border: none; border-radius: 12px;
  font: inherit; font-weight: 600; font-size: 15px;
  padding: 12px 18px; cursor: pointer;
}
.btn--primary { background: var(--coral); color: #fff; }
.btn--primary:active { background: #d84b4a; }
.btn--ghost { background: transparent; color: var(--ink-soft); padding: 12px 12px; }
#sheetDelete { color: var(--alert); }

@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, .sheet__panel, .sheet__scrim, .gauge__seg { animation: none !important; transition: none !important; }
}
