﻿@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600&display=swap");

:root {
  color-scheme: light;
  --bg: #f6f3ee;
  --bg-accent: #efe8dd;
  --ink: #1e2b2a;
  --muted: #62706c;
  --card: #ffffff;
  --accent: #1b7a6b;
  --accent-dark: #0f5a4f;
  --border: #e5ded3;
  --shadow: 0 24px 60px rgba(18, 28, 26, 0.12);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
}

html {
  background:
    radial-gradient(1200px 900px at 10% -10%, #e9f2ee 0%, transparent 70%),
    radial-gradient(900px 700px at 90% 10%, #f8efe3 0%, transparent 65%),
    #f3f4f6;
  background-attachment: fixed;
  background-size: cover;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 900px at 20% 0%, #f2ebe0 0%, transparent 70%),
    radial-gradient(900px 700px at 80% 10%, #e7efe9 0%, transparent 65%),
    var(--bg);
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

body.app-body {
  display: block;
  padding: 0;
  background: transparent;
}

#loading {
  margin-top: 32px;
}

.card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  display: grid;
  gap: 20px;
}

h1 {
  margin: 0;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

label {
  font-size: 0.95rem;
  font-weight: 500;
}

input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 1rem;
  background: #fff;
}

select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 1rem;
  background: #fff;
}

textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 1rem;
  background: #fff;
  resize: vertical;
}

input:focus {
  outline: 2px solid rgba(27, 122, 107, 0.25);
  border-color: var(--accent);
}

textarea:focus {
  outline: 2px solid rgba(27, 122, 107, 0.25);
  border-color: var(--accent);
}

select:focus {
  outline: 2px solid rgba(27, 122, 107, 0.25);
  border-color: var(--accent);
}

