/* =========================================================
   Vantafold — sign in, sign up, and the dashboard app shell.
   Builds on the tokens in styles.css and components in pages.css.
   ========================================================= */

.nav__avatar {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px; margin-left: -6px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.2); font-size: 10px; font-weight: 600; letter-spacing: 0;
}

/* =========================================================
   Auth pages
   ========================================================= */
.auth {
  position: relative; min-height: 100vh; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.auth__main { position: relative; z-index: 1; display: flex; flex-direction: column; padding: 28px clamp(24px, 5vw, 64px); }
.auth__top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.auth__top p { font-size: 13.5px; color: var(--text-3); }
.auth__top p a { color: var(--accent-soft); }
.auth__box { width: 100%; max-width: 420px; margin: auto; padding-block: 48px; }
.auth__box h1 { font-size: clamp(28px, 3vw, 34px); letter-spacing: -0.035em; }
.auth__box > p { margin-top: 10px; color: var(--text-2); font-size: 15px; }
.auth__form { margin-top: 30px; }
.auth__legal { font-size: 12px; color: var(--text-3); text-align: center; margin-top: auto; }
.auth__legal a { color: var(--text-2); }

.field__label-row { display: flex; align-items: baseline; justify-content: space-between; }
.field__label-row a { font-size: 12.5px; color: var(--accent-soft); }
.field__pw { position: relative; }
.field__pw input { padding-right: 64px; }
.field__pw button {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  padding: 5px 9px; border-radius: 7px; font-size: 12px; color: var(--text-3);
}
.field__pw button:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.field__err { display: none; font-size: 12.5px; color: var(--viz-crit); }
.field.is-invalid input, .field.is-invalid select { border-color: rgba(241, 102, 106, 0.55); }
.field.is-invalid .field__err { display: block; }

.meter { display: flex; gap: 4px; margin-top: 2px; }
.meter i { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.08); transition: background-color 0.2s; }
.meter[data-score="1"] i:nth-child(-n+1) { background: var(--viz-crit); }
.meter[data-score="2"] i:nth-child(-n+2) { background: var(--viz-warn); }
.meter[data-score="3"] i:nth-child(-n+3) { background: #A3D96B; }
.meter[data-score="4"] i { background: var(--ok); }

.check-row { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; color: var(--text-2); cursor: pointer; }
.check-row input { margin: 3px 0 0; width: 15px; height: 15px; accent-color: var(--accent); flex: none; }
.check-row a { color: var(--accent-soft); }

.alert {
  display: none; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: 10px; font-size: 13.5px;
  border: 1px solid rgba(241, 102, 106, 0.32); background: rgba(241, 102, 106, 0.08); color: #F7A3A5;
}
.alert.is-shown { display: flex; }
.alert--info { border-color: var(--accent-line); background: var(--accent-dim); color: #CFC2FF; }
.alert a { color: inherit; text-decoration: underline; }

.btn[disabled], .btn.is-busy { opacity: 0.6; pointer-events: none; }
.btn.is-busy::before {
  content: ""; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.steps-mini { display: flex; gap: 8px; margin-top: 26px; }
.steps-mini i { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.08); }
.steps-mini i.is-on { background: var(--accent); }

.auth__side {
  position: relative; z-index: 1; margin: 14px; border-radius: var(--r-xl);
  border: 1px solid var(--line); overflow: hidden;
  background: linear-gradient(180deg, rgba(124, 92, 255, 0.10), rgba(16, 16, 19, 0.9) 55%);
  display: flex; flex-direction: column; justify-content: center; padding: clamp(32px, 4vw, 56px);
}
.auth__side .grid-overlay { mask-image: radial-gradient(ellipse 80% 60% at 50% 20%, #000 20%, transparent 80%); -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 20%, #000 20%, transparent 80%); }
.auth__side > * { position: relative; }
.auth__side h2 { font-size: clamp(24px, 2.4vw, 32px); letter-spacing: -0.035em; max-width: 18ch; }
.auth__side > p { margin-top: 14px; color: var(--text-2); max-width: 38em; }
.auth__side .code { margin-top: 30px; }
.auth__side .checks { margin-top: 30px; }
.auth__stats { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 34px; padding-top: 24px; border-top: 1px solid var(--line); }
.auth__stats strong { display: block; font-size: 20px; letter-spacing: -0.03em; }
.auth__stats span { font-size: 12.5px; color: var(--text-3); }

@media (max-width: 980px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth__side { display: none; }
}

/* =========================================================
   Dashboard shell
   ========================================================= */
.app { min-height: 100vh; display: grid; grid-template-columns: 252px minmax(0, 1fr); background: var(--bg); }
.app.is-loading { visibility: hidden; }

.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  border-right: 1px solid var(--line); background: var(--bg-alt); padding: 18px 14px 14px;
}
.side .brand { padding: 4px 8px 18px; }
.org {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.02);
}
.org__mark {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #4E7BFF); font-size: 12.5px; font-weight: 600; color: #fff;
}
.org__name { font-size: 13.5px; font-weight: 600; letter-spacing: -0.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org__plan { font-size: 11.5px; color: var(--text-3); }
.org > div { min-width: 0; }

.side__nav { display: grid; gap: 2px; margin-top: 18px; overflow-y: auto; }
.side__label { margin: 14px 10px 6px; font-size: 10.5px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--text-3); }
.side__nav a {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px;
  font-size: 14px; color: var(--text-2); transition: background-color 0.15s, color 0.15s;
}
.side__nav a svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0.8; }
.side__nav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.side__nav a[aria-current="page"] { color: var(--text); background: var(--accent-dim); }
.side__nav a[aria-current="page"] svg { stroke: var(--accent-soft); opacity: 1; }
.side__nav a .count { margin-left: auto; font-size: 11px; font-family: var(--font-mono); color: var(--text-3); }

.side__foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.me__avatar {
  flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line-strong); font-size: 12px; font-weight: 600;
}
.me > div { min-width: 0; flex: 1; }
.me strong { display: block; font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me span { display: block; font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: var(--text-3);
}
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: 60px; display: flex; align-items: center; gap: 14px;
  padding: 0 clamp(16px, 3vw, 32px); border-bottom: 1px solid var(--line);
  background: rgba(10, 10, 11, 0.82); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.topbar__menu { display: none; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-3); min-width: 0; }
