:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --border: #e5e7eb;
  --border-strong: #dde1e6;
  --text: #1f2937;
  --muted: #667085;
  --primary: #2f3742;
  --primary-soft: #eceff3;
  --success: #3f6b58;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shell-max: 1680px;
  --shell-pad: clamp(10px, 1.1vw, 18px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Sohne", "Geist", "SF Pro Text", "PingFang SC", sans-serif;
  letter-spacing: 0.01em;
}

.bg-orb { display: none; }

.shell {
  max-width: none;
  width: 100%;
  margin: 0 auto;
  padding: var(--shell-pad);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: calc(-1 * var(--shell-pad)) calc(-1 * var(--shell-pad)) 14px;
  padding: 14px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: color-mix(in srgb, #ffffff 80%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
}

.title h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: 0;
}

.title p {
  margin: 5px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f3f4f6;
}

.lang-switch button {
  width: auto;
  min-width: 44px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: #4b5563;
  font-size: 12px;
  line-height: 1.2;
}

.lang-switch button:hover {
  background: #eef1f4;
  border-color: #dde1e6;
}

.lang-switch button.active {
  background: #e4e7eb;
  border-color: #d6dbe2;
  color: #111827;
}

.lang-switch.floating {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 50;
}

.nav a {
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  color: #4b5563;
  border: 1px solid transparent;
  padding: 7px 12px;
  border-radius: 9px;
  transition: all .15s ease;
}

.nav a:hover {
  color: #111827;
  background: var(--surface-2);
  border-color: var(--border);
}

.nav a.active {
  color: #0f172a;
  background: var(--primary-soft);
  border-color: var(--border-strong);
}

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

.card {
  grid-column: span 12;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0;
}

.card h3 {
  margin: 10px 0 8px;
  font-size: 13px;
  font-weight: 650;
}

.card p {
  margin: 6px 0;
  font-size: 13px;
  color: var(--muted);
}

.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

label {
  display: block;
  font-size: 12px;
  color: #4b5563;
  margin-bottom: 8px;
  font-weight: 550;
}

input,
select,
textarea,
button {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #c9ced6;
  box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.16);
}

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

button {
  font-weight: 600;
  cursor: pointer;
  background: #f3f4f6;
  border-color: #dde1e6;
  box-shadow: none;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}

button:hover {
  border-color: #d3d8df;
  background: #eef1f4;
}

button:active {
  border-color: #c7cdd6;
  background: #e6e9ee;
}

button:disabled,
button[disabled] {
  cursor: not-allowed;
  color: #9aa3b2;
  border-color: #dde2e8;
  background: #edf0f4;
  box-shadow: none;
  opacity: 1;
}

button.primary {
  background: #1f7a53;
  border-color: #1f7a53;
  color: #fff;
  box-shadow: none;
}

button.primary:hover {
  background: #1b6e4a;
  border-color: #1b6e4a;
}

button.primary:active {
  background: #165d3e;
  border-color: #165d3e;
}

button.success {
  background: #7f9f91;
  border-color: #7f9f91;
  color: #fff;
  box-shadow: none;
}

button.success:hover {
  background: #76978a;
  border-color: #76978a;
}

button.success:active {
  background: #6d8f82;
  border-color: #6d8f82;
}

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

.path-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 8px;
}

.path-input button {
  width: auto;
  padding: 8px 12px;
}

.btn-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.btn-grid a {
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  transition: all .15s ease;
}

.btn-grid a:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.btn-grid strong {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}

.btn-grid span {
  font-size: 12px;
  color: var(--muted);
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  width: auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  padding: 4px 10px;
  font-size: 11px;
  color: #374151;
}

.chip.job-chip.running {
  background: #1f7a53;
  border-color: #1f7a53;
  color: #fff;
  box-shadow: none;
}

.chip.job-chip.failed {
  background: #c25757;
  border-color: #c25757;
  color: #fff;
  box-shadow: none;
}