button {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: none;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.btn-small {
  width: auto;
  padding: 8px 12px;
  font-size: 0.9rem;
  border-radius: 10px;
}

.btn-large {
  width: auto;
  padding: 14px 56px;
  font-size: 1.1rem;
  border-radius: 12px;
}

.btn-wiggle {
  animation: wiggle 5s ease-in-out infinite;
  transform-origin: center;
}

@keyframes wiggle {
  0%,
  84% {
    transform: translateX(0) rotate(0deg);
  }
  88% {
    transform: translateX(-2px) rotate(-1.5deg);
  }
  92% {
    transform: translateX(2px) rotate(1.5deg);
  }
  96% {
    transform: translateX(-1px) rotate(-1deg);
  }
  100% {
    transform: translateX(0) rotate(0deg);
  }
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(27, 122, 107, 0.2);
  background: var(--accent-dark);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-subtle {
  background: rgba(31, 111, 235, 0.18);
  color: #1f6feb;
  border: 1px solid rgba(31, 111, 235, 0.45);
  box-shadow: inset 0 0 0 1px rgba(31, 111, 235, 0.2);
  box-shadow: none;
}

.btn-subtle:hover {
  background: rgba(31, 111, 235, 0.25);
  color: #1f6feb;
  transform: none;
  box-shadow: none;
}

.notice {
  padding: 10px 12px;
  border-radius: 12px;
  background: #f4f1ec;
  border: 1px dashed var(--border);
  font-size: 0.9rem;
  color: var(--muted);
}

.device-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.device-option {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: #94a3b8;
  border-radius: 12px;
  padding: 10px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}

.device-option svg {
  width: 18px;
  height: 18px;
}

.device-option.is-active {
  border-color: rgba(31, 111, 235, 0.45);
  background: rgba(31, 111, 235, 0.18);
  color: #1f6feb;
  box-shadow: inset 0 0 0 1px rgba(31, 111, 235, 0.2);
}

.device-option:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.device-select-input {
  display: none;
}

.panel {
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.endpoint-row {
  display: grid;
  gap: 12px;
}

@media (min-width: 960px) {
  .endpoint-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.error {
  color: #b93833;
  font-size: 0.9rem;
}

.help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid #cbd5f5;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: help;
  background: #f8fafc;
  position: relative;
}

.help-tip:hover {
  color: #1f6feb;
  border-color: rgba(31, 111, 235, 0.4);
  background: rgba(31, 111, 235, 0.08);
}

.help-tip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 140%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: #0f172a;
  color: #f8fafc;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.72rem;
  line-height: 1.3;
  max-width: 220px;
  width: max-content;
  white-space: normal;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.2);
  transition: opacity 150ms ease, transform 150ms ease;
  z-index: 5;
}

.help-tip::before {
  content: "";
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  border-width: 6px 6px 0;
  border-style: solid;
  border-color: #0f172a transparent transparent;
  opacity: 0;
  transition: opacity 150ms ease, transform 150ms ease;
  z-index: 5;
}

.help-tip:hover::after,
.help-tip:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.app-shell {
  width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  column-gap: 32px;
  padding: 0;
  background: transparent;
}

.app-sidebar {
  background: #0f1f1a;
  color: #f5f7f6;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-radius: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  align-self: start;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-mark {
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.brand-logo {
  width: 84px;
  height: 84px;
}

.brand-title {
  font-size: 1.65rem;
  font-weight: 600;
  line-height: 1.1;
  display: grid;
  gap: 2px;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
}

.sidebar-nav {
  display: grid;
  gap: 10px;
  overflow-x: hidden;
}

.sidebar-nav .nav-link {
  color: rgba(255, 255, 255, 0.7);
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-nav .nav-link.active,
.sidebar-nav .nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke: currentColor;
  opacity: 0.85;
}

.sidebar-nav .nav-link.active .nav-icon,
.sidebar-nav .nav-link:hover .nav-icon {
  opacity: 1;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
  width: 100%;
}

.sidebar-footer-links {
  display: grid;
  gap: 6px;
  width: 100%;
}

.sidebar-footer-link {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  text-align: left;
  padding: 6px 8px;
  border-radius: 10px;
  font-size: 0.9rem;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-footer-link:hover {
  color: #fff;
}

.footer-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.85;
}

.help-links {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.help-links a {
  text-decoration: none;
  color: var(--primary);
  font-weight: 600;
}

.help-links a:hover {
  text-decoration: underline;
}

.topbar-contents {
  margin: 10px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.topbar-contents a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.topbar-contents a:hover {
  text-decoration: underline;
}

.help-section h3 {
  margin-bottom: 6px;
}

.help-section h3 a {
  color: inherit;
  text-decoration: none;
}

.help-section h3 a:hover {
  text-decoration: underline;
}

.help-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
}

.help-list li {
  margin: 6px 0;
}

.refer-steps {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
}

.refer-steps li {
  margin: 6px 0;
}

.faq-item {
  margin-top: 12px;
}

.faq-question {
  font-weight: 600;
}

.sidebar-account {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-radius: 14px;
  text-align: left;
  cursor: pointer;
  width: 100%;
}

.sidebar-account:hover {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(35, 179, 155, 0.25);
  display: grid;
  place-items: center;
  font-weight: 600;
  color: #e7f8f3;
  text-transform: uppercase;
}

.sidebar-account-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.sidebar-account-name {
  font-size: clamp(0.78rem, 1.4vw, 0.95rem);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-account-label {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.6);
}

.app-version {
  font-size: 0.64rem;
  color: rgba(255, 255, 255, 0.45);
  text-align: center;
  margin-top: 2px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-content {
  padding: 32px 32px 48px 0;
  display: grid;
  gap: 24px;
  min-width: 0;
}

.app-topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 22px 26px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

.app-topbar h1 {
  font-size: 1.5rem;
  margin-bottom: 6px;
}

.app-topbar p {
  color: var(--muted);
}

#page-subtitle {
  min-height: 0;
}

.funnels-grid {
  display: grid;
  gap: 20px;
}

.funnels-list {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.funnels-list.is-empty {
  justify-items: start;
}

.funnels-list.is-empty .funnel-card.new {
  max-width: min(50%, 520px);
  width: 100%;
}

.funnels-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0 16px;
  position: sticky;
  top: 12px;
  z-index: 5;
  background: #ffffff;
  padding: 8px 0;
}

.empty-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  border-radius: 16px;
  border: 1px dashed var(--border);
  background: linear-gradient(135deg, #f3efe7, #ffffff);
  margin-bottom: 16px;
}

.empty-banner-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.funnels-toolbar .toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.funnels-toolbar select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  background: #fff;
  font-size: 0.85rem;
}

.bulk-group {
  margin-left: auto;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.bulk-actions {
  display: flex;
  gap: 8px;
  min-height: 36px;
  visibility: hidden;
  pointer-events: none;
}

.bulk-group.has-selection .bulk-actions {
  visibility: visible;
  pointer-events: auto;
}

.bulk-group .bulk-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.bulk-select-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bulk-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.bulk-select input {
  width: 16px;
  height: 16px;
}

.bulk-count {
  font-size: 0.85rem;
  color: var(--muted);
  margin-right: 4px;
}

.funnel-select {
  display: inline-flex;
  align-items: center;
}

.funnel-select input {
  width: 16px;
  height: 16px;
}

.btn.danger {
  border-color: #fecaca;
  color: #b91c1c;
}

.btn.danger:hover {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

.snapshots-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.snapshot-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-pill {
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease, color 150ms ease, background 150ms ease;
}

.filter-pill:hover {
  border-color: rgba(27, 122, 107, 0.4);
}

.filter-pill.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(27, 122, 107, 0.2);
}

.snapshot-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border-radius: 12px;
  background: #f8f5f0;
  border: 1px solid var(--border);
  flex-wrap: wrap;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.snapshot-card:hover {
  border-color: rgba(27, 122, 107, 0.35);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
}

.snapshot-card h4 {
  margin: 0;
  font-size: 1rem;
}

.snapshot-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

.snapshot-status {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.snapshot-status.ok {
  background: #e6f7f2;
  color: #13795b;
}

.snapshot-status.error {
  background: #fdecea;
  color: #b93833;
}

.funnel-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 12px;
  background: #f8f5f0;
  border: 1px solid var(--border);
  position: relative;
  z-index: 0;
  cursor: pointer;
  min-height: 240px;
}

.funnel-card-select {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border);
  z-index: 3;
}

.funnel-card-select input {
  width: 16px;
  height: 16px;
}

.funnel-card.is-disabled {
  opacity: 0.6;
  filter: grayscale(0.25);
}

.funnel-card.is-disabled:hover {
  transform: none;
  box-shadow: none;
}

.funnel-card.new {
  border-style: solid;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  box-shadow: 0 18px 30px rgba(15, 23, 42, 0.08);
}

.funnel-card.new .funnel-preview {
  background: linear-gradient(140deg, #e7f5f2, #f8f1e6);
  border-style: solid;
  border-color: rgba(27, 122, 107, 0.25);
}

.funnel-card.new h4 {
  color: var(--ink);
}

.funnel-card.new .funnel-meta {
  color: #5b6f69;
}


.funnel-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.funnel-card-body {
  display: grid;
  gap: 6px;
}

.funnel-warning {
  font-size: 1rem;
  color: #f59e0b;
  display: none;
  cursor: help;
}

.funnel-warning.visible {
  display: inline-flex;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9ca3af;
}

.status-dot.status-ok {
  background: #22c55e;
}

.status-dot.status-warning {
  background: #f59e0b;
}

.status-dot.status-error {
  background: #ef4444;
}

.status-dot.status-disabled {
  background: #9ca3af;
}

.status-dot.status-idle {
  background: #9ca3af;
}

.funnel-card h4 {
  margin: 0;
  font-size: 1rem;
}

.funnel-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.toggle.is-reversed {
  flex-direction: row;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  width: 42px;
  height: 24px;
  background: #e5e7eb;
  border-radius: 999px;
  position: relative;
  transition: background 150ms ease;
}

.toggle-slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 4px 8px rgba(15, 23, 42, 0.12);
  transition: transform 150ms ease;
}

.toggle input:checked + .toggle-slider {
  background: #22c55e;
}

.toggle input:checked + .toggle-slider::after {
  transform: translateX(18px);
}

.funnel-menu {
  position: relative;
  z-index: 2;
}

.menu-button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 1.1rem;
  line-height: 1;
  box-shadow: none;
  color: #475569;
}

.menu-button:hover {
  background: #f8fafc;
  box-shadow: none;
  transform: none;
}

.menu-panel {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
  padding: 6px;
  display: none;
  min-width: 128px;
  z-index: 50;
}

.funnel-card.menu-open {
  z-index: 20;
}

.menu-panel.open {
  display: grid;
  gap: 4px;
}

.menu-item {
  border: none;
  background: #fff;
  padding: 6px 9px;
  text-align: left;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  color: #334155;
}

.menu-item:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.menu-item--danger {
  color: #b91c1c;
}

.menu-item--danger:hover {
  background: #fee2e2;
  color: #991b1b;
}

.funnel-card-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
}

