:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-strong: #eef2f0;
  --ink: #18211e;
  --muted: #65716c;
  --line: #dce3df;
  --accent: #0b6b53;
  --accent-hover: #095943;
  --accent-soft: #e1f1eb;
  --blue: #2f69a8;
  --blue-soft: #e8f0f8;
  --amber: #a86608;
  --amber-soft: #fff2d8;
  --red: #a33b3b;
  --red-soft: #f9e7e7;
  --shadow: 0 10px 30px rgba(22, 37, 31, 0.08);
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--bg); font-size: 14px; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.hidden { display: none !important; }

.auth-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 520px);
  align-items: stretch;
  background: var(--surface);
}
.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 48px;
  background: #172621;
  color: white;
}
.auth-brand h1 { margin: 0; font-size: 36px; line-height: 1.2; }
.auth-brand p { margin: 8px 0 0; color: #b8c9c2; font-size: 16px; }
.brand-mark {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.32);
  background: #0b6b53;
  color: white;
  border-radius: 6px;
  font: 600 22px/1 "IBM Plex Mono", monospace;
}
.brand-mark.small { width: 38px; height: 38px; font-size: 13px; }
.auth-panel { align-self: center; width: calc(100% - 48px); max-width: 360px; margin: auto; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; margin-bottom: 28px; background: var(--surface-strong); border-radius: 6px; }
.segment { border: 0; padding: 10px; background: transparent; color: var(--muted); border-radius: 4px; }
.segment.active { background: white; color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); font-weight: 600; }
.field { display: grid; gap: 8px; margin-bottom: 18px; }
.field > span { color: #39443f; font-size: 13px; font-weight: 600; }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: white;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 92px; resize: vertical; }
.form-error { color: var(--red); background: var(--red-soft); padding: 10px 12px; border-radius: 5px; }

.primary-button, .secondary-button, .danger-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 5px;
  padding: 8px 14px;
  font-weight: 600;
  border: 1px solid transparent;
}
.primary-button { color: white; background: var(--accent); }
.primary-button:hover { background: var(--accent-hover); }
.secondary-button { color: var(--ink); background: white; border-color: var(--line); }
.secondary-button:hover { border-color: #aebbb5; background: #fafcfb; }
.danger-button { color: var(--red); background: var(--red-soft); }
.full-width { width: 100%; }
.primary-button svg, .secondary-button svg, .danger-button svg, .icon-button svg, .nav-item svg { width: 17px; height: 17px; stroke-width: 1.8; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 5px; background: transparent; color: var(--muted); }
.icon-button:hover { background: var(--surface-strong); color: var(--ink); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 14px; background: #17211e; color: #e8eeeb; }
.sidebar-brand { height: 54px; display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.sidebar-brand > div:last-child { display: grid; }
.sidebar-brand strong { font-size: 15px; }
.sidebar-brand span { color: #96aaa1; font-size: 12px; }
.main-nav { display: grid; gap: 4px; margin-top: 24px; }
.nav-item { height: 42px; display: flex; align-items: center; gap: 11px; border: 0; border-radius: 5px; padding: 0 12px; background: transparent; color: #aebdb7; text-align: left; }
.nav-item:hover { color: white; background: rgba(255,255,255,.06); }
.nav-item.active { color: white; background: #2b3a35; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding-top: 14px; }
.user-block { display: grid; grid-template-columns: 34px minmax(0, 1fr) 36px; gap: 9px; align-items: center; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); font-weight: 700; }
.user-copy { display: grid; min-width: 0; }
.user-copy strong, .user-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-copy strong { font-size: 13px; }
.user-copy span { color: #8fa199; font-size: 11px; }
.sidebar .icon-button { color: #91a39b; }

.main-area { min-width: 0; }
.topbar { min-height: 82px; display: flex; align-items: center; gap: 16px; padding: 16px 28px; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(10px); }
.topbar h2 { margin: 2px 0 0; font-size: 20px; line-height: 1.3; }
.eyebrow { margin: 0; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.page-content { max-width: 1480px; margin: 0 auto; padding: 26px 28px 60px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin: 28px 0 12px; }
.section-heading:first-child { margin-top: 0; }
.section-heading h3 { margin: 0; font-size: 16px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; }
.metric { min-height: 112px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.metric-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); }
.metric-top svg { width: 18px; }
.metric strong { display: block; margin-top: 14px; font: 600 30px/1 "IBM Plex Mono", monospace; }
.metric span { color: var(--muted); font-size: 12px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.panel-toolbar { min-height: 52px; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.panel-toolbar strong { font-size: 14px; }
.panel-toolbar .spacer { margin-left: auto; }
.empty-state { min-height: 190px; display: grid; place-items: center; text-align: center; padding: 30px; color: var(--muted); }
.empty-state svg { width: 28px; height: 28px; margin-bottom: 10px; }
.empty-state p { margin: 0 0 14px; }

.project-grid, .tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.project-card, .tool-card { background: white; border: 1px solid var(--line); border-radius: 6px; padding: 16px; transition: border-color .15s, box-shadow .15s; }
.project-card:hover, .tool-card.available:hover { border-color: #a9bbb3; box-shadow: var(--shadow); }
.project-card button.card-hit { width: 100%; border: 0; padding: 0; background: transparent; color: inherit; text-align: left; }
.card-heading { display: flex; align-items: flex-start; gap: 11px; }
.card-icon { width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 5px; color: var(--accent); background: var(--accent-soft); }
.card-icon svg { width: 18px; height: 18px; }
.card-heading h4 { margin: 0; font-size: 14px; }
.card-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.card-meta { display: flex; gap: 14px; margin-top: 18px; color: var(--muted); font-size: 11px; }
.tool-card.unavailable { background: #f8faf9; }
.tool-card .card-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }

.badge { display: inline-flex; align-items: center; gap: 5px; min-height: 24px; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge.completed, .badge.available { color: var(--accent); background: var(--accent-soft); }
.badge.running { color: var(--blue); background: var(--blue-soft); }
.badge.queued { color: var(--amber); background: var(--amber-soft); }
.badge.failed, .badge.canceled { color: var(--red); background: var(--red-soft); }
.badge.planned { color: var(--muted); background: var(--surface-strong); }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 10px 14px; background: #f8faf9; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; font-weight: 600; text-align: left; }
.data-table td { padding: 12px 14px; border-bottom: 1px solid #edf1ef; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr.clickable:hover { background: #fafcfb; cursor: pointer; }
.mono { font-family: "IBM Plex Mono", monospace; font-size: 12px; }
.muted { color: var(--muted); }
.file-name { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.row-actions { display: flex; justify-content: flex-end; gap: 4px; }

.drop-zone { display: grid; place-items: center; min-height: 150px; padding: 24px; border: 1px dashed #aebcb6; border-radius: 6px; background: #fafcfb; color: var(--muted); text-align: center; }
.drop-zone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.drop-zone input { display: none; }
.drop-zone svg { width: 26px; height: 26px; margin-bottom: 8px; }
.drop-zone strong { color: var(--ink); }
.drop-zone p { margin: 4px 0 0; font-size: 12px; }

.pipeline-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; }
.pipeline-steps { position: relative; padding: 10px 18px; }
.pipeline-step { position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding: 14px 0; }
.pipeline-step:not(:last-child)::after { content: ""; position: absolute; left: 16px; top: 48px; bottom: -5px; width: 1px; background: var(--line); }
.step-index { width: 34px; height: 34px; display: grid; place-items: center; z-index: 1; border-radius: 50%; background: var(--surface-strong); color: var(--muted); font: 500 12px/1 "IBM Plex Mono", monospace; }
.pipeline-step h4 { margin: 1px 0 4px; font-size: 14px; }
.pipeline-step p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.side-note { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.side-note h4 { margin: 0 0 10px; font-size: 13px; }
.side-note ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 12px; line-height: 1.8; }

.job-header { display: flex; align-items: flex-start; gap: 14px; padding: 18px; }
.job-header .job-copy { flex: 1; min-width: 0; }
.job-header h3 { margin: 0; font-size: 17px; }
.job-header p { margin: 5px 0 0; }
.job-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; margin-top: 16px; }
.log-view { min-height: 360px; max-height: 620px; overflow: auto; margin: 0; padding: 16px; background: #111916; color: #d9e4df; font: 12px/1.7 "IBM Plex Mono", monospace; white-space: pre-wrap; word-break: break-word; }
.result-list { display: grid; }
.result-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 14px; border-bottom: 1px solid #edf1ef; }
.result-row:last-child { border-bottom: 0; }

.modal { width: min(620px, calc(100vw - 28px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 24px 70px rgba(14, 27, 22, .25); }
.modal::backdrop { background: rgba(12, 23, 19, .45); backdrop-filter: blur(2px); }
.modal-header { display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-header h3 { margin: 2px 0 0; font-size: 17px; }
.modal-header .icon-button { margin-left: auto; }
.modal-body { padding: 18px; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.parameter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox-field { display: flex; align-items: center; gap: 9px; min-height: 42px; }
.checkbox-field input { width: 17px; min-height: 17px; }
.toast-region { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 100; }
.toast { min-width: 260px; max-width: 380px; padding: 11px 13px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 5px; background: white; box-shadow: var(--shadow); }
.toast.error { border-left-color: var(--red); }
.mobile-only { display: none; }

@media (max-width: 1000px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .pipeline-layout, .job-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .auth-view { grid-template-columns: minmax(0, 1fr); overflow-x: hidden; }
  .auth-brand { min-width: 0; min-height: 220px; padding: 32px 24px; }
  .auth-brand > div:last-child { min-width: 0; max-width: calc(100% - 72px); }
  .auth-brand h1 { font-size: 22px; white-space: normal; overflow-wrap: anywhere; }
  .auth-panel { width: auto; max-width: none; margin: auto 24px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; width: 244px; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: grid; }
  .topbar { padding: 14px 16px; }
  .page-content { padding: 18px 14px 50px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .project-grid, .tool-grid { grid-template-columns: 1fr; }
  .topbar-actions .secondary-button span { display: none; }
  .data-table { min-width: 700px; }
  .panel.table-panel { overflow-x: auto; }
  .parameter-grid { grid-template-columns: 1fr; }
}
@media (max-width: 430px) {
  .metric-grid { grid-template-columns: 1fr; }
  .auth-brand { justify-content: flex-start; }
  .auth-brand { gap: 14px; }
  .brand-mark { width: 58px; height: 58px; }
}
