/* Wigital Hub — sobre, lisible, accent dégradé rouge → orange de la marque */
:root {
  --red: #e52d27;
  --orange: #f39200;
  --grad: linear-gradient(90deg, var(--red), var(--orange));
  --ink: #111214;
  --ink-2: #4a4d55;
  --ink-3: #8a8e98;
  --line: #e7e8ec;
  --bg: #f6f6f4;
  --card: #ffffff;
  --accent: #e8541d;
  --accent-soft: #fff1e8;
  --green: #1f8a4c;
  --green-soft: #e6f5ec;
  --blue: #2a5bd7;
  --blue-soft: #e9effc;
  --yellow: #a26b00;
  --yellow-soft: #fff6d9;
  --violet: #6b46c1;
  --violet-soft: #f0ebfb;
  --redsoft: #fdeceb;
  --grey-soft: #f0f0f2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(17, 18, 20, .04), 0 4px 16px rgba(17, 18, 20, .04);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 750; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
small, .muted { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }

/* --- Layout -------------------------------------------------------------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #fff; padding: 22px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; text-decoration: none; }
.sidebar .brand img { height: 30px; }
.sidebar .brand span { font-size: 12px; color: #9a9ca3; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; margin-top: 8px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: #c9cbd1; font-weight: 550; }
.nav a:hover { background: #1f2125; color: #fff; }
.nav a.active { background: #26282d; color: #fff; box-shadow: inset 3px 0 0 var(--orange); }
.nav svg { width: 19px; height: 19px; flex: none; }
.nav .count { margin-left: auto; background: var(--grad); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 20px; font-weight: 700; }
.sidebar .bottom { margin-top: auto; }
.main { padding: 26px 34px 80px; max-width: 1280px; width: 100%; }
.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.topbar .title { flex: 1; min-width: 200px; }
.topbar .sub { color: var(--ink-3); margin-top: 4px; }
.search { position: relative; }
.search input[name] { width: 260px; padding: 9px 12px 9px 34px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font: inherit; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }

.mobile-top, .mobile-nav { display: none; }

/* --- Timer --------------------------------------------------------------- */
.timer-bar { display: flex; align-items: center; gap: 12px; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 18px; }
.timer-bar .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 4px rgba(243, 146, 0, .25); animation: pulse 1.6s infinite; }
.timer-bar .what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timer-bar .clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; }
@keyframes pulse { 50% { opacity: .4; } }