.note {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.log {
  background: #0f172a;
  color: #d9fbe4;
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 10px;
  min-height: 180px;
  max-height: 320px;
  overflow: auto;
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

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

.panel-left {
  position: sticky;
  top: 86px;
  height: calc(100vh - 110px);
  overflow: auto;
}

.panel-right {
  display: grid;
  gap: 12px;
}

.tree-pane {
  max-height: calc(100vh - 250px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  background: var(--surface-2);
}

.tree-list button {
  margin-bottom: 0;
  text-align: left;
}

.tree-ul {
  list-style: none;
  margin: 0;
  padding-left: 10px;
  margin-left: 8px;
  border-left: 1px solid #dde2e8;
}

.tree-li {
  margin: 0;
  position: relative;
}

.tree-li::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 14px;
  width: 7px;
  height: 1px;
  background: #dde2e8;
}

.tree-node {
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 12px;
  padding: 3px 7px;
  min-height: 24px;
  box-shadow: none;
  display: flex;
  align-items: center;
  gap: 5px;
  color: #344054;
}

.tree-node::before {
  content: "•";
  color: #9ca3af;
  font-size: 11px;
  line-height: 1;
  flex: 0 0 auto;
}

.tree-node.dir::before {
  content: "▸";
  color: #7c8798;
}

.tree-node.file::before {
  content: "•";
  color: #a3acb9;
}

.tree-node.up::before {
  content: "↩";
  color: #7c8798;
}

.tree-node:hover {
  border: 0;
  background: #edf1f5;
}

.tree-node:active {
  background: #e6ebf1;
}

.tree-node.selected {
  background: #e6ebf1;
  color: #1f2937;
}

.tree-node.root {
  margin-bottom: 4px;
  padding: 4px 7px;
  font-weight: 650;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #475569;
}

.tree-node.root::before {
  content: "";
  display: none;
}

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

.visual-window {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0b1220;
  overflow: hidden;
}

.visual-window img {
  width: 100%;
  display: block;
}

.visual-window svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.visual-window.small {
  max-width: 360px;
}

.compare {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  background: var(--surface-2);
}

.compare-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 8;
  border-radius: 8px;
  overflow: hidden;
  background: #0b1220;
}

.compare-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.compare-frame .overlay { clip-path: inset(0 0 0 50%); }

#splitLine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: #f59e0b;
}

.triple {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.triple figure {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  background: var(--surface-2);
}

.triple img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}

.triple figcaption {
  margin-top: 5px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
}

#chart {
  width: 100%;
  height: 320px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.hidden { display: none !important; }

.pp-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: grid;
  place-items: center;
  z-index: 2000;
  padding: 20px;
}

