:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #202632;
  --muted: #637083;
  --line: #d9e0ea;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #0f8a5f;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(31, 41, 55, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "Segoe UI", Arial, sans-serif;
  font-size: 15px;
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  background: #152033;
  color: #f8fafc;
  padding: 24px 18px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #f5b84b;
  color: #111827;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.brand p,
.tool-item span,
.eyebrow {
  margin: 0;
  color: #9fb0c8;
  font-size: 13px;
}

.tool-list {
  display: grid;
  gap: 10px;
}

.tool-item {
  width: 100%;
  min-height: 68px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
  text-align: left;
  padding: 12px;
}

.tool-item strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

.tool-item.active {
  border-color: #f5b84b;
  background: rgba(245, 184, 75, 0.16);
}

.tool-item.disabled {
  opacity: 0.55;
}

.workspace {
  padding: 28px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

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

.page-header h2 {
  margin: 4px 0 0;
  font-size: 26px;
  line-height: 1.2;
}

.state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  padding: 8px 12px;
}

.state.ready {
  color: var(--success);
}

.state.error {
  color: var(--danger);
}

.panel,
.log-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

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

.full {
  grid-column: 1 / -1;
}

label,
legend {
  color: #344054;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 9px 11px;
}

input:focus,
select:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(37, 99, 235, 0.14);
}

.path-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.path-row.three {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.output-box {
  display: grid;
  gap: 12px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.rule-maintenance {
  display: grid;
  gap: 14px;
}

.rule-section {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.rule-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.rule-section h3 {
  margin: 0;
  font-size: 15px;
}

.rule-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.34fr) minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}

.rule-actions {
  display: flex;
  justify-content: flex-end;
}

.path-row.compact {
  gap: 8px;
}

.radio-line {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 500;
}

.radio-line input {
  width: 16px;
  min-height: 16px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 9px 14px;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.secondary {
  border-color: var(--line);
  background: #fff;
  color: #27364a;
}

.secondary:hover:not(:disabled) {
  background: #f8fafc;
}

.small {
  min-height: 36px;
  padding: 8px 12px;
  white-space: nowrap;
}

.compact-button {
  min-height: 36px;
  padding: 7px 12px;
  white-space: nowrap;
}

.hidden {
  display: none;
}

.log-panel {
  margin-top: 18px;
  overflow: hidden;
}

.log-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
}

.log-header h3 {
  margin: 0;
  font-size: 16px;
}

.log-header span {
  color: var(--muted);
}


.job-summary {
  margin: 14px 16px;
  padding: 14px 16px;
  border: 1px solid #cbd5e1;
  border-left-width: 4px;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
}

.job-summary.hidden {
  display: none;
}

.job-summary.running {
  border-left-color: var(--primary);
  background: #f8fbff;
}

.job-summary.success {
  border-left-color: var(--success);
  background: #f7fdf9;
}

.job-summary.warning {
  border-left-color: #d97706;
  background: #fffaf0;
}

.job-summary.error {
  border-left-color: var(--danger);
  background: #fff7f7;
}

.summary-title {
  font-weight: 700;
  line-height: 1.5;
}

.summary-list,
.summary-action-list {
  margin: 8px 0 0;
  padding-left: 20px;
}

.summary-list li,
.summary-action-list li {
  margin: 4px 0;
  line-height: 1.55;
}

.summary-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.summary-actions {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(100, 116, 139, 0.25);
}

.summary-action-title {
  font-weight: 700;
  font-size: 13px;
}

pre {
  min-height: 210px;
  max-height: 360px;
  margin: 0;
  overflow: auto;
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px 18px;
  white-space: pre-wrap;
  word-break: break-word;
}

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.28);
}

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

.dialog-head h3 {
  margin: 0;
  font-size: 18px;
}

.path-picker-form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.picker-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 36px;
  align-items: center;
}

.picker-crumb {
  min-height: 32px;
  border-color: var(--line);
  background: #f8fafc;
  color: #344054;
  padding: 5px 9px;
  font-weight: 600;
}

.picker-list {
  display: grid;
  gap: 6px;
  min-height: 260px;
  max-height: min(54vh, 460px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.picker-empty,
.picker-status {
  color: var(--muted);
}

.picker-empty {
  padding: 18px 10px;
  text-align: center;
}

.picker-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #fff;
}

.picker-row.selected {
  border-color: #93b4ff;
  background: #f7faff;
}

.picker-main {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
  min-height: 50px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 8px;
  text-align: left;
}

.picker-main:hover,
.picker-select:hover {
  background: #f8fafc;
}

.picker-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 7px;
  background: #e8eef8;
  color: #27364a;
  font-size: 12px;
  font-weight: 800;
}

.picker-icon.file {
  background: #eef8ef;
  color: #116149;
}

.picker-name {
  min-width: 0;
}

.picker-name strong,
.picker-name span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-name span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.picker-select {
  min-height: 36px;
  margin-right: 8px;
  padding: 7px 12px;
}

.picker-status {
  min-height: 20px;
  font-size: 13px;
}

.picker-actions {
  flex-wrap: wrap;
}

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

  .sidebar {
    padding: 18px;
  }

  .tool-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workspace {
    padding: 20px;
  }
}

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

  .path-row,
  .rule-grid,
  .tool-list {
    grid-template-columns: 1fr;
  }

  .page-header,
  .actions,
  .header-actions,
  .dialog-head {
    align-items: stretch;
    flex-direction: column;
  }

  .picker-row,
  .picker-actions {
    grid-template-columns: 1fr;
  }

  .picker-select {
    margin: 0 8px 8px;
  }
}
