:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-soft: #fafbff;
  --border: #ebeef5;
  --border-strong: #dfe5ef;
  --text: #111827;
  --muted: #6b7280;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --success: #22c55e;
  --success-soft: #ecfdf3;
  --warning: #f59e0b;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

a {
  color: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.shell-header,
.flash-stack,
.shell-main {
  width: min(1600px, calc(100vw - 32px));
  margin: 0 auto;
}

.shell-header {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  margin-top: 16px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
}

.brand-lockup,
.brand-row {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 16px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, #111827 0%, #2f3644 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.brand-row {
  gap: 14px;
  margin-bottom: 6px;
}

.brand-row h1 {
  font-size: 20px;
  font-weight: 700;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.brand-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.12);
}

.subtitle,
.muted,
.bundle-slug,
.agent-card-copy,
.target-chip-card code,
.detail-box code,
.empty-state,
.empty-console p,
.step-list,
.console-toggle {
  color: var(--muted);
}

.subtitle {
  max-width: 880px;
  line-height: 1.5;
  font-size: 14px;
}

.shell-main {
  padding: 16px 0 28px;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.flash {
  padding: 14px 18px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.flash-success {
  color: #166534;
}

.flash-error {
  color: #991b1b;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.stat-card {
  padding: 18px 22px;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 14px;
  align-items: center;
  min-height: 92px;
}

.stat-card + .stat-card {
  border-left: 1px solid var(--border);
}

.stat-symbol {
  width: 28px;
  height: 28px;
  border-radius: 12px;
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8);
}

.stat-symbol-orange {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
}

.stat-symbol-green {
  background: linear-gradient(135deg, #ecfdf3 0%, #dcfce7 100%);
}

.stat-symbol-violet {
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
}

.stat-symbol-yellow {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}

.stat-value {
  display: block;
  font-size: 34px;
  line-height: 1;
  font-weight: 700;
}

.stat-label {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  color: var(--muted);
}

.stat-subvalue {
  margin-left: 6px;
  color: #9ca3af;
  font-size: 18px;
  font-weight: 600;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 0;
  min-height: calc(100vh - 196px);
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--surface);
}

.panel {
  background: var(--surface);
}

.sidebar-panel {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.sidebar-head,
.tab-row,
.console-toolbar {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.counter-pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: #f5f7fb;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.sidebar-list {
  padding: 14px;
  display: grid;
  gap: 14px;
  overflow: auto;
}

.agent-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}

.agent-card-active {
  border-color: #d8dcff;
  box-shadow: 0 10px 22px rgba(79, 70, 229, 0.12);
}

.agent-card-head,
.manage-summary-head,
.bundle-detail-lockup {
  display: flex;
  align-items: center;
}

.agent-card-head {
  gap: 12px;
}

.bundle-logo-wrap,
.bundle-detail-logo {
  border-radius: 16px;
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
  border: 1px solid var(--border);
}

.bundle-logo-wrap {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.bundle-logo-wrap-dark {
  background: linear-gradient(135deg, #0f172a 0%, #1f2937 100%);
  color: #fff;
}

.logo-letter {
  font-size: 22px;
  font-weight: 700;
}

.bundle-logo-wrap img {
  max-width: 42px;
  max-height: 42px;
}

.agent-card-title {
  min-width: 0;
}

.agent-card-title h3 {
  font-size: 16px;
  margin-bottom: 4px;
}

.agent-card-title p {
  font-size: 13px;
  color: var(--muted);
}

.status-dot {
  margin-left: auto;
  font-size: 13px;
  color: #9ca3af;
}

.status-dot-ready {
  color: #6b7280;
}

.agent-card-copy {
  margin: 16px 0 14px;
  min-height: 40px;
  line-height: 1.45;
}

.target-row,
.target-list-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.target-pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: #f4f6fb;
  color: #6b7280;
  font-size: 12px;
  font-weight: 700;
}

.agent-card-foot {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #9ca3af;
  font-size: 13px;
}

.run-button,
.tab-link,
.ghost-button,
.primary-button {
  border-radius: 14px;
  text-decoration: none;
  font-weight: 700;
}

.run-button {
  padding: 10px 16px;
  background: linear-gradient(135deg, #effdf4 0%, #e8fff0 100%);
  color: #16a34a;
  border: 1px solid #d9fbe5;
  min-width: 92px;
  justify-content: center;
}

.console-panel {
  display: flex;
  flex-direction: column;
}

.tab-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.tab-link {
  padding: 12px 18px;
  color: #9ca3af;
  background: transparent;
  border-bottom: 3px solid transparent;
  border-radius: 0;
}

.tab-link-active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.console-toggle {
  margin-left: auto;
  font-size: 14px;
  font-weight: 600;
}

.console-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar-pill {
  padding: 11px 14px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
}

.toolbar-search {
  min-width: 320px;
  padding: 11px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  color: #9ca3af;
  background: #fff;
}

.console-autoscroll {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 600;
}

.toggle-pill {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  position: relative;
  background: #dbe1ea;
  display: inline-block;
}

.toggle-pill::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.toggle-pill-on {
  background: #4f46e5;
}

.toggle-pill-on::after {
  left: 21px;
}

.tab-content {
  padding: 20px;
  flex: 1;
  overflow: auto;
}

.create-layout {
  display: grid;
  grid-template-columns: minmax(0, 520px) minmax(0, 1fr);
  gap: 20px;
}

.create-form-panel,
.create-info-panel,
.manage-summary,
.json-side-panel {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #fff;
}

.create-form-panel,
.manage-summary,
.json-side-panel {
  padding: 20px;
}

.create-info-panel {
  padding: 20px;
  display: grid;
  gap: 16px;
  align-content: start;
  background: #fcfcfe;
}

.panel-head {
  margin-bottom: 18px;
}

.eyebrow {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid label span {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
}

input[type="text"],
input[type="url"],
input[type="file"] {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: #fff;
  padding: 13px 16px;
  font-size: 15px;
  color: var(--text);
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 18px;
  cursor: pointer;
}

.primary-button {
  border: 1px solid transparent;
  color: #fff;
  background: linear-gradient(135deg, #111827 0%, #2f3644 100%);
}

.ghost-button {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
}

.info-box {
  padding: 18px;
  border-radius: 18px;
  line-height: 1.6;
}

.info-box-large {
  background: linear-gradient(180deg, #fbfcff 0%, #f7f9ff 100%);
  border: 1px solid #e6ebfb;
}

.preview-grid {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.preview-step {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--border);
}

.preview-step span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #111827;
  color: #fff;
  font-weight: 700;
}

.workspace-blank {
  min-height: 280px;
  border-radius: 18px;
  border: 1px dashed var(--border-strong);
  background: #fff;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
}

.blank-mark {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  margin: 0 auto 14px;
}

.step-list {
  margin: 12px 0 0;
  padding-left: 18px;
}

.manage-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 20px;
}

.manage-summary-head {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.bundle-detail-lockup {
  gap: 16px;
}

.bundle-detail-logo {
  width: 78px;
  height: 78px;
  object-fit: contain;
  padding: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--success-soft);
  color: #15803d;
  font-size: 13px;
  font-weight: 700;
}

.detail-matrix {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.detail-matrix-compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-box,
.target-chip-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-soft);
}

.detail-box {
  padding: 16px;
}

.detail-kicker {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}

.detail-box strong,
.detail-box a {
  overflow-wrap: anywhere;
}

.compact-form {
  margin-bottom: 20px;
}

.target-list-inline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.target-chip-card {
  padding: 14px;
}

.target-chip-card strong {
  display: block;
  margin-bottom: 8px;
}

.json-side-panel {
  overflow: hidden;
}

.panel-head-tight {
  margin-bottom: 14px;
}

.no-bottom {
  margin-bottom: 0;
}

.history-header,
.history-row {
  display: grid;
  grid-template-columns: 180px 1fr 90px;
  gap: 16px;
  align-items: center;
  padding: 12px 2px;
}

.history-header {
  margin-top: 8px;
  color: #9ca3af;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.history-row {
  border-top: 1px solid var(--border);
  color: #374151;
  font-size: 14px;
}

.json-preview {
  margin: 16px 0 0;
  padding: 18px;
  min-height: 280px;
  border-radius: 16px;
  background: #0f172a;
  color: #e5eefc;
  overflow: auto;
  line-height: 1.55;
}

.empty-state,
.empty-console {
  border: 1px dashed var(--border-strong);
  border-radius: 20px;
  background: #fcfcfe;
}

.empty-state {
  padding: 18px;
}

.empty-console {
  min-height: 520px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 30px;
}

.empty-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
}

@media (max-width: 1200px) {
  .workspace-grid,
  .create-layout,
  .manage-layout {
    grid-template-columns: 1fr;
  }

  .sidebar-panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .target-list-inline,
  .detail-matrix,
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .shell-header,
  .tab-row,
  .console-toolbar,
  .manage-summary-head,
  .brand-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats-grid,
  .target-list-inline,
  .detail-matrix {
    grid-template-columns: 1fr;
  }

  .console-toggle {
    margin-left: 0;
  }
}
