:root {
  --bg-1: #f3f6fb;
  --bg-2: #e6edf7;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-strong: #ffffff;
  --text: #0d1b2a;
  --muted: #526178;
  --line: #d8e0ec;
  --brand: #0b7a75;
  --brand-2: #1b4f8a;
  --danger: #b24646;
  --shadow: 0 12px 30px rgba(11, 38, 67, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans SC", "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg-1), var(--bg-2));
}

.ambient {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(11, 122, 117, 0.15), transparent 40%),
    radial-gradient(circle at 85% 15%, rgba(27, 79, 138, 0.14), transparent 45%),
    radial-gradient(circle at 70% 85%, rgba(38, 130, 184, 0.1), transparent 40%);
  pointer-events: none;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 18px;
}

.sidebar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 18px;
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: slide-in 0.35s ease-out;
}

.brand h1 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.35rem;
  letter-spacing: 0.4px;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

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

.nav-btn {
  border: 1px solid transparent;
  border-radius: 12px;
  background: #f5f8fc;
  color: var(--text);
  text-align: left;
  padding: 10px 12px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.22s ease;
}

.nav-btn:hover {
  border-color: #c6d4e8;
  transform: translateX(2px);
}

.nav-btn.active {
  background: linear-gradient(120deg, rgba(11, 122, 117, 0.2), rgba(27, 79, 138, 0.16));
  border-color: rgba(11, 122, 117, 0.35);
  font-weight: 600;
}

.status-card {
  margin-top: auto;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.status-card h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.status-card p {
  margin: 0;
  color: var(--muted);
}

.main-panel {
  display: grid;
}

.view {
  display: none;
  animation: fade-in 0.28s ease;
}

.view.active {
  display: block;
}

.view-header h2 {
  margin: 6px 0 4px;
  font-size: 1.35rem;
}

.view-header p {
  margin: 0;
  color: var(--muted);
}

.panel {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
  color: #2c4058;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid #bfd0e6;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
  color: var(--text);
  background: #ffffff;
}

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

textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: #7ba6d9;
  box-shadow: 0 0 0 3px rgba(84, 132, 196, 0.18);
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.btn {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 9px 14px;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn.primary {
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  color: #ffffff;
}

.btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(15, 69, 123, 0.22);
}

.btn.secondary {
  background: #f3f7fd;
  border-color: #c7d6e9;
  color: #1f3856;
}

.btn.secondary:hover {
  background: #edf3fa;
}

.btn.warn {
  background: #fff3f1;
  border-color: #ebc2bf;
  color: var(--danger);
}

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

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

.instruction-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #d6e2f2;
  background: #f8fbff;
  color: #24405f;
  font-size: 0.9rem;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(11, 122, 117, 0.14);
  border: 1px solid rgba(11, 122, 117, 0.3);
  color: #0b5a57;
  font-size: 0.78rem;
  white-space: nowrap;
}

.flow-tip {
  margin-top: 10px;
}

.tip {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.message {
  min-height: 1.2rem;
  color: #234b77;
  font-size: 0.9rem;
}

#tasksMessage {
  margin-top: 8px;
}

#reportsMessage {
  margin-top: 8px;
}

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

.task-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
  align-items: start;
}

