/* DealerID — central auth app on top of DS tokens */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--ds-font-ui);
  background: var(--ds-bg-muted);
  color: var(--ds-ink);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: transparent; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--ds-a-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--ds-a); outline-offset: 2px; border-radius: 4px; }

/* ===================== Brand mark ===================== */
.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.brand-mark .logo-tile {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, oklch(0.55 0.15 268), oklch(0.43 0.16 268));
  display: grid; place-items: center;
  color: #fff;
  font-family: var(--ds-font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.02em;
  position: relative;
  overflow: hidden;
}
.brand-mark .logo-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 70% 20%, rgba(255,255,255,0.18), transparent 60%);
}
.brand-mark .wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}
.brand-mark .wordmark b {
  font-family: var(--ds-font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.015em;
  color: var(--ds-ink);
}
.brand-mark .wordmark span {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ds-muted);
  font-weight: 600;
}

/* ===================== Buttons ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px;
  border-radius: 8px;
  font-weight: 500; font-size: 13px;
  border: 1px solid transparent;
  transition: background 120ms, border-color 120ms, color 120ms, box-shadow 120ms;
  white-space: nowrap;
}
.btn-primary { background: var(--ds-a); color: #fff; }
.btn-primary:hover { background: var(--ds-a-hover); }
.btn-ghost { color: var(--ds-ink-2); }
.btn-ghost:hover { background: var(--ds-surface-3); }
.btn-outline { background: var(--ds-surface); border-color: var(--ds-border-strong); color: var(--ds-ink); }
.btn-outline:hover { background: var(--ds-surface-2); }
.btn-danger { background: var(--ds-error); color: #fff; }
.btn-danger:hover { filter: brightness(0.95); }
.btn-block { width: 100%; }
.btn-lg { padding: 11px 16px; font-size: 13.5px; border-radius: 9px; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===================== Inputs ===================== */
.field {
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0;
}
.field label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ds-muted);
  letter-spacing: 0.01em;
}
.field .hint {
  font-size: 11.5px;
  color: var(--ds-muted-2);
}
.field .req { color: var(--ds-hot); margin-left: 2px; }

.input,
.select,
.textarea {
  width: 100%;
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: 8px;
  padding: 0 12px;
  height: 40px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ds-ink);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
.textarea {
  height: auto;
  padding: 9px 12px;
  resize: vertical;
  min-height: 80px;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--ds-border-strong); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--ds-a);
  box-shadow: var(--ds-shadow-focus);
}
.input::placeholder, .textarea::placeholder { color: var(--ds-muted-2); }
.input.mono { font-family: var(--ds-font-mono); letter-spacing: 0.02em; }

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-wrap .input { padding-left: 38px; }
.input-wrap .lead-icon {
  position: absolute;
  left: 12px;
  display: grid; place-items: center;
  color: var(--ds-muted);
  pointer-events: none;
}
.input-wrap .reveal {
  position: absolute;
  right: 6px;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  color: var(--ds-muted);
  border-radius: 6px;
}
.input-wrap .reveal:hover { background: var(--ds-surface-2); color: var(--ds-ink); }

