/* ============================================================
   BudgetFlow - feuille de style unique (mobile-first)
   ============================================================ */

/* ---------------------------------------------------- tokens */
:root {
  --bg:            #0b1020;
  --bg-soft:       #111834;
  --surface:       #151d3b;
  --surface-2:     #1b2447;
  --surface-3:     #232e57;
  --border:        #2a3563;
  --border-soft:   #212b52;

  --text:          #eef2ff;
  --text-muted:    #a3aed0;
  --text-dim:      #7683ab;

  --accent:        #6366f1;
  --accent-soft:   #818cf8;
  --accent-ghost:  rgba(99, 102, 241, .16);

  --ok:            #22c55e;
  --ok-ghost:      rgba(34, 197, 94, .15);
  --warn:          #f59e0b;
  --warn-ghost:    rgba(245, 158, 11, .15);
  --danger:        #f43f5e;
  --danger-ghost:  rgba(244, 63, 94, .15);
  --info:          #38bdf8;
  --info-ghost:    rgba(56, 189, 248, .15);

  --radius:        18px;
  --radius-sm:     12px;
  --radius-xs:     9px;
  --shadow:        0 10px 30px rgba(3, 7, 24, .45);
  --shadow-sm:     0 4px 14px rgba(3, 7, 24, .3);

  --nav-h:         66px;
  --max-w:         1180px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="light"] {
  --bg:            #f4f6fc;
  --bg-soft:       #eef1fa;
  --surface:       #ffffff;
  --surface-2:     #f7f8fd;
  --surface-3:     #eef1fa;
  --border:        #dfe4f3;
  --border-soft:   #e9ecf7;

  --text:          #131a33;
  --text-muted:    #5a6485;
  --text-dim:      #8a93b0;

  --accent-ghost:  rgba(99, 102, 241, .12);
  --shadow:        0 10px 30px rgba(28, 40, 90, .09);
  --shadow-sm:     0 3px 10px rgba(28, 40, 90, .07);
}

