/* Application pleine largeur : barre du haut, puis liste à gauche et fiche à droite. */
:root {
  --bg: #f2f5f8; --surface: #ffffff; --fg: #15202b; --muted: #586675; --line: #d9e0e7;
  --accent: #1d5d8a; --on-accent: #ffffff; --ok: #1d7549;
  --urgent: #b93226; --today: #a66300; --week: #2a66a8; --info: #66727f;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root {
  --bg: #0f151b; --surface: #172029; --fg: #e5ebf0; --muted: #96a4b2; --line: #2a3643;
  --accent: #74b6e2; --on-accent: #0f151b; --ok: #6fcf97;
  --urgent: #f27d6f; --today: #e8a84c; --week: #82b4ec; --info: #96a4b2; color-scheme: dark } }

html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.5; }
#root { min-height: 100%; display: flex; flex-direction: column; }
[hidden] { display: none !important; }
.gut { padding-left: 20px; padding-right: 20px; }
h1, h2, h3 { font-weight: 600; margin: 0; text-wrap: balance; }
h1 { font-size: 26px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
p { margin: 0; max-width: 80ch; }
a { color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: 13px; }
.label { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; min-width: 0; width: 100%; box-sizing: border-box; }
textarea { resize: vertical; min-height: 64px; }
.primary { background: var(--accent); color: var(--on-accent); border: 0; border-radius: 6px; padding: 9px 16px; font-weight: 600; text-decoration: none; display: inline-block; }
.ghost { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; text-decoration: none; color: var(--fg); display: inline-block; }
.ghost:hover { border-color: var(--accent); }
.ghost[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.danger { color: var(--urgent); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; }
.b-urgent { background: var(--urgent); } .b-today { background: var(--today); } .b-week { background: var(--week); } .b-info { background: var(--info); }
.c-urgent { color: var(--urgent); } .c-today { color: var(--today); } .c-week { color: var(--week); } .c-info { color: var(--info); } .c-ok { color: var(--ok); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.err { color: var(--urgent); }

/* Connexion */
.login { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.login-intro { background: var(--surface); border-right: 1px solid var(--line); padding-block: 48px; display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.login-form { padding-block: 48px; display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.login-form > * { max-width: 420px; width: 100%; box-sizing: border-box; }

/* Barre du haut */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; position: sticky; top: 0; z-index: 5; }
.brand { padding-block: 10px; display: flex; flex-direction: column; line-height: 1.25; }
.brand b { font-size: 17px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; min-width: 0; align-self: stretch; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 0 14px; min-height: 46px; white-space: nowrap; color: var(--muted); font-weight: 500; }
.tabs button:hover { color: var(--fg); }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.tabs .n { font-size: 12px; margin-left: 6px; color: var(--urgent); font-weight: 600; font-variant-numeric: tabular-nums; }
.tools { display: flex; gap: 8px; padding-block: 8px; align-items: center; flex-wrap: wrap; }
.banner { border-bottom: 1px solid var(--line); padding-block: 8px; font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.banner.warn { color: var(--today); } .banner.bad { color: var(--urgent); }

.page { flex: 1; padding-block: 20px 40px; display: flex; flex-direction: column; gap: 20px; }
section { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.head { display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; align-items: flex-end; }

/* Tour de contrôle */
.boxes { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px; text-align: left; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.box:hover { border-color: var(--accent); }
.box .big { font-size: 26px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; gap: 2px; background: var(--line); }
.bar i { display: block; }
.counts { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; font-variant-numeric: tabular-nums; }
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; }

/* Listes */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.row { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 4px 14px; padding: 12px 14px; border: 0; border-top: 1px solid var(--line); background: none; width: 100%; text-align: left; }
.row:first-child { border-top: 0; }
.row:hover { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.row.sel { background: color-mix(in srgb, var(--accent) 13%, var(--surface)); }
.row.done { opacity: .6; }
.row .body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row .who { font-weight: 600; }
.row .clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); align-items: center; }
.row .todo { font-size: 13px; color: var(--muted); }
.empty { padding: 24px 14px; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filters button { background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; font-size: 13px; }
.filters button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.filters input { width: 220px; padding: 5px 10px; border-radius: 99px; font-size: 13px; }
.views { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.views button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 12px; color: var(--muted); }
.views button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }

/* Liste + fiche */
.split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
.listcol { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.detail { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; position: sticky; top: 70px; max-height: calc(100vh - 100px); overflow-y: auto; }
.detail dl { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; align-items: center; }
.detail dt { color: var(--muted); font-size: 13px; } .detail dd { margin: 0; overflow-wrap: anywhere; }
.detail dd input, .detail dd select { width: auto; padding: 4px 8px; }
.why { border-left: 3px solid currentColor; padding-left: 10px; }
.ctx { color: var(--urgent); font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back { display: none; align-self: flex-start; }
.notes { display: flex; flex-direction: column; gap: 8px; }
.note { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }

/* Tableaux et formulaires */
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 12px; text-align: right; border-top: 1px solid var(--line); white-space: nowrap; }
thead th { border-top: 0; font-size: 12px; color: var(--muted); font-weight: 600; }
th:first-child, td:first-child { text-align: left; } tbody th { font-weight: 500; }
td.left { text-align: left; }
td button.num { background: none; border: 0; padding: 2px 8px; border-radius: 4px; color: var(--accent); font-weight: 600; text-decoration: underline; }
td.zero { color: var(--line); }
.conn { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) 130px 140px; gap: 8px 16px; align-items: center; padding: 14px; border-top: 1px solid var(--line); }
.conn:first-child { border-top: 0; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; align-items: end; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--fg); color: var(--bg); border-radius: 8px; padding: 10px 14px; display: flex; gap: 14px; align-items: center; z-index: 10; max-width: calc(100vw - 32px); }
.toast button { background: none; border: 0; color: inherit; font-weight: 600; text-decoration: underline; }

@media (max-width: 900px) {
  .login, .cols, .split { grid-template-columns: minmax(0, 1fr); }
  .login-intro { border-right: 0; border-bottom: 1px solid var(--line); padding-block: 28px; }
  .login-form { padding-block: 28px; }
  .split .detail { display: none; position: static; max-height: none; }
  .split.opened .detail { display: flex; }
  .split.opened .listcol { display: none; }
  .back { display: inline-block; }
  .conn, .row { grid-template-columns: minmax(0, 1fr); }
  .topbar { position: static; }
}
