/* Console : coque (barre latérale + contenu) et composants des vues. */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100dvh;
}

/* ---------------------------------------------------------------- barre latérale */

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  padding: var(--s4) var(--s3);
  background: var(--surface-2);
  border-inline-end: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s1) var(--s2);
  color: var(--text);
  font-weight: 650;
  font-size: var(--fs-lg);
  text-decoration: none;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.nav {
  display: grid;
  gap: 2px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 34px;
  padding: 0 var(--s3);
  border-radius: var(--r-sm);
  color: var(--text-2);
  text-decoration: none;
  font-weight: 500;
}

.nav a:hover {
  background: var(--raised);
  color: var(--text);
}

.nav a[aria-current="page"] {
  background: var(--raised);
  color: var(--text);
}

.nav a[aria-current="page"] .icon {
  color: var(--accent);
}

.nav-sep {
  height: 1px;
  margin: var(--s2) var(--s3);
  background: var(--line);
}

.sidebar-foot {
  margin-block-start: auto;
  display: grid;
  gap: var(--s2);
}

.account {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2);
  border-radius: var(--r-md);
  min-width: 0;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--r-pill);
  background: var(--raised);
  color: var(--text-2);
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: 600;
  flex: none;
  object-fit: cover;
}

.account-text {
  min-width: 0;
  display: grid;
  line-height: 1.3;
}

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

.account-text .email {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.sidebar-actions {
  display: flex;
  gap: var(--s1);
}

.menu-toggle {
  display: none;
}

/* ---------------------------------------------------------------- contenu */

.main {
  min-width: 0;
  padding: var(--s6) var(--s6) var(--s8);
}

.view {
  max-width: 1080px;
  margin-inline: auto;
  display: grid;
  gap: var(--s6);
}

.view-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s4);
}

.view-head p {
  margin-block-start: var(--s1);
  color: var(--text-2);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s5);
  display: grid;
  gap: var(--s4);
  align-content: start;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2) var(--s4);
}

.panel-head .meta {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.grid-main {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: var(--s4);
  align-items: start;
}

.stack {
  display: grid;
  gap: var(--s4);
}

/* panneau dominant : l'action principale de la vue */
.hero-panel {
  border-color: var(--line-strong);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  align-items: end;
}

.inline-form .field {
  flex: 1 1 14rem;
  max-width: 24rem;
}

/* ---------------------------------------------------------------- clé révélée */

.secret {
  display: grid;
  gap: var(--s3);
  padding: var(--s4);
  border-radius: var(--r-md);
  background: var(--code-bg);
  border: 1px solid var(--line-strong);
}

.secret-row {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.secret-value {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: var(--fs-md);
  color: var(--text);
  overflow-wrap: anywhere;
  user-select: all;
}

.secret-note {
  display: flex;
  gap: var(--s2);
  align-items: center;
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.secret-note .icon {
  color: var(--text);
}

/* ---------------------------------------------------------------- onglets */

.tabs {
  display: flex;
  gap: var(--s1);
  border-block-end: 1px solid var(--line);
}

.tabs button {
  min-height: 34px;
  padding: 0 var(--s3);
  border: 0;
  border-block-end: 2px solid transparent;
  margin-block-end: -1px;
  background: none;
  color: var(--text-2);
  font: 500 var(--fs-sm) / 1 var(--font);
  cursor: pointer;
}

.tabs button:hover {
  color: var(--text);
}

.tabs button[aria-selected="true"] {
  color: var(--text);
  border-block-end-color: var(--accent);
}

/* ---------------------------------------------------------------- quota */

.meter {
  display: grid;
  gap: var(--s2);
}

.meter-figures {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
}

.meter-figures strong {
  font-size: var(--fs-xl);
  font-weight: 600;
}

.meter-bar {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--raised);
  overflow: hidden;
}

.meter-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width var(--t-med) var(--ease-out);
}

.meter[data-level="high"] .meter-bar span,
.meter[data-level="full"] .meter-bar span {
  background: repeating-linear-gradient(135deg, var(--text) 0 4px, var(--text-3) 4px 8px);
}

.facts {
  display: grid;
  gap: var(--s2);
  margin: 0;
  font-size: var(--fs-sm);
}

.facts div {
  display: flex;
  justify-content: space-between;
  gap: var(--s4);
}

.facts dt {
  color: var(--text-2);
}

.facts dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.facts-wide {
  grid-template-columns: repeat(auto-fit, minmax(min(13rem, 100%), 1fr));
  gap: var(--s2) var(--s6);
}

.panel > input[type="search"] {
  max-width: 22rem;
}

/* ---------------------------------------------------------------- graphique */

.chart {
  position: relative;
}

.chart svg {
  width: 100%;
  height: 140px;
  overflow: visible;
}

.chart .grid-line {
  stroke: var(--chart-grid);
  stroke-width: 1;
}

.chart .axis-label {
  fill: var(--text-3);
  font: var(--fs-xs) var(--font);
  font-variant-numeric: tabular-nums;
}

.chart .bar {
  fill: var(--chart-bar);
}

.chart .bar-zero {
  fill: var(--chart-grid);
}

.chart .hit {
  fill: transparent;
  cursor: default;
}

.chart .hit:focus-visible {
  outline: none;
}

.chart .hit:hover + .bar,
.chart .hit:focus-visible + .bar,
.chart .hit[data-active] + .bar {
  fill: var(--accent-hover);
}

.chart-tip {
  position: absolute;
  z-index: var(--z-tooltip);
  pointer-events: none;
  padding: var(--s1) var(--s2);
  border-radius: var(--r-sm);
  background: var(--raised);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-xs);
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 8px));
}

