/* AuraGrid Ops — Linear / Vercel / Stripe tier admin UI. CSP-safe: no inline styles required. */
:root {
  --ops-indigo: #4F46E5;
  --ops-violet: #7C3AED;
  --ops-cyan: #06B6D4;
  --ops-bg: #EEF2FF;
  --ops-bg-2: #F5F3FF;
  --ops-surface: #F8FAFC;
  --ops-surface-2: #F1F5F9;
  --ops-elevated: rgba(248, 250, 252, 0.92);
  --ops-text: #0F172A;
  --ops-text-2: #334155;
  --ops-muted: #64748B;
  --ops-line: rgba(79, 70, 229, 0.12);
  --ops-line-2: rgba(15, 23, 42, 0.08);
  --ops-rain: linear-gradient(125deg, #fbcfe8, #e9d5ff 25%, #bfdbfe 50%, #a7f3d0 75%, #fde68a);
  --ops-accent: linear-gradient(135deg, var(--ops-indigo), var(--ops-violet) 55%, var(--ops-cyan));
  --ops-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 12px 32px rgba(79, 70, 229, 0.1);
  --ops-radius: 14px;
  --ops-rail: 56px;
  --ops-rail-wide: 220px;
  --ops-top: 56px;
  --ops-tab: 64px;
  --ops-focus: 0 0 0 3px rgba(6, 182, 212, 0.45);
  --ops-zebra: rgba(79, 70, 229, 0.03);
  color-scheme: light;
}

html[data-theme="dark"] {
  --ops-bg: #0B1020;
  --ops-bg-2: #111827;
  --ops-surface: #151B2E;
  --ops-surface-2: #1E293B;
  --ops-elevated: rgba(21, 27, 46, 0.94);
  --ops-text: #F1F5F9;
  --ops-text-2: #CBD5E1;
  --ops-muted: #94A3B8;
  --ops-line: rgba(124, 58, 237, 0.22);
  --ops-line-2: rgba(148, 163, 184, 0.12);
  --ops-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 16px 40px rgba(0, 0, 0, 0.45);
  --ops-zebra: rgba(6, 182, 212, 0.06);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

.ops-body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--ops-bg);
  color: var(--ops-text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.ops-loading { padding: 48px; text-align: center; color: var(--ops-muted); }

/* —— Auth split —— */
.ops-auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.ops-auth-brand {
  position: relative;
  overflow: hidden;
  padding: clamp(24px, 5vw, 48px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  background: var(--ops-bg-2);
  border-right: 1px solid var(--ops-line-2);
}

.ops-mesh {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(ellipse 60% 50% at 20% 30%, rgba(244, 114, 182, 0.45), transparent 55%),
    radial-gradient(ellipse 55% 45% at 80% 20%, rgba(124, 58, 237, 0.4), transparent 50%),
    radial-gradient(ellipse 50% 55% at 60% 80%, rgba(6, 182, 212, 0.35), transparent 55%),
    radial-gradient(ellipse 40% 40% at 10% 85%, rgba(253, 230, 138, 0.35), transparent 50%);
  animation: ops-mesh-shift 18s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes ops-mesh-shift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(-3%, 2%, 0) scale(1.06); }
}

.ops-auth-brand-inner { position: relative; z-index: 1; max-width: 420px; }

.ops-logo-glow {
  display: inline-flex;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--ops-surface);
  border: 1px solid var(--ops-line);
  box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.08), 0 0 48px rgba(124, 58, 237, 0.25);
}

.ops-logo-glow img { height: 36px; width: auto; display: block; }

.ops-slogan {
  margin: 8px 0 0;
  font-size: clamp(1.25rem, 2.5vw, 1.65rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.25;
  color: var(--ops-text);
}

.ops-auth-3d {
  margin-top: 24px;
  width: min(280px, 70%);
  filter: drop-shadow(0 24px 40px rgba(79, 70, 229, 0.25));
  animation: ops-float 5s ease-in-out infinite;
}

@keyframes ops-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.ops-auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--ops-bg);
}

