/* =====================================================================
   Design system — application de gestion des declarations
   Theme clair + sombre, accent bleu professionnel.
   ===================================================================== */
:root {
  /* Surfaces & texte */
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f5f7fc;
  --surface-3: #eef1f8;
  --border: #e6e9f2;
  --border-strong: #d5dbe9;
  --text: #0f1729;
  --text-2: #334155;
  --muted: #6b7488;

  /* Accent bleu */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #e9f0fe;
  --primary-softer: #f3f7ff;
  --on-primary: #ffffff;

  /* Couleurs secondaires */
  --accent: #f59e0b;
  --violet: #7c3aed;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #e11d48;
  --teal: #0d9488;

  /* Tags / pills (theme-aware) */
  --tag-neutral-bg: #eef1f6; --tag-neutral-fg: #475569;
  --tag-blue-bg: #e6effe;   --tag-blue-fg: #1d4ed8;
  --tag-amber-bg: #fef3c7;  --tag-amber-fg: #92400e;
  --tag-red-bg: #ffe4e9;    --tag-red-fg: #9f1239;
  --tag-green-bg: #dcfce7;  --tag-green-fg: #065f46;
  --tag-violet-bg: #f1ebff; --tag-violet-fg: #5b21b6;

  /* Divers */
  --radius: 14px;
  --radius-sm: 10px;
  --ring: rgba(37,99,235,.18);
  --glass: rgba(255,255,255,.82);
  --shadow-sm: 0 1px 2px rgba(15,23,41,.05), 0 1px 3px rgba(15,23,41,.05);
  --shadow: 0 4px 14px rgba(15,23,41,.06), 0 10px 30px rgba(15,23,41,.07);
  --shadow-lg: 0 24px 60px rgba(15,23,41,.20);
  --sidebar-w: 246px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0b1020;
  --surface: #131b2e;
  --surface-2: #0f1728;
  --surface-3: #1b2540;
  --border: #243149;
  --border-strong: #33425f;
  --text: #e7ecf6;
  --text-2: #c3ccdd;
  --muted: #8b97af;

  --primary: #5b93f8;
  --primary-dark: #3b82f6;
  --primary-soft: rgba(91,147,248,.16);
  --primary-softer: rgba(91,147,248,.09);

  --accent: #fbbf24;
  --violet: #a78bfa;
  --success: #34d399;
  --danger: #fb7185;
  --teal: #2dd4bf;

  --tag-neutral-bg: #1e2740; --tag-neutral-fg: #a9b4cb;
  --tag-blue-bg: rgba(91,147,248,.18);  --tag-blue-fg: #9ec0fb;
  --tag-amber-bg: rgba(251,191,36,.16); --tag-amber-fg: #fcd34d;
  --tag-red-bg: rgba(251,113,133,.18);  --tag-red-fg: #fda4b4;
  --tag-green-bg: rgba(52,211,153,.16); --tag-green-fg: #6ee7b7;
  --tag-violet-bg: rgba(167,139,250,.18); --tag-violet-fg: #c4b5fd;

  --ring: rgba(91,147,248,.32);
  --glass: rgba(19,27,46,.82);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow: 0 6px 20px rgba(0,0,0,.4);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  line-height: 1.55; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body.app-body {
  background-image: radial-gradient(1100px 460px at 100% -8%, rgba(37,99,235,.06), transparent 60%),
                    radial-gradient(760px 420px at -6% 0%, rgba(13,148,136,.05), transparent 55%);
  background-attachment: fixed;
}
[data-theme="dark"] body.app-body { background-image: none; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; letter-spacing: -.01em; color: var(--text); }
h1 { font-size: 1.4rem; font-weight: 800; }
h2 { font-size: 1.1rem; font-weight: 750; }
h3 { font-size: .98rem; font-weight: 700; }
button { font: inherit; cursor: pointer; }
::selection { background: var(--primary-soft); }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 3px solid var(--surface); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

input, select, textarea {
  font: inherit; width: 100%; padding: .58rem .75rem; border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
label { display: block; font-size: .82rem; color: var(--muted); margin: .7rem 0 .25rem; font-weight: 600; }
textarea { min-height: 74px; resize: vertical; }
select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7488' stroke-width='3'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right .7rem center; padding-right: 2rem; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .58rem 1rem; border: 1.5px solid transparent; border-radius: var(--radius-sm);
  background: var(--primary); color: var(--on-primary); font-weight: 650; letter-spacing: .01em;
  box-shadow: 0 1px 2px rgba(37,99,235,.25); transition: transform .12s, background .15s, box-shadow .15s; }
.btn:hover { background: var(--primary-dark); box-shadow: 0 6px 18px rgba(37,99,235,.3); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn.secondary:hover { background: var(--surface-2); border-color: var(--primary); color: var(--primary); }
.btn.danger { background: var(--danger); box-shadow: 0 1px 2px rgba(225,29,72,.25); }
.btn.danger:hover { background: #be123c; }
.btn.ghost { background: transparent; color: var(--muted); border-color: transparent; box-shadow: none; padding: .35rem .55rem; }
.btn.ghost:hover { color: var(--primary); background: var(--primary-soft); transform: none; box-shadow: none; }
.btn.small { padding: .35rem .65rem; font-size: .82rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---- Auth (login / reset / verify) ---- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: linear-gradient(150deg, #0b1a3a 0%, #14307a 45%, #2563eb 100%); }
.auth-card { background: var(--surface); width: 100%; max-width: 470px; border-radius: 22px; box-shadow: var(--shadow-lg); padding: 2.2rem; }
.auth-card h1 { font-size: 1.35rem; }
.brand { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.3rem; font-size: 1.05rem; font-weight: 750; }
.brand .dot { width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%); box-shadow: 0 4px 12px rgba(37,99,235,.4); }
.tabs-switch { display: flex; gap: .3rem; margin-bottom: 1.2rem; background: var(--surface-2); padding: .3rem; border-radius: 12px; border: 1px solid var(--border); }
.tabs-switch button { flex: 1; background: transparent; border: none; border-radius: 9px; padding: .55rem; font-weight: 650; color: var(--muted); transition: all .15s; }
.tabs-switch button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* ---- Shared utilities ---- */
.hidden { display: none !important; }
.msg { padding: .65rem .85rem; border-radius: var(--radius-sm); font-size: .9rem; margin: .6rem 0; border: 1px solid transparent; }
.msg.error { background: var(--tag-red-bg); color: var(--tag-red-fg); border-color: transparent; }
.msg.ok { background: var(--tag-green-bg); color: var(--tag-green-fg); border-color: transparent; }
.muted { color: var(--muted); font-size: .85rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.flex { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.between { justify-content: space-between; }
.spacer { flex: 1; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.3rem; margin-bottom: 1.2rem; }
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.1rem; }
kbd { font-family: var(--font); font-size: .72rem; font-weight: 700; color: var(--muted);
  background: var(--surface-3); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; padding: .05rem .35rem; }

/* ---- App shell : sidebar + topbar ---- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); flex: none; position: fixed; inset: 0 auto 0 0; z-index: 45;
  background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.side-brand { display: flex; align-items: center; gap: .65rem; padding: 1.05rem 1.15rem; border-bottom: 1px solid var(--border); }
.side-brand .dot { width: 32px; height: 32px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, var(--primary), #4f46e5); box-shadow: 0 4px 12px rgba(37,99,235,.4); }
.side-brand .bt { font-weight: 800; font-size: .98rem; line-height: 1.1; letter-spacing: -.01em; }
.side-brand .bs { font-size: .72rem; color: var(--muted); }
.side-scroll { flex: 1; overflow: auto; padding: .7rem .7rem 1rem; }
.side-cat { font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; padding: .8rem .7rem .3rem; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav button { display: flex; align-items: center; gap: .7rem; width: 100%; text-align: left;
  background: transparent; border: none; padding: .55rem .7rem; border-radius: 9px; color: var(--text-2);
  font-weight: 600; font-size: .9rem; transition: background .13s, color .13s; position: relative; }
.side-nav button svg { width: 18px; height: 18px; flex: none; stroke-width: 2; opacity: .85; }
.side-nav button:hover { background: var(--surface-2); color: var(--text); }
.side-nav button.active { background: var(--primary-soft); color: var(--primary); }
.side-nav button.active::before { content: ''; position: absolute; left: -4px; top: 20%; bottom: 20%; width: 3px; border-radius: 3px; background: var(--primary); }
.side-nav .nav-badge { margin-left: auto; }
.side-foot { border-top: 1px solid var(--border); padding: .7rem .8rem; display: flex; align-items: center; gap: .6rem; }
.side-foot .who { flex: 1; min-width: 0; }
.side-foot .who .nm { font-weight: 700; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .who .rl { font-size: .72rem; color: var(--muted); }

.app-main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .8rem;
  padding: .7rem 1.4rem; background: var(--glass); border-bottom: 1px solid var(--border); backdrop-filter: blur(10px); }
.page-title { font-size: 1.12rem; font-weight: 750; margin: 0; letter-spacing: -.01em; }
.icon-btn.menu-toggle { display: none; }
.search-trigger { display: inline-flex; align-items: center; gap: .5rem; min-width: 210px; padding: .48rem .7rem;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: .85rem; transition: border-color .15s; }
.search-trigger:hover { border-color: var(--primary); }
.search-trigger svg { width: 16px; height: 16px; }
.search-trigger .st-text { flex: 1; text-align: left; }
.icon-btn { position: relative; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-2); display: grid; place-items: center; transition: background .13s, color .13s, border-color .13s; }
.icon-btn:hover { background: var(--surface-2); color: var(--primary); border-color: var(--primary); }
.icon-btn svg { width: 18px; height: 18px; stroke-width: 2; }
.icon-btn .dot-badge { position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 99px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface); }
main { max-width: 1440px; width: 100%; margin: 1.5rem auto; padding: 0 1.8rem; }
.section { display: none; animation: fade .25s ease; }
.section.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.page-head { margin-bottom: 1.2rem; }
.page-head h1 { margin-bottom: .2rem; }
.page-head p { color: var(--muted); margin: 0; }

/* ---- Command palette (Ctrl+K) ---- */
.palette-back { position: fixed; inset: 0; z-index: 90; background: rgba(9,14,28,.5); backdrop-filter: blur(3px);
  display: flex; justify-content: center; align-items: flex-start; padding: 12vh 1rem 1rem; animation: fade .15s ease; }
.palette { width: min(620px, 94vw); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; }
.palette-search { display: flex; align-items: center; gap: .6rem; padding: .3rem .9rem; border-bottom: 1px solid var(--border); }
.palette-search svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.palette-search input { border: none; border-radius: 0; padding: .85rem 0; font-size: 1rem; background: transparent; }
.palette-search input:focus { box-shadow: none; }
.pal-list { max-height: 56vh; overflow: auto; padding: .4rem; }
.pal-group { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: .6rem .7rem .25rem; }
.pal-item { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: 9px; cursor: pointer; }
.pal-item.active { background: var(--primary-soft); }
.pal-ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); font-size: .82rem; font-weight: 700; flex: none; }
.pal-ic svg { width: 15px; height: 15px; }
.pal-tt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
.pal-meta { color: var(--muted); font-size: .76rem; white-space: nowrap; }
.pal-empty { padding: 1.4rem; text-align: center; color: var(--muted); }
.palette-foot { display: flex; gap: 1rem; padding: .5rem .9rem; border-top: 1px solid var(--border); font-size: .74rem; color: var(--muted); }

/* ---- Notifications ---- */
.notif-panel { position: fixed; top: 62px; right: 18px; width: min(390px, 94vw); z-index: 70;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; animation: fade .15s ease; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--border); font-weight: 750; }
.notif-head a { font-size: .8rem; font-weight: 600; cursor: pointer; }
.notif-list { max-height: 62vh; overflow: auto; }
.notif-item { display: flex; gap: .7rem; align-items: flex-start; padding: .7rem 1rem; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-2); }
.notif-ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.notif-ic svg { width: 16px; height: 16px; }
.notif-ic.red { background: var(--tag-red-bg); color: var(--tag-red-fg); }
.notif-ic.amber { background: var(--tag-amber-bg); color: var(--tag-amber-fg); }
.notif-ic.blue { background: var(--tag-blue-bg); color: var(--tag-blue-fg); }
.notif-tt { flex: 1; min-width: 0; }
.notif-tt .t { font-weight: 650; font-size: .88rem; }
.notif-tt .s { font-size: .78rem; color: var(--muted); }
.notif-empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }

