/* ===== Thème Sycothic ===== */
@font-face {
  font-family: "A Charming Font Expanded";
  src: url("../assets/fonts/ACharmingFontExpanded.woff2") format("woff2"),
       url("../assets/fonts/ACharmingFontExpanded.ttf") format("truetype"),
       url("../assets/fonts/ACharmingFontExpanded.otf") format("opentype");
  font-display: swap;
}
:root {
  --night: #120D18; --surface: #1A1322; --raised: #241A30; --sunk: #0E0A13; --line: #382A4C; --line-soft: #2A2038;
  --ink: #F0E9F7; --muted: #A898BA; --faint: #74668A;
  --violet: #A237FF; --violet-ink: #FFFFFF; --deep: #5E2492; --glow: rgba(162, 55, 255, .28); --silver: #CFC9D8;
  --ok: #63D3A4; --ok-bg: rgba(99, 211, 164, .12); --warn: #F2B45E; --warn-bg: rgba(242, 180, 94, .13); --danger: #FF7398; --danger-bg: rgba(255, 115, 152, .12);
  --f-deco: "Cinzel Decorative", "Cinzel", Georgia, serif;
  --f-title: "Cinzel", Georgia, serif;
  --f-charm: "A Charming Font Expanded", "Cinzel Decorative", Georgia, serif;
  --f-body: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r-s: 6px; --r-m: 12px;
  color-scheme: dark;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); background: var(--night); }
body { margin: 0; background: var(--night); color: var(--ink); font: 15px/1.55 var(--f-body); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); background: var(--night); z-index: 30; }
a { color: var(--violet); }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }

h1, h2, h3 { margin: 0; font-weight: 400; }
h1 { font-family: var(--f-deco); font-size: clamp(26px, 5vw, 38px); line-height: 1.1; color: var(--silver); letter-spacing: .01em; }
h2 { font-family: var(--f-title); font-size: 20px; font-weight: 600; line-height: 1.25; color: var(--ink); }
h3 { font-family: var(--f-title); font-size: 16px; font-weight: 600; color: var(--ink); }
.hint { color: var(--muted); font-size: 13.5px; margin: 4px 0 14px; max-width: 75ch; }
.small { font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }

/* Formulaires */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  background: var(--sunk); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-s); padding: 6px 9px; min-width: 0;
}
input::placeholder { color: var(--faint); }
input[type=number] { text-align: right; }
input[type=checkbox] { accent-color: var(--violet); width: 17px; height: 17px; }
select { padding-right: 26px; }
button { cursor: pointer; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--raised); color: var(--ink); padding: 7px 13px; }
button:hover { border-color: var(--deep); }
button.primary { background: var(--violet); color: var(--violet-ink); border-color: var(--violet); font-weight: 600; padding: 9px 17px; }
button.primary:hover { background: #B158FF; }
button.ghost { background: none; border-color: transparent; color: var(--violet); padding: 3px 6px; text-decoration: underline; text-underline-offset: 3px; }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }

/* Barre d'application */
.appbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 18px; background: rgba(18, 13, 24, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line-soft); }
.appbar .home { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--sunk); padding: 0; flex: none; }
.appbar .home img { width: 30px; height: 30px; }
.appbar h1 { font-size: clamp(20px, 4vw, 26px); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page { max-width: 1240px; margin: 0 auto; padding: 22px 18px 130px; }

/* Blocs */
.block { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-m); padding: 20px; margin-bottom: 18px; }
.block > header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.spread { justify-content: space-between; }