/* ===================== Cards ===================== */
.card {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: 12px;
}
.card-head {
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--ds-border);
}
.card-head h3 {
  margin: 0;
  font-family: var(--ds-font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ds-ink);
}
.card-head p {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--ds-muted);
}
.card-body { padding: 18px; }
.card-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--ds-border);
  background: var(--ds-surface-2);
  border-radius: 0 0 12px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ===================== Login layout ===================== */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  background: var(--ds-bg);
}
.auth-side {
  background:
    radial-gradient(circle at 20% 10%, oklch(0.62 0.16 268 / 0.35), transparent 55%),
    radial-gradient(circle at 90% 90%, oklch(0.55 0.18 235 / 0.35), transparent 50%),
    linear-gradient(160deg, oklch(0.32 0.08 268), oklch(0.18 0.04 250));
  color: #fff;
  padding: 40px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
  overflow: hidden;
}
.auth-side::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 56px 56px;
  background-position: -1px -1px;
  pointer-events: none;
  mask-image: radial-gradient(circle at 30% 40%, #000, transparent 75%);
}
.auth-side > * { position: relative; }
.auth-side .group-mark {
  height: 28px;
  display: inline-flex; align-items: center;
}
.auth-side .group-mark img {
  height: 28px;
  width: auto;
}
.auth-side h1 {
  margin: auto 0 12px;
  font-family: var(--ds-font-display);
  font-weight: 600;
  font-size: 44px;
  letter-spacing: -0.025em;
  line-height: 1.05;
  max-width: 16ch;
  text-wrap: balance;
}
.auth-side h1 em {
  font-style: normal;
  background: linear-gradient(90deg, oklch(0.85 0.18 232), oklch(0.93 0.12 100));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.auth-side .lede {
  font-size: 14.5px;
  color: oklch(0.85 0.02 250);
  line-height: 1.55;
  max-width: 42ch;
  margin: 0 0 24px;
}
.auth-side .feature-list {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}
.auth-side .feature {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  align-items: start;
}
.auth-side .feature .ic {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  display: grid; place-items: center;
  color: oklch(0.92 0.10 232);
}
.auth-side .feature h4 {
  margin: 0 0 2px;
  font-family: var(--ds-font-display);
  font-size: 13.5px;
  font-weight: 600;
}
.auth-side .feature p {
  margin: 0;
  font-size: 12.5px;
  color: oklch(0.78 0.015 250);
  line-height: 1.45;
}
.auth-side .meta-foot {
  margin-top: auto;
  font-size: 11.5px;
  color: oklch(0.72 0.015 250);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.auth-side .meta-foot a { color: inherit; opacity: 0.8; }
.auth-side .meta-foot a:hover { opacity: 1; }

.auth-main {
  display: grid;
  place-items: center;
  padding: 32px;
}
.auth-card {
  width: 100%;
  max-width: 440px;
}
.auth-card .head {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 24px;
}
.auth-card .head h2 {
  margin: 0;
  font-family: var(--ds-font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ds-ink);
}
.auth-card .head p {
  margin: 0;
  color: var(--ds-muted);
  font-size: 13.5px;
}

/* OAuth provider buttons */
.oauth-stack {
  display: grid;
  gap: 8px;
}
.oauth-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--ds-surface);
  border: 1px solid var(--ds-border-strong);
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ds-ink);
  width: 100%;
  text-align: left;
  transition: background 120ms, border-color 120ms;
}
.oauth-btn:hover {
  background: var(--ds-surface-2);
  border-color: var(--ds-n-400);
}
.oauth-btn .pmark {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.oauth-btn small {
  margin-left: auto;
  color: var(--ds-muted);
  font-size: 11.5px;
  font-weight: 400;
}

/* divider */
.or-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 20px 0;
  font-size: 11px;
  color: var(--ds-muted-2);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
}
.or-divider::before, .or-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--ds-border);
}

.auth-meta-row {
  display: flex; align-items: center; justify-content: space-between;
  margin: -2px 0 14px;
}
.auth-meta-row label {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px;
  color: var(--ds-ink-2);
  cursor: pointer;
}
.auth-meta-row label input { accent-color: var(--ds-a); }

/* ===================== App shell ===================== */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "topbar topbar"
    "side main";
  height: 100vh;
}
.topbar {
  grid-area: topbar;
  background: var(--ds-surface);
  border-bottom: 1px solid var(--ds-border);
  display: flex;
  align-items: center;
  padding: 0 18px 0 22px;
  gap: 16px;
}
.topbar .crumb {
  font-size: 11.5px;
  color: var(--ds-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar .crumb b { color: var(--ds-ink); font-weight: 500; }
.topbar .spacer { flex: 1; }
.topbar .top-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--ds-ink-2);
  background: transparent;
  transition: background 120ms;
  position: relative;
}
.icon-btn:hover { background: var(--ds-surface-2); }
.icon-btn .dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ds-error); border: 2px solid var(--ds-bg);
}
.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: var(--ds-surface-2);
  border: 1px solid var(--ds-border);
  cursor: pointer;
}
.user-pill:hover { background: var(--ds-surface-3); }
.user-pill .name { font-size: 12.5px; font-weight: 500; line-height: 1.1; }
.user-pill .role { font-size: 11px; color: var(--ds-muted); line-height: 1.1; }

.sidebar {
  grid-area: side;
  background: var(--ds-surface);
  border-right: 1px solid var(--ds-border);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.sidebar .nav-section {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ds-muted-2);
  font-weight: 700;
  padding: 12px 10px 6px;
}
.sidebar .nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--ds-ink-2);
  font-size: 13px;
  font-weight: 500;
  transition: background 120ms, color 120ms;
  cursor: pointer;
}
.sidebar .nav-item:hover { background: var(--ds-surface-2); color: var(--ds-ink); }
.sidebar .nav-item.active {
  background: var(--ds-a-soft);
  color: var(--ds-a-ink);
}
.sidebar .nav-item.active svg { color: var(--ds-a); }
.sidebar .nav-item .badge {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 600;
  background: var(--ds-surface-3);
  color: var(--ds-muted);
  padding: 1px 7px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}
