/* DCTR SaaS — premium minimalist (Stripe / Vercel aesthetic) */

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --border: #eaeaea;
  --border-strong: #d4d4d4;
  --text: #171717;
  --text-secondary: #525252;
  --muted: #737373;
  --accent: #0070f3;
  --accent-hover: #0060df;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

[x-cloak] {
  display: none !important;
}

/* ── Auth layout ── */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 960px) {
  .auth-shell {
    grid-template-columns: 1fr 1fr;
  }
}

.auth-brand {
  display: none;
  position: relative;
  overflow: hidden;
  background: #0a0a0a;
  color: #fafafa;
  padding: 3rem;
}

@media (min-width: 960px) {
  .auth-brand {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
}

.auth-brand__mesh {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 20%, rgba(0, 112, 243, 0.35), transparent 50%),
    radial-gradient(ellipse 60% 50% at 80% 80%, rgba(99, 102, 241, 0.2), transparent 50%),
    radial-gradient(ellipse 40% 40% at 60% 40%, rgba(255, 255, 255, 0.04), transparent 50%);
  pointer-events: none;
}

.auth-brand__content {
  position: relative;
  z-index: 1;
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  background: var(--surface);
}

@media (min-width: 960px) {
  .auth-panel {
    background: var(--bg);
  }
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
}

@media (min-width: 960px) {
  .auth-card {
    box-shadow: var(--shadow);
  }
}

/* ── Form controls ── */
.field-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

.field-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 112, 243, 0.12);
}

.field-input::placeholder {
  color: #a3a3a3;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.625rem 1rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.btn-primary:hover {
  background: #262626;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: #f5f5f5;
  border-color: var(--border-strong);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-accent:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.btn-ghost:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ── App shell ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(250, 250, 250, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.app-nav-tab {
  position: relative;
  display: inline-block;
  padding: 0.875rem 0;
  margin-right: 1.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s;
}

.app-nav-tab:hover {
  color: var(--text);
}

.app-nav-tab.is-active {
  color: var(--text);
}

.app-nav-tab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}

/* ── Metric cards ── */
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow-sm);
}