.task-editor {
  margin-top: 14px;
  position: sticky;
  top: 16px;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.task-editor.collapsed {
  opacity: 0.45;
  transform: translateX(12px);
  pointer-events: none;
}

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

.drawer-head h3 {
  margin: 0;
}

.form-grid.single {
  grid-template-columns: 1fr;
  margin-top: 10px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0;
  font-size: 1.02rem;
}

.card.running {
  border-color: rgba(11, 122, 117, 0.45);
  box-shadow: 0 0 0 2px rgba(11, 122, 117, 0.15), var(--shadow);
}

.run-pill {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  color: #0b5a57;
  background: rgba(11, 122, 117, 0.14);
  border: 1px solid rgba(11, 122, 117, 0.28);
}

.run-pill.breathing {
  animation: breathing 1.2s ease-in-out infinite;
}

.meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.task-progress {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-progress-track {
  position: relative;
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: #dce7f5;
  overflow: hidden;
}

.task-progress-bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  transition: width 0.35s ease;
}

.task-progress.active .task-progress-bar {
  animation: progress-glow 1.4s ease-in-out infinite;
}

.task-progress-text {
  min-width: 44px;
  text-align: right;
  color: #35587f;
  font-size: 0.82rem;
}

.report-detail {
  min-height: 60vh;
  position: sticky;
  top: 16px;
}

.report-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.markdown-box {
  margin-top: 12px;
  background: #f8fbff;
  border: 1px solid #d5e2f1;
  border-radius: 12px;
  padding: 14px 14px 10px;
  max-height: 50vh;
  overflow: auto;
  line-height: 1.62;
  font-size: 0.9rem;
}
.markdown-box h1,
.markdown-box h2,
.markdown-box h3 {
  margin: 0.55em 0 0.35em;
  line-height: 1.35;
}
.markdown-box h1 {
  font-size: 1.1rem;
}
.markdown-box h2 {
  font-size: 1rem;
  color: #1d426d;
}
.markdown-box h3 {
  font-size: 0.95rem;
  color: #2a4f78;
}
.markdown-box p {
  margin: 0.35em 0 0.52em;
}
.markdown-box ul,
.markdown-box ol {
  margin: 0.25em 0 0.6em;
  padding-left: 1.2rem;
}
.markdown-box li {
  margin: 0.24em 0;
}
.markdown-box a {
  color: #1f5f9f;
  text-decoration: none;
  border-bottom: 1px dashed rgba(31, 95, 159, 0.4);
}
.markdown-box a:hover {
  border-bottom-style: solid;
}

.headline-feed {
  display: grid;
  gap: 14px;
}

.headline-card {
  background: linear-gradient(180deg, #1b1848 0%, #1a1f5a 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-left: 8px solid #ff5b4d;
  border-radius: 14px;
  padding: 14px 14px 12px;
  color: #f1f5ff;
  box-shadow: 0 12px 20px rgba(10, 10, 35, 0.26);
}

.headline-top {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.84rem;
}

.headline-ratio {
  color: rgba(241, 245, 255, 0.8);
}

.headline-title {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.4;
  font-weight: 600;
  color: #f8fbff;
}

.headline-meta {
  margin-top: 8px;
  color: rgba(224, 233, 255, 0.78);
  font-size: 0.85rem;
}

.headline-divider {
  margin: 10px 0 10px;
  border-top: 1px solid rgba(241, 245, 255, 0.28);
}

.headline-event {
  margin: 0;
  color: rgba(236, 241, 255, 0.92);
  line-height: 1.75;
  font-size: 0.96rem;
}

.reference-block {
  margin-top: 14px;
  background: #f6f9ff;
  border: 1px solid #cfdef1;
  border-radius: 12px;
  padding: 12px 14px;
}

.reference-block h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: #23446b;
}

.reference-block ul {
  margin: 0;
  padding-left: 1.2rem;
}

.reference-block li {
  margin: 0.35rem 0;
}

.reference-block a {
  color: #1f5f9f;
  text-decoration: none;
}

.reference-block a:hover {
  text-decoration: underline;
}

.monitor-grid {
  align-items: start;
}

.monitor-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.monitor-stat {
  border: 1px solid #d8e4f2;
  border-radius: 12px;
  padding: 12px;
  background: #f8fbff;
}

.monitor-stat .label {
  color: var(--muted);
  font-size: 0.82rem;
}

.monitor-stat .value {
  margin-top: 6px;
  font-size: 1rem;
  font-weight: 700;
  color: #173654;
}

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

.monitor-card {
  border: 1px solid #d7e2ef;
  border-radius: 12px;
  padding: 12px;
  background: #f9fbff;
}

.monitor-card h4 {
  margin: 0;
  font-size: 0.96rem;
}

.monitor-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.monitor-card.error {
  border-color: rgba(178, 70, 70, 0.28);
  background: #fff7f6;
}

.monitor-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.monitor-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #d3deec;
  background: #ffffff;
  color: #264565;
  font-size: 0.78rem;
}

.monitor-chip.running {
  border-color: rgba(11, 122, 117, 0.34);
  color: #0b5a57;
}

.monitor-chip.failed {
  border-color: rgba(178, 70, 70, 0.34);
  color: var(--danger);
}

.monitor-chip.success {
  border-color: rgba(35, 97, 71, 0.3);
  color: #236147;
}

.monitor-empty {
  color: var(--muted);
  font-size: 0.88rem;
}

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

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

@keyframes breathing {
  0% {
    opacity: 0.45;
    transform: scale(0.98);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0.45;
    transform: scale(0.98);
  }
}

@keyframes progress-glow {
  0% {
    filter: saturate(1);
  }
  50% {
    filter: saturate(1.25);
  }
  100% {
    filter: saturate(1);
  }
}

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

  .sidebar {
    position: static;
  }

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

  .task-layout {
    grid-template-columns: 1fr;
  }

  .report-detail {
    position: static;
  }

  .task-editor {
    position: static;
  }
}

@media (max-width: 680px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .app-shell {
    padding: 12px;
  }

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