.sidebar .nav-item.active .badge { background: var(--ds-a); color: #fff; }
.sidebar .nav-foot {
  margin-top: auto;
  padding: 12px 10px;
  font-size: 11px;
  color: var(--ds-muted);
  border-top: 1px solid var(--ds-border);
  display: flex; align-items: center; gap: 8px;
}
.sidebar .nav-foot .pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ds-success);
  box-shadow: 0 0 0 0 currentColor;
  animation: pulseDot 2.4s ease-in-out infinite;
  color: var(--ds-success);
}
@keyframes pulseDot {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in oklch, currentColor 50%, transparent); }
  50% { box-shadow: 0 0 0 5px transparent; }
}

.main {
  grid-area: main;
  overflow-y: auto;
  background: var(--ds-bg-muted);
}
.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 36px 56px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}
.page-head h1 {
  margin: 0;
  font-family: var(--ds-font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ds-ink);
}
.page-head p {
  margin: 4px 0 0;
  color: var(--ds-muted);
  font-size: 13.5px;
}
.page-head .actions { display: flex; gap: 8px; }

.eyebrow {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ds-muted);
  font-weight: 700;
}

/* ===================== Profile / forms ===================== */
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.avatar-edit {
  display: flex; align-items: center; gap: 18px;
}
.avatar-blob {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ds-a), oklch(0.45 0.18 268));
  color: #fff;
  display: grid; place-items: center;
  font-family: var(--ds-font-display);
  font-weight: 600;
  font-size: 36px;
  letter-spacing: -0.02em;
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar-blob img {
  width: 100%; height: 100%; object-fit: cover;
}
.avatar-blob .change {
  position: absolute;
  inset: auto 0 0 0;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  text-align: center;
  padding: 6px 0;
  opacity: 0;
  transition: opacity 120ms;
}
.avatar-blob:hover .change { opacity: 1; }
.avatar-edit .meta { display: flex; flex-direction: column; gap: 6px; }
.avatar-edit .meta b {
  font-family: var(--ds-font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.avatar-edit .meta span {
  color: var(--ds-muted);
  font-size: 12.5px;
}
.avatar-edit .meta .actions {
  margin-top: 8px;
  display: flex; gap: 8px;
}

/* ===================== 2FA ===================== */
.method-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ds-border);
}
.method-row:last-child { border-bottom: 0; }
.method-row .ic {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--ds-surface-2);
  color: var(--ds-ink-2);
  display: grid; place-items: center;
}
.method-row .ic.brand { background: var(--ds-a-soft); color: var(--ds-a); }
.method-row .ic.success { background: var(--ds-success-soft); color: var(--ds-success); }
.method-row .info b {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ds-ink);
  letter-spacing: -0.005em;
}
.method-row .info span {
  display: block;
  font-size: 12px;
  color: var(--ds-muted);
  margin-top: 2px;
}
.method-row .info span.recommended {
  display: inline-block;
  margin-top: 6px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ds-success-ink);
  background: var(--ds-success-soft);
  padding: 2px 8px;
  border-radius: 4px;
}