/* ---------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  /* Pas de zoom au pincement ni au double-tap : l app reste stable au doigt.
     Le defilement horizontal et vertical reste possible. */
  touch-action: pan-x pan-y;
}
/* L attribut hidden doit toujours l emporter sur nos regles de display. */
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.015em; line-height: 1.25; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
p  { margin: 0 0 .6rem; }
a  { color: var(--accent-soft); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
.ico { flex: none; vertical-align: -.18em; }
hr { border: 0; border-top: 1px solid var(--border-soft); margin: 1rem 0; }
::selection { background: var(--accent); color: #fff; }

/* ---------------------------------------------------- layout */
.shell { display: flex; min-height: 100vh; }
.sidebar { display: none; }

.main { flex: 1; min-width: 0; }
.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 14px 28px;
}

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px calc(12px + env(safe-area-inset-top, 0px));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar h1 { font-size: 1.15rem; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .sub { font-size: .74rem; color: var(--text-dim); font-weight: 500; letter-spacing: .02em; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 18px 0 12px; flex-wrap: wrap; }
.page-head p { color: var(--text-muted); font-size: .86rem; margin: 2px 0 0; }

/* ---------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { display: flex; align-items: center; gap: 8px; }
.card-title-ico { color: var(--accent-soft); }
.card.flush { padding: 0; overflow: hidden; }
.card.accent { border-color: var(--accent); background: linear-gradient(160deg, var(--accent-ghost), transparent 60%), var(--surface); }

.grid { display: grid; gap: 12px; }
.grid.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* ------------------------------------------------ hero budget */
.hero {
  position: relative;
  background:
    radial-gradient(120% 100% at 100% 0%, rgba(99,102,241,.35), transparent 60%),
    radial-gradient(90% 80% at 0% 100%, rgba(236,72,153,.22), transparent 55%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 20px 18px;
  overflow: hidden;
}
.hero.state-warn  { background: radial-gradient(120% 100% at 100% 0%, rgba(245,158,11,.32), transparent 60%), var(--surface); border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.hero.state-over  { background: radial-gradient(120% 100% at 100% 0%, rgba(244,63,94,.34), transparent 60%), var(--surface); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.hero .label { font-size: .78rem; text-transform: uppercase; letter-spacing: .09em; color: var(--text-muted); font-weight: 650; }
.hero .amount { font-size: clamp(2.4rem, 12vw, 3.4rem); font-weight: 750; letter-spacing: -.035em; line-height: 1.05; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.hero .amount.neg { color: var(--danger); }
.hero .hint { color: var(--text-muted); font-size: .9rem; }
.hero-foot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.mini {
  flex: 1 1 auto; min-width: 96px;
  background: color-mix(in srgb, var(--surface-2) 80%, transparent);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}
.mini .k { font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-dim); font-weight: 650; }
.mini .v { font-size: 1rem; font-weight: 680; font-variant-numeric: tabular-nums; margin-top: 1px; }

/* ---------------------------------------------------- stats */
.stat { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 13px; }
.stat .k { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-dim); font-weight: 680; display: flex; align-items: center; gap: 5px; }
.stat .v { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; margin-top: 3px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: .76rem; color: var(--text-muted); margin-top: 1px; }

.pos { color: var(--ok); }
.neg { color: var(--danger); }
.zero { color: var(--text-muted); }
.dim { color: var(--text-muted); }
.tiny { font-size: .76rem; }
.small { font-size: .84rem; }
.num { font-variant-numeric: tabular-nums; }
.strong { font-weight: 680; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 12px; }
.mt-sm { margin-top: 6px; }
.mb { margin-bottom: 12px; }

/* ------------------------------------------------- progress */
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .4s ease; }
.progress.thin { height: 5px; }
.progress.tall { height: 11px; }
.progress > span.ok { background: linear-gradient(90deg, #16a34a, #4ade80); }
.progress > span.warn { background: linear-gradient(90deg, #d97706, #fbbf24); }
.progress > span.over { background: linear-gradient(90deg, #e11d48, #fb7185); }

.progress-marker { position: relative; }
.progress-marker::after {
  content: ""; position: absolute; top: -3px; bottom: -3px; width: 2px;
  background: var(--text-dim); border-radius: 2px; left: var(--marker, 50%);
}

/* ------------------------------------------------- enveloppes */
.env-list { display: flex; flex-direction: column; gap: 11px; }
.env {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center;
  padding: 11px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border-soft);
}
.env.over { border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); }
.env.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.env-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; }
.env-body { min-width: 0; }
.env-name { font-weight: 640; font-size: .92rem; display: flex; align-items: center; gap: 6px; }
.env-sub { font-size: .76rem; color: var(--text-muted); margin-bottom: 5px; font-variant-numeric: tabular-nums; }
.env-right { text-align: right; }
.env-left-amount { font-weight: 700; font-size: .98rem; font-variant-numeric: tabular-nums; }
.env-left-label { font-size: .68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }

/* ---------------------------------------------------- listes */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 14px; border-bottom: 1px solid var(--border-soft);
  color: inherit; text-decoration: none;
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-2); text-decoration: none; }
.list-ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; color: #fff; font-weight: 700; }
.list-body { flex: 1; min-width: 0; }
.list-title { font-weight: 600; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { font-size: .76rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-amount { font-weight: 680; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .95rem; }
.list-head { padding: 8px 14px; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-dim); font-weight: 700; background: var(--surface-2); border-bottom: 1px solid var(--border-soft); }

/* --------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 99px; font-size: .7rem; font-weight: 680;
  background: var(--surface-3); color: var(--text-muted); white-space: nowrap;
}
.badge.ok { background: var(--ok-ghost); color: var(--ok); }
.badge.warn { background: var(--warn-ghost); color: var(--warn); }
.badge.danger { background: var(--danger-ghost); color: var(--danger); }
.badge.info { background: var(--info-ghost); color: var(--info); }
.badge.accent { background: var(--accent-ghost); color: var(--accent-soft); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }

/* --------------------------------------------------- boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 15px; border-radius: var(--radius-xs); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: .88rem; font-weight: 620;
  cursor: pointer; text-decoration: none; transition: filter .15s, transform .06s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.12); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #04240f; }
.btn.danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 11px; font-size: .8rem; border-radius: 8px; }
.btn.xs { padding: 4px 8px; font-size: .74rem; border-radius: 7px; }
.btn.block { width: 100%; }
.btn.icon { padding: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-group { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-xs); overflow: hidden; }
.btn-group .btn { border: 0; border-radius: 0; background: transparent; }
.btn-group .btn.active { background: var(--accent); color: #fff; }

/* ------------------------------------------------- formulaires */
.field { margin-bottom: 13px; }
.field > label, .label {
  display: block; font-size: .78rem; font-weight: 650; color: var(--text-muted);
  margin-bottom: 5px; letter-spacing: .01em;
}
/* Sans min-width:0, un champ date refuse de retrecir sous sa taille
   intrinseque et fait deborder la grille sur petit ecran. */
.field-row > *, .grid > * { min-width: 0; }

.input, .select, textarea.input {
  width: 100%; min-width: 0; padding: 11px 12px; font: inherit; font-size: 16px; /* 16px = pas de zoom iOS */
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, textarea.input:focus {
  outline: 0; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ghost);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a3aed0' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 34px;
}
textarea.input { min-height: 76px; resize: vertical; line-height: 1.5; }
.input.big { font-size: 2rem; font-weight: 700; text-align: center; padding: 14px; letter-spacing: -.02em; }
.hint { font-size: .76rem; color: var(--text-dim); margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.check { display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 9px 11px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-xs); font-size: .87rem; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.check.on { border-color: var(--accent); background: var(--accent-ghost); }

input[type="color"] { width: 100%; height: 42px; padding: 3px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-xs); cursor: pointer; }
input[type="range"] { width: 100%; accent-color: var(--accent); }

.seg { display: grid; grid-auto-flow: column; gap: 6px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-xs); padding: 4px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 8px 6px; border-radius: 7px;
  font-size: .84rem; font-weight: 640; color: var(--text-muted); cursor: pointer; transition: .15s; }
.seg input:checked + span { background: var(--accent); color: #fff; }
.seg.danger input:checked + span { background: var(--danger); }
.seg.ok input:checked + span { background: var(--ok); color: #04240f; }

/* --------------------------------------------------- alertes */
.alert {
  display: flex; gap: 10px; padding: 12px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); margin-bottom: 10px;
}
.alert .ico { margin-top: 2px; flex: none; }
.alert b { display: block; font-size: .9rem; margin-bottom: 1px; }
.alert p { margin: 0; font-size: .82rem; color: var(--text-muted); line-height: 1.45; }
.alert.ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); background: var(--ok-ghost); }
.alert.ok .ico { color: var(--ok); }
.alert.warn, .alert.warning { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); background: var(--warn-ghost); }
.alert.warn .ico, .alert.warning .ico { color: var(--warn); }
.alert.danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); background: var(--danger-ghost); }
.alert.danger .ico { color: var(--danger); }
.alert.info { border-color: color-mix(in srgb, var(--info) 40%, var(--border)); background: var(--info-ghost); }
.alert.info .ico { color: var(--info); }
.alert.success { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); background: var(--ok-ghost); }
.alert.success .ico { color: var(--ok); }

