/* ==========================================================================
   GEOLOC-IN — feuille de style unique
   Langage visuel reprenant CLAUDE-EVERYWHERE : variables CSS, theme clair
   et sombre par data-theme, accent terracotta / bleu, echelle typographique
   serree, libelles micro-capitales, un seul point de rupture a 768 px.
   Aucun build, aucune dependance, aucune police distante.
   ========================================================================== */

/* --- Jetons --------------------------------------------------------------- */
:root {
    color-scheme: light;
    --bg:       #faf8f5;
    --sidebar:  #f2eee9;
    --surface:  #fffdfb;
    --surface2: #f7f2ed;
    --line:     #e6ddd4;
    --line2:    #d6c9bd;
    --text:     #2b2929;
    --muted:    #817a76;
    --muted2:   #625b56;
    --accent:   #ba5f41;
    --accent2:  #9f482f;
    --accentbg: #f9e9e0;
    --good:     #31856c;
    --warning:  #ad741f;
    --info:     #2462c5;
    --red:      #c44d4d;
    --shadow:   rgba(68, 42, 22, .05);
    --radius:   15px;
    --rsm:      10px;
    --sans: "Söhne", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg:       #0b111b;
    --sidebar:  #0e1724;
    --surface:  #141e2c;
    --surface2: #182536;
    --line:     #283649;
    --line2:    #37485d;
    --text:     #eef3fa;
    --muted:    #8496ac;
    --muted2:   #a5b3c5;
    --accent:   #77a6ff;
    --accent2:  #4e7ed5;
    --accentbg: #182b49;
    --good:     #5fd4a0;
    --warning:  #eabc77;
    --info:     #57aaff;
    --red:      #ed8989;
    --shadow:   rgba(1, 7, 15, .31);
    --radius:   13px;
    --rsm:      9px;
}

/* --- Socle --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 13px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 700; }
h1 { font-size: 24px; letter-spacing: -.045em; font-weight: 740; }
h2 { font-size: 16px; letter-spacing: -.02em; }
h3 { font-size: 14px; letter-spacing: -.012em; }
p  { margin: 0 0 10px; }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: transparent; }
button:disabled { cursor: not-allowed; opacity: .5; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

code, .mono, pre { font-family: var(--mono); font-size: 12px; }

hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* --- Mise en page -------------------------------------------------------- */
.shell { display: flex; min-height: 100dvh; }