.qr-pane {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  padding: 20px;
  background: var(--ds-surface-2);
  border-radius: 10px;
  margin-top: 12px;
}
.qr-pane .qr-box {
  width: 200px; height: 200px;
  background: #fff;
  border: 1px solid var(--ds-border);
  border-radius: 10px;
  padding: 12px;
  display: grid; place-items: center;
}
.qr-pane .qr-box svg { width: 100%; height: 100%; }
.qr-pane ol {
  margin: 0;
  padding-left: 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.qr-pane ol li {
  font-size: 12.5px;
  color: var(--ds-ink-2);
  line-height: 1.55;
}
.code-input {
  display: flex; gap: 6px;
  margin-top: 8px;
}
.code-input input {
  width: 38px; height: 46px;
  text-align: center;
  border: 1px solid var(--ds-border-strong);
  border-radius: 7px;
  background: var(--ds-surface);
  font-family: var(--ds-font-mono);
  font-size: 18px;
  font-weight: 500;
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
.code-input input:focus {
  border-color: var(--ds-a);
  box-shadow: var(--ds-shadow-focus);
}

.recovery-codes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 14px;
  padding: 14px 16px;
  background: var(--ds-surface-2);
  border: 1px dashed var(--ds-border-strong);
  border-radius: 8px;
  font-family: var(--ds-font-mono);
  font-size: 12.5px;
  color: var(--ds-ink-2);
  letter-spacing: 0.04em;
}

/* ===================== Apps grid ===================== */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.app-card {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 120ms, box-shadow 120ms, transform 120ms;
  position: relative;
  text-align: left;
}
.app-card:hover {
  border-color: var(--ds-border-strong);
  box-shadow: var(--ds-shadow-md);
}
.app-card.disabled {
  opacity: 0.6;
}
.app-card .top {
  display: flex; align-items: flex-start; gap: 12px;
}
.app-card .ico {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: grid; place-items: center;
  color: #fff;
  font-family: var(--ds-font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.app-card .meta {
  flex: 1;
  min-width: 0;
}
.app-card .meta b {
  display: block;
  font-family: var(--ds-font-display);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ds-ink);
  line-height: 1.2;
}
.app-card .meta .url {
  display: block;
  font-family: var(--ds-font-mono);
  font-size: 11px;
  color: var(--ds-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-card .desc {
  font-size: 12.5px;
  color: var(--ds-ink-2);
  line-height: 1.5;
  flex: 1;
}
.app-card .roles {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.app-card .foot {
  display: flex; align-items: center; gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--ds-border);
  font-size: 11.5px;
  color: var(--ds-muted);
}
.app-card .foot .open {
  margin-left: auto;
  color: var(--ds-a-ink);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--ds-surface-3);
  color: var(--ds-ink-2);
}
.chip.brand { background: var(--ds-a-soft); color: var(--ds-a-ink); }
.chip.success { background: var(--ds-success-soft); color: var(--ds-success-ink); }
.chip.warn { background: var(--ds-warm-soft); color: var(--ds-warm-ink); }
.chip.error { background: var(--ds-hot-soft); color: var(--ds-hot-ink); }
.chip .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ===================== Tables ===================== */
.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}
.tbl thead th {
  text-align: left;
  font-weight: 500;
  font-size: 10.5px;
  color: var(--ds-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 12px;
  background: var(--ds-surface-2);
  border-bottom: 1px solid var(--ds-border);
  white-space: nowrap;
}
.tbl tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--ds-border);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--ds-surface-2); }
.tbl .mono { font-family: var(--ds-font-mono); }
.tbl td .ic-row { display: inline-flex; align-items: center; gap: 8px; }

/* user-app matrix in admin */
.matrix-cell {
  display: grid; place-items: center;
  height: 28px;
}
.toggle {
  position: relative;
  width: 36px; height: 20px;
  border-radius: 999px;
  background: var(--ds-n-300);
  transition: background 120ms;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 160ms cubic-bezier(0.2,0.8,0.2,1);
  box-shadow: 0 1px 2px rgba(0,0,0,0.18);
}
.toggle.on { background: var(--ds-a); }
.toggle.on::after { transform: translateX(16px); }