/* ------------------------------------------------------ flash */
.flash-zone { position: fixed; left: 10px; right: 10px; top: calc(10px + env(safe-area-inset-top, 0px)); z-index: 90; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.flash-zone .alert { pointer-events: auto; box-shadow: var(--shadow); animation: slideIn .3s ease; background: var(--surface); }
@keyframes slideIn { from { opacity: 0; transform: translateY(-12px); } }

/* ------------------------------------------------------- nav */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: var(--nav-h); color: var(--text-dim); font-size: .64rem; font-weight: 620;
  text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.bottom-nav a.active { color: var(--accent-soft); }
.bottom-nav a.active .ico { transform: translateY(-1px); }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom, 0px));
  z-index: 55; width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #fff; border: 0;
  display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 8px 24px rgba(99, 102, 241, .45);
}
.fab:active { transform: scale(.94); }

/* ----------------------------------------------------- modal */
dialog {
  width: min(560px, calc(100% - 20px));
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); padding: 0;
  box-shadow: var(--shadow); margin: auto;
}
dialog::backdrop { background: rgba(4, 8, 22, .68); backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 15px 16px; border-bottom: 1px solid var(--border-soft); }
.modal-head h2 { flex: 1; font-size: 1rem; }
.modal-body { padding: 16px; max-height: min(70vh, 620px); overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; padding: 13px 16px; border-top: 1px solid var(--border-soft); }
.modal-foot .btn { flex: 1; }

/* ----------------------------------------------------- table */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.tbl th { text-align: left; padding: 9px 11px; font-size: .7rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-dim); border-bottom: 1px solid var(--border); white-space: nowrap; font-weight: 700; }
table.tbl td { padding: 10px 11px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------- onglets */
.tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 12px;
  scrollbar-width: none; -ms-overflow-style: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 8px 14px; border-radius: 99px; font-size: .84rem; font-weight: 620;
  color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border-soft);
  white-space: nowrap; cursor: pointer; text-decoration: none;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab:hover { text-decoration: none; }

/* --------------------------------------------------- charts */
.chart-box { position: relative; height: 220px; }
.chart-box.sm { height: 170px; }
.chart-box.lg { height: 280px; }

