:root {
  --page: #f7f8fb;
  --ink: #172033;
  --muted: #667085;
  --panel: #ffffff;
  --line: #d8dee9;
  --primary: #E8651A;
  --primary-dark: #C85415;
  --primary-soft: #FEE8D6;
  --neutral-soft: #eef2f7;
  --green: #10b981;
  --green-soft: #d1fae5;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --red: #dc2626;
  --shadow: 0 18px 45px rgba(23, 32, 51, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(232, 101, 26, 0.06), rgba(232, 101, 26, 0.02) 42%, transparent 70%),
    var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { border: 0; }

[v-cloak] { display: none !important; }

/* ── Shell ── */
.workflow-list-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-separator { color: var(--line); }
.breadcrumb-current { color: var(--ink); font-weight: 500; }

.page-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Agent CTA ── */
.agent-cta {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: linear-gradient(135deg, #F0965A 0%, #E8651A 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 16px 22px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  margin-bottom: 20px;
  box-shadow: 0 4px 16px rgba(232, 101, 26, 0.22);
  text-align: left;
}

.agent-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(232, 101, 26, 0.35);
}

.agent-cta-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  flex-shrink: 0;
}

.agent-cta-text { flex: 1; min-width: 0; }

.agent-cta-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}

.agent-cta-desc {
  font-size: 12px;
  opacity: 0.85;
  line-height: 1.4;
}

/* ── Search / Filter bar ── */
.toolbar-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(23, 32, 51, 0.04);
}

.search-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  color: var(--muted);
}

.search-wrapper input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  min-width: 0;
}