/* ===================== Modal ===================== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: color-mix(in oklch, var(--ds-n-900) 55%, transparent);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
}
.modal {
  width: 100%;
  max-width: 560px;
  background: var(--ds-surface);
  border-radius: 14px;
  box-shadow: var(--ds-shadow-lg);
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-head {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--ds-border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-head h3 {
  margin: 0;
  font-family: var(--ds-font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
  flex: 1;
}
.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--ds-border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  background: var(--ds-surface-2);
}

/* ===================== OAuth consent ===================== */
.consent-shell {
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, oklch(0.92 0.05 268 / 0.5), transparent 50%),
    radial-gradient(circle at 80% 100%, oklch(0.92 0.06 232 / 0.5), transparent 50%),
    var(--ds-bg-muted);
  display: grid;
  place-items: center;
  padding: 32px;
}
.consent-card {
  width: 100%;
  max-width: 480px;
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: 16px;
  box-shadow: var(--ds-shadow-lg);
  overflow: hidden;
}
.consent-head {
  padding: 28px 28px 0;
  text-align: center;
}
.consent-handshake {
  display: flex; align-items: center; justify-content: center;
  gap: 14px;
  margin: 8px 0 18px;
}
.consent-handshake .arc {
  width: 64px; height: 64px;
  border-radius: 16px;
  display: grid; place-items: center;
  font-family: var(--ds-font-display);
  font-weight: 700;
  font-size: 22px;
  color: #fff;
  letter-spacing: -0.02em;
}
.consent-handshake .arrow {
  display: grid; place-items: center;
  color: var(--ds-muted);
  position: relative;
}
.consent-handshake .arrow::before,
.consent-handshake .arrow::after {
  content: "";
  position: absolute;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--ds-a);
  animation: dotMove 1.4s ease-in-out infinite;
}
.consent-handshake .arrow::after { animation-delay: 0.7s; }
@keyframes dotMove {
  0% { transform: translateX(-22px); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translateX(22px); opacity: 0; }
}
.consent-head h2 {
  margin: 0;
  font-family: var(--ds-font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.consent-head p {
  margin: 8px 0 0;
  color: var(--ds-muted);
  font-size: 13.5px;
}
.consent-head p b { color: var(--ds-ink); font-weight: 600; }
.consent-body { padding: 22px 28px; }
.scope-list {
  border: 1px solid var(--ds-border);
  border-radius: 10px;
  overflow: hidden;
}
.scope {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--ds-border);
  align-items: start;
}
.scope:last-child { border-bottom: 0; }
.scope .ic {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--ds-a-soft);
  color: var(--ds-a);
}
.scope b {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ds-ink);
}
.scope span {
  display: block;
  font-size: 12px;
  color: var(--ds-muted);
  margin-top: 2px;
  line-height: 1.45;
}
.consent-foot {
  padding: 16px 28px 24px;
  display: grid;
  gap: 10px;
}
.consent-foot .meta-line {
  font-size: 11px;
  text-align: center;
  color: var(--ds-muted-2);
  margin-top: 6px;
}
.consent-foot .meta-line code {
  font-family: var(--ds-font-mono);
  background: var(--ds-surface-2);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ===================== Misc ===================== */
.kbd {
  display: inline-flex; align-items: center;
  font-family: var(--ds-font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  background: var(--ds-surface-3);
  border: 1px solid var(--ds-border);
  border-radius: 4px;
  color: var(--ds-muted);
}
.tip-banner {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(180deg,
    color-mix(in oklch, var(--ds-a) 7%, var(--ds-surface)),
    var(--ds-surface));
  border: 1px solid color-mix(in oklch, var(--ds-a) 18%, var(--ds-border));
  border-radius: 12px;
}
.tip-banner .ic {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--ds-a);
  color: #fff;
  display: grid; place-items: center;
}
.tip-banner b {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ds-ink);
}
.tip-banner span {
  display: block;
  font-size: 12px;
  color: var(--ds-muted);
  margin-top: 2px;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--ds-muted);
}
.empty-state .ic {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: var(--ds-surface-3);
  color: var(--ds-muted);
  display: inline-grid; place-items: center;
  margin-bottom: 12px;
}
.empty-state b {
  display: block;
  color: var(--ds-ink);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.session-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ds-border);
  align-items: center;
}
.session-row:last-child { border-bottom: 0; }
.session-row .ic {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--ds-surface-2);
  color: var(--ds-ink-2);
  display: grid; place-items: center;
}
.session-row b { font-size: 13px; font-weight: 600; }
.session-row span { display: block; font-size: 11.5px; color: var(--ds-muted); margin-top: 2px; }
.session-row .now {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ds-success-ink);
  background: var(--ds-success-soft);
  padding: 2px 8px;
  border-radius: 999px;
}

/* ===================== Responsive ===================== */

/* Tablet — auth screens stackują, sidebar znika, brand-marka się skraca */
@media (max-width: 880px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .row-2, .row-3 { grid-template-columns: 1fr; }
  .app { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .sidebar { display: none; }
  /* Topbar — chowamy crumb (Konto › Twoje aplikacje) bo i tak page H1
   * to mówi. Wordmark zostaje na tablecie. */
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar .crumb { display: none; }
  .topbar > span[style*="width: 1px"] { display: none; }
  /* User pill — kompakt: avatar + chevron, bez tekstu */
  .user-pill .name, .user-pill .role { display: none; }
  .user-pill { padding: 4px; }
  /* Page padding redukujemy */
  .page { padding: 22px 16px 40px; }
}

/* Mobile — apps grid pełna szerokość, brand-mark tylko ikoną */
@media (max-width: 560px) {
  /* Brand mark w topbarze — chowamy wordmark (DealerID + subtitle),
   * zostaje tylko kwadrat z "ID". */
  .topbar .brand-mark .wordmark { display: none; }
  .topbar { padding: 0 10px; }
  /* Apps grid 1-kol */
  .apps-grid { grid-template-columns: 1fr; gap: 10px; }
  .app-card { padding: 14px; }
  .app-card .ico { width: 36px; height: 36px; font-size: 13px; }
  /* Strona */
  .page { padding: 18px 12px 32px; }
  .page h1 { font-size: 24px; }
  .page .desc { font-size: 13.5px; }
  /* Notification icon-btn pod min-touch-size */
  .icon-btn { width: 36px; height: 36px; }
}
