@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=IBM+Plex+Sans+KR:wght@400;500;700&display=swap');

:root {
  --bg: #0b1119;
  --bg-soft: #111a26;
  --panel: #152231;
  --panel-alt: #1b2c40;
  --line: #2e465d;
  --line-soft: #3a5c7a;
  --text: #e5eef8;
  --muted: #9fb3c9;
  --brand: #2cc497;
  --brand-strong: #1ea681;
  --accent: #58b4ef;
  --danger: #d76751;
  --warn: #d2ab4c;
  --radius: 14px;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  color: var(--text);
  background:
    radial-gradient(circle at 0% 0%, rgba(44, 196, 151, 0.2), transparent 28%),
    radial-gradient(circle at 100% 0%, rgba(88, 180, 239, 0.16), transparent 28%),
    linear-gradient(155deg, #081018, #101927 45%, #0a131f);
  font-family: "Space Grotesk", "IBM Plex Sans KR", "Apple SD Gothic Neo", sans-serif;
}

.bg-glow {
  position: fixed;
  inset: -35vmax;
  pointer-events: none;
  z-index: 0;
  background: conic-gradient(from 210deg, rgba(44, 196, 151, 0.09), rgba(88, 180, 239, 0.08), transparent, rgba(215, 103, 81, 0.08));
  animation: spinGlow 28s linear infinite;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1880px;
  margin: 0 auto;
  padding: 20px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(150deg, rgba(20, 32, 46, 0.95), rgba(12, 23, 34, 0.95));
  box-shadow: var(--shadow);
}

.hero h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0.03em;
}

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

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

.layout-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 14px;
  height: fit-content;
}

.side-nav h2 {
  margin: 0;
  font-size: 18px;
}

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

.nav-btn {
  justify-content: flex-start;
}

.nav-btn.active {
  border-color: rgba(44, 196, 151, 0.6);
  background: rgba(30, 50, 66, 0.92);
}

.side-note {
  padding: 10px;
  border: 1px dashed var(--line-soft);
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
}

.view-shell {
  min-width: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: riseIn 0.24s ease-out;
}

.two-panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: linear-gradient(165deg, rgba(21, 34, 49, 0.95), rgba(13, 24, 35, 0.95));
  box-shadow: var(--shadow);
}

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

.panel-head h2,
.panel-subhead h3 {
  margin: 0;
}

.panel-head h2 {
  font-size: 18px;
}

.panel-subhead h3 {
  font-size: 15px;
}

.badge,
.chip,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  color: var(--muted);
  background: rgba(19, 34, 47, 0.85);
  font-size: 12px;
}

.tag.repeated,
.repeated {
  border-color: rgba(210, 171, 76, 0.6);
  color: #ffd991;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #0d1824;
  color: var(--text);
  padding: 10px;
  font: inherit;
  font-size: 14px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 180, 239, 0.22);
}

textarea {
  resize: vertical;
  min-height: 72px;
}

.col-span-2 {
  grid-column: span 2;
}

.inline-check {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
}

.inline-check input {
  width: auto;
  margin: 0;
}

.form-actions,
.inline-actions,
.workspace-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.workspace-actions {
  margin-bottom: 12px;
}

.decision-panel {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(16, 30, 43, 0.9);
  padding: 10px;
  margin-bottom: 12px;
}

.tiny-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.2s ease, background 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(120deg, var(--brand), #26a6bf);
  color: #062117;
  border-color: rgba(44, 196, 151, 0.6);
}

