/* Traffic Counter — design system (sombre). Les couleurs de séries suivent un ordre fixe validé CVD. */
:root {
  color-scheme: dark;
  --surface-0: #0b0d10;   /* fond de page */
  --surface-1: #14171c;   /* cartes */
  --surface-2: #1b1f26;   /* éléments surélevés, champs */
  --surface-3: #252a33;   /* survol */
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text-1: #eef0f3;
  --text-2: #a3a9b4;
  --text-3: #6d7380;
  --accent: #3987e5;
  --accent-strong: #5598e7;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --radius: 18px;
}

html { background: var(--surface-0); }
body {
  background:
    radial-gradient(900px 480px at 0% -10%, rgba(57, 135, 229, 0.10), transparent 70%),
    radial-gradient(700px 420px at 100% 0%, rgba(25, 158, 112, 0.05), transparent 70%),
    var(--surface-0);
  color: var(--text-1);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
.tabular { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- cartes */
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0) 40%), var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 30px -18px rgba(0, 0, 0, 0.6);
}
.card-title { font-size: 0.875rem; font-weight: 500; color: var(--text-1); letter-spacing: -0.005em; }
.card-sub { font-size: 0.75rem; color: var(--text-3); }
.eyebrow { font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); font-weight: 500; }

/* ---------------------------------------------------------------- barre supérieure */
.topbar {
  background: rgba(11, 13, 16, 0.72);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.segmented button {
  padding: 0.375rem 0.75rem; border-radius: 9px; font-size: 0.8125rem; color: var(--text-2);
  transition: background-color .15s, color .15s; white-space: nowrap;
}
@media (max-width: 640px) { .segmented button { padding: 0.375rem 0.55rem; } }
.segmented button:hover { color: var(--text-1); }
.segmented button[aria-pressed="true"] { background: var(--surface-3); color: var(--text-1); box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.icon-btn {
  display: inline-grid; place-items: center; height: 2.25rem; width: 2.25rem; border-radius: 11px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2); transition: color .15s, background-color .15s;
}
.icon-btn:hover { color: var(--text-1); background: var(--surface-3); }

/* ---------------------------------------------------------------- onglets */
.tab {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.6rem 0.85rem; font-size: 0.8125rem; color: var(--text-2);
  border-bottom: 2px solid transparent; transition: color .15s, border-color .15s; white-space: nowrap;
}
.tab:hover { color: var(--text-1); }
.tab[aria-selected="true"] { color: var(--text-1); border-bottom-color: var(--accent); }
.tab .dot { width: 0.4rem; height: 0.4rem; box-shadow: none; }

/* ---------------------------------------------------------------- éditeur de zones */
.zline { border: 1px solid var(--line); border-radius: 14px; padding: 0.85rem; background: var(--surface-2); transition: border-color .15s, box-shadow .15s; cursor: pointer; }
.zline.selected { border-color: var(--zc, var(--accent)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--zc, var(--accent)) 22%, transparent); }
.zline .field { padding: 0.45rem 0.65rem; font-size: 0.8125rem; background: var(--surface-1); }
.zline .mini { font-size: 0.6875rem; color: var(--text-3); }
.btn-ghost:disabled { opacity: .45; cursor: not-allowed; }
.btn-danger { display: inline-flex; align-items: center; gap: 0.35rem; border-radius: 10px; padding: 0.35rem 0.6rem; font-size: 0.75rem; color: #f08a8a; border: 1px solid rgba(208,59,59,.35); }
.btn-danger:hover { background: rgba(208,59,59,.12); }

/* ---------------------------------------------------------------- pastilles d'état */
.pill {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0.7rem 0.3rem 0.55rem;
  border-radius: 999px; font-size: 0.75rem; border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2);
  white-space: nowrap;
}
.dot { width: 0.5rem; height: 0.5rem; border-radius: 999px; background: var(--text-3); flex: none; }
.dot.good { background: var(--good); box-shadow: 0 0 0 3px rgba(12, 163, 12, 0.18); }
.dot.warning { background: var(--warning); box-shadow: 0 0 0 3px rgba(250, 178, 25, 0.16); }
.dot.critical { background: var(--critical); box-shadow: 0 0 0 3px rgba(208, 59, 59, 0.2); }
.dot.live { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(12, 163, 12, 0); } }