/* --- Cards & grids -------------------------------------------------------- */
.grid { display: grid; gap: 18px; }
.grid.home { grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); align-items: start; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card + .card { margin-top: 18px; }
.grid > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { flex: 1; }
.kpi { padding: 16px 18px; }
.kpi .label { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }
.kpi .value { font-size: 24px; font-weight: 760; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 13px; font-weight: 600; }
.kpi.alert .value { color: var(--red); }
.kpi.accent { background: var(--ink); color: #fff; border-color: var(--ink); }
.kpi.accent .label { color: #9a9ca3; }

/* Sélecteur de tarif (liste clients) et recherche dans les listes */
.rate-select { width: auto; padding: 3px 26px 3px 9px; border-radius: 20px; font-size: 12.5px; font-weight: 650; background-color: var(--grey-soft); border-color: transparent; color: var(--ink-2); cursor: pointer; }
.rate-select.ami { background-color: var(--yellow-soft); color: var(--yellow); }
input.combo { width: 100%; }
.doc-group { margin-top: 18px; }
.doc-group:first-child { margin-top: 0; }
.doc-group-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 4px 2px 8px; }
.doc-group-head a { font-weight: 700; text-decoration: none; }
.legacy { font-size: 11.5px; color: var(--ink-3); }
.doc-group table.list { table-layout: fixed; }
.doc-group td:nth-child(1) { width: 48%; }
.doc-group td:nth-child(2) { width: 16%; }
.doc-group td:nth-child(3) { width: 20%; }
@media (max-width: 760px) { .doc-group td:nth-child(1) { width: 52%; } .doc-group td:nth-child(3) { width: 26%; } }

/* Timbreuse (accueil) */
.timbreuse .t-form { display: grid; gap: 8px; }
.timbreuse .t-running { display: flex; align-items: center; gap: 12px; background: var(--ink); color: #fff; padding: 12px 14px; border-radius: 10px; }
.timbreuse .t-running small { color: #9a9ca3; }
.timbreuse .t-running .what { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.timbreuse .t-running .clock { font-variant-numeric: tabular-nums; font-weight: 750; font-size: 20px; }
.timbreuse .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 4px rgba(243, 146, 0, .25); animation: pulse 1.6s infinite; flex: none; }
.timbreuse .t-list { margin-top: 12px; border-top: 1px solid var(--line); }
.timbreuse .t-entry { display: grid; grid-template-columns: 88px minmax(0, 1fr) auto; gap: 8px; padding: 7px 2px; border-bottom: 1px solid var(--line); text-decoration: none; font-size: 13.5px; }
.timbreuse .t-entry:hover { background: #fafafa; }
.timbreuse .t-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Tasks (Ma journée) -------------------------------------------------- */
.bucket { margin-top: 16px; }
.bucket:first-of-type { margin-top: 4px; }
.bucket-title { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); padding: 6px 2px; }
.bucket-title .n { background: var(--grey-soft); color: var(--ink-2); border-radius: 20px; padding: 0 7px; font-size: 11px; }
.bucket.overdue .bucket-title { color: var(--red); }
.bucket.overdue .bucket-title .n { background: var(--redsoft); color: var(--red); }
details.bucket > summary { list-style: none; cursor: pointer; }
details.bucket > summary::-webkit-details-marker { display: none; }
.task { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 6px; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task:hover { background: #fafafa; }
.task .t-title { font-weight: 560; overflow-wrap: anywhere; }
.task .t-title a { text-decoration: none; }
.task .t-meta { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 1px; }
.task.done .t-title { text-decoration: line-through; color: var(--ink-3); }
.task .t-actions { display: flex; gap: 4px; align-items: center; }
.check { width: 22px; height: 22px; border-radius: 7px; border: 2px solid #c7c9cf; background: #fff; cursor: pointer; display: grid; place-items: center; padding: 0; }
.check:hover { border-color: var(--accent); }
.task.done .check { background: var(--green); border-color: var(--green); }
.task.done .check::after { content: ""; width: 6px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.prio-1 .t-title::before { content: "!"; color: var(--accent); font-weight: 800; margin-right: 6px; }
.prio-2 .t-title::before { content: "!!"; color: var(--red); font-weight: 800; margin-right: 6px; }
.quick-add { display: grid; grid-template-columns: minmax(0, 1fr) 190px 150px auto; gap: 8px; margin-bottom: 6px; }

/* --- Buttons, badges, forms ---------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c9cbd1; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #26282d; }
.btn.brand { background: var(--grad); color: #fff; border: 0; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 5px 9px; font-size: 13px; border-radius: 8px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--grey-soft); }
.btn.icon { padding: 6px; width: 32px; height: 32px; }
.btn svg { width: 16px; height: 16px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; margin: 0; }
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.badge.grey { background: var(--grey-soft); color: var(--ink-2); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.orange { background: var(--accent-soft); color: var(--accent); }
.badge.yellow { background: var(--yellow-soft); color: var(--yellow); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }
.badge.red { background: var(--redsoft); color: var(--red); }
.chip { font-size: 12px; color: var(--ink-2); background: var(--grey-soft); padding: 1px 8px; border-radius: 6px; text-decoration: none; }

input[type=search], input[type=text], input[type=email], input[type=number], input[type=date], input[type=datetime-local], input[type=password], input[type=url], input:not([type]), select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #d9dbe0; border-radius: 9px; font: inherit; background: #fff; color: var(--ink);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(232, 84, 29, .25); border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 650; color: var(--ink-2); }
.field .help { font-size: 12px; color: var(--ink-3); }
.field .err { font-size: 12.5px; color: var(--red); }
.field.check-field { flex-direction: row; align-items: center; gap: 8px; }
.field.check-field input { width: auto; }
.field ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.field ul label { font-weight: 500; display: flex; gap: 8px; align-items: flex-start; }
.field ul input { width: auto; margin-top: 3px; }

/* --- Tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover td { background: #fafafa; }
table.list td a.row-link { text-decoration: none; font-weight: 600; }
table.list tfoot td { font-weight: 750; border-top: 2px solid var(--ink); border-bottom: 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--ink-3); font-weight: 650; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.active { color: var(--ink); border-color: var(--accent); }
.tabs a .n { font-size: 11px; background: var(--grey-soft); padding: 0 6px; border-radius: 10px; margin-left: 4px; }

.validate-item { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.validate-item:last-child { border-bottom: 0; }
.validate-item .label { flex: 1; min-width: 0; font-size: 14px; }
.validate-item .ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; font-size: 15px; }

.proj-card { display: block; text-decoration: none; padding: 12px 0; border-bottom: 1px solid var(--line); }
.proj-card:last-child { border-bottom: 0; }
.proj-card .row1 { display: flex; gap: 8px; align-items: center; }
.proj-card .name { font-weight: 650; flex: 1; min-width: 0; }
.bar { height: 6px; background: var(--grey-soft); border-radius: 6px; overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; background: var(--grad); border-radius: 6px; }
.bar.over > span { background: var(--red); }

.messages { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.messages li { padding: 10px 14px; border-radius: 10px; background: var(--green-soft); color: var(--green); font-weight: 600; }
.messages li.error { background: var(--redsoft); color: var(--red); }
.messages li.info { background: var(--blue-soft); color: var(--blue); }

.empty { color: var(--ink-3); padding: 18px 4px; text-align: center; }
.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.prose { overflow-wrap: anywhere; }
.prose h1 { font-size: 22px; margin: 18px 0 8px; }
.prose h2 { font-size: 18px; margin: 16px 0 6px; }
.prose h3 { font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--ink); margin: 12px 0 4px; }
.prose table { border-collapse: collapse; }
.prose td, .prose th { border: 1px solid var(--line); padding: 4px 8px; }
.pre { white-space: pre-line; }

/* Lignes de document */
.doc-lines td.desc .d { color: var(--ink-3); font-size: 13px; white-space: pre-line; }
.doc-lines tr.section td { font-weight: 750; background: #fafafa; }
.doc-lines tr.neg td.amount { color: var(--red); }
.doc-total { display: flex; justify-content: flex-end; gap: 30px; padding: 14px 10px 0; font-size: 19px; font-weight: 800; }

/* Stats */
.chart { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 8px; align-items: end; height: 200px; padding-top: 10px; }
.chart .col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart .bars { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.chart .b { width: 42%; max-width: 22px; border-radius: 5px 5px 0 0; min-height: 2px; }
.chart .b.rev { background: var(--grad); background: linear-gradient(180deg, var(--orange), var(--red)); }
.chart .b.exp { background: #c9cbd1; }
.chart .lbl { font-size: 11px; color: var(--ink-3); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 6px 0; }
.hbar .track { grid-column: 1 / -1; height: 8px; background: var(--grey-soft); border-radius: 6px; overflow: hidden; }
.hbar .track span { display: block; height: 100%; background: var(--grad); }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--ink); padding: 16px; }
.login-card { background: #fff; padding: 34px; border-radius: 18px; width: 100%; max-width: 380px; }
.login-card img { height: 42px; margin-bottom: 20px; }

/* --- Mobile ---------------------------------------------------------------- */
@media (max-width: 960px) {
  .grid.home, .grid.cols-3, .grid.cols-2 { grid-template-columns: minmax(0, 1fr); }
  /* Accueil mobile : la timbreuse passe en premier */
  .grid.home > .side { display: contents; }
  .grid.home .timbreuse { order: -1; margin-top: 0; }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  body { font-size: 15px; }
  .app { display: block; }
  .sidebar { display: none; }
  .mobile-top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--ink); position: sticky; top: 0; z-index: 20; }
  .mobile-top img { height: 24px; }
  .mobile-top .sp { flex: 1; }
  .mobile-top a { color: #fff; }
  .mobile-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .mobile-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; font-size: 11px; font-weight: 650; color: var(--ink-3); text-decoration: none; }
  .mobile-nav a.active { color: var(--accent); }
  .mobile-nav svg { width: 22px; height: 22px; }
  .main { padding: 16px 16px 96px; }
  h1 { font-size: 22px; }
  .topbar .search { display: none; }
  .quick-add, .card .quick-add[style] { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important; }
  .quick-add > input:first-of-type { grid-column: 1 / -1; }
  .quick-add > button { grid-column: 1 / -1; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: 110px minmax(0, 1fr); }
  .task .t-actions .hide-sm { display: none; }
  .card { padding: 14px; }
  .table-wrap { margin: 0 -14px; padding: 0 14px; }
  table.list .hide-sm { display: none; }
  .kpi .value { font-size: 20px; }
}

/* Planning */
.plan-week { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; align-items: start; }
.plan-week .card + .card { margin-top: 0; }
.plan-day.over { border-color: var(--red); }
.plan-item { display: block; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); text-decoration: none; overflow-wrap: anywhere; }
.plan-item .num { font-weight: 700; margin-right: 4px; }
.plan-item.ev { color: var(--blue); }
.plan-item.dl { color: var(--accent); font-weight: 600; }
.events-today { display: grid; gap: 6px; margin: 4px 0 10px; }
.events-today div { font-size: 13.5px; padding: 6px 10px; border-radius: 8px; background: var(--blue-soft); color: var(--blue); }
@media (max-width: 960px) { .plan-week { grid-template-columns: minmax(0, 1fr); } }

.ring { --p: 0; width: 84px; height: 84px; border-radius: 50%; background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--grey-soft) 0); display: grid; place-items: center; flex: none; }
.ring div { width: 62px; height: 62px; border-radius: 50%; background: var(--card); display: grid; place-items: center; font-weight: 750; font-size: 14px; }
.settings-block + .settings-block { margin-top: 18px; }
code.secret { display: block; padding: 8px 10px; background: var(--grey-soft); border-radius: 8px; font-size: 12.5px; overflow-wrap: anywhere; }