.crumbs b { color: var(--text); font-weight: 500; }
.crumbs .sep { opacity: 0.5; }
.proj-select {
  appearance: none; max-width: 200px; padding: 6px 30px 6px 10px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236E6E7A' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E") no-repeat right 8px center / 14px;
  color: var(--text); font: inherit; font-size: 13px;
}
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.badge-sample {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  border: 1px dashed var(--line-strong); font-size: 11.5px; color: var(--text-3);
}
.topbar .btn { height: 34px; font-size: 13px; }

.view { padding: clamp(20px, 3vw, 36px) clamp(16px, 3vw, 32px) 64px; max-width: 1320px; width: 100%; }
.view:focus { outline: none; }
.view-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; margin-bottom: 26px; }
.view-head h1 { font-size: clamp(22px, 2.4vw, 28px); letter-spacing: -0.035em; }
.view-head p { margin-top: 6px; color: var(--text-2); font-size: 14.5px; max-width: 60em; }
.view-head__actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--main { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.stack { display: grid; gap: 16px; align-content: start; }

.box { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); min-width: 0; }
.box__head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.box__head h2, .box__head h3 { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
.box__head p { font-size: 12.5px; color: var(--text-3); }
.box__head > :last-child:not(:first-child) { margin-left: auto; }
.box__body { padding: 18px; }
.box__body--flush { padding: 0; }
.box__foot { padding: 12px 18px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--text-3); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.box .chart { border: 0; background: none; padding: 0; }
.box .table-wrap { border: 0; border-radius: 0; }
.box .table { min-width: 620px; }
.muted { color: var(--text-3); }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.link { color: var(--accent-soft); }
.link:hover { color: #B7A4FF; }

.btn--sm { height: 30px; padding: 0 12px; font-size: 12.5px; }
.btn--danger { color: #F7A3A5; border: 1px solid rgba(241, 102, 106, 0.35); background: rgba(241, 102, 106, 0.06); }
.btn--danger:hover { background: rgba(241, 102, 106, 0.14); color: #fff; }

.welcome {
  position: relative; overflow: hidden; padding: 24px; border-radius: var(--r-lg);
  border: 1px solid var(--accent-line);
  background: radial-gradient(120% 140% at 100% 0%, rgba(124, 92, 255, 0.22), transparent 55%), var(--surface);
  display: flex; flex-wrap: wrap; align-items: center; gap: 18px;
}
.welcome h1 { font-size: clamp(22px, 2.4vw, 28px); letter-spacing: -0.035em; }
.welcome p { margin-top: 6px; color: var(--text-2); font-size: 14.5px; }
.welcome dl { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 16px 0 0; }
.welcome dt { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }
.welcome dd { margin: 2px 0 0; font-size: 14px; color: var(--text); }
.welcome__actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }

.checklist { display: grid; }
.checklist li { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 14px; }
.checklist li:first-child { border-top: 0; }
.checklist .dot {
  flex: none; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid var(--line-strong);
}
.checklist li.is-done .dot { border-color: rgba(74, 222, 128, 0.5); background: rgba(74, 222, 128, 0.12); }
.checklist li.is-done .dot::after { content: ""; width: 5px; height: 9px; margin-top: -2px; border: solid var(--ok); border-width: 0 1.5px 1.5px 0; transform: rotate(42deg); }
.checklist li.is-done span { color: var(--text-3); text-decoration: line-through; }
.checklist li a, .checklist li button { margin-left: auto; font-size: 12.5px; color: var(--accent-soft); }
.progress { height: 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.4s var(--ease); }
.progress--warn i { background: var(--viz-warn); }
.progress--crit i { background: var(--viz-crit); }

.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 9px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.02); }
.seg button { padding: 4px 11px; border-radius: 6px; font-size: 12.5px; color: var(--text-3); }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { color: var(--text); background: rgba(255, 255, 255, 0.08); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar input, .toolbar select, .inline-input {
  padding: 7px 11px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
}
.toolbar input:focus, .toolbar select:focus, .inline-input:focus { outline: none; border-color: var(--accent-line); }
.toolbar input[type="search"] { min-width: 220px; }

.table tbody tr.is-clickable { cursor: pointer; }
.table td .pill-state, .table td .tag { white-space: nowrap; }
.table td.mono, .table th.mono { white-space: nowrap; }
.box .table.table--compact { min-width: 480px; }
.table .num { text-align: right; white-space: nowrap; font-family: var(--font-mono); font-size: 12.5px; }
.table th.num { font-family: var(--font-sans); }
.key-mask { font-family: var(--font-mono); font-size: 12.5px; color: var(--text); }
.role-pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 11.5px; border: 1px solid var(--line-strong); color: var(--text-2); }
.empty { padding: 36px 20px; text-align: center; color: var(--text-3); font-size: 14px; }
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 6px; }
.empty .btn { margin-top: 16px; }

