/* Opale Vault — frontend produit, charte Opale Core. */

:root {
  --green: #0d9488;
  --green-soft: #e6f5f2;
  --green-border: #a6ddd3;
  --bg: #f6f7f6;
  --surface: #ffffff;
  --surface-2: #eef2ee;
  --border: #e6eae6;
  --border-strong: #d4dad4;
  --text: #15201a;
  --text-soft: #5a6960;
  --text-faint: #9aa79d;
  --red: #c0362f;
  --red-soft: #fbeeed;
  --red-border: #efc2bf;
  --amber: #b4791b;
  --amber-soft: #fbf3e2;
  --amber-border: #ecd49c;
  --blue: #2563eb;
  --blue-soft: #e9f0fe;
  --blue-border: #c7d8fd;
  --ink: #0c1512;
  --ink-fg: #eaf2ed;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(20,40,30,.04), 0 12px 32px rgba(20,40,30,.05);
  --shadow-lg: 0 26px 64px rgba(20,40,30,.14);
  --font: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --display: "Space Grotesk", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Existing JS/CSS class aliases. */
  --accent: var(--green);
  --accent-soft: var(--green-soft);
  --accent-border: var(--green-border);
}

* { box-sizing: border-box; }

::selection { background: rgba(13,148,136,.18); }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 36px;
}

.hidden { display: none !important; }

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 66px;
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(246,247,246,.86);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--green);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--green) 40%, transparent);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1;
  min-width: 0;
}

.brand-name {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.brand b {
  font-family: var(--mono);
  font-weight: 500;
  color: var(--text-faint);
  font-size: 9.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  margin-top: 3px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-soft);
}

.badge.online {
  background: var(--green-soft);
  border-color: var(--green-border);
  color: var(--green);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  flex: 0 0 auto;
}

.dot.pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* Layout */
main { padding: 54px 0 80px; }

.view-head { margin-bottom: 34px; }
.view-head h1 {
  font-family: var(--display);
  font-size: 34px;
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin: 0;
}
.view-head p {
  color: var(--text-soft);
  font-size: 14.5px;
  line-height: 1.55;
  margin: 8px 0 0;
}

.admin-bar {
  padding-right: 0 !important;
  padding-left: 0 !important;
}

/* Tenant bar */
.tenant-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}

.tenant-pick {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.tenant-pick span,
.lbl {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-faint);
  font-weight: 600;
}

.tenant-pick select,
.field input,
.field select {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  padding: 11px 38px 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  transition: border-color .16s, background .16s, box-shadow .16s;
}

.tenant-pick select {
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a6960' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.tenant-pick select:focus,
.field input:focus,
.field select:focus,
.otp-input:focus {
  border-color: var(--green);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(13,148,136,.12);
}

.tenant-iso {
  font-size: 12px;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid var(--green-border);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 600;
}

/* Tabs */
.tabs {
  display: inline-flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 5px;
  border-radius: 16px;
  border: 1px solid var(--border);
  margin-bottom: 40px;
}

.tab {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-soft);
  padding: 10px 20px;
  border-radius: 12px;
  transition: color .16s, background .16s, box-shadow .16s;
}