.search-wrapper input::placeholder { color: #98a2b3; }

.toolbar-divider {
  width: 1px;
  height: 28px;
  background: var(--line);
  flex-shrink: 0;
}

.filter-select-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.filter-select-wrap select {
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding-right: 4px;
}

.view-toggle {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.view-toggle button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.view-toggle button:first-child { border-right: 1px solid var(--line); }
.view-toggle button.active { background: var(--primary); color: #fff; }
.view-toggle button:not(.active):hover { background: var(--neutral-soft); }

/* ── Results count ── */
.results-count {
  margin: 18px 0 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Card grid ── */
.workflow-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 16px;
}

.workflow-grid.list-view {
  grid-template-columns: 1fr;
}

/* ── Workflow Card ── */
.workflow-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.2s, border-color 0.2s;
  cursor: pointer;
}

.workflow-card:hover {
  border-color: #c0c8d4;
  box-shadow: 0 20px 50px rgba(23, 32, 51, 0.12);
}

.workflow-cover {
  width: 100%;
  height: 140px;
  background: linear-gradient(135deg, #F0965A 0%, #E8651A 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.6);
  font-size: 48px;
  overflow: hidden;
}

.workflow-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.workflow-body {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

/* ── Title row ── */
.workflow-title-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.workflow-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--primary);
  overflow-wrap: anywhere;
  flex: 1;
  min-width: 0;
}

.status-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.status-enabled { color: #047857; background: var(--green-soft); }
.status-pill.status-disabled { color: #b91c1c; background: #fee2e2; }
.status-pill.status-draft { color: #92400e; background: var(--amber-soft); }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.menu-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.menu-trigger:hover { background: var(--neutral-soft); }

/* ── Card dropdown menu ── */
.card-menu-wrap { position: relative; }

.card-menu {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 20;
  min-width: 140px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(23, 32, 51, 0.14);
  padding: 4px;
  animation: scaleIn 0.12s ease;
}

.card-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}

.card-menu .menu-edit,
.card-menu .menu-item { color: var(--ink); }
.card-menu .menu-edit:hover,
.card-menu .menu-item:hover { background: var(--neutral-soft); }
.card-menu .menu-delete { color: var(--red); }
.card-menu .menu-delete:hover { background: #fef2f2; }

/* ── Description ── */
.workflow-desc {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Card meta ── */
.workflow-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  margin-top: auto;
}

.workflow-card-meta .meta-icon {
  color: var(--primary);
  opacity: 0.6;
  flex-shrink: 0;
}

/* ── Action buttons ── */
.workflow-actions {
  display: flex;
  gap: 10px;
  padding: 0 20px 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  transition: transform 0.12s ease, filter 0.18s ease, background 0.15s;
}

.btn:focus-visible {
  outline: 3px solid rgba(232, 101, 26, 0.24);
  outline-offset: 2px;
}

.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  flex: 1;
  box-shadow: 0 4px 14px rgba(232, 101, 26, 0.2);
}

.btn-secondary {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-secondary:hover { background: var(--neutral-soft); }

.btn-create {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(232, 101, 26, 0.25);
}

.btn-create:hover {
  background: var(--primary-dark);
  box-shadow: 0 6px 18px rgba(232, 101, 26, 0.35);
}

.btn-icon-only {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  padding: 0;
}

.btn-icon-only:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

/* ── Pagination ── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 28px;
}

.pagination-btn {
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  transition: background 0.15s;
}

.pagination-btn:hover:not(:disabled) { background: var(--neutral-soft); }

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-info {
  font-size: 14px;
  color: var(--muted);
  margin: 0 12px;
}

/* ── Empty / loading / error states ── */
.loading,
.empty-state,
.error-state {
  min-height: 240px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 28px;
  margin-top: 16px;
}

.loading { grid-auto-flow: column; gap: 12px; }

.loading-ring {
  width: 28px;
  height: 28px;
  border: 3px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

/* ── Toast ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 90px);
  padding: 11px 18px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
  z-index: 2000;
}

.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: var(--red); }
.toast.success { background: var(--primary); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(23, 32, 51, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.18s ease;
}

.modal {
  width: min(720px, calc(100vw - 32px));
  background: var(--panel);
  border-radius: 14px;
  padding: 28px 24px 22px;
  box-shadow: 0 24px 60px rgba(23, 32, 51, 0.18);
  animation: scaleIn 0.2s ease;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title {
  margin: 0 0 20px;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.modal-two-column {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 24px;
}

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  background: #f8fafc;
}

.form-input:focus {
  border-color: var(--primary);
  background: #fff;
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

/* ── Ratio selector ── */
.ratio-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  transition: all 0.2s;
  background: #fff;
  min-height: 120px;
  cursor: pointer;
  gap: 8px;
}

.ratio-option input[type="radio"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  margin: 0;
  accent-color: var(--primary);
}

.ratio-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  border: 2px solid var(--primary);
  border-radius: 4px;
  opacity: 0.5;
}

.ratio-icon-landscape { width: 64px; height: 36px; }
.ratio-icon-portrait { width: 36px; height: 64px; }

.ratio-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.ratio-value { font-size: 14px; font-weight: 700; color: var(--ink); }
.ratio-label { font-size: 12px; color: var(--muted); }

.ratio-option:has(input[type="radio"]:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.ratio-option:has(input[type="radio"]:checked) .ratio-icon {
  opacity: 1;
}

.ratio-option.checked {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.modal-actions .btn { font-size: 14px; }

.btn-danger {
  background: var(--red);
  color: #fff;
}

.btn-danger:hover { background: #b91c1c; }

/* ── Delete confirm modal ── */
.modal-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #fee2e2;
  color: var(--red);
  margin-bottom: 14px;
}

.modal-desc-text {
  margin: 0 0 22px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Feedback button ── */
.feedback-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #E8651A 0%, #C85415 100%);
  color: #fff;
  border-radius: 50px;
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(232, 101, 26, 0.3);
  transition: transform 0.15s, box-shadow 0.2s;
  z-index: 999;
}

.feedback-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(232, 101, 26, 0.4);
}

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.92) } to { opacity: 1; transform: scale(1) } }
@keyframes spin { to { transform: rotate(360deg) } }

@media (max-width: 760px) {
  .toolbar-bar { flex-wrap: wrap; gap: 8px; }
  .search-wrapper { flex-basis: 100%; }
  .toolbar-divider { display: none; }
  .workflow-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .modal-two-column { grid-template-columns: 1fr; }
  .modal-right-column .form-group > div { flex-direction: row !important; gap: 10px !important; }
  .ratio-option { flex-direction: row; min-height: auto; padding: 10px 14px; gap: 10px; flex: 1; }
  .ratio-icon-landscape { width: 40px; height: 22px; }
  .ratio-icon-portrait { width: 22px; height: 40px; }
  .ratio-text { align-items: flex-start; }
}

@media (max-width: 480px) {
  .workflow-list-shell { width: calc(100% - 16px); padding: 16px 0 32px; }
  .page-title { font-size: 20px; }
  .agent-cta { padding: 12px 16px; gap: 10px; }
  .workflow-body { padding: 14px 16px 16px; gap: 10px; }
  .workflow-actions { padding: 0 16px 16px; }
  .workflow-title { font-size: 15px; }
  .pagination { gap: 4px; margin-top: 20px; }
  .pagination-btn { padding: 6px 12px; font-size: 12px; }
  .feedback-btn { padding: 10px 16px; font-size: 12px; bottom: 16px; right: 16px; }
  .toast { max-width: calc(100vw - 32px); }
}