.metric-card__label {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.metric-card__value {
  font-size: 2.25rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.metric-card__icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

/* ── Status badge ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-badge--active {
  background: #ecfdf5;
  color: #047857;
}

.status-badge--active::before {
  background: var(--success);
}

.status-badge--depleted {
  background: #fef3c7;
  color: #b45309;
}

.status-badge--depleted::before {
  background: var(--warning);
}

.status-badge--inactive {
  background: #fef2f2;
  color: #b91c1c;
}

.status-badge--inactive::before {
  background: var(--danger);
}

/* ── API key block ── */
.api-key-box {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.875rem 1rem;
  word-break: break-all;
  line-height: 1.5;
}

/* ── Sandbox ── */
.sandbox-tabs {
  display: inline-flex;
  background: #f5f5f5;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.sandbox-tab {
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sandbox-tab.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.json-output {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.6;
  background: #0a0a0a;
  color: #a3e635;
  border-radius: var(--radius);
  padding: 1.25rem;
  min-height: 180px;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.json-output.is-error {
  color: #fca5a5;
}

.json-output.is-idle {
  color: #525252;
}

/* ── Pricing ── */
.pricing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.pricing-card:hover {
  box-shadow: var(--shadow);
}

.pricing-card--featured {
  border-color: var(--text);
  box-shadow: var(--shadow);
  position: relative;
}

.pricing-card__badge {
  position: absolute;
  top: -0.75rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
}

/* ── Activity table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  font-weight: 500;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.75rem 1.5rem;
  background: #fafafa;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 0.875rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: #fafafa;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  background: var(--text);
  color: #fff;
  font-size: 0.875rem;
  padding: 0.75rem 1.125rem;
  border-radius: 10px;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Auth mode toggle ── */
.auth-toggle {
  display: flex;
  background: #f5f5f5;
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 1.75rem;
}

.auth-toggle button {
  flex: 1;
  padding: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.auth-toggle button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.section-card__header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.section-card__body {
  padding: 1.5rem;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--muted);
  font-size: 0.875rem;
}

/* ── Activity log / analytics bar ── */
.activity-log {
  margin-top: 0.5rem;
}

.activity-log__summary {
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.activity-log__dot {
  margin: 0 0.35rem;
  opacity: 0.5;
}

.endpoint-pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
}

.endpoint-pill--search {
  background: #eff6ff;
  color: #1d4ed8;
}

.endpoint-pill--lot {
  background: #f5f3ff;
  color: #6d28d9;
}

.endpoint-pill--other {
  background: #f5f5f5;
  color: var(--text-secondary);
}

.credit-spent {
  display: inline-flex;
  align-items: center;
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 0.15rem 0.45rem;
}

.credit-spent--free {
  color: #047857;
  background: #ecfdf5;
  border-color: #a7f3d0;
}

/* ── Automation panel ── */
.automation-status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: #f5f5f5;
  color: var(--muted);
  border: 1px solid var(--border);
}

.automation-status-pill.is-live {
  background: rgba(5, 150, 105, 0.1);
  color: var(--success);
  border-color: rgba(5, 150, 105, 0.25);
}

.toggle-pill {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fafafa;
  color: var(--muted);
}

.toggle-pill.is-on {
  background: rgba(0, 112, 243, 0.1);
  color: var(--accent);
  border-color: rgba(0, 112, 243, 0.25);
}

.log-level-pill {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: #f5f5f5;
}

.log-level--error {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
}

.log-level--warning {
  background: rgba(217, 119, 6, 0.1);
  color: var(--warning);
}

.log-level--info {
  background: rgba(0, 112, 243, 0.08);
  color: var(--accent);
}

/* ── Car preview cards (publish panel) ── */
.car-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border, #e5e5e5);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  background: #fff;
  position: relative;
  transition: border-color .15s, box-shadow .15s;
}
.car-card.is-selected {
  border-color: var(--accent, #0070f3);
  box-shadow: 0 0 0 2px rgba(0, 112, 243, 0.15);
}
.car-card__check {
  position: absolute;
  top: 8px;
  inset-inline-start: 8px;
  width: 18px;
  height: 18px;
  z-index: 2;
  accent-color: var(--accent, #0070f3);
}
.car-card__img {
  aspect-ratio: 4 / 3;
  background-color: #f3f4f6;
  background-size: cover;
  background-position: center;
}
.car-card__body { padding: 8px 10px; }
.car-card__title {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.car-card__meta { font-size: 11px; color: #737373; margin-top: 3px; font-family: ui-monospace, monospace; }
.car-card__status { font-size: 11px; margin-top: 4px; font-weight: 600; }

/* ═══════════ Ops surface: chips, richer cards, pager, modal ═══════════ */

/* Status chip system — reused for role/subscription/fb/connection state */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter .15s;
}
.chip:hover { filter: brightness(0.97); }
.chip--neutral { background: #f4f4f5; color: #52525b; border-color: #e4e4e7; }
.chip--accent  { background: rgba(0,112,243,0.10); color: var(--accent); border-color: rgba(0,112,243,0.20); }
.chip--success { background: rgba(5,150,105,0.10); color: var(--success); border-color: rgba(5,150,105,0.20); }
.chip--danger  { background: rgba(220,38,38,0.10); color: var(--danger); border-color: rgba(220,38,38,0.20); }

/* Usage bar (admin credits balance / allowance) */
.usage-bar { height: 6px; width: 96px; border-radius: 999px; background: #ececec; overflow: hidden; }
.usage-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* Richer car card overlays + states */
.car-card__img { position: relative; }
.car-card__source {
  position: absolute; top: 6px; inset-inline-end: 6px;
  background: rgba(0,0,0,0.62); color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 6px;
}
.car-card__imgcount {
  position: absolute; bottom: 6px; inset-inline-start: 6px;
  background: rgba(0,0,0,0.55); color: #fff;
  font-size: 10px; padding: 2px 6px; border-radius: 6px;
}
.car-card__chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.mini-chip {
  font-size: 10px; padding: 1px 6px; border-radius: 6px;
  background: #f4f4f5; color: #52525b; white-space: nowrap;
}
.car-card.is-done { border-color: var(--success); box-shadow: 0 0 0 2px rgba(5,150,105,0.15); }
.car-card.is-error { border-color: var(--danger); box-shadow: 0 0 0 2px rgba(220,38,38,0.12); }

/* Skeletons */
.car-card--skeleton { pointer-events: none; }
.skeleton-line { height: 10px; border-radius: 4px; background: #eee; }
.car-card--skeleton .car-card__img { background: #eee; }
.car-card--skeleton .car-card__img,
.skeleton-line { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-card {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  width: 100%; max-width: 400px; padding: 22px;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .chip--neutral { background: #27272a; color: #a1a1aa; border-color: #3f3f46; }
  .mini-chip { background: #27272a; color: #a1a1aa; }
  .usage-bar { background: #3f3f46; }
  .skeleton-line, .car-card--skeleton .car-card__img { background: #333; }
}
