/* Back office MakoConcierge : Material Design 3 à plat.
   Fond blanc, aucune ombre, bordures 1 px #DADCE0, pilules 999 px, accent #1A73E8. */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --ink: #202124;
  --muted: #5f6368;
  --line: #dadce0;
  --accent: #1a73e8;
  --accent-ink: #ffffff;
  --accent-soft: #e8f0fe;
  --ok: #188038;
  --ok-soft: #e6f4ea;
  --warn: #b06000;
  --warn-soft: #fef7e0;
  --bad: #c5221f;
  --bad-soft: #fce8e6;
  --font: Roboto, "Google Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font);
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 500; margin: 0; }
h2 { font-size: 16px; font-weight: 500; margin: 0; }
h3 { font-size: 14px; font-weight: 500; margin: 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Squelette */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100%; }
.nav {
  border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface);
}
.brand { font-weight: 500; font-size: 16px; padding: 8px 12px 14px; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.nav a.item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 14px;
  border-radius: 999px; color: var(--ink); text-decoration: none;
}
.nav a.item:hover { background: var(--surface-2); }
.nav a.item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.nav .spacer { flex: 1; }
.main { min-width: 0; padding: 24px clamp(16px, 3vw, 32px) 64px; max-width: 1180px; width: 100%; }
.topbar { display: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

@media (max-width: 859px) {
  .shell { display: block; }
  .nav {
    position: fixed; z-index: 20; inset: auto 0 0 0; height: auto; flex-direction: row; overflow-x: auto;
    border-right: 0; border-top: 1px solid var(--line); padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom));
    gap: 2px;
  }
  .nav .brand, .nav .spacer, .nav .nav-user { display: none; }
  .nav a.item { flex: none; padding: 8px 12px; font-size: 13px; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px;
    border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 10;
  }
  .main { padding-bottom: 96px; }
}

/* Composants */
.card { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); min-width: 0; }
.card-h { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.card-b { padding: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.tile .v { font-size: 26px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile .l { color: var(--muted); font-size: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 500; }
.btn.primary:hover { background: #1765cc; }
.btn.danger { color: var(--bad); border-color: var(--bad-soft); }
.btn.small { height: 28px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.pill {
  display: inline-flex; align-items: center; height: 28px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); cursor: pointer; font-size: 13px;
}
.pill.on { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent); font-weight: 500; }
.badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.open { background: var(--accent-soft); color: var(--accent); }
.badge.escalated, .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.taken, .badge.in_progress { background: #e0f2f1; color: #00695c; }
.badge.done, .badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.cancelled { background: var(--surface-2); color: var(--muted); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.banner { border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner.warn { background: var(--warn-soft); border-color: var(--warn-soft); }
.banner.bad { background: var(--bad-soft); border-color: var(--bad-soft); }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
thead th {
  position: sticky; top: 0; background: var(--surface); text-align: left; font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover, tbody tr:hover { background: var(--surface-2); }
tbody tr .hover-actions { opacity: 0; transition: opacity .1s; display: flex; gap: 6px; justify-content: flex-end; }
tbody tr:hover .hover-actions, tbody tr:focus-within .hover-actions { opacity: 1; }
@media (hover: none) { tbody tr .hover-actions { opacity: 1; } }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

/* Formulaires */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 12px; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=time], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: var(--surface); width: 100%; min-height: 38px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
textarea { resize: vertical; min-height: 84px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }

/* Dialogues */
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(32, 33, 36, .4); }
.dlg-h { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dlg-b { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.dlg-f { padding: 12px 20px 16px; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* Conversation */
.thread { display: flex; flex-direction: column; gap: 6px; padding: 14px; max-height: 460px; overflow-y: auto; background: var(--surface-2); border-radius: 0 0 12px 12px; }
.bubble { max-width: 82%; padding: 8px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); overflow-wrap: anywhere; white-space: pre-wrap; }
.bubble.client { align-self: flex-start; }
.bubble.agent, .bubble.system { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.bubble.team { align-self: flex-end; background: var(--ok-soft); border-color: transparent; }
.bubble .meta { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.composer { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); align-items: flex-end; }
.composer textarea { min-height: 38px; height: 38px; }

/* Détail ticket */
.detail { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 859px) { .detail { grid-template-columns: 1fr; } }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
ul.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
ul.timeline li { display: grid; grid-template-columns: 54px 1fr; gap: 10px; }
ul.timeline time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.dot { color: var(--muted); }

/* Liste de démarrage */
ol.todo { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
ol.todo li { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
ol.todo li:last-child { border-bottom: 0; }
ol.todo .tick { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 13px; color: var(--accent-ink); }
ol.todo li.done .tick { background: var(--ok); border-color: var(--ok); }
ol.todo li.done .t { color: var(--muted); text-decoration: line-through; }

/* Connexion */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: min(400px, 100%); }
.copybox { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 6px 6px 6px 12px; background: var(--surface-2); }
.copybox code { flex: 1; overflow-wrap: anywhere; font-size: 12.5px; }

/* Notifications */
#toasts { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
@media (min-width: 860px) { #toasts { bottom: 24px; } }
.toast { background: #303134; color: #fff; padding: 10px 18px; border-radius: 999px; max-width: min(520px, 92vw); pointer-events: auto; }
.toast.bad { background: var(--bad); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