.chart-tip strong {
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- tableaux */

.table-wrap {
  position: relative;
  overflow-x: auto;
  margin-inline: calc(var(--s5) * -1);
  padding-inline: var(--s5);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

table.data th {
  text-align: start;
  font-weight: 500;
  color: var(--text-3);
  padding: 0 var(--s3) var(--s2);
  white-space: nowrap;
}

table.data td {
  padding: var(--s3);
  border-block-start: 1px solid var(--line);
  vertical-align: middle;
}

table.data th:first-child,
table.data td:first-child {
  padding-inline-start: 0;
}

table.data th:last-child,
table.data td:last-child {
  padding-inline-end: 0;
  text-align: end;
}

table.data .mono {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--text-2);
}

.cell-user {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-width: 12rem;
}

.cell-user .account-text {
  font-size: var(--fs-sm);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  padding: 2px var(--s2);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 500;
  background: var(--raised);
  color: var(--text-2);
  white-space: nowrap;
}

.tag[data-tone="danger"] {
  background: var(--text);
  color: var(--bg);
}

.tag[data-tone="accent"] {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--text);
}

.quota-edit {
  display: flex;
  gap: var(--s1);
  justify-content: flex-end;
}

.quota-edit .input {
  width: 7.5rem;
  min-height: 32px;
  text-align: end;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- état vide */

.empty {
  display: grid;
  justify-items: start;
  gap: var(--s3);
  padding: var(--s5) 0;
}

.empty p {
  color: var(--text-2);
}

/* ---------------------------------------------------------------- playground */

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  gap: var(--s3);
  min-height: 220px;
  padding: var(--s5);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  text-align: center;
  color: var(--text-2);
  transition:
    border-color var(--t-fast) var(--ease-out),
    background-color var(--t-fast) var(--ease-out);
}

.dropzone[data-over] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone .icon {
  width: 24px;
  height: 24px;
  color: var(--text-3);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.preview {
  display: grid;
  gap: var(--s3);
}

.preview img {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.preview-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  align-items: center;
  justify-content: space-between;
}

.preview-name {
  font-size: var(--fs-sm);
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.verdict {
  display: grid;
  gap: var(--s4);
}

.verdict-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s4);
  border-radius: var(--r-md);
}

.verdict-head .icon {
  width: 24px;
  height: 24px;
}