/* ---- KPI / dashboard ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.kpi { display: flex; gap: .9rem; align-items: center; padding: 1.05rem 1.1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-sm); }
.kpi-ic { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; flex: none; }
.kpi-ic svg { width: 22px; height: 22px; stroke-width: 2; }
.kpi-ic.blue { background: var(--tag-blue-bg); color: var(--tag-blue-fg); }
.kpi-ic.amber { background: var(--tag-amber-bg); color: var(--tag-amber-fg); }
.kpi-ic.red { background: var(--tag-red-bg); color: var(--tag-red-fg); }
.kpi-ic.green { background: var(--tag-green-bg); color: var(--tag-green-fg); }
.kpi-ic.violet { background: var(--tag-violet-bg); color: var(--tag-violet-fg); }
.kpi-val { font-size: 1.7rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.kpi-label { font-size: .82rem; color: var(--muted); margin-top: .25rem; }
.dash-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 1rem; align-items: start; }
.dash-grid > .card { grid-column: span 12; margin-bottom: 0; }
.dash-grid > .span6 { grid-column: span 6; }
.dash-grid > .span7 { grid-column: span 7; }
.dash-grid > .span5 { grid-column: span 5; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.card-head h2 { margin: 0; }
.card-head a { font-size: .82rem; cursor: pointer; }
.mini-row { display: flex; align-items: center; gap: .7rem; padding: .58rem 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.mini-row:last-child { border-bottom: none; }
.mini-row:hover { background: var(--surface-2); }
.mini-row .mr-main { flex: 1; min-width: 0; }
.mini-row .mr-title { font-weight: 620; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-row .mr-sub { font-size: .76rem; color: var(--muted); }
.dist { display: flex; flex-direction: column; gap: .7rem; }
.dist-row { display: grid; grid-template-columns: 96px 1fr 30px; align-items: center; gap: .7rem; font-size: .84rem; }
.dist-bar { height: 9px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.dist-fill { height: 100%; border-radius: 6px; background: var(--primary); }
.dist-fill.todo { background: var(--muted); }
.dist-fill.in_progress { background: var(--primary); }
.dist-fill.blocked { background: var(--danger); }
.dist-fill.done { background: var(--success); }
.dist-row .dist-n { text-align: right; font-weight: 700; color: var(--text-2); }
.empty-state { text-align: center; color: var(--muted); padding: 1.4rem .5rem; }

/* ---- Calendar ---- */
.cal-grid { display: block; }
.cal-dows, .cal-week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.dow { text-align: center; font-size: .72rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: .3rem 0; }
.cal-week { position: relative; margin-top: 6px; }
.cal-bars { position: absolute; inset: 0; pointer-events: none; }
.cal-bar { position: absolute; height: 19px; line-height: 15px; border-radius: 6px; font-size: 11px; font-weight: 600; color: #fff;
  padding: 2px 8px; box-sizing: border-box; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; border: none; cursor: pointer; pointer-events: auto; text-align: left; }
