:root {
  --bg: #f6f7f9;
  --bg-soft: #fbfcfd;
  --card: #ffffff;
  --ink: #1b2430;
  --muted: #637083;
  --line: #e3e8ef;
  --accent: #2165f5;
  --accent-soft: #edf3ff;
  --ok: #1f8b4d;
  --error: #b24040;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(18, 38, 63, 0.06);
  --font-ui: "Manrope", "Nunito Sans", "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(900px 360px at -10% -10%, #f0f5ff 10%, transparent 70%),
    radial-gradient(900px 360px at 110% -10%, #f9f7ff 10%, transparent 70%),
    var(--bg);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #6ca4ff, #2165f5);
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 12px;
}

.sidebar-nav {
  display: grid;
  gap: 8px;
}

.nav-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  border-radius: 10px;
  text-align: left;
  padding: 10px 12px;
  font: inherit;
  cursor: pointer;
}

.nav-btn:hover {
  background: var(--bg-soft);
}

.nav-btn.active {
  background: var(--accent-soft);
  color: #0f3fa8;
  border-color: #d7e5ff;
}

.sidebar-section {
  min-height: 140px;
}

.section-title {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.agent-list {
  display: grid;
  gap: 8px;
}

.agent-tile {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  background: #fff;
  cursor: pointer;
}

.agent-tile:hover {
  border-color: #ced9ea;
}

.agent-tile.active {
  border-color: #bfd1f6;
  background: var(--accent-soft);
}

.agent-tile-name {
  font-size: 13px;
  font-weight: 600;
}

.agent-tile-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.agent-inline-tabs {
  margin-top: 8px;
  display: flex;
  gap: 6px;
}

.mini-tab {
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  padding: 4px 8px;
  background: #fff;
  cursor: pointer;
}

.mini-tab.active {
  border-color: #b7caf1;
  background: #eef4ff;
  color: #1947ad;
}

.sidebar-bottom {
  margin-top: auto;
}

.main {
  padding: 28px clamp(16px, 4vw, 54px);
  animation: fade-in 240ms ease-out;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero {
  max-width: 760px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow);
  padding: clamp(16px, 3vw, 28px);
  animation: rise-in 320ms ease-out both;
}

.hero h1 {
  margin: 0;
  font-size: clamp(22px, 4vw, 32px);
}

.hero p {
  margin: 8px 0 16px;
  color: var(--muted);
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  color: inherit;
}

textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: #9fbaf0;
  box-shadow: 0 0 0 3px rgba(33, 101, 245, 0.08);
}

.inline-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

label span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

button {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  background: #eef2f8;
  color: #24364d;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.98);
}

button.primary {
  background: var(--accent);
  color: #fff;
}

.hero .primary {
  margin-top: 14px;
}

.recent {
  max-width: 760px;
  margin: 16px auto 0;
}

.recent-list {
  display: grid;
  gap: 8px;
}

.recent-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  animation: rise-in 240ms ease-out both;
}

.recent-item-title {
  font-size: 13px;
  font-weight: 600;
}

.recent-item-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.view-head h2 {
  margin: 0;
}

.view-head p {
  margin: 8px 0 18px;
  color: var(--muted);
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.catalog-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 8px;
}

.catalog-card-title {
  font-weight: 700;
  font-size: 15px;
}

.catalog-card-desc {
  color: var(--muted);
  font-size: 13px;
}

.catalog-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.state {
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  padding: 14px;
  margin-bottom: 10px;
}

.state.error {
  border-color: #f2c7c7;
  color: #8c2f2f;
  background: #fff7f7;
}

.hidden {
  display: none !important;
}

.skeleton-grid {
  display: grid;
  gap: 10px;
}

.skeleton {
  height: 74px;
  border-radius: 12px;
  background: linear-gradient(90deg, #eef2f7 25%, #f6f8fb 50%, #eef2f7 75%);
  background-size: 260% 100%;
  animation: shimmer 1.4s infinite linear;
}

.agent-workspace {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

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

.agent-title {
  font-weight: 700;
}

.tabs {
  display: flex;
  gap: 8px;
}

.tab-btn {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 7px 11px;
  font-size: 13px;
}

.tab-btn.active {
  border-color: #bfd1f6;
  background: var(--accent-soft);
  color: #0f3fa8;
}

.agent-tab,
.settings-pane {
  display: none;
}

.agent-tab.active,
.settings-pane.active {
  display: block;
}

.agent-feed {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.feed-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 11px;
}

.feed-item-title {
  font-size: 13px;
  font-weight: 600;
}

.feed-item-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.settings-tabs {
  margin: 4px 0 12px;
}

.integration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.integration-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.integration-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.pill {
  font-size: 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 3px 7px;
  color: var(--muted);
}

.pill.ok {
  border-color: #bee2cb;
  color: var(--ok);
  background: #f2fbf5;
}

.simple-form {
  max-width: 560px;
  display: grid;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

.form-actions {
  display: flex;
  gap: 8px;
}

.advanced {
  margin-top: 4px;
}

.advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}

.advanced-grid {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: #16263f;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 20;
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -20% 0;
  }
}

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

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    gap: 10px;
  }

  .sidebar-bottom {
    margin-top: 0;
  }

  .inline-controls {
    grid-template-columns: 1fr;
  }
}
