:root {
  --bg: #edf2f8;
  --bg-2: #f7fafc;
  --side: #0d1827;
  --side-2: #17273b;
  --surface: #ffffff;
  --surface-soft: #f4f7fb;
  --ink: #122237;
  --muted: #5a6d88;
  --line: #d5e0ef;
  --primary: #0e67d7;
  --ok: #1d7d4c;
  --warn: #a6711a;
  --danger: #bd3636;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: 'Pretendard', 'Noto Sans KR', 'Apple SD Gothic Neo', sans-serif;
  background: linear-gradient(150deg, var(--bg) 0%, var(--bg-2) 70%);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
}

.sidebar {
  background: linear-gradient(180deg, var(--side), #0a1421);
  color: #e8f0ff;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.brand h1 {
  margin: 0;
  font-size: 1.2rem;
}

.brand p {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: #b8cae9;
}

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

.nav-route {
  display: block;
  text-decoration: none;
  color: #d8e6ff;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 10px;
  font-weight: 700;
}

.nav-route.active {
  background: linear-gradient(180deg, #2b4d77, #254366);
  border-color: #5379aa;
  color: #fff;
}

.sidebar-panel {
  display: grid;
  gap: 8px;
  min-height: 0;
}

.sidebar-panel h2 {
  margin: 6px 2px 0;
  font-size: 0.95rem;
}

.timeline-list {
  max-height: calc(100vh - 230px);
  overflow: auto;
  display: grid;
  gap: 8px;
}

.timeline-item {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  padding: 8px;
}

.timeline-running {
  border-color: rgba(243, 203, 113, 0.7);
}

.timeline-completed {
  border-color: rgba(116, 223, 145, 0.65);
}

.timeline-failed {
  border-color: rgba(239, 125, 125, 0.7);
}

.timeline-title {
  font-weight: 700;
  font-size: 0.84rem;
}

.timeline-meta,
.timeline-detail {
  margin-top: 4px;
  font-size: 0.76rem;
  color: #cad7ef;
}

.content {
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.topbar,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.topbar {
  padding: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.topbar h2 {
  margin: 0;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.route-page {
  display: none;
  gap: 12px;
}

.route-page.active {
  display: grid;
}

.panel {
  padding: 14px;
  box-shadow: 0 6px 16px rgba(16, 35, 63, 0.05);
}

.panel h3,
.panel h4 {
  margin: 0 0 10px;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.hint,
.hint-inline {
  font-size: 0.84rem;
  color: var(--muted);
}

.global-status-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.status-card {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.status-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 700;
}

.status-value {
  margin-top: 6px;
  font-size: 1.02rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.status-sub {
  margin-top: 4px;
  font-size: 0.76rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.layout-main {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 12px;
}

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

.stacked-form {
  display: grid;
  gap: 8px;
}

.stacked-form.compact {
  gap: 6px;
}

.stacked-form label {
  font-weight: 700;
  font-size: 0.88rem;
}

.inline-inputs {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.filters-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 150px 140px minmax(0, 1fr) auto;
  gap: 8px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
}

textarea {
  resize: vertical;
  font-family: var(--mono);
  line-height: 1.45;
}

.btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

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

.btn-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

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

.session-list,
.result-list,
.workspace-file-list,
.cron-list {
  display: grid;
  gap: 8px;
  max-height: 54vh;
  overflow: auto;
}

.session-item,
.workspace-file-item,
.cron-item,
.result-card {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 10px;
  padding: 10px;
}

.session-item,
.workspace-file-item {
  width: 100%;
  cursor: pointer;
}

.session-item.active,
.workspace-file-item.active,
.result-card.active {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(14, 103, 215, 0.25);
}

.session-top,
.result-card-top,
.result-card-mid,
.cron-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.session-tags {
  display: flex;
  align-items: center;
  gap: 6px;
}

.source-tag,
.pill,
.badge {
  border-radius: 999px;
  font-size: 0.72rem;
  padding: 3px 8px;
  font-weight: 800;
}

.source-local {
  background: #e8f1ff;
  color: #1c5db8;
}

.source-openclaw {
  background: #e4f8ec;
  color: #1d6b46;
}

.pill-live {
  background: #e6f6eb;
  color: var(--ok);
}

.pill-idle {
  background: #eef3fa;
  color: #50617a;
}

.badge {
  background: #eef3fa;
  color: #445773;
}

.session-meta,
.session-preview,
.result-card-mid,
.result-card-preview,
.cron-meta,
.workspace-file-meta {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.meta {
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 9px;
  font-size: 0.84rem;
  line-height: 1.45;
}

.controls {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

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

.detail-view,
.log-view,
.workspace-content {
  margin: 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f8fbff;
  color: #1f3150;
  font-size: 12px;
  line-height: 1.45;
  font-family: var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
  padding: 10px;
  overflow: auto;
}

.detail-view {
  min-height: 72px;
  max-height: 18vh;
}

.workspace-content {
  min-height: 520px;
  max-height: 66vh;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(560px, 100vw);
  height: 100vh;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: -8px 0 24px rgba(11, 26, 48, 0.18);
  transform: translateX(105%);
  transition: transform 0.22s ease;
  z-index: 30;
  padding: 14px;
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
  gap: 10px;
}

.drawer.open {
  transform: translateX(0);
}

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

.drawer-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: var(--surface-soft);
}

.drawer-section .log-view {
  min-height: 160px;
  max-height: 40vh;
  background: #0d1a2b;
  color: #d8e6ff;
  border-color: #0d1a2b;
}

.toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  display: grid;
  gap: 8px;
}

.toast {
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 220px;
  color: #fff;
  font-size: 0.85rem;
  background: #223a57;
  box-shadow: 0 6px 14px rgba(11, 29, 54, 0.25);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-error {
  background: #9f2f2f;
}

.toast-ok {
  background: #1f7a4b;
}

.toast.hide {
  opacity: 0;
  transform: translateY(5px);
}

@media (max-width: 1400px) {
  .global-status-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

  .sidebar {
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  }

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

  .timeline-list {
    max-height: 240px;
  }
}

@media (max-width: 760px) {
  .content {
    padding: 10px;
  }

  .topbar {
    flex-direction: column;
  }

  .global-status-grid {
    grid-template-columns: 1fr;
  }

  .filters-row,
  .inline-inputs,
  .inline-form,
  .controls {
    grid-template-columns: 1fr;
  }

  .workspace-content {
    min-height: 420px;
  }
}