/* Tableaux */
.tbl { overflow-x: auto; margin: 0 -6px; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { font-weight: 500; color: var(--muted); text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 13px; }
td { padding: 6px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.n, th.n { text-align: right; white-space: nowrap; }
tr.off td { opacity: .42; }
tr.off td:first-child { opacity: 1; }
td input[type=text] { width: 100%; min-width: 120px; }
td input[type=number] { width: 96px; }

.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--raised); color: var(--muted); white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.violet { background: rgba(162, 55, 255, .16); color: #C98BFF; }
.note { background: var(--warn-bg); color: var(--warn); border-radius: var(--r-s); padding: 10px 13px; font-size: 14px; margin: 12px 0 0; }
.note.info { background: rgba(162, 55, 255, .1); color: #D4B0FF; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 0; }
.missing { border-color: var(--warn) !important; background: var(--warn-bg) !important; }

/* Notification éphémère */
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--night); padding: 10px 16px; border-radius: var(--r-s); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; z-index: 50; }
.toast.on { opacity: 1; }
.banner { background: var(--deep); color: #fff; font-size: 13px; text-align: center; padding: 6px 12px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ===== Comptabilité ===== */
.monthnav { display: flex; align-items: center; gap: 4px; }
.monthnav button { padding: 5px 11px; font-size: 18px; line-height: 1; }
.monthnav select { font-family: var(--f-title); font-weight: 600; }
.drop { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 760px) { .drop { grid-template-columns: 1fr; } }
.slot { text-align: left; border: 1.5px dashed var(--line); border-radius: var(--r-m); padding: 14px 16px; background: var(--sunk); }
.slot b { display: block; font-weight: 600; font-family: var(--f-title); }
.slot span { color: var(--muted); font-size: 13px; }
.slot.done { border-style: solid; border-color: rgba(99, 211, 164, .45); }
.slot.done span { color: var(--ok); }
#imp.over .slot { border-color: var(--violet); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.chip { display: inline-flex; gap: 8px; align-items: baseline; background: var(--raised); border: 1px solid var(--line-soft); border-radius: 99px; padding: 4px 12px; font-size: 13px; color: var(--muted); }
.chip b { color: var(--ink); font-weight: 600; }
.chip.warn { border-color: rgba(242, 180, 94, .5); color: var(--warn); }
details summary { cursor: pointer; list-style-position: outside; }
.grid-set { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-top: 16px; }
.grid-set label { display: block; font-size: 13.5px; color: var(--muted); }
.grid-set label > input, .grid-set label > select { display: block; margin-top: 5px; width: 100%; }
.grid-set label > .small { display: block; margin-top: 4px; }
.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: rgba(26, 19, 34, .96); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px)); }
.bar .in { max-width: 1240px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; justify-content: space-between; }
.bar .figs { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13.5px; color: var(--muted); }
.bar .figs strong { color: var(--ink); font-size: 16px; margin-left: 4px; }
.bar .acts { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 560px) { .appbar { flex-wrap: wrap; } .monthnav { width: 100%; } .monthnav select { flex: 1; } }
@media (max-width: 560px) {
  .bar { padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)); }
  .bar .in { gap: 6px; }
  .bar .figs { gap: 12px; font-size: 12px; width: 100%; justify-content: space-between; }
  .bar .figs strong { font-size: 14px; display: block; margin: 0; }
  .bar .acts { width: 100%; flex-wrap: nowrap; }
  .bar .acts button { flex: 1; padding: 8px 6px; font-size: 13.5px; }
  .toast { bottom: calc(130px + env(safe-area-inset-bottom, 0px)); }
}

