/* Terrain's agenda: the office's (UNO's AgendaPanel on a phone, after Google
   Agenda) cut down to one technician's day. The same header and week strip,
   the same hour grid with the plage behind it and the red line for now, the
   same solid status-coloured cards with white text, and the office's preview
   rising from the bottom, where the job is read, activated and closed.
   Colours: styles.css carries the office agenda's palette. */

/* Status colours: UNO's --st-*, one per status, the same on black and on
   white. Notes, the now line and the plage follow the scheme. */
:root{--st-planned:#f6bf26;--st-confirmed:#3f51b5;--st-needs_review:#d81b60;--st-blocked:#c5221f;--st-cancelled:#5f6368;--st-in_progress:#7e57c2;--st-completed:#0b8043;--st-note:#9aa0a6;--ag-now:#f28b82;--ag-note-bg:#35373a;--ag-note-line:#5f6368}
@media(prefers-color-scheme:light){:root{--st-note:#5f6368;--ag-now:#d93025;--ag-note-bg:#f1f3f4;--ag-note-line:#dadce0}}

/* Header: the title and its tools; ‹ the month › and Aujourd'hui; the week. */
.ag-top{position:sticky;top:env(safe-area-inset-top);z-index:20;padding:4px 8px 0;background:var(--bg);border-bottom:1px solid var(--border)}
.ag-top-row{display:flex;align-items:center;gap:2px;min-height:48px}
.ag-top-title{flex:1;min-width:0;display:flex;align-items:baseline;gap:8px;padding-left:6px}
.ag-top-title h1{margin:0;font-size:20px;font-weight:600}
.ag-top-title .muted{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-size:13px}
.ag-pill{min-height:36px;padding:6px 14px;border:1px solid var(--border);border-radius:999px;background:var(--surface);color:var(--text);font:inherit;font-size:14px;font-weight:600}
.ag-icon{display:inline-grid;place-items:center;width:44px;height:44px;padding:0;border:0;border-radius:50%;background:transparent;color:var(--muted);flex:none}
.ag-icon:active{background:var(--surface-2)}
.ag-icon:disabled{opacity:.4}
.ag-icon svg,.ag-month svg,.tn-ind svg,.js-icon{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.ag-month-row{display:flex;align-items:center;min-width:0}
.ag-month{position:relative;flex:1;min-width:0;display:flex;align-items:center;justify-content:center;gap:6px;padding:8px 0;font-size:16px;font-weight:600;white-space:nowrap}
.ag-month svg{width:16px;height:16px;color:var(--muted)}
/* The date field lies invisibly over the month: a tap opens the phone's picker. */
.ag-month input{position:absolute;inset:0;width:100%;height:100%;opacity:0;border:0;padding:0;min-height:0}
/* Aujourd'hui, the office's pill: its colour, a dot of the accent. */
.ag-today{display:inline-flex;align-items:center;gap:8px;flex:none;min-height:40px;margin-left:4px;padding:0 12px;border:1px solid color-mix(in srgb,var(--accent) 28%,var(--surface));border-radius:12px;background:var(--accent-soft);color:var(--accent-text);font:inherit;font-size:13px;font-weight:650}
.ag-today::before{content:'';width:7px;height:7px;flex:none;border-radius:50%;background:var(--accent)}

/* The week: the letter over the date, the chosen day in a filled circle on
   its tinted cell, today in the accent, a dot under a day with a job. */
.agenda-week{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:2px;padding:6px 0 8px}
.wk-day{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;min-height:60px;padding:4px 0;border:0;border-radius:12px;background:transparent;color:var(--text);font:inherit}
.wk-letter{font-size:12px;color:var(--muted);text-transform:uppercase}
.wk-number{display:grid;place-items:center;width:28px;height:28px;border-radius:50%;font-size:18px;font-weight:500;font-variant-numeric:tabular-nums}
.wk-day.is-today .wk-number{color:var(--accent-text);font-weight:700}
.wk-day[aria-pressed=true]{background:var(--selection)}
.wk-day[aria-pressed=true] .wk-number{background:var(--accent);color:var(--on-accent)}
.wk-dot{width:4px;height:4px;border-radius:50%;background:transparent}
.wk-dot.has-events{background:var(--muted)}

/* The day: its date, its plage, how fresh the copy is; then the grid. */
.agenda-main{width:100%;max-width:640px;margin:0 auto;padding:4px 8px 110px}
.ag-day-head{display:flex;flex-wrap:wrap;align-items:center;gap:4px 10px;margin:8px 4px}
.ag-day-head h2{margin:0;font-size:15px;font-weight:600}
.ag-plage-chip{padding:1px 9px;border:1px solid var(--border);border-radius:999px;font-size:12px;font-weight:600;line-height:18px;color:var(--muted);white-space:nowrap}
.ag-plage-chip.is-off{border-style:dashed}
.ag-day-head .muted{flex-basis:100%;margin:0;font-size:12px}
.agenda-none{margin:0 4px 8px;font-size:13px;color:var(--muted)}
.agenda-empty{margin:18px 0;padding:40px 18px;text-align:center;border:1px dashed var(--border);border-radius:16px;color:var(--muted)}
.agenda-empty.is-loading{border-style:solid;animation:ag-wait 1.4s ease-in-out infinite}
@keyframes ag-wait{50%{opacity:.55}}

/* Today's shift, at the top of the agenda: started or not, one tap to start. */
.ag-shift{display:flex;align-items:center;gap:10px;margin:6px 0 2px;padding:6px 6px 6px 14px;border:1px solid var(--border);border-radius:999px;background:var(--surface)}
.ag-shift-label{flex:1;min-width:0;min-height:40px;padding:0;border:0;background:transparent;color:var(--text);font:inherit;font-size:14px;font-weight:600;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.ag-shift.is-on .ag-shift-label{color:var(--ok)}
.agenda-main .ag-shift-start{flex:none;min-height:40px;padding:0 18px;border:0;border-radius:999px;background:var(--accent);color:var(--on-accent);font:inherit;font-size:14px;font-weight:700}
.agenda-main .ag-shift-start:disabled{opacity:.5}

/* The hour grid (the office's .ag-grid in its day view). */
.tg{display:grid;grid-template-columns:44px minmax(0,1fr);border:1px solid var(--border);border-radius:10px;overflow:hidden;background:var(--surface)}
.tg-hours{position:relative;border-right:1px solid var(--border)}
.tg-hours span{position:absolute;right:6px;font-size:11px;color:var(--muted);transform:translateY(-50%);font-variant-numeric:tabular-nums}
.tg-hours span:first-child{transform:translateY(2px)}
.tg-day{position:relative;background:repeating-linear-gradient(to bottom,transparent 0,transparent calc(var(--hour) - 1px),var(--border) calc(var(--hour) - 1px),var(--border) var(--hour))}
/* The plage behind the cards, as Google showed « PLAGE 8@5 »: a faint block
   in the technician's colour (--plage-color, set by agenda.js), grey without one. */
.tg-plage{position:absolute;left:2px;right:2px;z-index:1;pointer-events:none;border-left:3px solid color-mix(in srgb,var(--plage-color,var(--muted)) 55%,transparent);border-radius:6px;background:color-mix(in srgb,var(--plage-color,var(--muted)) 13%,transparent)}
.tg-plage span{position:absolute;top:4px;left:7px;right:6px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-size:11px;font-weight:600;color:color-mix(in srgb,var(--plage-color,var(--muted)) 65%,var(--text))}
/* A job: solid in its status colour, white text, as the office's cards. */
.tg-event{position:absolute;z-index:2;display:flex;flex-direction:column;gap:1px;min-width:0;margin:0;padding:5px 8px;border:1px solid var(--event);border-radius:5px;background:var(--event);color:#fff;font:inherit;text-align:left;overflow:hidden;container:tgcard/size;-webkit-tap-highlight-color:transparent}
.tg-event:active{filter:brightness(1.08)}
.tg-head{display:flex;align-items:baseline;gap:6px;min-width:0}
/* Done by the technician: a check before the hour, in the card's white. */
.tg-done{flex:none;align-self:center;width:12px;height:12px;margin-right:-3px;fill:none;stroke:currentColor;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round}
.tg-time{flex:none;font-size:11px;line-height:15px;font-variant-numeric:tabular-nums}
.tg-refs{min-width:0;margin-left:auto;font-size:11px;line-height:15px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tg-title{font-size:14px;font-weight:600;line-height:17px;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;flex-shrink:0}
.tg-sub{font-size:11px;line-height:15px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tg-event.status-cancelled .tg-title{text-decoration:line-through}
/* Under an hour: no room for two lines of name. Half an hour: one line. */
@container tgcard (max-height:70px){.tg-title{-webkit-line-clamp:1}}
@container tgcard (max-height:50px){.tg-sub{display:none}}
.tg-event.is-tiny{flex-direction:row;align-items:center;gap:6px;padding:2px 6px}
.tg-event.is-tiny .tg-head{flex:none}
.tg-event.is-tiny .tg-refs,.tg-event.is-tiny .tg-sub{display:none}
.tg-event.is-tiny .tg-title{flex:1;min-width:0;display:block;white-space:nowrap;text-overflow:ellipsis}
/* A note: the office's muted block, unless the office coloured it in Google. */
.tg-event.is-note:not(.is-colored){border-style:dashed;border-color:var(--ag-note-line);border-left:3px solid var(--event);background:var(--ag-note-bg);color:var(--text)}
.tg-event.is-note:not(.is-colored) .tg-sub{color:var(--muted)}
.tg-now{position:absolute;left:0;right:0;z-index:4;height:2px;background:var(--ag-now);pointer-events:none}
.tg-now::before{content:'';position:absolute;left:-5px;top:-4px;width:10px;height:10px;border-radius:50%;background:var(--ag-now)}

/* Bottom bar, Material style: an icon in a pill that fills for the current screen. */
.terrain-nav{position:fixed;bottom:0;left:0;right:0;z-index:40;display:flex;padding:6px 12px calc(8px + env(safe-area-inset-bottom));background:var(--bg);border-top:1px solid var(--border)}
.terrain-nav[hidden]{display:none}
.terrain-nav button{flex:1;display:flex;flex-direction:column;align-items:center;gap:3px;min-height:56px;padding:4px 0;border:0;background:transparent;color:var(--muted);font:inherit;font-size:12px;font-weight:600}
.tn-ind{display:grid;place-items:center;width:60px;height:30px;border-radius:999px}
.terrain-nav button[aria-current=true]{color:var(--text)}
.terrain-nav button[aria-current=true] .tn-ind{background:var(--accent-soft);color:var(--accent-text)}
.terrain-nav button:disabled{opacity:.45}
#view-clock{padding-bottom:100px}
.ag-top button:focus-visible,.agenda-main button:focus-visible,.terrain-nav button:focus-visible,.job-sheet :is(button,a,input):focus-visible{outline:2px solid var(--accent);outline-offset:2px}

/* ── A job: the office's preview, from the bottom (its .ag-preview on a phone). */
html.sheet-open body{overflow:hidden}
.job-sheet{position:fixed;inset:0;z-index:44}
.job-sheet[hidden]{display:none}
.job-sheet-backdrop{position:absolute;inset:0;background:rgba(0,0,0,.42);animation:js-fade .18s ease-out both}
.job-sheet-panel{position:absolute;left:8px;right:8px;bottom:8px;max-width:620px;max-height:calc(100dvh - env(safe-area-inset-top) - 20px);margin:0 auto;overflow-y:auto;overscroll-behavior:contain;padding:8px 16px calc(16px + env(safe-area-inset-bottom));border:1px solid var(--border);border-radius:20px;background:var(--elevated);box-shadow:var(--shadow);animation:js-up .26s cubic-bezier(.16,1,.3,1) both}
@keyframes js-up{from{opacity:0;transform:translateY(18px) scale(.96)}to{opacity:1;transform:none}}
@keyframes js-fade{from{opacity:0}}
.js-tools{display:flex;justify-content:flex-end;margin:0 -8px 2px 0}
.js-close{display:grid;place-items:center;width:44px;height:44px;padding:0;border:0;border-radius:50%;background:transparent;color:var(--muted)}
.js-close:active{background:var(--surface-2)}
.js-head,.js-row{display:grid;grid-template-columns:16px minmax(0,1fr);gap:14px;align-items:start}
.js-swatch{width:16px;height:16px;margin-top:5px;border-radius:4px}
.js-head h3{margin:0;font-size:20px;font-weight:600;line-height:1.3;overflow-wrap:anywhere}
.js-sub{margin:3px 0 0;font-size:12px;color:var(--muted);overflow-wrap:anywhere}
.js-when{margin:5px 0 0;font-size:14px;color:var(--muted)}
.js-office-note{margin-top:14px;padding:9px 11px;border-left:3px solid var(--event);border-radius:6px;background:color-mix(in srgb,var(--event) 13%,transparent)}
.js-office-note>span{display:block;margin-bottom:4px;font-size:11px;font-weight:650;letter-spacing:.04em;text-transform:uppercase;color:var(--muted)}
.js-office-note>p{margin:0;font-size:14px;line-height:1.5;white-space:pre-wrap;overflow-wrap:anywhere}
.js-rows{display:flex;flex-direction:column;gap:12px;margin-top:18px}
.js-row{font-size:15px;line-height:1.45}
.js-row>.js-icon{width:16px;height:16px;margin-top:2px;color:var(--muted)}
.js-row p{margin:0;min-width:0;overflow-wrap:anywhere}
.js-row small{display:block;font-size:13px;color:var(--muted);overflow-wrap:anywhere}
.js-dot{width:10px;height:10px;margin:6px 3px 0;border-radius:50%}
.job-sheet a{color:inherit;text-decoration:underline;text-decoration-color:color-mix(in srgb,currentColor 35%,transparent);text-underline-offset:3px}
.js-actions{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:8px;margin-top:16px}
.job-sheet .js-actions a{display:flex;align-items:center;justify-content:center;gap:8px;min-height:46px;border:1px solid var(--border);border-radius:999px;background:var(--surface-2);font-size:15px;font-weight:600;text-decoration:none}
.js-actions .js-icon{width:18px;height:18px}
.js-vehicles{margin-top:18px}
.js-vehicles h4{margin:0 0 8px;font-size:12px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--muted)}
.js-finish{margin-top:16px}
.js-terminate{width:100%;min-height:50px;border:0;border-radius:999px;background:var(--accent);color:var(--on-accent);font:inherit;font-size:16px;font-weight:700}
.js-terminate:disabled{opacity:.45}
/* Terminer l'installation waits for every vehicle to be confirmed. */
.js-finish-hint{margin:0;padding:12px 14px;border:1px dashed var(--border);border-radius:14px;color:var(--muted);font-size:14px;line-height:1.45;text-align:center}
.js-done{display:flex;align-items:center;justify-content:center;gap:8px;min-height:50px;margin:0;border-radius:999px;background:var(--event);color:#fff;font-size:15px;font-weight:700}

/* A vehicle, in the sheet: its stock number and the end of its NIV are what
   gets looked for on a lot; its module's activation under it. */
.tc-vehicle{margin-top:8px;padding:12px;border:1px solid var(--border);border-radius:12px;background:var(--surface)}
.tc-vehicle-head{display:flex;align-items:baseline;justify-content:space-between;gap:10px}
.tc-vehicle-head strong{font-size:15px}
.tc-stock{flex-shrink:0;font-size:15px;font-weight:700;font-variant-numeric:tabular-nums}
.tc-specs{display:grid;grid-template-columns:auto 1fr;gap:4px 14px;margin:8px 0 0;font-size:13px}.tc-specs dt{color:var(--muted)}
.tc-specs dd{margin:0;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:14px;letter-spacing:.3px;overflow-wrap:anywhere}
.tc-specs dd span{color:var(--muted)}
.tc-specs dd b{font-size:16px;font-weight:700}
.tc-act{margin-top:10px;padding-top:10px;border-top:1px solid var(--border)}
.tc-act-state{margin:0;font-size:15px;font-weight:650;line-height:1.4}
.tc-act-detail{margin:4px 0 0;font-size:13px;color:var(--muted);overflow-wrap:anywhere}
.tc-act.is-confirmed .tc-act-state{color:var(--ok)}
.job-sheet .tc-act button{min-height:44px;padding:0 16px;border:1px solid var(--border);border-radius:999px;background:var(--surface-2);color:var(--text);font:inherit;font-size:14px;font-weight:700}
.job-sheet .tc-act > button{width:100%;margin-top:10px}
.job-sheet .tc-act > button:first-child{margin-top:0}
.job-sheet .tc-act button.is-primary{background:var(--accent);border-color:var(--accent);color:var(--on-accent)}
.job-sheet .tc-act button:disabled{opacity:.45}
.tc-act-form{display:grid;gap:10px}
.tc-act-form label{display:grid;gap:4px;font-size:12px;font-weight:700;letter-spacing:.4px;color:var(--muted)}
.tc-act-form input{width:100%;min-height:48px;padding:0 12px;border:1px solid var(--border);border-radius:12px;background:var(--bg);color:var(--text);font:inherit;font-size:17px}
.tc-act-error{margin:0;font-size:14px;line-height:1.45;color:var(--danger)}
.tc-act-buttons{display:grid;grid-template-columns:1fr 2fr;gap:8px}
.tc-act-alt{display:flex;gap:8px}
.job-sheet .tc-act .tc-act-alt button{flex:1;min-height:40px;background:transparent;font-weight:600}
.tc-act-ok{margin:0;font-size:14px;font-weight:650;color:var(--ok);font-variant-numeric:tabular-nums}
@media(prefers-reduced-motion:reduce){.job-sheet-panel,.job-sheet-backdrop{animation:none}}

/* Not the booked car (vinRead): red, big, the office a tap away. */
.tc-act-wrong{display:grid;gap:4px;padding:14px;border-radius:12px;background:var(--danger);color:var(--on-danger)}
.tc-act-wrong strong{font-size:20px;font-weight:800;letter-spacing:.01em;text-transform:uppercase}
.tc-act-wrong p{margin:0;font-size:15px;line-height:1.4;font-weight:600;font-variant-numeric:tabular-nums}
.job-sheet .tc-act-wrong .tc-act-call{display:flex;align-items:center;justify-content:center;min-height:48px;margin-top:8px;border-radius:999px;background:var(--on-danger);color:var(--danger);font-size:16px;font-weight:800;text-decoration:none}
