:root {
  --bg: #f5f6fa; --card: #fff; --text: #1d2130; --muted: #6b7185; --line: #e6e8ef;
  --primary: #4f46e5; --primary-2: #4338ca; --danger: #dc2626; --ok: #16a34a; --now: #eef2ff;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
h1 { margin: 0; font-size: 1.6rem; }
h2 { margin: 0 0 1rem; font-size: 1.05rem; }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1.5rem; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.topbar nav { display: flex; gap: 1.2rem; align-items: center; }
.topbar nav a { color: var(--muted); font-weight: 500; }
.topbar nav a:hover { color: var(--text); }
.user { color: var(--muted); font-size: .9rem; border-left: 1px solid var(--line); padding-left: 1.2rem; }

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 400px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.4rem; margin-bottom: 1.2rem; }
.card.scroll { overflow-x: auto; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; gap: 1rem; }

label { display: block; margin-bottom: .9rem; font-weight: 500; font-size: .9rem; }
input { font: inherit; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; }
label input { margin-top: .3rem; }
input:focus { outline: 2px solid color-mix(in srgb, var(--primary) 30%, transparent); border-color: var(--primary); }
input[type=color] { width: 44px; height: 38px; padding: 2px; cursor: pointer; flex: none; }
input.amount { text-align: right; max-width: 160px; }

.btn { display: inline-block; font: inherit; font-weight: 500; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.small { padding: .3rem .7rem; font-size: .85rem; }
.btn.full { width: 100%; }
button.link { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 500; cursor: pointer; padding: 0; }
.inline { display: inline; }
.row { display: flex; gap: .6rem; align-items: center; }
.row.tight input:not([type=color]) { max-width: 260px; }
.actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }
.muted { color: var(--muted); } .center { text-align: center; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash.err { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .6rem .7rem; border-bottom: 1px solid var(--line); text-align: left; }
.table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; white-space: nowrap; }
.table tfoot th, .table tfoot td { border-bottom: 0; }
.table tfoot tr:first-child th { border-top: 2px solid var(--text); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.zero { color: #c0c4d0; }
.strong { font-weight: 600; }
.grand { color: var(--primary); font-size: 1.05rem; }
.table tr.now td { background: var(--now); }
.pct td { color: var(--muted); font-size: .85rem; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .45rem; vertical-align: middle; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem 1.2rem; display: flex; flex-direction: column; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat strong { font-size: 1.5rem; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-size: .8rem; }
.stat.accent { background: var(--primary); border-color: var(--primary); color: #fff; }
.stat.accent span { color: rgba(255,255,255,.8); }

.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: .5rem; height: 200px; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: .3rem; color: var(--muted); font-size: .75rem; }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.bar-stack { width: 70%; max-width: 44px; display: flex; flex-direction: column-reverse; border-radius: 4px 4px 0 0; overflow: hidden; min-height: 0; transition: opacity .15s; }
.bar-col:hover .bar-stack { opacity: .8; }
.legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; font-size: .85rem; color: var(--muted); }

@media (max-width: 640px) {
  .topbar { flex-direction: column; gap: .5rem; }
  .user { display: none; }
  .container { padding: 1rem; }
  h1 { font-size: 1.25rem; }
  .row { flex-wrap: wrap; }
  .bars { gap: .2rem; height: 150px; }
}

/* === Campagne === */
.month-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.month-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.stat.compact { flex-direction: row; align-items: baseline; gap: 1rem; padding: .8rem 1.2rem; }
.stat.compact strong { font-size: 1.3rem; margin: 0; }
.channel-block { border-left: 4px solid var(--ch); }
.channel-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .8rem; }
.channel-head h2 { margin: 0; }
.channel-head h2 small { font-weight: 400; font-size: .85rem; margin-left: .5rem; }
.channel-head strong { font-size: 1.15rem; }
.camp-row { display: grid; grid-template-columns: 2fr 140px 2fr auto; gap: .6rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.camp-row input.amount { max-width: none; }
.camp-header { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding-top: 0; }
.camp-name { font-weight: 500; }
.camp-row.add { border-bottom: 0; padding-top: .8rem; }
.camp-row.add input { background: var(--bg); }
.camp-row.editing { background: var(--now); margin: 0 -.6rem; padding: .5rem .6rem; border-radius: 8px; }
.row-actions { display: flex; gap: .4rem; justify-content: flex-end; }
small.cnt { display: block; color: var(--muted); font-size: .72rem; }
@media (max-width: 760px) {
  .camp-row { grid-template-columns: 1fr 1fr; }
  .camp-header { display: none; }
  .camp-row .row-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