.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 10px 16px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); min-width: 0; overflow-wrap: anywhere; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch i { flex: none; position: relative; width: 34px; height: 20px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); transition: background-color 0.2s; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 0.2s var(--ease); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(14px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent-soft); outline-offset: 2px; }
.switch input:disabled + i { opacity: 0.45; }

.setting { display: flex; align-items: center; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.setting:first-child { border-top: 0; padding-top: 0; }
.setting > div { flex: 1; min-width: 0; }
.setting strong { display: block; font-size: 14px; font-weight: 500; }
.setting span { display: block; font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

.chain { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.field .toolbar select { width: auto; min-width: 200px; }
.chain li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.02); font-family: var(--font-mono); font-size: 12.5px; }
.chain li b { font-family: var(--font-sans); font-size: 11px; font-weight: 500; color: var(--text-3); min-width: 18px; }
.chain li .icon-btn { width: 26px; height: 26px; }
.chain li .icon-btn:first-of-type { margin-left: auto; }

.locked { position: relative; }
.locked__veil {
  position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; text-align: center; padding: 24px;
  border-radius: var(--r-lg); background: rgba(10, 10, 11, 0.72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.locked__veil h3 { font-size: 18px; letter-spacing: -0.025em; }
.locked__veil p { margin: 8px auto 16px; max-width: 34em; font-size: 14px; color: var(--text-2); }

.plan-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.plan { display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: var(--r-md); border: 1px solid var(--line); background: rgba(255, 255, 255, 0.015); }
.plan.is-current { border-color: var(--accent-line); background: var(--accent-dim); }
.plan h3 { font-size: 16px; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
.plan__price { font-size: 24px; font-weight: 600; letter-spacing: -0.035em; }
.plan__price span { font-size: 13px; font-weight: 400; color: var(--text-3); letter-spacing: 0; }
.plan ul { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.plan ul li::before { content: "— "; color: var(--text-3); }
.plan .btn { margin-top: auto; }

.trace-detail { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.trace-detail > * { min-width: 0; }
.trace-detail .trace__row { grid-template-columns: 170px minmax(0, 1fr) 60px; }
.json { margin: 0; padding: 14px 16px; border-radius: var(--r-md); border: 1px solid var(--line); background: #0C0C0F; font-family: var(--font-mono); font-size: 12px; line-height: 1.65; color: var(--text-2); overflow: auto; max-height: 360px; white-space: pre; }

.playground textarea { min-height: 88px; }
.pg-out { margin-top: 16px; }

/* ---------- dialog ---------- */
.modal {
  width: min(520px, calc(100vw - 32px)); padding: 0; border-radius: var(--r-lg);
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 1);
}
.modal--wide { width: min(760px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(5, 5, 7, 0.7); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal__head { display: flex; align-items: center; gap: 10px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal__head h2 { font-size: 16.5px; letter-spacing: -0.02em; }
.modal__head .icon-btn { margin-left: auto; }
.modal__body { padding: 20px; display: grid; gap: 16px; max-height: calc(100vh - 200px); overflow-y: auto; }
.modal__body > p { font-size: 14px; color: var(--text-2); }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.secret {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--accent-line); background: #0C0C0F; font-family: var(--font-mono); font-size: 12.5px; overflow-wrap: anywhere;
}
.secret code { flex: 1; min-width: 0; }

/* ---------- toast ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 300; display: grid; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: #18181D; font-size: 13.5px;
  box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 1); animation: toast-in 0.3s var(--ease);
}
.toast i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.toast--err i { background: var(--viz-crit); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.scrim { display: none; }
.show-xs { display: none; }

@media (max-width: 1180px) {
  .grid--main { grid-template-columns: minmax(0, 1fr); }
  .plan-cards { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; z-index: 60; left: 0; top: 0; width: 268px;
    transform: translateX(-100%); transition: transform 0.25s var(--ease);
  }
  .app.is-menu .side { transform: none; }
  .app.is-menu .scrim { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.55); }
  .topbar__menu { display: grid; }
  .grid--2, .grid--3 { grid-template-columns: minmax(0, 1fr); }
  .badge-sample, .topbar .hide-sm { display: none; }
}
@media (max-width: 620px) {
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .toolbar input[type="search"] { min-width: 0; width: 100%; }
  .crumbs .hide-sm, .hide-xs { display: none; }
  .show-xs { display: inline; }
  .topbar { gap: 10px; }
  .proj-select { max-width: 150px; }
  .trace-detail .trace__row { grid-template-columns: 110px minmax(0, 1fr) 50px; }
}
