:root {
  --bg: #070b14;
  --bg-mid: #0c1220;
  --surface: #121a2a;
  --surface-elevated: #161f32;
  --border: rgba(148, 163, 184, 0.12);
  --text: #e8eef8;
  --muted: #8b9cb8;
  --lime: #bef264;
  --lime-deep: #84cc16;
  --cyan: #22d3ee;
  --cyan-bright: #00f0ff;
  --orange: #fb923c;
  --purple: #c084fc;
  --pink: #ff00aa;
  --font: 'Inter', system-ui, sans-serif;
  --display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(34, 211, 238, 0.08), transparent 50%),
    radial-gradient(ellipse 80% 60% at 80% 100%, rgba(255, 0, 170, 0.06), transparent 45%),
    linear-gradient(180deg, #0a1020 0%, var(--bg) 100%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(34, 211, 238, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.04) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 40%, black, transparent);
  z-index: 0;
}

.bg-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.35), transparent),
    radial-gradient(1px 1px at 30% 70%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1.5px 1.5px at 70% 30%, rgba(34,211,238,0.5), transparent),
    radial-gradient(1px 1px at 85% 60%, rgba(255,255,255,0.25), transparent),
    radial-gradient(1px 1px at 50% 90%, rgba(190,242,100,0.4), transparent);
}

.holo-panel {
  position: fixed;
  top: 50%;
  transform: translateY(-50%) perspective(800px) rotateY(12deg);
  width: 140px;
  height: 200px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
}

.holo-left { left: 2%; transform: translateY(-50%) perspective(800px) rotateY(18deg); }
.holo-right {
  right: 2%;
  transform: translateY(-50%) perspective(800px) rotateY(-18deg);
}

.holo-screen {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  border: 1px solid rgba(34, 211, 238, 0.25);
  background: linear-gradient(145deg, rgba(18, 26, 42, 0.9), rgba(8, 12, 22, 0.95));
  box-shadow: 0 0 30px rgba(34, 211, 238, 0.15), inset 0 0 20px rgba(34, 211, 238, 0.05);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.holo-screen.pink {
  border-color: rgba(255, 0, 170, 0.25);
  box-shadow: 0 0 30px rgba(255, 0, 170, 0.12), inset 0 0 20px rgba(255, 0, 170, 0.04);
}

.holo-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 48px;
}

.holo-bars::before,
.holo-bars::after {
  content: '';
  display: block;
  width: 8px;
  background: rgba(34, 211, 238, 0.5);
  border-radius: 2px;
}

.holo-bars::before { height: 60%; }
.holo-bars::after { height: 90%; width: 10px; margin-left: 6px; box-shadow: 0 0 8px var(--cyan); }

.holo-line {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(34, 211, 238, 0.6), transparent);
}

.holo-line.short { width: 60%; }

.holo-wave {
  height: 40px;
  border-bottom: 2px solid rgba(255, 0, 170, 0.5);
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
  box-shadow: 0 4px 12px rgba(255, 0, 170, 0.2);
}

.holo-dots {
  display: flex;
  gap: 6px;
}

.holo-dots::before,
.holo-dots::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(192, 132, 252, 0.7);
}

@media (max-width: 1100px) {
  .holo-panel { display: none; }
}

.dashboard {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 3.5rem 1.5rem 4rem;
  text-align: center;
}

.hero h1 {
  font-family: var(--display);
  font-size: clamp(2.5rem, 6vw, 3.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(90deg, var(--lime) 0%, #fde047 35%, var(--cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 30px rgba(190, 242, 100, 0.2));
  margin-bottom: 0.75rem;
}

.tagline {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 640px;
  margin: 0 auto 2rem;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  margin-bottom: 3rem;
}

.btn {
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.8rem 1.6rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn:active { transform: scale(0.98); }

.btn-start {
  background: linear-gradient(135deg, #d9f99d 0%, #bef264 40%, #a3e635 100%);
  color: #1a2e05;
  box-shadow:
    0 0 0 1px rgba(190, 242, 100, 0.4),
    0 8px 28px rgba(190, 242, 100, 0.25),
    0 0 40px rgba(190, 242, 100, 0.15);
}

.btn-start:hover {
  filter: brightness(1.05);
  box-shadow:
    0 0 0 1px rgba(190, 242, 100, 0.6),
    0 10px 36px rgba(190, 242, 100, 0.35);
}

.btn-stop {
  background: #1e293b;
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.btn-stop:hover { background: #273449; }

.btn-live {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.25), rgba(34, 211, 238, 0.1));
  color: var(--cyan);
  border: 1px solid rgba(34, 211, 238, 0.45);
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.15);
  cursor: default;
}

.btn-live.online {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.35), rgba(34, 211, 238, 0.15));
  box-shadow: 0 0 24px rgba(34, 211, 238, 0.3);
}

.btn-live.offline {
  color: var(--muted);
  border-color: var(--border);
  background: #151c2b;
  box-shadow: none;
}

.live-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 0.55rem;
  background: rgba(255, 255, 255, 0.9);
  color: var(--cyan);
  border-radius: 50%;
}