.funnel-card-actions .toggle {
  margin-left: auto;
}

.funnel-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  background: #0f172a;
  border: 1px solid var(--border);
  overflow: hidden;
}

.funnel-preview.empty {
  background: #f1f5f9;
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  border-style: dashed;
}

.funnel-preview.loading {
  background: #f1f5f9;
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  border-style: dashed;
}

.funnel-preview .preview-status {
  z-index: 1;
  text-align: center;
  padding: 12px 16px;
}

.funnel-preview .preview-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  animation-name: previewFade;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-fill-mode: both;
  animation-play-state: paused;
}

.funnel-preview .preview-frame.is-ready {
  animation-play-state: running;
}

.funnel-preview .preview-frame.is-missing {
  display: none;
}

.funnel-preview.static .preview-frame {
  animation: none;
  opacity: 0;
}

.funnel-preview.static .preview-frame.is-ready {
  opacity: 1;
}

@keyframes previewFade {
  0% {
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  60% {
    opacity: 1;
  }
  80% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .funnel-preview .preview-frame {
    animation: none;
    opacity: 0;
    animation-play-state: paused;
  }

  .funnel-preview .preview-frame.is-ready:first-child {
    opacity: 1;
  }
}

.detail-grid {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(140px, 180px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.detail-field {
  display: grid;
  gap: 6px;
}

.detail-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.detail-value {
  font-weight: 600;
  color: var(--ink);
  word-break: break-word;
}

.detail-sub-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 10px;
}

.detail-sub-value {
  font-weight: 600;
  color: var(--ink);
  word-break: break-word;
}

#funnel-detail-name {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 1rem;
  font-weight: 600;
  background: #fff;
  transition: border-color 150ms ease, background 150ms ease;
}

#funnel-detail-name.is-readonly {
  border-color: transparent;
  background: transparent;
  padding: 0;
}