.tab:hover { color: var(--text); }
.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* Cards & buttons */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: background .16s, color .16s, border-color .16s, box-shadow .16s, filter .16s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--text);
  color: var(--surface);
  box-shadow: var(--shadow);
}
.btn-primary:hover { background: var(--green); color: #fff; }
.btn-accent {
  background: var(--green);
  color: #fff;
  box-shadow: 0 10px 26px rgba(13,148,136,.22);
}
.btn-accent:hover { filter: brightness(.96); }
.btn-ghost {
  background: var(--surface-2);
  color: var(--text-soft);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-danger-ghost {
  background: transparent;
  color: var(--text-faint);
  border-color: transparent;
  padding: 8px;
}
.btn-danger-ghost:hover { background: var(--red-soft); color: var(--red); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-icon {
  padding: 8px;
  border-radius: 10px;
  background: transparent;
  border-color: transparent;
  color: var(--text-faint);
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }

/* Login */
.login-wrap {
  min-height: calc(100vh - 228px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 440px;
  padding: 42px 38px;
  text-align: center;
}

.login-logo {
  width: 58px;
  height: 58px;
  border-radius: 17px;
  margin: 0 auto 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: #fff;
  background: var(--green);
  box-shadow: 0 12px 30px rgba(13,148,136,.22);
}

.login-card h2 {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}

.login-card .sub {
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 30px;
}

.login-card .btn { width: 100%; padding: 15px; }
.totp-step { margin-top: 8px; }
.totp-label { font-size: 13px; color: var(--text-soft); margin-bottom: 14px; }

.otp-input {
  width: 100%;
  text-align: center;
  font-family: var(--mono);
  font-size: 26px;
  letter-spacing: .45em;
  padding: 16px 0 16px .45em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: border-color .16s, background .16s, box-shadow .16s;
}

.muted-link {
  background: none;
  border: 0;
  color: var(--text-faint);
  font-size: 12px;
  cursor: pointer;
  margin-top: 18px;
  font-family: inherit;
}
.muted-link:hover { color: var(--green); text-decoration: underline; }

/* Project/environment groups */
.proj-group { margin-bottom: 36px; }
.proj-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.proj-head h2 {
  font-family: var(--display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
.proj-head .proj-ic { font-size: 15px; }
.env-group { margin: 16px 0 0; }
.env-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 12px;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--surface-2);
}
.env-label.production { background: var(--red-soft); color: var(--red); }
.env-label.staging { background: var(--amber-soft); color: var(--amber); }
.env-label.development { background: var(--blue-soft); color: var(--blue); }

/* Secrets */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.secret-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  transition: border-color .16s, transform .16s, box-shadow .16s;
}
.secret-card:hover {
  border-color: var(--green-border);
  transform: translateY(-2px);
  box-shadow: 0 24px 58px rgba(20,40,30,.11);
}
.secret-card .row { display: flex; align-items: center; justify-content: space-between; }
.type-badge {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 5px 9px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-soft);
  font-weight: 600;
}
.type-badge.internal { background: var(--green-soft); color: var(--green); }
.secret-card h3 { font-size: 16px; font-weight: 600; margin: 0; }
.secret-card .sid {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
  margin: 4px 0 0;
}
.secret-card .foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-soft);
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.rot { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.rot.ok { color: var(--green); }
.rot.warn { color: var(--amber); }
.rot.expired { color: var(--red); }
.card-actions { display: flex; gap: 4px; }

/* Empty/loading states */
.empty { text-align: center; padding: 72px 24px; }
.empty .ic { font-size: 44px; margin-bottom: 16px; opacity: .65; }
.empty h3 { font-size: 18px; font-weight: 600; margin: 0 0 8px; }
.empty p { color: var(--text-soft); font-size: 14px; margin: 0 0 24px; }
.skeleton {
  height: 168px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-2) 25%, #e3e9e4 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Activity feed */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 16px; padding: 16px 4px; border-bottom: 1px solid var(--border); }
.feed-item:last-child { border-bottom: 0; }
.feed-ic {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  background: var(--surface-2);
}
.feed-body { flex: 1; min-width: 0; }
.feed-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.feed-type { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.feed-reason { color: var(--text-soft); font-size: 13px; margin: 3px 0 0; }
.feed-time { color: var(--text-faint); font-size: 12px; white-space: nowrap; }
.decision {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 7px;
}
.decision.allow { background: var(--green-soft); color: var(--green); }
.decision.deny { background: var(--red-soft); color: var(--red); }
.decision.info { background: var(--blue-soft); color: var(--blue); }

/* Identity */
.identity-card {
  padding: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.identity-card .val { font-family: var(--mono); font-size: 15px; margin-top: 4px; }

/* Slide-over */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(12,21,18,.38);
  backdrop-filter: blur(2px);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s;
}
.overlay.open { opacity: 1; pointer-events: auto; }

.slideover {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: 440px;
  max-width: 92vw;
  z-index: 70;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform .26s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
}
.slideover.open { transform: translateX(0); }
.slideover header {
  padding: 28px 28px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.slideover header h2 {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
.slideover header p { font-size: 13px; color: var(--text-soft); margin: 4px 0 0; }
.slideover .body { padding: 24px 28px; overflow-y: auto; flex: 1; }
.slideover .foot {
  padding: 18px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
}
.slideover .foot .btn { flex: 1; }

.field { margin-bottom: 20px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.field .hint { font-size: 12px; color: var(--text-faint); margin-top: 6px; }
.field input,
.field select {
  width: 100%;
  background: var(--surface);
}
.field input.mono { font-family: var(--mono); }

/* QR modal */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -48%);
  z-index: 70;
  width: 360px;
  max-width: 92vw;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
}
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%); }
.modal h2 {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 6px;
}
.modal-sub { font-size: 13px; color: var(--text-soft); margin: 0 0 16px; }
.qr-host { display: flex; justify-content: center; margin: 8px 0 20px; }
.qr-host svg { width: 220px; height: 220px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.qr-secret {
  display: inline-block;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: .04em;
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  word-break: break-all;
  user-select: all;
}

/* Toasts */
.toasts {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  min-width: 240px;
  animation: slideIn .25s ease;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
}

@media (max-width: 720px) {
  .app-shell { padding: 0 20px; }
  .topbar { height: 66px; }
  .badge { display: none; }
  main { padding: 44px 0 70px; }
  .view-head h1 { font-size: 28px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .btn { width: 100%; }
  .login-card { padding: 34px 24px; }
  .tabs { width: 100%; overflow-x: auto; }
  .tab { flex: 1; min-width: max-content; }
  .slideover { width: 100%; max-width: 100vw; }
  .toasts { left: 20px; right: 20px; }
  .toast { min-width: 0; }
}