.ops-auth-card {
  width: min(420px, 100%);
  padding: 28px;
  border-radius: 20px;
  border: 1px solid var(--ops-line);
  background: var(--ops-elevated);
  box-shadow: var(--ops-shadow);
}

@media (min-width: 769px) {
  .ops-auth-card--glass {
    background: color-mix(in srgb, var(--ops-elevated) 78%, transparent);
    backdrop-filter: blur(18px);
  }
}

.ops-auth-card h1 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.ops-auth-sub { margin: 0 0 20px; font-size: 14px; color: #1e293b; line-height: 1.45; }

.ops-auth-stack { display: flex; flex-direction: column; gap: 14px; }

.ops-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ops-text-2);
  margin-bottom: 6px;
}

.ops-field input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--ops-line-2);
  background: var(--ops-surface);
  color: var(--ops-text);
  font: inherit;
}

.ops-field input:focus {
  outline: none;
  border-color: var(--ops-cyan);
  box-shadow: var(--ops-focus);
}

.ops-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  color: var(--ops-text);
  background: var(--ops-surface);
}

.ops-btn:focus-visible { outline: none; box-shadow: var(--ops-focus); }

.ops-btn--primary {
  background: var(--ops-accent);
  color: #fff;
  border: none;
}

.ops-btn--ghost {
  background: transparent;
  border-color: var(--ops-line-2);
}

.ops-btn--sm { padding: 7px 10px; font-size: 13px; border-radius: 10px; }

.ops-btn--icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
}

.ops-icon {
  width: 18px;
  height: 18px;
  display: block;
  flex-shrink: 0;
}

.ops-hidden { display: none !important; }

@media (max-width: 768px) {
  .ops-auth { grid-template-columns: 1fr; }
  .ops-auth-brand {
    min-height: 38vh;
    border-right: none;
    border-bottom: 1px solid var(--ops-line-2);
    text-align: center;
    align-items: center;
  }
  .ops-auth-brand-inner { display: flex; flex-direction: column; align-items: center; }
  .ops-auth-3d { width: 160px; margin-top: 12px; }
  .ops-mesh { animation: none; opacity: 0.85; }
}

/* —— App shell —— */
.ops-app {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--ops-rail) 1fr;
  grid-template-rows: var(--ops-top) 1fr;
  grid-template-areas:
    "rail top"
    "rail main";
  background: var(--ops-bg);
}

.ops-app.ops-app--wide { grid-template-columns: var(--ops-rail-wide) 1fr; }

.ops-rail {
  grid-area: rail;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 10px 8px;
  gap: 6px;
  background: var(--ops-surface);
  border-right: 1px solid var(--ops-line-2);
  z-index: 20;
}

.ops-rail-toggle {
  align-self: center;
  margin-bottom: 4px;
}

.ops-rail a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--ops-muted);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
}

.ops-rail a:hover { background: var(--ops-surface-2); color: var(--ops-text); }

.ops-rail a.on {
  color: var(--ops-indigo);
  background: color-mix(in srgb, var(--ops-indigo) 12%, transparent);
  border-color: var(--ops-line);
}

html[data-theme="dark"] .ops-rail a.on { color: #A5B4FC; }

.ops-rail-label {
  white-space: nowrap;
  overflow: hidden;
  opacity: 0;
  max-width: 0;
  transition: max-width 0.2s, opacity 0.15s;
}

.ops-app--wide .ops-rail-label {
  opacity: 1;
  max-width: 160px;
}

.ops-rail-foot {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--ops-line-2);
  font-size: 11px;
  color: var(--ops-muted);
  text-align: center;
  overflow: hidden;
}

.ops-app--wide .ops-rail-foot { text-align: left; padding-left: 10px; }

.ops-topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--ops-line-2);
  background: var(--ops-surface);
}

.ops-search {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--ops-line-2);
  background: var(--ops-bg);
  color: var(--ops-muted);
  font-size: 13px;
  cursor: pointer;
}

.ops-search kbd {
  margin-left: auto;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--ops-line-2);
  background: var(--ops-surface);
  color: var(--ops-muted);
}