#funnel-detail-name.is-readonly:focus {
  outline: none;
}

.detail-header h3 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.detail-actions {
  display: grid;
  gap: 12px;
  align-items: start;
  justify-items: start;
  margin-left: auto;
}

.detail-actions .toggle {
  align-items: center;
}

.detail-input {
  width: 100%;
}

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

.detail-steps {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 8px;
}

.detail-steps li {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f1f5f9;
  color: #1f2937;
  font-size: 0.9rem;
}

.detail-title {
  display: grid;
  gap: 4px;
}

.detail-title input {
  font-size: 1.2rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  background: #fff;
  color: #0f172a;
  max-width: 360px;
  width: 100%;
}

.detail-title input[readonly] {
  background: #f8fafc;
  color: #475569;
}

.detail-save-status {
  min-height: 18px;
}

.detail-actions {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.detail-edit-toggle {
  font-weight: 600;
}

.detail-edit-hint {
  font-size: 0.8rem;
  text-align: right;
}

.detail-input {
  margin-top: 6px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.2);
  padding: 20px;
  max-width: 420px;
  width: 100%;
  display: grid;
  gap: 12px;
}

.modal-card.modal-card-lg {
  max-width: 820px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-close {
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 1.4rem;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
}

.modal-close:hover {
  color: #0f172a;
  background: rgba(148, 163, 184, 0.2);
  border-radius: 8px;
}

.run-detail-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.run-error {
  color: #b93833;
  font-size: 0.9rem;
  display: none;
}

.run-diagram {
  padding: 12px;
  border-radius: 14px;
  border: 1px dashed #e2e8f0;
  background: #f8fafc;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
}

.run-diagram.empty {
  color: var(--muted);
}

.run-diagram .diagram-node {
  display: grid;
  place-items: center;
  min-width: 86px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #475569;
  font-size: 0.85rem;
  text-align: center;
}

.run-diagram .diagram-node.complete {
  border-color: #86efac;
  background: #dcfce7;
  color: #14532d;
}

.run-diagram .diagram-node.error {
  border-color: #fca5a5;
  background: #fee2e2;
  color: #7f1d1d;
}

.run-diagram .diagram-connector {
  width: 32px;
  height: 2px;
  background: #cbd5f5;
  flex: 0 0 auto;
}

.run-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
  font-size: 0.9rem;
}

