:root {
  --bg: #0c0e14;
  --surface: #141820;
  --surface2: #1a1f2b;
  --border: #2a3142;
  --text: #e8eaef;
  --muted: #8b92a8;
  --accent: #22c55e;
  --brand: #d62828;
  --danger: #f87171;
  --font: 'DM Sans', system-ui, sans-serif;
  --eco-h: var(--vallon-eco-bar-h, 38px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
.err { color: var(--danger); font-size: .85rem; margin-top: 8px; }
.muted { color: var(--muted); font-size: .8rem; }
.hint { color: var(--muted); font-size: .72rem; line-height: 1.4; }
.link-muted { color: var(--muted); font-size: .8rem; text-decoration: none; }
.link-muted:hover { color: var(--text); }
.app-version { font-size: .68rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.btn-primary {
  padding: 10px 16px; border: none; border-radius: 10px;
  background: linear-gradient(135deg, #16a34a, #22c55e); color: #fff; font-weight: 700; cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-text {
  padding: 8px 12px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; cursor: pointer;
}
.btn-text:hover { background: rgba(255,255,255,.06); border-color: var(--border); }
.chk { display: flex; align-items: flex-start; gap: 10px; font-size: .82rem; cursor: pointer; margin-top: 8px; line-height: 1.35; }
.chk input {
  width: 18px; height: 18px; min-width: 18px; margin: 1px 0 0;
  accent-color: var(--accent); cursor: pointer; flex-shrink: 0;
}
.chk-spaced { margin: 12px 0; padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,.03); border: 1px solid var(--border); }
.chk-fav { font-weight: 600; }
.chk-fav span { color: #fbbf24; }

.logo, .logo-icon {
  width: 36px; height: 36px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, #22c55e 14%, #0c0e14);
  border: 1px solid color-mix(in srgb, #22c55e 40%, #2a3142);
}
.logo img { display: block; }

.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% -10%, rgba(34,197,94,.15), transparent 50%), var(--bg);
}
.login-box {
  width: min(400px, 94vw); padding: 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
}
.login-brand { text-align: center; margin-bottom: 18px; }
.login-brand .logo { margin: 0 auto 12px; width: 52px; height: 52px; }
.login-box label { display: block; font-size: .72rem; color: var(--muted); margin: 12px 0 4px; }
.login-box input {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg);
}
.login-box .btn-primary { width: 100%; margin-top: 16px; }

.shell {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
}
html.vallon-has-eco-bar body .shell,
body.vallon-has-eco-bar .shell {
  height: calc(100dvh - var(--eco-h));
}
.topbar {
  height: 50px; flex-shrink: 0; display: flex; align-items: center; gap: 12px;
  padding: 0 14px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.top-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.top-brand strong { font-size: .92rem; }
.top-user { font-size: .75rem; color: var(--muted); margin-left: 6px; }
.top-search { flex: 1; max-width: 480px; }
.top-search input {
  width: 100%; padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg);
}
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.main {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 200px minmax(280px, 1fr) minmax(300px, 1.1fr);
}
.side {
  border-right: 1px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; overflow: auto; padding: 10px 8px;
}
.side-head {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 700; padding: 6px 8px 10px;
}
.cat {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  padding: 9px 10px; margin-bottom: 3px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; text-align: left; cursor: pointer;
  font-size: .84rem; gap: 8px;
}
.cat:hover { background: rgba(255,255,255,.04); }
.cat.on { background: rgba(34,197,94,.14); border-color: rgba(34,197,94,.35); color: #86efac; font-weight: 600; }
.cat-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cat-left i { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.cat-count { font-size: .72rem; color: var(--muted); font-weight: 700; flex-shrink: 0; }
.cat-custom { font-style: normal; font-size: .62rem; opacity: .7; margin-left: 4px; text-transform: uppercase; }
.side-foot { margin-top: auto; padding: 12px 8px; border-top: 1px solid var(--border); }

.list-pane { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; }
.list-tools {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.list-tools select {
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg);
}
.contact-list { flex: 1; overflow: auto; }
.c-row {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid rgba(42,49,66,.5);
  cursor: pointer; border-left: 3px solid transparent;
}
.c-row:hover { background: rgba(255,255,255,.03); }
.c-row.on { background: rgba(34,197,94,.1); border-left-color: var(--accent); }
.c-av {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem; background: var(--surface2);
}
.c-main { min-width: 0; }
.c-name { font-weight: 600; font-size: .9rem; }
.c-sub { font-size: .75rem; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-badge {
  font-size: .65rem; font-weight: 700; padding: 3px 8px; border-radius: 99px;
  background: rgba(255,255,255,.06); color: var(--muted); white-space: nowrap;
}
.c-badge.src { opacity: .75; }
.star { color: #fbbf24; font-size: .85em; }

.detail-pane { overflow: auto; padding: 18px 20px; background: var(--bg); }
.empty-detail { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty-detail h3 { color: var(--text); margin-bottom: 8px; }
.detail-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px;
}
.detail-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.detail-card h2 { font-size: 1.2rem; margin: 0; line-height: 1.3; }
.pill-cat {
  font-size: .72rem; font-weight: 700; padding: 4px 10px; border-radius: 99px;
  border: 1px solid transparent; white-space: nowrap;
}
.detail-meta { font-size: .88rem; margin-bottom: 12px; }
.meta-row {
  display: grid; grid-template-columns: 100px 1fr; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid rgba(42,49,66,.45);
}
.meta-row span { color: var(--muted); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.meta-row strong { font-weight: 600; color: var(--text); word-break: break-word; }
.meta-row a { color: #86efac; }
.meta-notes {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px;
  background: var(--surface2); color: var(--muted); font-size: .85rem; line-height: 1.45; white-space: pre-wrap;
}
.meta-src { margin-top: 10px; font-size: .72rem; color: var(--muted); }
.phone-block { margin: 10px 0; padding: 10px 12px; border-radius: 12px; background: var(--surface2); border: 1px solid var(--border); }
.phone-lab { display: block; font-size: .78rem; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions-row.tight { margin-top: 6px; }
.act {
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface2); cursor: pointer; font-weight: 600; font-size: .84rem;
  text-decoration: none; color: var(--text); display: inline-flex; align-items: center; gap: 6px;
}
.act:hover { border-color: var(--accent); color: #86efac; }
.act.danger { color: var(--danger); }
.act.gps { border-color: rgba(14,165,233,.35); }
.act.gps:hover { border-color: #38bdf8; color: #7dd3fc; }
.pill-src {
  display: inline-block; margin-left: 8px; font-size: .68rem; padding: 2px 8px;
  border-radius: 99px; background: rgba(148,163,184,.15); color: #94a3b8; vertical-align: middle;
}
.gps-block, .vcard-block {
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border);
}
.gps-title { font-size: .82rem; font-weight: 700; margin-bottom: 8px; }

.modal[hidden] { display: none !important; }
.modal {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.panel {
  width: min(440px, 100%); max-height: 90vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
}
.panel-lg { width: min(560px, 100%); }
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.panel-body { padding: 14px 16px 18px; }
.panel-body label { display: block; font-size: .72rem; color: var(--muted); margin: 0 0 4px; font-weight: 600; }
.panel-body input, .panel-body select, .panel-body textarea {
  width: 100%; padding: 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg);
}
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px 12px;
}
.form-grid .fg-full { grid-column: 1 / -1; }
.form-row { display: flex; gap: 8px; margin-top: 16px; align-items: center; }
.cat-add-row { display: flex; gap: 8px; margin: 12px 0; align-items: center; }
.cat-add-row input { flex: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text, inherit); }
/* Formulaire de création SOUS la liste (ordre logique : voir → créer) */
.cat-add-below {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.cat-manage-list { margin-top: 4px; max-height: min(50vh, 360px); overflow: auto; }
.cat-manage-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .88rem;
}
.cat-manage-row i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.cat-manage-row .danger { color: var(--danger); }

@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .meta-row { grid-template-columns: 1fr; gap: 2px; }
}

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 300; padding: 12px 18px; border-radius: 10px;
  background: var(--surface2); border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0,0,0,.4); font-size: .88rem;
}
.toast[hidden] { display: none !important; }

@media (max-width: 900px) {
  .main { grid-template-columns: 1fr; grid-template-rows: auto minmax(180px, 40vh) 1fr; }
  .side { max-height: 140px; border-right: none; border-bottom: 1px solid var(--border); flex-direction: row; flex-wrap: wrap; align-items: flex-start; }
  .side-foot { display: none; }
  .list-pane { border-right: none; border-bottom: 1px solid var(--border); }
}