.sidebar {
    width: 270px;
    flex: 0 0 270px;
    background: var(--sidebar);
    border-right: 1px solid var(--line);
    padding: 20px 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.workspace { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: 64px;
    flex: 0 0 64px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 22px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar .spacer { flex: 1 1 auto; }

.mainview { flex: 1 1 auto; padding: 26px 22px 60px; }
.column   { width: min(100%, 900px); margin: 0 auto; }
.column.wide { width: min(100%, 1180px); }

/* --- Marque -------------------------------------------------------------- */
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 14px; }
.brand img, .brand svg { width: 30px; height: 30px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 13px; font-weight: 780; letter-spacing: -.01em; }
.brand-text span {
    font-size: 9px; font-weight: 650; text-transform: uppercase;
    letter-spacing: .18em; color: var(--accent);
}

/* --- Navigation ---------------------------------------------------------- */
.nav { display: flex; flex-direction: column; gap: 2px; }

.navlink {
    display: flex; align-items: center; gap: 11px;
    min-height: 40px; padding: 0 12px;
    border-radius: var(--rsm);
    font-size: 13px; color: var(--muted2);
    text-decoration: none;
}
.navlink:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.navlink[aria-current="page"] { background: var(--accentbg); color: var(--accent); font-weight: 650; }
.navlink svg { flex: 0 0 16px; }
.navlink .count {
    margin-left: auto;
    font: 650 10px var(--mono);
    border: 1px solid var(--line2);
    padding: 2px 6px; border-radius: 5px;
    color: var(--muted);
}
.navlink .count.hot { border-color: var(--red); color: var(--red); }

.nav-section {
    font-size: 10px; font-weight: 730; text-transform: uppercase;
    letter-spacing: .09em; color: var(--muted);
    padding: 16px 12px 6px;
}

.side-bottom { margin-top: auto; padding: 10px 12px 0; border-top: 1px solid var(--line); }

/* --- Cartes -------------------------------------------------------------- */
.card {
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 3px 15px var(--shadow);
    margin-bottom: 16px;
}
.card.flat { box-shadow: none; }
.card.pad0 { padding: 0; overflow: hidden; }

.eyebrow {
    font-size: 10px; font-weight: 730; text-transform: uppercase;
    letter-spacing: .09em; color: var(--muted);
    margin-bottom: 10px;
}

.card-head {
    display: flex; align-items: center; gap: 12px;
    flex-wrap: wrap; margin-bottom: 14px;
}
.card-head .spacer { flex: 1 1 auto; }

.lead { color: var(--muted2); font-size: 13px; }
.hint { color: var(--muted); font-size: 11px; margin-top: 4px; }

/* --- Tuiles -------------------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile {
    border: 1px solid var(--line); background: var(--surface);
    border-radius: var(--radius); padding: 15px 16px;
}
.tile .n { font-size: 26px; font-weight: 740; letter-spacing: -.04em; line-height: 1.1; }
.tile .k { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.tile.alert .n { color: var(--red); }
.tile.good  .n { color: var(--good); }
.tile.warn  .n { color: var(--warning); }

/* --- Boutons ------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border: 1px solid var(--line2);
    background: var(--surface2);
    color: var(--text);
    padding: 9px 13px;
    border-radius: var(--rsm);
    font-size: 12px; font-weight: 600;
    text-decoration: none;
    transition: background-color .12s, border-color .12s, color .12s;
    white-space: nowrap;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn svg { flex: 0 0 auto; }

.btn-primary {
    background: var(--accent); border-color: var(--accent);
    color: #fff; font-weight: 750; padding: 10px 15px;
}
.btn-primary:hover { background: var(--accent2); border-color: var(--accent2); color: #fff; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--muted2); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); border-color: transparent; }

.btn-danger { color: var(--red); border-color: var(--line2); }
.btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }

.btn-sm { padding: 6px 10px; font-size: 11px; }
.btn-block { width: 100%; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* --- Formulaires --------------------------------------------------------- */
.field { margin-bottom: 14px; }

.label {
    display: block;
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .08em; color: var(--muted);
    margin-bottom: 6px;
}

.input, select.input, textarea.input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line2);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--rsm);
    font-size: 13px;
}
.input::placeholder { color: var(--muted); }
.input:focus {
    border-color: var(--accent); outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.input.mono { font-family: var(--mono); font-size: 12px; }
textarea.input { resize: vertical; min-height: 72px; }
select.input { appearance: none; background-image: none; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }

.check { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 10px; font-size: 13px; }
.check input { margin-top: 3px; flex: 0 0 auto; }
.check span small { display: block; color: var(--muted); font-size: 11px; }

/* --- Pastilles ----------------------------------------------------------- */
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 11px; font-weight: 600;
    white-space: nowrap;
}
.pill::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; flex: 0 0 6px;
}
.pill.nodot::before { display: none; }
.pill-good    { color: var(--good);    border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.pill-warning { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.pill-red     { color: var(--red);     border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.pill-info    { color: var(--info);    border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.pill-accent  { color: var(--accent);  border-color: transparent; background: var(--accentbg); }
.pill-muted   { color: var(--muted);   border-color: var(--line); }

.tag {
    display: inline-block;
    font: 600 10px var(--mono);
    color: var(--muted); border: 1px solid var(--line);
    padding: 2px 6px; border-radius: 5px;
}

/* Double point de sante : SMS d'un cote, flux Traccar de l'autre */
.health { display: inline-flex; align-items: center; gap: 4px; }
.health i {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--line2); display: block;
}
.health i.on  { background: var(--good); }
.health i.off { background: var(--red); }
.health i.na  { background: var(--line2); }

/* --- Listes -------------------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 0;
    border-top: 1px solid var(--line);
}
.list > li:first-child { border-top: 0; }
.list > li .spacer { flex: 1 1 auto; min-width: 0; }
.list.boxed { border: 1px solid var(--line); border-radius: var(--rsm); padding: 0 14px; }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Tableaux (seulement pour les grilles admin denses) ------------------ */
.table { width: 100%; border-collapse: collapse; font-size: 12px; }
.table th {
    text-align: left;
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .08em; color: var(--muted);
    padding: 8px 10px; border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-family: var(--mono); }
.table-wrap { overflow-x: auto; }

/* --- Bandeaux ------------------------------------------------------------ */
.banner {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: var(--rsm);
    font-size: 12px;
    margin-bottom: 14px;
}
.banner svg { flex: 0 0 16px; margin-top: 1px; }
.banner-ok   { color: var(--good);    border-color: color-mix(in srgb, var(--good) 30%, transparent);    background: color-mix(in srgb, var(--good) 8%, transparent); }
.banner-warn { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 32%, transparent); background: color-mix(in srgb, var(--warning) 9%, transparent); }
.banner-err  { color: var(--red);     border-color: color-mix(in srgb, var(--red) 32%, transparent);     background: color-mix(in srgb, var(--red) 9%, transparent); }
.banner-info { color: var(--info);    border-color: color-mix(in srgb, var(--info) 30%, transparent);    background: color-mix(in srgb, var(--info) 8%, transparent); }
.banner strong { font-weight: 700; }

/* --- Fil d'Ariane -------------------------------------------------------- */
.crumb { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; min-width: 0; }
.crumb a { color: var(--muted); }
.crumb strong { color: var(--text); font-weight: 650; }

/* --- Chronologie du provisionnement -------------------------------------- */
.steps { list-style: none; margin: 0; padding: 0; }
.steps > li { display: flex; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.steps > li:first-child { border-top: 0; }

.steps .seq {
    flex: 0 0 24px; height: 24px;
    border-radius: 50%; border: 1px solid var(--line2);
    display: grid; place-items: center;
    font: 700 10px var(--mono); color: var(--muted);
}
.steps li.ok   .seq { border-color: var(--good);    color: var(--good); }
.steps li.wait .seq { border-color: var(--warning); color: var(--warning); }
.steps li.bad  .seq { border-color: var(--red);     color: var(--red); }

.steps .body { flex: 1 1 auto; min-width: 0; }
.steps .step-title { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 7px; }
.steps .step-title strong { font-size: 13px; font-weight: 650; }

/* Le SMS exact et la reponse exacte, en mono : ce sont des chaines que
   l'operateur doit pouvoir comparer caractere par caractere. */
.sms {
    font-family: var(--mono); font-size: 11.5px;
    background: var(--surface2);
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 7px 9px;
    white-space: pre-wrap; word-break: break-word;
    margin: 0 0 6px;
}
.sms-out { border-left: 2px solid var(--accent); }
.sms-in  { border-left: 2px solid var(--good); }
.sms-label {
    font-size: 9px; font-weight: 730; text-transform: uppercase;
    letter-spacing: .09em; color: var(--muted); margin-bottom: 3px;
}
.step-meta { font-size: 11px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }

/* --- Conversation SMS ---------------------------------------------------- */
.convo { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.convo > li { display: flex; }
.convo .bubble {
    max-width: min(78%, 560px);
    font-family: var(--mono); font-size: 11.5px;
    padding: 8px 11px;
    border: 1px solid var(--line);
    white-space: pre-wrap; word-break: break-word;
}
.convo .meta { font-size: 10px; color: var(--muted); margin-top: 4px; font-family: var(--sans); }
.convo li.out { justify-content: flex-end; }
.convo li.out .bubble { background: var(--accentbg); border-color: transparent; border-radius: 13px 13px 3px 13px; }
.convo li.in  .bubble { background: var(--surface2); border-radius: 13px 13px 13px 3px; }

/* --- Interrupteur Privacy (vue client) ----------------------------------- */
.switch {
    display: flex; gap: 4px; padding: 4px;
    background: var(--surface2);
    border: 1px solid var(--line);
    border-radius: 999px;
}
.switch button {
    flex: 1 1 0; padding: 11px 14px;
    border-radius: 999px;
    font-size: 13px; font-weight: 650;
    color: var(--muted2);
}
.switch button[aria-pressed="true"] {
    background: var(--surface); color: var(--text);
    box-shadow: 0 1px 5px var(--shadow); font-weight: 720;
}
.switch button[aria-pressed="true"].on { background: var(--accent); color: #fff; }
.switch button:disabled { opacity: .55; cursor: not-allowed; }

.client-card { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.client-card h3 { margin-bottom: 3px; }
.client-state { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.client-state .big { font-size: 17px; font-weight: 740; letter-spacing: -.02em; }

/* --- Page de connexion --------------------------------------------------- */
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { justify-content: center; padding-bottom: 20px; }

/* --- Divers -------------------------------------------------------------- */
.empty { text-align: center; padding: 34px 20px; color: var(--muted); font-size: 12px; }
.empty svg { opacity: .4; margin-bottom: 10px; }

.muted  { color: var(--muted); }
.muted2 { color: var(--muted2); }
.small  { font-size: 11px; }
.nowrap { white-space: nowrap; }
.right  { text-align: right; }
.mb0 { margin-bottom: 0; }
.mt16 { margin-top: 16px; }

details > summary { cursor: pointer; color: var(--muted2); font-size: 12px; }
details > summary:hover { color: var(--text); }
details[open] > summary { margin-bottom: 10px; }

.unverified {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 10px; font-weight: 730; text-transform: uppercase; letter-spacing: .06em;
    color: var(--warning);
    border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent);
    background: color-mix(in srgb, var(--warning) 10%, transparent);
    padding: 2px 7px; border-radius: 5px;
}

/* --- Tiroir mobile ------------------------------------------------------- */
.burger { display: none; }
.scrim { display: none; }

@media (max-width: 768px) {
    .sidebar {
        position: fixed; inset: 0 auto 0 0; z-index: 40;
        width: 86%; max-width: 310px;
        transform: translateX(-100%);
        transition: transform .18s ease-out;
        box-shadow: 0 0 40px var(--shadow);
    }
    body.drawer-open .sidebar { transform: translateX(0); }
    body.drawer-open .scrim {
        display: block; position: fixed; inset: 0; z-index: 30;
        background: rgba(0, 0, 0, .42);
    }
    .burger { display: inline-flex; }
    .topbar { padding: 0 14px; gap: 10px; }
    .mainview { padding: 18px 14px 48px; }
    .grid2, .grid3 { grid-template-columns: 1fr; }
    .tiles { grid-template-columns: 1fr 1fr; }
    h1 { font-size: 21px; }
    .card { padding: 16px; }
    .crumb { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