.delta { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 500; }
.delta.up { color: #6fd36f; background: rgba(12, 163, 12, 0.12); }
.delta.down { color: #f08a8a; background: rgba(208, 59, 59, 0.14); }
.delta.flat { color: var(--text-2); background: var(--surface-2); }

.status { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.75rem; font-weight: 500; }
.status.good { color: #6fd36f; }
.status.warning { color: var(--warning); }
.status.serious { color: var(--serious); }
.status.critical { color: #f08a8a; }

/* ---------------------------------------------------------------- KPI */
.kpi-value { font-size: 2.25rem; line-height: 1; font-weight: 600; letter-spacing: -0.03em; }
.hero-value { font-size: 3.75rem; line-height: 0.95; font-weight: 600; letter-spacing: -0.045em; }
@media (max-width: 640px) { .hero-value { font-size: 3rem; } .kpi-value { font-size: 1.875rem; } }

/* ---------------------------------------------------------------- barres de répartition */
.meter { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; transition: width .5s ease; }
.stackbar { display: flex; gap: 2px; height: 10px; border-radius: 999px; overflow: hidden; }
.stackbar > span { display: block; height: 100%; transition: flex-grow .5s ease; min-width: 0; }
.stackbar > span:first-child { border-radius: 999px 0 0 999px; }
.stackbar > span:last-child { border-radius: 0 999px 999px 0; }
.swatch { width: 0.625rem; height: 0.625rem; border-radius: 3px; flex: none; }

/* ---------------------------------------------------------------- carte de chaleur */
.heatmap { display: grid; grid-template-columns: 2.25rem repeat(24, minmax(0, 1fr)); gap: 3px; }
.heatmap .cell { aspect-ratio: 1 / 1; border-radius: 4px; background: var(--surface-2); transition: transform .12s, outline-color .12s; outline: 1px solid transparent; }
.heatmap .cell:hover { transform: scale(1.18); outline-color: rgba(255,255,255,.55); position: relative; z-index: 1; }
.heatmap .day { font-size: 0.6875rem; color: var(--text-3); align-self: center; }
.heatmap .hour { font-size: 0.625rem; color: var(--text-3); text-align: center; }
.legend-ramp { height: 8px; width: 9rem; border-radius: 999px; background: linear-gradient(90deg, #1b2230, #0d366b, #256abf, #3987e5, #6da7ec, #cde2fb); }

/* ---------------------------------------------------------------- journal */
.feed-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.625rem 0.5rem; border-radius: 12px; transition: background-color .15s; }
.feed-item:hover { background: var(--surface-2); }
.feed-icon { display: grid; place-items: center; height: 2.125rem; width: 2.125rem; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); flex: none; }
.feed-new { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: rgba(57, 135, 229, 0.16); } to { background: transparent; } }
.fade-in { animation: fade .35s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- métriques système */
.metric { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.55rem 0; border-top: 1px solid var(--line); font-size: 0.8125rem; }
.metric:first-child { border-top: 0; }
.metric dt { color: var(--text-2); display: flex; align-items: center; gap: 0.5rem; }
.metric dd { color: var(--text-1); font-variant-numeric: tabular-nums; text-align: right; }
.alert { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.7rem 0.8rem; border-radius: 12px; font-size: 0.8125rem; }
.alert.critical { background: rgba(208, 59, 59, 0.1); border: 1px solid rgba(208, 59, 59, 0.3); color: #f6b3b3; }
.alert.warning { background: rgba(250, 178, 25, 0.08); border: 1px solid rgba(250, 178, 25, 0.25); color: #f8d58a; }

/* ---------------------------------------------------------------- formulaires */
.field {
  width: 100%; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-strong);
  padding: 0.625rem 0.85rem; color: var(--text-1); font-size: 0.875rem; transition: border-color .15s, box-shadow .15s;
}
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(57, 135, 229, 0.18); }
.field::-webkit-calendar-picker-indicator { filter: invert(0.75); }
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; border-radius: 12px; padding: 0.65rem 1rem;
  background: var(--accent); color: #fff; font-weight: 500; font-size: 0.875rem; transition: background-color .15s, transform .1s, opacity .15s;
}
.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; }
.btn-ghost { display: inline-flex; align-items: center; gap: 0.4rem; border-radius: 10px; padding: 0.4rem 0.7rem; font-size: 0.8125rem; color: var(--text-2); border: 1px solid var(--line); background: var(--surface-2); }
.btn-ghost:hover { color: var(--text-1); background: var(--surface-3); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- infobulle */
.tip {
  position: fixed; z-index: 50; pointer-events: none; padding: 0.5rem 0.65rem; border-radius: 10px;
  background: rgba(11, 13, 16, 0.94); border: 1px solid var(--line-strong); font-size: 0.75rem; color: var(--text-1);
  box-shadow: 0 8px 24px rgba(0,0,0,.5); opacity: 0; transition: opacity .1s;
}
.tip.show { opacity: 1; }

/* ---------------------------------------------------------------- squelettes de chargement */
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; color: transparent !important; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------------------------------------------------------- page de connexion */
.login-bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.login-bg .grid-lines {
  position: absolute; inset: -50%;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 56px 56px;
  transform: perspective(700px) rotateX(58deg) translateY(-8%);
  mask-image: radial-gradient(ellipse at 50% 40%, #000 20%, transparent 65%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 40%, #000 20%, transparent 65%);
}
.login-bg .trail {
  position: absolute; height: 2px; width: 22vw; border-radius: 999px; opacity: 0;
  background: linear-gradient(90deg, transparent, var(--c, #3987e5));
  animation: drive var(--d, 6s) linear infinite; animation-delay: var(--delay, 0s);
}
@keyframes drive {
  0% { transform: translateX(-30vw); opacity: 0; }
  10% { opacity: .85; }
  90% { opacity: .85; }
  100% { transform: translateX(130vw); opacity: 0; }
}
.login-card { backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); background: rgba(20, 23, 28, 0.78); }
.shake { animation: shake .4s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.spinner { width: 1rem; height: 1rem; border-radius: 999px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
