/* Same visual language as ecostore.dataservices.fr: white header underlined in
   red, light grey page, white rounded cards with soft shadows, red actions. */
:root {
  --primary: #af1111; --primary-dark: #8b0d0d; --primary-light: #db4128;
  --bg: #f2f2f2; --card: #fff; --text: #1a1a1a; --text-2: #333; --muted: #666; --line: #e0e0e0;
  --header: #fff; --footer: #1a1a1a; --field: #fff; --link: #af1111;
  --ok: #0b7a55; --drift: #a15c00; --critical: #c81e1e; --err: #a3195b; --silent: #5b45b0; --never: #666;
  --radius: 8px; --radius-lg: 12px;
  --shadow-sm: 0 2px 4px rgb(0 0 0 / .1); --shadow-md: 0 4px 8px rgb(0 0 0 / .1); --shadow-lg: 0 8px 16px rgb(0 0 0 / .15);
  --gradient: linear-gradient(135deg, var(--primary), var(--primary-light));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414; --card: #1f1f1f; --text: #f2f2f2; --text-2: #dcdcdc; --muted: #a3a3a3; --line: #363636;
    --header: #1a1a1a; --footer: #0d0d0d; --field: #141414; --link: #ff8a75;
    --ok: #34d399; --drift: #fbbf24; --critical: #f87171; --err: #f472b6; --silent: #a996ee; --never: #a3a3a3;
    --shadow-sm: 0 2px 4px rgb(0 0 0 / .5); --shadow-md: 0 4px 8px rgb(0 0 0 / .5); --shadow-lg: 0 8px 16px rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body { margin: 0; min-height: 100%; display: flex; flex-direction: column; background: var(--bg); color: var(--text);
  font: 15px/1.55 "Roboto", "Segoe UI", system-ui, sans-serif; }
a { color: var(--link); }
h1 { font-size: 1.6rem; font-weight: 700; margin: 0; line-height: 1.25; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 14px; }
p { margin: 0 0 10px; } p:last-child { margin-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }
.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 20px; }

/* Header */
.main-header { background: var(--header); box-shadow: var(--shadow-sm); border-bottom: 2px solid var(--primary); position: sticky; top: 0; z-index: 10; }
.header-content { display: flex; align-items: center; gap: 28px; height: 64px; }
.logo { display: flex; align-items: baseline; gap: 8px; text-decoration: none; flex: none; }
.logo img { height: 42px; width: auto; align-self: center; }
.logo strong { font-size: 1.5rem; font-weight: 700; color: var(--primary); letter-spacing: -.01em; }
.logo .tagline { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.main-nav { display: flex; gap: 4px; flex: 1; }
.nav-link { color: var(--text-2); text-decoration: none; font-weight: 500; padding: 8px 16px; border-radius: var(--radius); transition: background .2s, color .2s; }
.nav-link:hover, .nav-link.active { color: var(--link); background: var(--bg); }
.menu { position: relative; flex: none; margin-left: auto; }
.menu summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px 10px 4px 4px; border-radius: 999px; font-weight: 500; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: "▾"; color: var(--muted); font-size: .8rem; }
.menu summary:hover, .menu[open] summary { background: var(--bg); }
.avatar { width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--gradient); color: #fff; display: grid; place-items: center; font-weight: 700; text-transform: uppercase; }
.menu .name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 8px); width: 250px; background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--line); padding: 6px; z-index: 20; }
.menu-who { display: grid; padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; overflow-wrap: anywhere; }
.menu-item { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: var(--radius); background: none; border: 0; color: var(--text); font: inherit; font-weight: 400; text-decoration: none; cursor: pointer; }
.menu-item:hover { background: var(--bg); color: var(--link); transform: none; box-shadow: none; }