.verdict-head strong {
  font-size: var(--fs-xl);
  font-weight: 600;
}

.verdict-head .score {
  margin-inline-start: auto;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}

/* monochrome : la forme porte le niveau (bloc inversé, pointillés, aplat discret) */
.verdict[data-level="scam"] .verdict-head {
  background: var(--text);
  color: var(--bg);
}

.verdict[data-level="suspect"] .verdict-head {
  border: 1px dashed var(--text);
  color: var(--text);
}

.verdict[data-level="safe"] .verdict-head {
  background: var(--raised);
  color: var(--text-2);
}

.reasons {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--s2);
}

.reasons li {
  display: flex;
  gap: var(--s2);
  align-items: baseline;
}

.reasons li::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  margin-block-start: 0.45em;
  border-radius: var(--r-pill);
  background: var(--text-3);
}

details.ocr summary {
  cursor: pointer;
  color: var(--text-2);
  font-size: var(--fs-sm);
}

details.ocr pre {
  margin: var(--s2) 0 0;
  padding: var(--s3);
  max-height: 260px;
  overflow: auto;
  border-radius: var(--r-md);
  background: var(--code-bg);
  border: 1px solid var(--line);
  font-size: var(--fs-xs);
  white-space: pre-wrap;
  color: var(--text-2);
}

/* ---------------------------------------------------------------- squelettes */

.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--raised), var(--surface-2), var(--raised));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.skeleton-block {
  height: 72px;
}

html.low-perf .skeleton {
  animation: none;
}

.boot {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  color: var(--text-3);
}

/* ---------------------------------------------------------------- dialogue */

dialog.confirm {
  width: min(28rem, calc(100vw - 2 * var(--s4)));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-2);
}

dialog.confirm::backdrop {
  background: oklch(0.1 0 0 / 0.6);
}

dialog.confirm form {
  display: grid;
  gap: var(--s4);
  padding: var(--s5);
}

dialog.confirm p {
  color: var(--text-2);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s2);
}

dialog.confirm[open] {
  animation: dialog-in var(--t-med) var(--ease-out);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
}

/* ---------------------------------------------------------------- erreurs de vue */

.notice {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--scam-soft);
  color: var(--text);
  font-size: var(--fs-sm);
}

.notice .icon {
  color: var(--scam);
  margin-block-start: 2px;
}

.notice[data-tone="warn"] {
  background: var(--suspect-soft);
  border-style: dashed;
}

.notice[data-tone="warn"] .icon {
  color: var(--suspect);
}

/* ---------------------------------------------------------------- responsive */

@media (max-width: 960px) {
  .grid-main {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(280px, 85vw);
    z-index: var(--z-drawer);
    transform: translateX(-100%);
    transition: transform var(--t-med) var(--ease-out);
    box-shadow: var(--shadow-2);
  }

  .shell[data-menu-open] .sidebar {
    transform: none;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    display: flex;
    align-items: center;
    gap: var(--s2);
    padding: var(--s2) var(--s3);
    background: var(--surface-2);
    border-block-end: 1px solid var(--line);
  }

  .menu-toggle {
    display: inline-flex;
  }

  .main {
    padding: var(--s5) var(--s4) var(--s7);
  }

  .panel {
    padding: var(--s4);
  }

  .table-wrap {
    margin-inline: calc(var(--s4) * -1);
    padding-inline: var(--s4);
  }

  .hide-sm {
    display: none;
  }
}

@media (min-width: 761px) {
  .topbar {
    display: none;
  }
}

/* ---------------------------------------------------------------- garde-fous de mise en page */

/* main reçoit le focus à chaque changement de vue (lecteurs d'écran) : pas d'anneau visuel */
.main:focus {
  outline: none;
}

/* les enfants de grille ne doivent jamais s'élargir au contenu (blocs de code, tableaux) */
.panel > *,
.stack > *,
.grid-main > *,
.view > * {
  min-width: 0;
}

.shell > * {
  min-width: 0;
}

table.data td.num {
  white-space: nowrap;
}