.pp-modal {
  width: min(860px, 96vw);
  height: min(78vh, 760px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  min-height: 0;
}

.pp-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pp-head strong {
  font-size: 14px;
}

.pp-head button {
  width: auto;
  min-width: 64px;
}

.pp-toolbar {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
}

.pp-toolbar button {
  width: auto;
}

.pp-list {
  margin: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  overflow: auto;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 8px;
}

.pp-row {
  text-align: left;
}

.pp-actions {
  border-top: 1px solid var(--border);
  padding: 8px 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.pp-actions button {
  width: auto;
  min-width: 120px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 12px;
}

.hero .kpi {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.hero .kpi div {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--surface-2);
}

.hero .kpi strong {
  display: block;
  font-size: 18px;
  margin-bottom: 3px;
}

.hero .kpi span {
  font-size: 11px;
  color: var(--muted);
}

.home-main {
  display: grid;
  gap: 14px;
}

.home-entry-wrap {
  padding: 18px;
}

.home-entry-head {
  margin-bottom: 14px;
}

.home-entry-head h2 {
  margin: 0;
  font-size: 18px;
}

.home-entry-head p {
  margin: 6px 0 0;
  font-size: 13px;
}

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

.home-entry {
  text-decoration: none;
  color: var(--text);
  background: #f7f8fa;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 15px;
  min-height: 102px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.home-entry:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 18px rgba(16, 24, 40, 0.06);
}

.home-entry strong {
  font-size: 15px;
  line-height: 1.25;
}

.home-entry span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.home-metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.metric-pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f6f7f9;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.metric-name {
  font-size: 11px;
  color: var(--muted);
  flex: 0 0 auto;
}

.metric-pill strong {
  font-size: 12px;
  font-weight: 700;
  color: #374151;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-pill strong.up {
  color: #b45309;
}

.metric-pill strong.down {
  color: #1f7a53;
}

.metric-pill strong.flat {
  color: #64748b;
}

.metric-pill em {
  margin-left: auto;
  font-style: normal;
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  color: #64748b;
}

.metric-pill em.up {
  color: #b45309;
}

.metric-pill em.down {
  color: #1f7a53;
}

@media (max-width: 980px) {
  .col-4,
  .col-6,
  .col-8 {
    grid-column: span 12;
  }

  .row,
  .btn-grid,
  .triple,
  .visual-grid,
  .hero,
  .hero .kpi {
    grid-template-columns: 1fr;
  }

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

  .panel-left {
    position: static;
    height: auto;
  }

  .home-entry-grid {
    grid-template-columns: 1fr;
  }

  .home-metric-strip {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: start;
    padding: 10px 10px;
  }

  .title h1 {
    font-size: 16px;
    line-height: 1.25;
  }

  .title p {
    display: none;
  }

  .nav {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    padding-bottom: 2px;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav a {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 6px 10px;
    font-size: 11px;
    border-radius: 999px;
  }
}

button.primary:disabled,
button.success:disabled,
button.primary[disabled],
button.success[disabled],
button:disabled,
button[disabled] {
  cursor: not-allowed;
  color: #9aa3b2;
  border-color: #dde2e8;
  background: #edf0f4;
  box-shadow: none;
  opacity: 1;
}

.prep-page .prep-grid {
  gap: 10px;
}

.prep-page .card {
  padding: 13px;
}

.prep-page .card h2 {
  margin-bottom: 9px;
}

.prep-page label {
  margin-bottom: 6px;
}

.prep-page .row {
  gap: 8px;
  margin-bottom: 2px;
}

.prep-page .path-input {
  --prep-side-w: 112px;
  grid-template-columns: minmax(0, 1fr) var(--prep-side-w);
  gap: 6px;
  margin-bottom: 6px;
}

.prep-page .path-input button {
  width: 100%;
  min-width: 0;
  padding: 7px 10px;
}

.prep-page .path-input.path-input-ghost .path-ghost {
  display: block;
  width: 100%;
  min-width: 0;
  border-radius: 10px;
  visibility: hidden;
}

.prep-page input[type="checkbox"] {
  width: auto;
  margin-right: 6px;
}

.prep-page .card > button.primary {
  margin-top: 2px;
  min-height: 34px;
}

.prep-page .prep-task-card h2 {
  min-height: 38px;
  line-height: 1.35;
  display: flex;
  align-items: center;
}

.prep-page .prep-task-card .inline-check {
  min-height: 30px;
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

.prep-page .prep-task-card .task-run {
  margin-top: auto;
}

.prep-page #pythonHint {
  display: flex;
  align-items: center;
  min-height: 34px;
}

.prep-page #jobChips {
  margin: 6px 0 8px;
  max-height: 94px;
  overflow: auto;
}

.prep-page #jobLog {
  min-height: 108px;
  max-height: 190px;
}

.prep-page #status {
  margin-top: 6px;
}

.prep-page .tr-job-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.prep-page .tr-job-row label {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 980px) {
  .prep-page .card {
    padding: 14px;
  }

  .prep-page .path-input {
    --prep-side-w: 96px;
  }
}