.btn-primary:hover {
  background: linear-gradient(120deg, var(--brand-strong), #218ca3);
}

.btn-ghost {
  background: rgba(17, 31, 42, 0.9);
  border-color: var(--line-soft);
  color: var(--text);
}

.btn-danger {
  background: rgba(215, 103, 81, 0.18);
  border-color: rgba(215, 103, 81, 0.55);
  color: #ffd0c5;
}

.stack-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(20, 35, 49, 0.9);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.item-card.selected {
  border-color: rgba(88, 180, 239, 0.65);
}

details.item-card {
  display: block;
}

.item-main {
  min-width: 0;
}

.item-title {
  margin: 0 0 6px;
  font-size: 14px;
}

.item-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.empty {
  padding: 13px;
  border: 1px dashed var(--line-soft);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(13, 24, 35, 0.7);
  font-size: 13px;
}

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

.kpi-seed-head h3 {
  margin: 0;
  font-size: 14px;
}

.kpi-seed-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kpi-seed-row {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(16, 30, 43, 0.9);
  padding: 8px;
  display: grid;
  grid-template-columns: 2fr 1.2fr 0.9fr 0.9fr auto;
  gap: 8px;
  align-items: center;
}

.kpi-seed-row input,
.kpi-seed-row select {
  padding: 8px;
  font-size: 12px;
}

.template-info {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(17, 29, 41, 0.88);
  padding: 10px;
  font-size: 12px;
  color: var(--muted);
}

.drag-board {
  border: 1px dashed var(--line-soft);
  border-radius: 10px;
  padding: 10px;
  min-height: 68px;
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: rgba(13, 25, 36, 0.8);
}

.drag-agent {
  border: 1px solid rgba(88, 180, 239, 0.55);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: grab;
  user-select: none;
  background: rgba(16, 34, 47, 0.95);
}

.drag-agent.dragging {
  opacity: 0.5;
}

.drag-agent.drop-target {
  border-color: rgba(44, 196, 151, 0.75);
  box-shadow: 0 0 0 2px rgba(44, 196, 151, 0.24);
}

.graph-wrap {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(10, 20, 30, 0.88);
  overflow: hidden;
}

#relationGraph {
  width: 100%;
  min-height: 300px;
  display: block;
}

.meta-grid,
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.meta-box,
.stat-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: rgba(18, 32, 46, 0.9);
}

.meta-key,
.stat-key {
  color: var(--muted);
  font-size: 12px;
}

.meta-value,
.stat-value {
  margin-top: 6px;
  font-size: 13px;
  word-break: break-word;
}

.latest-result {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(14, 25, 37, 0.9);
  padding: 12px;
  margin-bottom: 12px;
}

.latest-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.latest-title {
  margin: 0;
  font-size: 15px;
}

.kpi-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(18, 33, 48, 0.9);
}

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

.kpi-title {
  margin: 0;
  font-size: 14px;
}

.kpi-progress {
  margin: 8px 0;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  background: rgba(13, 23, 34, 0.9);
}

.kpi-progress-fill {
  height: 100%;
  background: linear-gradient(120deg, #2cc497, #58b4ef);
}

.kpi-progress-fill.warn {
  background: linear-gradient(120deg, #d2ab4c, #df8f35);
}

.kpi-progress-fill.bad {
  background: linear-gradient(120deg, #d76751, #d29544);
}

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

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timeline-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: rgba(18, 33, 48, 0.9);
}

.timeline-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

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

.timeline-time,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.code-block {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 16, 24, 0.9);
  padding: 8px;
  white-space: pre-wrap;
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
  margin-top: 6px;
}

.md-content {
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
}

.md-content h1,
.md-content h2,
.md-content h3,
.md-content h4 {
  margin: 10px 0 6px;
}

.md-content p {
  margin: 7px 0;
}

.md-content ul,
.md-content ol {
  margin: 6px 0 6px 20px;
}

.md-content code {
  border-radius: 6px;
  padding: 2px 5px;
  background: rgba(8, 16, 24, 0.95);
  border: 1px solid var(--line-soft);
}

.md-content pre {
  margin: 8px 0;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 16, 24, 0.95);
  padding: 10px;
  overflow-x: auto;
}

.md-content blockquote {
  margin: 8px 0;
  padding: 8px 10px;
  border-left: 3px solid var(--accent);
  color: #b7cae0;
  background: rgba(15, 27, 40, 0.8);
}

.md-content a {
  color: #8ecaff;
}

.billing-note {
  margin-bottom: 10px;
  padding: 10px;
  border: 1px dashed var(--line-soft);
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
}

.billing-filter {
  min-width: 220px;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: auto;
  background: rgba(10, 20, 30, 0.9);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid #243a50;
  padding: 8px;
  font-size: 12px;
  text-align: left;
}

.data-table th {
  color: #b9cde3;
  background: rgba(20, 34, 49, 0.95);
  position: sticky;
  top: 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(11, 22, 33, 0.96);
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  z-index: 10;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@keyframes spinGlow {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

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

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

  .side-nav {
    position: static;
  }

  .nav-stack {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .two-panel-grid,
  .two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app-shell {
    padding: 12px;
  }

  .hero {
    flex-direction: column;
  }

  .hero h1 {
    font-size: 24px;
  }

  .hero-actions {
    width: 100%;
    justify-content: space-between;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .col-span-2 {
    grid-column: span 1;
  }

  .kpi-seed-row {
    grid-template-columns: 1fr;
  }

  .nav-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