/* ===== Suivi ===== */
.yearsel { font-family: var(--f-title); font-weight: 600; }
.tabs { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 61px); z-index: 19; display: flex; gap: 4px; overflow-x: auto; padding: 8px 18px; background: rgba(18, 13, 24, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line-soft); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; border: none; background: none; color: var(--muted); padding: 7px 12px; border-radius: 99px; font-family: var(--f-title); font-weight: 600; font-size: 14px; white-space: nowrap; }
.tabs button[aria-selected="true"] { background: rgba(162, 55, 255, .18); color: var(--ink); }
.neg { color: var(--danger) !important; }
tr.tot td { border-top: 1px solid var(--line); font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }
.grid2 > .block { margin-bottom: 18px; min-width: 0; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; gap: 0; } }
.chartbox { position: relative; height: 260px; }
.chartbox.tall { height: 320px; }
.hero-year { display: grid; grid-template-columns: 1.1fr 1.4fr; gap: 26px; align-items: center; padding: 24px; margin-bottom: 18px; border-radius: var(--r-m); border: 1px solid var(--deep); background: radial-gradient(120% 140% at 0% 0%, rgba(162, 55, 255, .22), transparent 60%), var(--surface); }
@media (max-width: 760px) { .hero-year { grid-template-columns: 1fr; } }
.hero-year .label { font-family: var(--f-title); color: var(--muted); margin: 0; font-size: 15px; }
.hero-year .big, .balance .big { font-family: var(--f-deco); font-size: clamp(34px, 6vw, 52px); line-height: 1.1; margin: 4px 0 12px; color: var(--ink); }
.gauge { height: 10px; border-radius: 99px; background: var(--sunk); border: 1px solid var(--line); overflow: hidden; }
.gauge span { display: block; height: 100%; background: linear-gradient(90deg, var(--deep), var(--violet)); border-radius: 99px; }
.gauge.thin { height: 6px; margin-top: 8px; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 22px; margin: 0; }
.kpis > div { border-left: 2px solid var(--deep); padding-left: 12px; }
.kpis dt { font-size: 13px; color: var(--muted); }
.kpis dd { margin: 2px 0 0; font-family: var(--f-title); font-weight: 700; font-size: 22px; color: var(--ink); }
.kpis dd.txt { font-size: 18px; }
.kpis.four, .kpis.social { grid-template-columns: repeat(4, 1fr); margin-bottom: 18px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-m); padding: 18px; }
@media (max-width: 760px) { .kpis.four, .kpis.social { grid-template-columns: repeat(2, 1fr); } }
.kpis .small { margin: 3px 0 0; }
ol.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
ol.bars li { display: grid; grid-template-columns: minmax(110px, 200px) 1fr auto; gap: 12px; align-items: center; font-size: 14px; }
ol.bars .bar { height: 8px; background: var(--sunk); border-radius: 99px; overflow: hidden; }
ol.bars .bar span { display: block; height: 100%; background: var(--violet); border-radius: 99px; }
ol.bars .v { font-variant-numeric: tabular-nums; }
table.form th { color: var(--ink); font-weight: 500; font-size: 14px; white-space: normal; border-bottom: 1px solid var(--line-soft); }
table.form th input { width: 100%; }
table.form td input[type=number] { width: 130px; }
.balance .big { margin: 6px 0; }
dialog.sheet { width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); overflow-y: auto; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-m); padding: 22px; }
dialog.sheet::backdrop { background: rgba(8, 5, 12, .72); }
dialog.sheet form { display: grid; gap: 12px; }
dialog.sheet h3 { margin-top: 6px; font-size: 15px; }
dialog.sheet label { display: grid; gap: 5px; font-size: 13.5px; color: var(--muted); }
dialog.sheet .grid-set { margin-top: 0; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
dialog.sheet .grid-set.six { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
dialog.sheet input, dialog.sheet select, dialog.sheet textarea { width: 100%; padding: 8px 10px; font-size: 16px; }
dialog.sheet .actions { margin-top: 6px; }
.kpis.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 560px) { .kpis.three { grid-template-columns: repeat(2, 1fr); } }
.kpis.tight { margin: 4px 0 16px; }
.kpis.tight dd { font-size: 19px; }
.fab { position: fixed; right: max(18px, env(safe-area-inset-right, 0px)); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 26; background: var(--violet); color: #fff; border: none; border-radius: 99px; padding: 13px 20px; font-weight: 700; font-size: 15px; box-shadow: 0 8px 28px rgba(162, 55, 255, .45); }
.fab span { font-size: 20px; line-height: 0; margin-right: 4px; vertical-align: -2px; }
.fab:hover { background: #B158FF; }
.journal h3 { margin: 18px 0 6px; font-size: 15px; text-transform: none; }
.journal h3:first-child { margin-top: 0; }
.journal h3::first-letter { text-transform: uppercase; }
.journal ul { list-style: none; margin: 0; padding: 0; }
.journal li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.journal li .amt { font-weight: 700; min-width: 88px; }
.journal li .cm { flex: 1; min-width: 160px; color: var(--ink); }
.journal li.snap .cm { color: var(--muted); }
label.check { display: flex !important; grid-template-columns: none; align-items: center; gap: 10px; color: var(--ink) !important; font-size: 14px !important; }
label.check input { width: 18px !important; height: 18px; flex: none; }