.cal-bar.declaration { background: var(--accent); }
.cal-bar.event { background: var(--primary); }
.cal-bar.reminder { background: var(--violet); }
.cal-bar.task { background: var(--teal); }
.cal-bar.done { background: var(--success); text-decoration: line-through; opacity: .85; }
.cal-bar:hover { filter: brightness(1.06); }
.cal-cell { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; height: 106px; overflow: hidden; padding: .4rem; transition: box-shadow .15s; }
.cal-cell:hover { box-shadow: var(--shadow-sm); }
.cal-cell.empty { background: transparent; border: none; }
.cal-cell .day { font-size: .8rem; color: var(--muted); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; border-radius: 7px; }
.cal-cell.today { border-color: var(--primary); background: var(--primary-soft); }
.cal-cell.today .day { background: var(--primary); color: #fff; }
.evt { display: block; width: 100%; text-align: left; font-size: .7rem; font-weight: 600; padding: .2rem .4rem; border-radius: 6px; margin-top: .22rem; border: none; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; transition: filter .15s; }
.evt:hover { filter: brightness(1.07); }
.evt.declaration { background: var(--accent); }
.evt.event { background: var(--primary); }
.evt.reminder { background: var(--violet); }
.evt.done { background: var(--success); text-decoration: line-through; opacity: .85; }
.list-item { display: flex; gap: .8rem; align-items: flex-start; padding: .8rem 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.badge { font-size: .72rem; padding: .25rem .55rem; border-radius: 99px; font-weight: 700; white-space: nowrap; }
.badge.declaration { background: var(--tag-amber-bg); color: var(--tag-amber-fg); }
.badge.event { background: var(--tag-blue-bg); color: var(--tag-blue-fg); }
.badge.reminder { background: var(--tag-violet-bg); color: var(--tag-violet-fg); }
.badge.done { background: var(--tag-green-bg); color: var(--tag-green-fg); }

/* ---- Tasks board ---- */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: .9rem; }
.col { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: .7rem; min-height: 130px; }
.col h3 { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .6rem; }
.task { background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: .65rem; margin-bottom: .6rem; box-shadow: var(--shadow-sm); transition: box-shadow .15s, transform .15s; cursor: grab; }
.task:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.task.dragging { opacity: .5; }
.task .title { font-weight: 650; font-size: .9rem; cursor: pointer; }
.task .meta { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .4rem; align-items: center; }
.task-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .3rem; }
.tref { display: inline-flex; align-items: center; gap: .35rem; font-size: .72rem; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.tdot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.tdot.task { background: var(--primary); }
.tdot.bug { background: var(--danger); }
.tdot.story { background: var(--violet); }
.tdot.declaration { background: var(--accent); }
.tlabels { display: flex; flex-wrap: wrap; gap: .25rem; margin: .35rem 0; }
.tlabel { font-size: .68rem; font-weight: 700; padding: .1rem .45rem; border-radius: 5px; }
.avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; font-size: .64rem; font-weight: 700; display: inline-grid; place-items: center; }
.task-actions { display: flex; gap: .1rem; flex-wrap: wrap; margin-top: .35rem; border-top: 1px solid var(--border); padding-top: .3rem; }
.pri { font-size: .66rem; padding: .12rem .45rem; border-radius: 6px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.pri.low { background: var(--tag-neutral-bg); color: var(--tag-neutral-fg); }
.pri.medium { background: var(--tag-blue-bg); color: var(--tag-blue-fg); }
.pri.high { background: var(--tag-amber-bg); color: var(--tag-amber-fg); }
.pri.urgent { background: var(--tag-red-bg); color: var(--tag-red-fg); }
.pri.critical { background: var(--danger); color: #fff; }
.subtasks { margin-top: .45rem; padding-left: .4rem; border-left: 2px solid var(--border-strong); }
.subtask { display: flex; align-items: center; gap: .4rem; font-size: .82rem; padding: .22rem 0; }
.subtask .st-title { flex: 1; }
.subtask.done .st-title { text-decoration: line-through; color: var(--muted); }
.date-chip { font-size: .72rem; color: var(--muted); background: var(--surface-2); padding: .1rem .4rem; border-radius: 6px; }
.cd { font-size: .7rem; font-weight: 700; padding: .15rem .5rem; border-radius: 99px; white-space: nowrap; }
.cd-late { background: var(--tag-red-bg); color: var(--tag-red-fg); }
.cd-urgent { background: var(--tag-red-bg); color: var(--tag-red-fg); }
.cd-soon { background: var(--tag-amber-bg); color: var(--tag-amber-fg); }
.cd-far { background: var(--tag-neutral-bg); color: var(--tag-neutral-fg); }

/* ---- Tasks : sous-vues, filtres, timeline ---- */
.tviews { display: flex; gap: .3rem; background: var(--surface-2); padding: .25rem; border-radius: 10px; border: 1px solid var(--border); }
.tview { background: transparent; border: none; border-radius: 7px; padding: .4rem .8rem; font-weight: 650; color: var(--muted); cursor: pointer; }
.tview.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.task-filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.task-filters select { width: auto; }
.col-count { color: var(--muted); font-weight: 600; font-size: .78rem; }
.col-drop { min-height: 44px; border-radius: 8px; transition: background .12s; }
.col-drop.drag-over { background: var(--primary-soft); outline: 2px dashed var(--primary); }
.activity { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: .3rem; }
.act-list { display: flex; flex-direction: column; gap: .5rem; max-height: 220px; overflow: auto; }
.act-comment { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .6rem; font-size: .88rem; }
.act-head { font-size: .8rem; margin-bottom: .2rem; }
.act-log { font-size: .8rem; }
.tl-wrap { overflow-x: auto; }
.tl-row { display: flex; align-items: center; min-height: 30px; border-bottom: 1px solid var(--border); }
.tl-row:last-child { border-bottom: none; }
.tl-header { position: sticky; top: 0; background: var(--surface); font-size: .72rem; color: var(--muted); font-weight: 700; z-index: 2; }
.tl-label { width: 210px; flex: none; font-size: .8rem; padding: .3rem .5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; display: flex; align-items: center; gap: .3rem; }
.tl-track { position: relative; flex: 1; height: 26px; min-width: 480px; }
.tl-months { height: 20px; }
.tl-month { position: absolute; top: 0; font-size: .68rem; color: var(--muted); border-left: 1px solid var(--border); padding-left: 3px; height: 100%; }
.tl-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); z-index: 1; }
.tl-bar { position: absolute; top: 4px; height: 18px; border-radius: 5px; background: var(--primary); color: #fff; font-size: 10.5px; font-weight: 600; line-height: 18px; padding: 0 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; }
.tl-bar.urgent, .tl-bar.critical { background: var(--danger); }
.tl-bar.high { background: var(--accent); }
.tl-bar.low { background: var(--muted); }

/* ---- Table ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .65rem .5rem; border-bottom: 1px solid var(--border); font-size: .9rem; }
th { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }

/* ---- Modal ---- */
.modal-back { position: fixed; inset: 0; background: rgba(9,14,28,.55); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 60; padding: 1rem; animation: fade .2s ease; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; padding: 1.5rem; max-height: 90vh; overflow: auto; }
.modal h2 { font-size: 1.2rem; }
.ref-ob { padding: .75rem 0; border-bottom: 1px solid var(--border); }
.ref-ob:last-child { border-bottom: none; }
.qr { display: block; margin: .8rem auto; width: 190px; height: 190px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.codes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: 1rem 0; }
.codes-grid code { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .55rem .6rem; text-align: center; letter-spacing: .08em; font-size: .95rem; color: var(--text); }

/* ---- Help pastille ---- */
.help { display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; line-height: 1; margin-left: .35rem; cursor: help; position: relative; vertical-align: middle; user-select: none; }
.help .tip { display: none; position: absolute; left: 50%; top: 155%; transform: translateX(-50%); width: 250px; max-width: 72vw; background: #0b1a3a; color: #fff; padding: .6rem .75rem; border-radius: 10px; font-size: .76rem; font-weight: 400; line-height: 1.45; text-align: left; z-index: 70; box-shadow: var(--shadow-lg); }
.help:hover .tip, .help:focus .tip, .help:focus-within .tip { display: block; }
.help .tip::after { content: ''; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-bottom-color: #0b1a3a; }

/* ---- Chat assistant ---- */
.chat-log { display: flex; flex-direction: column; gap: .6rem; min-height: 160px; max-height: 54vh; overflow: auto; padding: .7rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; margin: .6rem 0; }
.bubble { padding: .6rem .85rem; border-radius: 14px; max-width: 88%; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9rem; line-height: 1.5; box-shadow: var(--shadow-sm); }
.bubble.user { align-self: flex-end; background: linear-gradient(135deg, var(--primary), #4f46e5); color: #fff; border-bottom-right-radius: 5px; }
.bubble.ai { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 5px; color: var(--text); }
.bubble.ai a { color: var(--primary); text-decoration: underline; }
.bubble.ai code, .detail-desc code, .act-body code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .86em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: .03rem .3rem; }
.bubble.ai strong { font-weight: 750; }
.bubble .src { display: block; margin-top: .5rem; padding-top: .4rem; border-top: 1px dashed var(--border-strong); font-size: .74rem; color: var(--muted); }
.bubble.typing { color: var(--muted); font-style: italic; box-shadow: none; }
.chat-input { display: flex; gap: .5rem; align-items: flex-end; }
.chat-input textarea { flex: 1; min-height: 44px; max-height: 120px; resize: none; }
.chat-input .btn { white-space: nowrap; }
.assistant-layout { display: grid; grid-template-columns: 250px 1fr; gap: 1rem; align-items: start; }
.conv-sidebar { display: flex; flex-direction: column; gap: .6rem; position: sticky; top: 76px; }
.conv-list { display: flex; flex-direction: column; gap: 2px; max-height: 60vh; overflow: auto; }
.conv-item { display: flex; align-items: center; gap: .4rem; padding: .5rem .6rem; border-radius: 8px; cursor: pointer; font-size: .88rem; color: var(--text); }
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.conv-item .conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-x { opacity: 0; border: none; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 .2rem; }
.conv-item:hover .conv-x { opacity: 1; }
.conv-x:hover { color: var(--danger); }
.assistant-main { margin-bottom: 0; }
.chat-empty { padding: .5rem; }
.suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .6rem; }
.suggestion { text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .6rem .7rem; font-size: .85rem; color: var(--text); cursor: pointer; }
.suggestion:hover { border-color: var(--primary); background: var(--primary-soft); }
.task-proposal { margin-top: .6rem; padding: .6rem .7rem; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--primary-soft); font-size: .85rem; }
.task-proposal .btn { margin-top: .5rem; }
.attach-preview { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; flex-wrap: wrap; }
.attach-item { position: relative; display: inline-flex; }
.attach-thumb { max-height: 56px; max-width: 90px; border-radius: 8px; border: 1px solid var(--border); object-fit: cover; }
.attach-x { position: absolute; top: -7px; right: -7px; width: 18px; height: 18px; border-radius: 50%; border: none; background: var(--danger); color: #fff; font-size: 13px; line-height: 1; cursor: pointer; display: grid; place-items: center; padding: 0; }
.chat-thumb { display: inline-block; max-width: 160px; max-height: 160px; border-radius: 10px; margin: 0 .3rem .3rem 0; vertical-align: top; }

/* ---- Alertes ---- */
.nav-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; }
.alert.unread { box-shadow: inset 3px 0 0 0 var(--primary), var(--shadow); }
.sev { font-size: .7rem; font-weight: 700; padding: .18rem .55rem; border-radius: 99px; text-transform: uppercase; letter-spacing: .03em; }
.sev-info { background: var(--tag-neutral-bg); color: var(--tag-neutral-fg); }
.sev-low { background: var(--tag-blue-bg); color: var(--tag-blue-fg); }
.sev-medium { background: var(--tag-amber-bg); color: var(--tag-amber-fg); }
.sev-high { background: var(--tag-red-bg); color: var(--tag-red-fg); }

/* ---- Stats (admin) ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .9rem; margin-bottom: 1.2rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-sm); padding: 1rem 1.1rem; }
.stat-val { font-size: 1.8rem; font-weight: 800; color: var(--text); letter-spacing: -.02em; line-height: 1.1; }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 600; margin-top: .25rem; }
.stat.danger .stat-val { color: var(--danger); }
.stat.accent .stat-val { color: var(--primary); }

/* ---- Floating help (login page) ---- */
.help-fab { position: fixed; right: 20px; bottom: 20px; z-index: 85; background: linear-gradient(135deg, var(--primary), #4f46e5); color: #fff; border: none; border-radius: 99px; padding: .75rem 1.2rem; font-weight: 700; box-shadow: var(--shadow-lg); cursor: pointer; transition: transform .12s; }
.help-fab:hover { transform: translateY(-2px); }
.help-panel { position: fixed; right: 20px; bottom: 20px; z-index: 85; width: min(380px, 92vw); display: flex; flex-direction: column; max-height: 74vh; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 1rem; }
.help-panel .help-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border); font-size: 1rem; }
.help-panel .help-head button { background: none; border: none; font-size: 1.5rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 .3rem; }
.help-panel .help-head button:hover { color: var(--text); }
.help-panel .chat-log { flex: 1 1 auto; min-height: 130px; max-height: none; margin: 0 0 .55rem; }

/* ---- Sidebar mobile backdrop ---- */
.side-backdrop { display: none; position: fixed; inset: 0; background: rgba(9,14,28,.45); z-index: 44; }

/* ---- Toast ---- */
#toast { position: fixed; top: 14px; right: 14px; z-index: 100; max-width: 360px; }
#toast .msg { box-shadow: var(--shadow-lg); }

/* ---- Fiche detaillee (facon Confluence) ---- */
.modal.modal-wide { max-width: 760px; padding: 2.1rem 2.4rem 2rem; }
.modal.modal-form { max-width: 680px; padding: 2rem 2.3rem 1.9rem; }
.modal-form h2 { font-size: 1.5rem; margin-bottom: .3rem; letter-spacing: -.01em; }
.modal-form label { margin-top: 1.3rem; font-size: .82rem; }
.modal-form input, .modal-form select, .modal-form textarea { padding: .74rem .9rem; }
.modal-form .row { gap: 1.2rem; }
.modal-form textarea { min-height: 130px; }
.modal-form .flex.between { margin-top: 1.8rem !important; }
.detail-head { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; margin-bottom: 1rem; }
.detail-title { font-size: 1.7rem; font-weight: 800; margin: 0 0 1.5rem; letter-spacing: -.02em; line-height: 1.25; }
.detail-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 1.15rem 1.8rem; padding: 1.3rem 1.5rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; margin-bottom: 1.8rem; }
.dm { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.dm-k { font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.dm-v { font-size: .96rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.dm-v a { font-weight: 600; word-break: break-all; }
.detail-actions { display: flex; gap: .55rem; flex-wrap: wrap; margin-bottom: 2rem; }
.detail-section { border-top: 1px solid var(--border); padding-top: 1.7rem; margin-top: 1.7rem; }
.detail-section h3 { font-size: .74rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin-bottom: 1rem; font-weight: 700; }
.detail-desc { font-size: .97rem; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); }
.detail-desc a { text-decoration: underline; }
.proof-box { display: flex; flex-direction: column; gap: .25rem; padding: .85rem 1.05rem; margin-bottom: 1.5rem; background: var(--tag-green-bg); border-radius: 12px; }
.proof-k { font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--tag-green-fg); font-weight: 700; }
.proof-v { font-size: .93rem; color: var(--text); }
.ai-tag { font-size: .58rem; font-weight: 800; letter-spacing: .05em; color: var(--tag-green-fg); background: var(--tag-green-bg); padding: .08rem .32rem; border-radius: 5px; vertical-align: middle; }
.att-list { display: flex; flex-direction: column; gap: .55rem; margin-bottom: 1rem; }
.att-row { display: flex; align-items: center; gap: .8rem; padding: .7rem .85rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; }
.att-ic { flex: none; width: 44px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: var(--tag-blue-bg); color: var(--tag-blue-fg); font-size: .63rem; font-weight: 800; letter-spacing: .03em; }
.att-name { flex: 1; min-width: 0; font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-size { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.att-add { display: inline-block; margin-top: .3rem; }
.att-add span { display: inline-flex; align-items: center; padding: .6rem 1.1rem; border: 1.5px dashed var(--border-strong); border-radius: 11px; color: var(--muted); font-weight: 650; font-size: .85rem; cursor: pointer; transition: all .13s; }
.att-add span:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-softer); }
.act-list { display: flex; flex-direction: column; gap: .8rem; max-height: 320px; overflow: auto; padding-right: .2rem; }
.act-av { width: 27px; height: 27px; border-radius: 50%; background: var(--primary); color: #fff; font-size: .66rem; font-weight: 700; display: inline-grid; place-items: center; flex: none; }
.act-comment { background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: .85rem .95rem; font-size: .9rem; }
.act-head { display: flex; align-items: center; gap: .55rem; margin-bottom: 0; }
.act-head .muted { margin-left: auto; font-size: .78rem; }
.act-body { margin-top: .55rem; font-size: .93rem; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.act-log { display: flex; align-items: center; gap: .6rem; font-size: .83rem; padding: .35rem 0; }
.act-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); flex: none; margin-left: .35rem; }
.comment-box { display: flex; gap: .6rem; margin-top: 1.3rem; }
.comment-box input { flex: 1; padding: .72rem .9rem; }

/* ---- Print / export PDF ---- */
#print-area { display: none; }
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { display: block; position: absolute; inset: 0; padding: 1.5rem; color: #000; }
  #print-area h1 { font-size: 18px; }
  #print-area table { width: 100%; border-collapse: collapse; }
  #print-area th, #print-area td { border: 1px solid #999; padding: 6px 8px; font-size: 11px; text-align: left; }
  @page { margin: 1.2cm; }
}

/* ---- Responsive ---- */
@media (max-width: 1000px) {
  .dash-grid > .span6, .dash-grid > .span7, .dash-grid > .span5 { grid-column: span 12; }
}
@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; width: 260px; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .side-backdrop.show { display: block; }
  .app-main { margin-left: 0; }
  .icon-btn.menu-toggle { display: grid; }
  .board { grid-template-columns: 1fr 1fr; }
  .row { grid-template-columns: 1fr; }
  .assistant-layout { grid-template-columns: 1fr; }
  .conv-sidebar { position: static; }
  .search-trigger { min-width: 0; }
  .search-trigger .st-text, .search-trigger kbd { display: none; }
}
@media (max-width: 560px) {
  .board { grid-template-columns: 1fr; }
  .cal-cell { height: 74px; }
  main { padding: 0 .9rem; }
  .suggestions { grid-template-columns: 1fr; }
  .page-title { font-size: 1rem; }
}

/* ---- Mobile : ajustements fins (fiches, tableaux, modales, topbar) ---- */
@media (max-width: 640px) {
  .card { overflow-x: auto; }
  table { font-size: .84rem; }
  th, td { padding: .5rem .35rem; }
  .topbar { padding: .6rem .9rem; gap: .5rem; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi { padding: .85rem; gap: .7rem; }
  .kpi-ic { width: 40px; height: 40px; }
  .kpi-ic svg { width: 19px; height: 19px; }
  .kpi-val { font-size: 1.45rem; }
  .modal, .modal.modal-wide, .modal.modal-form { padding: 1.4rem 1.25rem; border-radius: 16px; }
  .detail-meta { grid-template-columns: 1fr; gap: .8rem; padding: 1rem 1.1rem; }
  .detail-title { font-size: 1.35rem; margin-bottom: 1rem; }
  .codes-grid { grid-template-columns: 1fr; }
  .modal-back { padding: .6rem; }
  .palette-back { padding: 8vh .6rem 1rem; }
  .notif-panel { right: 8px; left: 8px; width: auto; top: 58px; }
  .search-trigger { min-width: 0; padding: .48rem; }
  .side-foot .who .nm { max-width: 150px; }
}
@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .tviews { width: 100%; }
  .tview { flex: 1; text-align: center; padding: .4rem .3rem; }
  .toolbar > .btn, .toolbar > input { flex: 1; }
}