/* --------------------------------------------------- divers */
.empty { text-align: center; padding: 34px 16px; color: var(--text-dim); }
.empty .ico { opacity: .35; margin-bottom: 10px; }
.empty p { font-size: .88rem; margin-bottom: 12px; }

.plan-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; background: var(--surface-2); }
.plan-card.active { border-color: var(--accent); background: linear-gradient(150deg, var(--accent-ghost), transparent 70%), var(--surface-2); }
.plan-bar { display: flex; height: 9px; border-radius: 99px; overflow: hidden; margin: 10px 0 8px; background: var(--surface-3); }
.plan-bar > span { height: 100%; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .76rem; color: var(--text-muted); }
.legend > span { display: inline-flex; align-items: center; gap: 5px; }

.kpi-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--border-soft); }
.kpi-line:last-child { border-bottom: 0; }
.kpi-line .k { color: var(--text-muted); font-size: .84rem; }
.kpi-line .v { font-weight: 680; font-variant-numeric: tabular-nums; }

.scroll-x { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; margin: 0 -14px; padding-left: 14px; padding-right: 14px;
  scrollbar-width: none; scroll-snap-type: x mandatory; }
.scroll-x::-webkit-scrollbar { display: none; }
.scroll-x > * { scroll-snap-align: start; flex: 0 0 auto; }

.sticky-actions { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); z-index: 30;
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px);
  padding: 10px 0; margin-top: 14px; border-top: 1px solid var(--border-soft); }

/* Zone de depot de fichier : grosse cible tactile.
   Selecteur volontairement specifique : .field > label imposerait sinon display:block. */
button.file-zone, .file-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  width: 100%; min-height: 132px; padding: 20px 14px; text-align: center; cursor: pointer;
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text-muted);
  font: inherit;
  transition: border-color .15s, background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
button.file-zone:hover, .file-zone:hover { border-color: var(--accent); color: var(--text); }
button.file-zone:active { transform: scale(.99); }
button.file-zone:focus-visible { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ghost); }
button.file-zone.on, .file-zone.on {
  border-style: solid; border-color: var(--ok); background: var(--ok-ghost); color: var(--text);
}
.file-zone.on .ico { color: var(--ok); }
.file-zone-main { display: block; font-weight: 650; font-size: .95rem; line-height: 1.35; word-break: break-word; }
.file-zone-sub  { display: block; font-size: .78rem; color: var(--text-dim); line-height: 1.35; }

.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: .82rem; flex: none; }

.pw-bar { height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin-top: 6px; }
.pw-bar > span { display: block; height: 100%; width: 0; transition: width .25s, background .25s; }

/* -------------------------------------------------- desktop */
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .container { padding: 0 24px 40px; }
  .grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .bottom-nav { display: none; }
  .fab { bottom: 26px; right: 26px; }
  h1 { font-size: 1.7rem; }
  .hero { padding: 26px 24px; }
  .hero .amount { font-size: 3.6rem; }
  .chart-box { height: 260px; }
  .scroll-x { margin: 0; padding-left: 0; padding-right: 0; }
  .sticky-actions { bottom: 0; }

  .sidebar {
    display: flex; flex-direction: column; gap: 3px;
    width: 234px; flex: none; padding: 18px 12px;
    border-right: 1px solid var(--border-soft);
    background: var(--surface); position: sticky; top: 0; height: 100vh;
  }
  .sidebar .brand { display: flex; align-items: center; gap: 9px; padding: 6px 10px 16px; font-weight: 750; font-size: 1.05rem; letter-spacing: -.02em; }
  .sidebar .brand .logo { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; color: #fff; }
  .sidebar a.nav-link {
    display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 10px;
    color: var(--text-muted); font-size: .88rem; font-weight: 600; text-decoration: none;
  }
  .sidebar a.nav-link:hover { background: var(--surface-2); color: var(--text); }
  .sidebar a.nav-link.active { background: var(--accent-ghost); color: var(--accent-soft); }
  .sidebar .nav-sep { margin: 10px 11px 5px; font-size: .66rem; text-transform: uppercase;
    letter-spacing: .09em; color: var(--text-dim); font-weight: 700; }
  .topbar { padding-top: 16px; }
  .field-row.g3 { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1200px) {
  .grid.g2-lg3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ------------------------------------------------ impression */
@media print {
  .bottom-nav, .fab, .sidebar, .topbar, .sticky-actions { display: none !important; }
  body { background: #fff; color: #000; padding: 0; }
}