.btn-live.offline .live-icon {
  background: #334155;
  color: #64748b;
}

.pillars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  text-align: left;
}

@media (max-width: 900px) {
  .pillars { grid-template-columns: 1fr; }
}

.pillar {
  background: linear-gradient(160deg, var(--surface-elevated), var(--surface));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.35rem 1.25rem 1rem;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.pillar-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}

.pillar-icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.pillar-icon-wrap svg {
  width: 22px;
  height: 22px;
  color: white;
}

.mock-icon { background: linear-gradient(135deg, #fb923c, #ea580c); box-shadow: 0 0 16px rgba(251, 146, 60, 0.35); }
.simulate-icon { background: linear-gradient(135deg, #22d3ee, #0891b2); box-shadow: 0 0 16px rgba(34, 211, 238, 0.35); }
.automate-icon { background: linear-gradient(135deg, #c084fc, #9333ea); box-shadow: 0 0 16px rgba(192, 132, 252, 0.35); }

.pillar h2 {
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.pillar-sub {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.1rem;
}

.pillar-status {
  font-size: 0.88rem;
  color: #94a3b8;
  margin-bottom: 0.75rem;
}

.pillar-status.running { color: var(--lime); }

.pillar-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.metric-label {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.metric-value {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.pillar-chart {
  width: 100%;
  height: 72px;
  margin-top: auto;
  border-radius: 8px;
  background: rgba(7, 11, 20, 0.6);
}

.automate-info {
  flex: 1;
  font-size: 0.9rem;
  color: #cbd5e1;
  line-height: 1.8;
}

.info-label {
  color: var(--muted);
  margin-right: 0.35rem;
}

.automate-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 0.5rem;
}

.gear-deco {
  font-size: 1.5rem;
  color: #475569;
  opacity: 0.7;
}

.mode-toggle { display: flex; gap: 0.3rem; }

.mode-btn {
  font-family: var(--mono);
  font-size: 0.65rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.8);
  color: var(--muted);
  cursor: pointer;
}

.mode-btn.active {
  border-color: rgba(192, 132, 252, 0.5);
  color: var(--purple);
  background: rgba(192, 132, 252, 0.1);
}

/* Operations (below pillars) */
.ops-panel {
  margin-top: 2.5rem;
  text-align: left;
}

.ops-panel section {
  margin-bottom: 1.5rem;
  background: linear-gradient(160deg, rgba(26, 24, 37, 0.9), rgba(20, 18, 28, 0.95));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.25);
}

.ops-panel h2 {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.85rem;
  color: var(--text);
}

.agent-panel {
  overflow: hidden;
  max-width: 100%;
}

.agent-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  min-width: 0;
}

@media (max-width: 900px) {
  .agent-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 540px) {
  .agent-grid { grid-template-columns: 1fr; }
}

.agent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.agent-card.wide { grid-column: 1 / -1; }
.agent-card h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.agent-card p,
.agent-card li,
.agent-card dd {
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.mono {
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.phase-track {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.phase-track span {
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--muted);
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
}

.phase-track span.active {
  border-color: rgba(34, 211, 238, 0.5);
  color: var(--cyan);
  background: rgba(34, 211, 238, 0.08);
}

.inline-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.2rem 0.75rem;
  min-width: 0;
}

.inline-stats dt { font-size: 0.65rem; color: var(--muted); }
.inline-stats dd {
  font-family: var(--mono);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.subtask-list, .memory-list, .tool-list {
  list-style: none;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  min-width: 0;
}

.subtask-list li, .memory-list li, .tool-list li {
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.tool-list li strong {
  font-weight: 600;
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (max-width: 540px) {
  .dashboard {
    padding: 2rem 1rem 3rem;
  }

  .ops-panel section {
    padding: 1rem;
    border-radius: 12px;
  }

  .agent-card {
    padding: 0.75rem;
  }

  .inline-stats {
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem 0.5rem;
  }

  .phase-track span {
    flex: 1 1 calc(50% - 0.2rem);
  }
}

.subtask-list li.completed { color: var(--cyan); }
.subtask-list li.running { color: var(--purple); }

.viz-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 900px) {
  .viz-row { grid-template-columns: 1fr; }
}

.warehouse-viz, .ml-viz {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  min-width: 0;
  overflow: visible;
}

.warehouse-viz {
  width: 100%;
}

.warehouse-viz h2 {
  margin: 0 0 0.65rem;
}

.floor-canvas-wrap {
  width: 100%;
  max-width: 100%;
}

#floor-canvas, #ml-chart {
  width: 100%;
  max-width: 100%;
  border-radius: 8px;
  background: var(--bg);
}

#floor-canvas {
  display: block;
  height: auto;
  aspect-ratio: 5 / 3;
  box-shadow:
    inset 0 0 40px rgba(34, 211, 238, 0.04),
    0 0 20px rgba(0, 240, 255, 0.05);
}

.ml-scores {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin: 0.75rem 0;
}

.ml-score {
  text-align: center;
  padding: 0.4rem;
  background: rgba(15, 23, 42, 0.8);
  border-radius: 8px;
  font-size: 0.75rem;
}

.ml-score .value { font-family: var(--mono); color: var(--cyan); }

.event-log {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  max-height: 200px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 0.72rem;
}

.event-log .event {
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.06);
  color: var(--muted);
}

.event-log .event .topic { color: var(--pink); }

.btn.small { padding: 0.45rem 0.9rem; font-size: 0.8rem; }

/* Signup page */
.signup-page .signup-shell {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

.signup-hero {
  text-align: center;
  margin-bottom: 2.5rem;
}

.signup-back {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
  transition: color 0.15s ease;
}

.signup-back:hover { color: var(--cyan); }

.signup-hero h1 {
  font-family: var(--display);
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(90deg, var(--lime) 0%, var(--cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.75rem;
}

.signup-form {
  background: linear-gradient(160deg, rgba(18, 26, 42, 0.95), rgba(12, 18, 32, 0.98));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  text-align: left;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem 1.25rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field span {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}

.field .optional {
  font-style: normal;
  font-weight: 400;
  color: var(--muted);
}

.field input,
.field select {
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(7, 11, 20, 0.8);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: rgba(34, 211, 238, 0.5);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

.field-hint {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
  cursor: pointer;
}

.checkbox-field input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--cyan);
}

.signup-message {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.signup-message.error {
  background: rgba(251, 146, 60, 0.12);
  border: 1px solid rgba(251, 146, 60, 0.35);
  color: #fdba74;
}

.signup-message.success {
  background: rgba(190, 242, 100, 0.1);
  border: 1px solid rgba(190, 242, 100, 0.35);
  color: var(--lime);
}

.signup-submit {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.signup-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.submit-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(26, 46, 5, 0.3);
  border-top-color: #1a2e05;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.signup-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 2rem;
  text-align: left;
}

@media (max-width: 700px) {
  .signup-features { grid-template-columns: 1fr; }
}

.signup-features article {
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(18, 26, 42, 0.5);
}

.signup-features h3 {
  font-family: var(--display);
  font-size: 0.95rem;
  color: var(--cyan);
  margin-bottom: 0.35rem;
}

.signup-features p {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

.hero-signup-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--cyan);
  text-decoration: none;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.35);
  background: rgba(34, 211, 238, 0.08);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.hero-signup-link:hover {
  background: rgba(34, 211, 238, 0.15);
  border-color: rgba(34, 211, 238, 0.55);
}

.warehouse-badge {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--lime);
  background: rgba(190, 242, 100, 0.1);
  border: 1px solid rgba(190, 242, 100, 0.25);
}

/* Mobile / lite performance */
html.lite-mode .bg-particles,
html.lite-mode .bg-grid {
  display: none;
}

html.lite-mode .ops-panel .agent-panel,
html.lite-mode .ops-panel .event-feed {
  content-visibility: auto;
  contain-intrinsic-size: auto 320px;
}

html.lite-mode .ops-panel .viz-row {
  content-visibility: visible;
}

@media (max-width: 768px) {
  .bg-particles {
    display: none;
  }

  .bg-grid {
    opacity: 0.45;
  }

  .pillars {
    content-visibility: auto;
    contain-intrinsic-size: auto 480px;
  }
}

/* Login */
.login-page .signup-form {
  max-width: 420px;
  margin: 0 auto;
}

.login-footer {
  text-align: center;
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-footer a {
  color: var(--cyan);
  text-decoration: none;
}

.login-footer a:hover {
  text-decoration: underline;
}

/* Admin */
.admin-page {
  min-height: 100vh;
}

.admin-header {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.admin-brand h1 {
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

.admin-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--lime);
  background: rgba(190, 242, 100, 0.12);
  border: 1px solid rgba(190, 242, 100, 0.3);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 0.35rem;
}

.admin-context {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.35rem;
}

.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.admin-tabs {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}

.admin-tab {
  font-family: var(--display);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.65rem 1rem;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.admin-tab:hover:not(.disabled) {
  color: var(--text);
}

.admin-tab.active {
  color: var(--cyan);
  border-bottom-color: var(--cyan);
}

.admin-tab.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.admin-tab-layout {
  opacity: 1;
  color: var(--text);
  cursor: pointer;
  pointer-events: auto;
}

.admin-tab-layout:hover {
  color: var(--cyan);
}

.admin-main {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
}

.admin-panel {
  display: none;
}

.admin-panel.active {
  display: block;
}

.admin-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.admin-panel-head h2,
.admin-card h2 {
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 600;
}

.admin-split {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 900px) {
  .admin-split {
    grid-template-columns: 1fr;
  }
}

.admin-card {
  background: linear-gradient(160deg, rgba(18, 26, 42, 0.95), rgba(12, 18, 32, 0.98));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
}

.admin-card-wide {
  min-width: 0;
}

.admin-hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.35rem 0 1rem;
  line-height: 1.5;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.admin-form .field-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.line-items {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.line-item-row {
  display: grid;
  grid-template-columns: 1fr 72px 32px;
  gap: 0.4rem;
  align-items: center;
}

.line-item-row select,
.line-item-row input {
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(7, 11, 20, 0.8);
  color: var(--text);
}

.btn-remove-line {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.2rem;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.admin-table th,
.admin-table td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.admin-table th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: rgba(7, 11, 20, 0.5);
}

.admin-table tbody tr:hover {
  background: rgba(34, 211, 238, 0.04);
}

.admin-empty {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem !important;
}

.admin-filters {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.admin-filters select {
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.status-pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
}

.status-pending { color: #fde047; background: rgba(253, 224, 71, 0.12); }
.status-processing { color: var(--cyan); background: rgba(34, 211, 238, 0.12); }
.status-completed { color: var(--lime); background: rgba(190, 242, 100, 0.12); }
.status-cancelled { color: var(--muted); background: rgba(148, 163, 184, 0.12); }

.btn-text {
  font-size: 0.8rem;
  color: var(--orange);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

a.admin-tab,
a.admin-tab-link {
  text-decoration: none;
  display: inline-block;
  opacity: 1;
  cursor: pointer;
}

a.admin-tab-link:hover {
  color: var(--text);
}

a.admin-tab-link:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

/* Layout editor */
.layout-editor-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.layout-topbar {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.layout-topbar-brand h1 {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 700;
}

.layout-context {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.layout-topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.layout-status {
  position: relative;
  z-index: 1;
  margin: 0.5rem 1.5rem 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: var(--lime);
  background: rgba(190, 242, 100, 0.08);
  border: 1px solid rgba(190, 242, 100, 0.25);
  border-radius: 8px;
}

.layout-status.error {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.3);
}

.layout-shell {
  position: relative;
  z-index: 1;
  flex: 1;
  display: grid;
  grid-template-columns: 160px 1fr 240px;
  gap: 0;
  min-height: 0;
  height: calc(100vh - 140px);
}

@media (max-width: 900px) {
  .layout-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    height: auto;
    min-height: calc(100vh - 160px);
  }
}

.layout-tools,
.layout-props {
  background: linear-gradient(160deg, rgba(18, 26, 42, 0.95), rgba(12, 18, 32, 0.98));
  border-color: var(--border);
  border-style: solid;
  padding: 1rem;
  overflow-y: auto;
}

.layout-tools {
  border-right-width: 1px;
}

.layout-props {
  border-left-width: 1px;
}

.layout-tools h2,
.layout-props h2,
.layout-bounds-panel h3 {
  font-family: var(--display);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.layout-tool {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.35rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}

.layout-tool:hover {
  color: var(--text);
  background: rgba(34, 211, 238, 0.06);
}

.layout-tool.active {
  color: var(--cyan);
  border-color: rgba(34, 211, 238, 0.35);
  background: rgba(34, 211, 238, 0.1);
}

.layout-tool-icon {
  font-size: 1rem;
  width: 1.25rem;
  text-align: center;
}

.layout-tool-hint {
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.layout-tool-hint p {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 0.35rem;
}

.layout-canvas-wrap {
  position: relative;
  min-width: 0;
  min-height: 320px;
  background: #04060c;
}

#layout-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.layout-props-body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.layout-props-body .field-label,
.layout-bounds-panel .field-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 500;
}

.layout-props-body input,
.layout-props-body select,
.layout-bounds-panel input[type="range"] {
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(8, 12, 22, 0.8);
  color: var(--text);
}

.layout-props-empty {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}

.layout-bounds-panel {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.layout-ops-panel {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.layout-ops-panel input[type="number"] {
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(8, 12, 22, 0.8);
  color: var(--text);
  max-width: 5rem;
}

.layout-ops-hint {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.45;
  margin-top: 0.35rem;
}

.layout-bounds-panel .field-label span {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 0.8rem;
}

.layout-stats {
  position: relative;
  z-index: 1;
  padding: 0.65rem 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  font-family: var(--mono);
}