main { flex: 1; }
main.container { padding-top: 28px; padding-bottom: 40px; }
.main-footer { background: var(--footer); color: #bdbdbd; font-size: .85rem; padding: 14px 0; }
.main-footer .container { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Page structure */
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.col-main, .col-side { display: grid; gap: 20px; min-width: 0; }
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; font-weight: 500; color: var(--c); background: color-mix(in srgb, var(--c) 10%, var(--card)); border-left: 4px solid var(--c); box-shadow: var(--shadow-sm); }

/* Cards and tables */
.card { background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 20px; min-width: 0; }
main > .card, main > .counts, main > .alert.big { margin-bottom: 20px; }
.card.danger { border-top: 3px solid var(--critical); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
#fleet-search { width: 320px; max-width: 100%; }
.empty { text-align: center; padding: 28px 16px; }
.empty button { margin-top: 8px; }
p.empty { padding: 20px 0 4px; }
.scroll { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 0; } th:last-child, td:last-child { padding-right: 0; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); white-space: nowrap; font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
td a { font-weight: 600; text-decoration: none; } td a:hover { text-decoration: underline; }
td.detail { max-width: 420px; }
td:first-child { overflow-wrap: anywhere; min-width: 70px; }
td.actions { text-align: right; white-space: nowrap; }
.who-cell { overflow-wrap: anywhere; } .who-cell strong { display: block; font-weight: 600; } .who-cell span { display: block; font-weight: 400; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); }
.ok { --c: var(--ok); } .drift { --c: var(--drift); } .critical { --c: var(--critical); }
.error { --c: var(--err); } .silent { --c: var(--silent); } .never { --c: var(--never); }
.counts { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
.count { display: block; text-align: left; background: var(--card); color: var(--text); border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  border: 0; border-top: 4px solid var(--c); padding: 14px 18px; cursor: pointer; font: inherit; }
.count:hover { background: var(--card); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.count[aria-pressed=true] { outline: 2px solid var(--c); outline-offset: 2px; }
.count strong { display: block; font-size: 2rem; font-weight: 700; line-height: 1.15; color: var(--c); }
.count span { color: var(--muted); font-size: .85rem; font-weight: 400; }
.kv { margin: 0; display: grid; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv > div:last-child { border-bottom: 0; padding-bottom: 0; } .kv > div:first-child { padding-top: 0; }
.kv dt { color: var(--muted); font-size: .88rem; } .kv dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.kv.stacked > div { display: block; } .kv.stacked dt { color: var(--text); font-weight: 600; } .kv.stacked dd { text-align: left; font-weight: 400; color: var(--muted); font-size: .88rem; }
.alert { padding: 10px 14px; border-radius: var(--radius); color: var(--c); background: color-mix(in srgb, var(--c) 10%, var(--card)); border-left: 4px solid var(--c); }
.alert.big { padding: 16px 18px; box-shadow: var(--shadow-sm); }
.alert.big ul, .alert.big ol { margin: 6px 0 10px; padding-left: 22px; color: var(--text); }
.alert.big ol li { margin: 4px 0; }
.alert.big p { color: var(--text); }
.alert.big form { margin-top: 10px; }
.todo { display: grid; gap: 14px; margin-bottom: 20px; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; }
:not(pre) > code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: .92rem; }
.events li { display: grid; grid-template-columns: 125px minmax(0, 1fr); gap: 12px; overflow-wrap: anywhere; }
.events a { text-decoration: none; font-weight: 500; } .events a:hover { text-decoration: underline; }
.events time { color: var(--muted); font-variant-numeric: tabular-nums; }
.kind { font-size: .72rem; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; margin-right: 4px; white-space: nowrap; }

/* Forms */
form.stack, .dialog-body { display: grid; gap: 14px; }
form.stack > button { justify-self: start; }
fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 10px; min-width: 0; }
fieldset:disabled { opacity: .65; }
hr { border: 0; border-top: 1px solid var(--line); width: 100%; margin: 2px 0; }
label { display: grid; gap: 6px; color: var(--text-2); font-size: .88rem; font-weight: 500; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: .92rem; color: var(--text); cursor: pointer; }
label.check input { margin: 3px 0 0; flex: none; width: 16px; height: 16px; }
input:not([type=radio]):not([type=checkbox]), select { width: 100%; padding: 10px 12px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--field); color: var(--text); font: inherit; font-weight: 400; transition: border-color .2s, box-shadow .2s; }
input:not([type=radio]):not([type=checkbox]):focus, select:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px rgb(175 17 17 / .15); }
input[type=radio], input[type=checkbox] { accent-color: var(--primary); }
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; border: 2px solid transparent; border-radius: var(--radius);
  background: var(--primary); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .2s, transform .2s, box-shadow .2s; }