.ops-topbar-title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.ops-main-scroll {
  grid-area: main;
  overflow: auto;
  padding: 20px 20px calc(20px + var(--ops-tab));
  -webkit-overflow-scrolling: touch;
}

.ops-page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.ops-page-head h1 { margin: 0; font-size: 1.35rem; letter-spacing: -0.03em; }

.ops-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ops-cyan) 18%, transparent);
  color: var(--ops-text-2);
  border: 1px solid color-mix(in srgb, var(--ops-cyan) 35%, transparent);
}

.ops-pill--warn {
  background: color-mix(in srgb, #F59E0B 20%, transparent);
  border-color: color-mix(in srgb, #F59E0B 40%, transparent);
}

.ops-pill--off {
  background: color-mix(in srgb, #EF4444 15%, transparent);
  border-color: color-mix(in srgb, #EF4444 35%, transparent);
}

/* KPI tiles */
.ops-kpi-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 20px;
}

.ops-kpi {
  position: relative;
  padding: 16px;
  border-radius: var(--ops-radius);
  background: var(--ops-surface);
  border: 1px solid transparent;
  background-clip: padding-box;
  box-shadow: var(--ops-shadow);
}

.ops-kpi::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: var(--ops-rain);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.ops-kpi h3 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ops-muted);
  font-weight: 600;
}

.ops-kpi-val {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.ops-kpi-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.ops-spark { width: 88px; height: 28px; flex-shrink: 0; }

.ops-spark path, .ops-spark polyline { fill: none; stroke: var(--ops-cyan); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Tables */
.ops-table-panel {
  border: 1px solid var(--ops-line-2);
  border-radius: var(--ops-radius);
  background: var(--ops-surface);
  overflow: hidden;
  box-shadow: var(--ops-shadow);
}

.ops-table-scroll { max-height: min(60vh, 520px); overflow: auto; }

.ops-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.ops-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ops-muted);
  background: var(--ops-surface-2);
  border-bottom: 1px solid var(--ops-line-2);
}

.ops-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--ops-line-2);
}

.ops-table tbody tr:nth-child(even) { background: var(--ops-zebra); }

.ops-table tbody tr[data-row] { cursor: pointer; }

.ops-table tbody tr[data-row]:hover { background: color-mix(in srgb, var(--ops-indigo) 10%, var(--ops-surface)); }

.ops-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--ops-surface-2);
  color: var(--ops-text-2);
  border: 1px solid var(--ops-line-2);
}