.run-steps li {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f1f5f9;
  color: #1f2937;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.modal-error {
  color: #b93833;
  font-size: 0.9rem;
  margin: 0;
  min-height: 18px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-actions.is-hidden {
  display: none;
}

.topbar-contents.is-hidden {
  display: none;
}

.page {
  display: none;
  animation: pageIn 180ms ease;
}

.page.active {
  display: grid;
  gap: 22px;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.account-panel {
  display: grid;
  gap: 16px;
}

.account-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.account-grid {
  margin-top: 0;
}

.account-actions {
  display: flex;
  justify-content: flex-end;
}

.account-link {
  font-weight: 600;
  color: #1d4ed8;
  text-decoration: underline;
}

.account-link:hover {
  color: #1e40af;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.overview-grid {
  display: grid;
  gap: 22px;
}

.overview-hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.overview-hero-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.overview-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.overview-value {
  font-size: 1rem;
  font-weight: 600;
}

.status-pill {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-pill.status-ok {
  background: rgba(35, 179, 155, 0.2);
  color: #0f5a4f;
}

.status-pill.status-warning {
  background: rgba(245, 186, 68, 0.2);
  color: #9b6a09;
}

.status-pill.status-error {
  background: rgba(197, 52, 45, 0.18);
  color: #a12e2e;
}

.status-pill.status-idle {
  background: rgba(71, 85, 105, 0.18);
  color: #475569;
}

.overview-actions-grid {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.overview-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.overview-graph-bars {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(56px, 1fr);
  gap: 20px;
  align-items: end;
  height: 180px;
  margin-top: 10px;
}

.overview-graph-summary {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.overview-graph-stat {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(71, 85, 105, 0.12);
  color: #475569;
}

.overview-graph-stat.stat-ok {
  background: rgba(34, 197, 94, 0.18);
  color: #0f5a4f;
}

.overview-graph-stat.stat-error {
  background: rgba(239, 68, 68, 0.18);
  color: #a12e2e;
}

.overview-graph-day {
  display: grid;
  gap: 8px;
  align-items: end;
}

.overview-graph-day-bars {
  display: grid;
  grid-template-columns: repeat(2, minmax(10px, 1fr));
  gap: 6px;
  align-items: end;
  height: 140px;
  position: relative;
}

.overview-graph-bar-wrap {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.overview-graph-bar-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}

.overview-graph-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

.overview-graph-bar {
  width: 100%;
  border-radius: 10px;
  background: rgba(71, 85, 105, 0.2);
  position: relative;
  min-height: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.overview-graph-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.overview-graph-bar.status-ok {
  background: rgba(34, 197, 94, 0.3);
}

.overview-graph-bar.status-warning {
  background: rgba(245, 158, 11, 0.3);
}

.overview-graph-bar.status-error {
  background: rgba(239, 68, 68, 0.3);
}

.overview-graph-bar.is-success {
  background: rgba(34, 197, 94, 0.3);
}

.overview-graph-bar.is-fail {
  background: rgba(239, 68, 68, 0.3);
}


.overview-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.overview-item-body {
  min-width: 0;
}

.overview-item-title {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.overview-item-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

@media (min-width: 1000px) {
  .overview-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }

  .overview-hero {
    grid-column: span 8;
  }

  .overview-actions {
    grid-column: span 4;
  }

  .overview-recent {
    grid-column: span 6;
  }

  .overview-next {
    grid-column: span 6;
  }

  .overview-graph {
    grid-column: span 12;
  }

  .overview-risk {
    grid-column: span 12;
  }
}

.search-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f7f5f1;
}

.search-pill input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.95rem;
  min-width: 160px;
}

.search-icon {
  color: var(--muted);
}

.badge {
  background: rgba(35, 179, 155, 0.16);
  color: #b3f0e4;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

@media (max-width: 1280px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
    column-gap: 24px;
  }

  .app-content {
    padding: 28px 28px 40px 0;
  }
}

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

  .app-sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 16px 20px;
    gap: 14px;
    overflow-y: visible;
  }

  .sidebar-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
  }

  .app-content {
    padding: 20px 20px 32px;
  }

  .app-topbar {
    padding: 18px 20px;
  }
}

@media (max-width: 720px) {
  .app-content {
    padding: 16px 16px 28px;
  }

  .search-pill {
    width: 100%;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .btn {
    width: 100%;
  }
}

.hidden {
  display: none;
}