button:hover, .btn:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid rgb(175 17 17 / .4); outline-offset: 2px; }
button.destructive { background: var(--critical); } button.destructive:hover { background: var(--primary-dark); }
button.ghost { background: transparent; color: inherit; border-color: currentColor; }
button.ghost:hover { background: color-mix(in srgb, currentColor 10%, transparent); box-shadow: none; }
button.quiet { background: transparent; color: var(--text-2); border-color: var(--line); font-weight: 500; }
button.quiet:hover { background: var(--bg); color: var(--link); box-shadow: none; transform: none; }
td button.quiet { padding: 5px 12px; font-size: .85rem; }

/* Dialogs */
dialog { border: 0; border-radius: var(--radius-lg); padding: 0; background: var(--card); color: var(--text); box-shadow: 0 16px 48px rgb(0 0 0 / .3);
  width: calc(100vw - 32px); max-width: 460px; max-height: calc(100vh - 32px); overflow: auto; border-top: 4px solid var(--primary); }
dialog.wide { max-width: 680px; }
dialog::backdrop { background: rgb(0 0 0 / .5); }
.dialog-body { padding: 24px; }
.dialog-body h2 { font-size: 1.25rem; margin: 0; overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.dialog-actions.split { justify-content: space-between; align-items: center; }
.dialog-actions .right { display: flex; gap: 10px; }
.choice { gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 14px; }
details.alt { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }
details.alt summary { cursor: pointer; color: var(--muted); font-size: .88rem; }
details.alt p { margin: 8px 0 2px; }
pre.log { margin-top: 8px; max-height: 320px; overflow: auto; white-space: pre; overflow-wrap: normal; font-size: .78rem; color: var(--text); }
.copy { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: start; margin-top: 8px; }

/* Login */
.login-hero { flex: 1; display: grid; place-items: center; padding: 32px 16px; background: linear-gradient(135deg, var(--card) 0%, var(--bg) 100%); }
.login-card { width: 100%; max-width: 880px; display: grid; grid-template-columns: 1fr 1fr; background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.login-pitch { background: var(--gradient); color: #fff; padding: 40px 36px; display: flex; flex-direction: column; justify-content: center; gap: 14px; min-width: 0; }
.login-pitch h1 { font-size: 2rem; display: block; }
.login-pitch p { margin: 0; font-size: 1.05rem; }
.login-pitch ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 12px; }
.login-pitch li { display: flex; gap: 12px; align-items: flex-start; font-size: .92rem; }
.login-pitch li::before { content: "✓"; flex: none; width: 24px; height: 24px; border-radius: 50%; background: rgb(255 255 255 / .2); display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.login-form { padding: 40px 36px; display: grid; gap: 16px; align-content: center; min-width: 0; }
.login-form h2 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.login-form form button { justify-self: stretch; padding: 12px; }
.btn-ms { background: var(--card); color: var(--text); border-color: var(--line); padding: 12px 16px; }
.btn-ms:hover { background: var(--bg); color: var(--text); border-color: var(--muted); }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .85rem; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .counts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .container { padding: 0 14px; }
  .header-content { gap: 10px; height: 56px; }
  .logo .tagline, .menu .name { display: none; }
  .nav-link { padding: 8px 10px; }
  .counts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .page-head { align-items: stretch; flex-direction: column; }
  .login-card { grid-template-columns: 1fr; }
  .login-pitch { padding: 24px 20px; } .login-pitch ul { display: none; } .login-pitch h1 { font-size: 1.5rem; }
  .login-form { padding: 24px 20px; }
  .events li { grid-template-columns: 1fr; gap: 0; }
  /* The fleet table becomes a list of cards: no sideways scrolling on a phone. */
  #fleet, #fleet tbody, #fleet tr, #fleet td { display: block; }
  #fleet thead { display: none; }
  #fleet tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  #fleet tr:last-child { border-bottom: 0; padding-bottom: 0; }
  #fleet td { border: 0; padding: 2px 0; max-width: none; }
  #fleet td:nth-child(3) { font-size: 1.05rem; }
  #fleet td:nth-child(4), #fleet td:nth-child(5) { display: inline-block; margin-right: 12px; color: var(--muted); font-size: .85rem; }
  #fleet td:nth-child(7) { color: var(--muted); font-size: .85rem; }
  .copy { grid-template-columns: 1fr; }
  .dialog-body { padding: 18px; }
  .kv > div { flex-direction: column; gap: 0; } .kv dd { text-align: left; }
}