.ops-badge--live { background: color-mix(in srgb, #10B981 18%, transparent); color: #047857; border-color: color-mix(in srgb, #10B981 35%, transparent); }

html[data-theme="dark"] .ops-badge--live { color: #6EE7B7; }

.ops-badge--rush { background: color-mix(in srgb, #F59E0B 22%, transparent); color: #B45309; border-color: color-mix(in srgb, #F59E0B 40%, transparent); }

/* Empty state */
.ops-empty {
  text-align: center;
  padding: 40px 24px;
  border-radius: var(--ops-radius);
  border: 1px dashed var(--ops-line);
  background: var(--ops-surface);
}

.ops-empty img { width: 160px; height: auto; margin-bottom: 12px; opacity: 0.9; }

.ops-empty p { margin: 0; color: var(--ops-muted); font-size: 14px; max-width: 36ch; margin-inline: auto; }
.ops-empty__hint { margin: 8px 0 0 !important; font-size: 13px; line-height: 1.45; color: var(--ops-muted); opacity: 0.92; max-width: 40ch; }

/* Mobile cards */
.ops-card-list { display: none; gap: 10px; }

.ops-card-row {
  padding: 14px;
  border-radius: var(--ops-radius);
  border: 1px solid var(--ops-line-2);
  background: var(--ops-surface);
  box-shadow: var(--ops-shadow);
}

.ops-card-row h3 { margin: 0 0 4px; font-size: 14px; }

.ops-card-row p { margin: 0; font-size: 13px; color: var(--ops-muted); }

/* Drawer */
.ops-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 40;
}

.ops-backdrop.open { opacity: 1; pointer-events: auto; }

.ops-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(440px, 100%);
  height: 100%;
  background: var(--ops-surface);
  border-left: 1px solid var(--ops-line-2);
  box-shadow: -16px 0 48px rgba(15, 23, 42, 0.15);
  transform: translateX(100%);
  transition: transform 0.22s ease;
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.ops-drawer.open { transform: translateX(0); }

.ops-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--ops-line-2);
}

.ops-drawer-body { padding: 18px; overflow: auto; flex: 1; }

/* Command palette */
.ops-palette {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
  background: rgba(15, 23, 42, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.ops-palette.open { opacity: 1; pointer-events: auto; }

.ops-palette-box {
  width: min(520px, 100%);
  border-radius: 16px;
  border: 1px solid var(--ops-line-2);
  background: var(--ops-surface);
  box-shadow: var(--ops-shadow);
  overflow: hidden;
}

.ops-palette-input {
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-bottom: 1px solid var(--ops-line-2);
  background: transparent;
  color: var(--ops-text);
  font: inherit;
  font-size: 15px;
}

.ops-palette-input:focus { outline: none; }

.ops-palette-list { max-height: 320px; overflow: auto; }

.ops-palette-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--ops-text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.ops-palette-item:hover, .ops-palette-item.on { background: color-mix(in srgb, var(--ops-indigo) 12%, transparent); }

/* Toasts */
.ops-toasts {
  position: fixed;
  bottom: calc(16px + var(--ops-tab));
  right: 16px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.ops-toast {
  pointer-events: auto;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--ops-line-2);
  background: var(--ops-surface);
  box-shadow: var(--ops-shadow);
  font-size: 13px;
  max-width: 320px;
  animation: ops-toast-in 0.25s ease;
}

@keyframes ops-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Skeleton */
.ops-skel {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--ops-surface-2) 0%, color-mix(in srgb, var(--ops-indigo) 8%, var(--ops-surface-2)) 50%, var(--ops-surface-2) 100%);
  background-size: 200% 100%;
  animation: ops-shimmer 1.2s ease infinite;
}

@keyframes ops-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.ops-skel-line { height: 12px; margin-bottom: 8px; }

.ops-skel-line--lg { height: 28px; width: 60%; }

/* Bottom tabs (mobile) */
.ops-tabs {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--ops-tab);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--ops-surface);
  border-top: 1px solid var(--ops-line-2);
  z-index: 30;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.ops-tabs a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  font-size: 10px;
  font-weight: 600;
  color: var(--ops-muted);
  border-radius: 10px;
  min-height: 44px;
}

.ops-tabs a.on {
  color: var(--ops-indigo);
  background: color-mix(in srgb, var(--ops-indigo) 14%, transparent);
}

html[data-theme="dark"] .ops-tabs a.on { color: #C4B5FD; }

.ops-alert {
  padding: 12px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, #F59E0B 12%, var(--ops-surface));
  border: 1px solid color-mix(in srgb, #F59E0B 35%, transparent);
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--ops-text);
}

.ops-code {
  font-size: 12px;
  padding: 14px;
  border-radius: var(--ops-radius);
  background: var(--ops-surface-2);
  border: 1px solid var(--ops-line-2);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 768px) {
  .ops-app { grid-template-columns: 1fr; grid-template-rows: var(--ops-top) 1fr; grid-template-areas: "top" "main"; }
  .ops-rail { display: none; }
  .ops-tabs { display: grid; }
  .ops-table-panel { display: none; }
  .ops-card-list { display: grid; }
  .ops-search kbd { display: none; }
  .ops-main-scroll { padding-bottom: calc(16px + var(--ops-tab)); }
}

@media (min-width: 769px) {
  .ops-tabs { display: none; }
}

.ops-btn--block { width: 100%; margin-top: 12px; }

.ops-search-input {
  max-width: 220px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--ops-line-2);
  background: var(--ops-surface);
  color: var(--ops-text);
  font: inherit;
}

.ops-skel-block { height: 200px; margin: 14px; border-radius: 12px; }

.ops-palette-empty { padding: 12px 16px; margin: 0; }

.ops-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
