:root {
  color-scheme: light;
  font-family: "Inter", "Segoe UI", "Microsoft YaHei UI", sans-serif;
  font-size: 14px;
  color: #1d2924;
  background: #f3f6f3;
  --ink: #1d2924;
  --muted: #68766f;
  --line: #dfe6e1;
  --canvas: #f3f6f3;
  --paper: #ffffff;
  --forest: #1d2b25;
  --forest-soft: #283a32;
  --green: #157a65;
  --green-pale: #e5f4ee;
  --amber: #a66016;
  --amber-pale: #fff1db;
  --red: #a43c37;
  --red-pale: #fdebe8;
  --steel: #435a70;
  --steel-pale: #eaf0f5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  height: 100vh;
  overflow: hidden;
  background: var(--canvas);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid #237e6b;
  outline-offset: 2px;
}

.app-shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); height: 100vh; }
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 22px 14px 14px;
  color: #f0f5f1;
  background: var(--forest);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 1px 11px 25px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 1px solid #6ea391;
  border-radius: 8px;
  color: #d6eee3;
  font-size: 11px;
  font-weight: 700;
}
.brand-name { display: grid; gap: 2px; font-size: 14px; font-weight: 650; }
.brand-name span { color: #aabbb2; font-size: 11px; font-weight: 450; }
.navigation { display: flex; flex: 1; flex-direction: column; gap: 4px; }
.nav-label { padding: 13px 12px 6px; color: #8fa399; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.nav-label-spaced { margin-top: 17px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  color: #cbd7d0;
  background: transparent;
  text-align: left;
}
.nav-item:hover { color: #fff; background: #2a3d34; }
.nav-item.is-active { color: #fff; background: #344b40; box-shadow: inset 2px 0 #80c8a7; }
.nav-glyph { width: 19px; color: #90a69a; font-size: 9px; font-variant-numeric: tabular-nums; }
.nav-item.is-active .nav-glyph { color: #a8ddc2; }
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  margin-top: 18px;
  padding: 9px 8px;
  border-top: 1px solid #35463e;
}
.sidebar-footer > div { display: grid; flex: 1; gap: 2px; min-width: 0; }
.sidebar-footer strong { overflow: hidden; color: #dfe9e3; font-size: 11px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer span:not(.service-indicator) { color: #8fa399; font-size: 10px; }
.service-indicator { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: #839189; }
.service-indicator.is-online { background: #63c794; }
.service-indicator.is-offline { background: #db726a; }
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 5px;
  color: currentColor;
  background: transparent;
  font-size: 18px;
}
.icon-button:hover { background: #ffffff17; }

.main-area { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  min-height: 111px;
  padding: 23px 34px 21px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.eyebrow { margin-bottom: 7px; color: #748279; font-size: 9px; font-weight: 700; }
h1 { margin: 0; font-size: 21px; font-weight: 650; line-height: 1.25; }
.page-header p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 14px; }
.policy-chip { color: #53665b; font-size: 11px; }
.policy-chip::before { display: inline-block; width: 6px; height: 6px; margin: 0 7px 1px 0; border-radius: 50%; background: #d89a48; content: ""; }
.policy-chip.is-automatic::before { background: #39a47f; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.button:disabled { cursor: not-allowed; opacity: .5; }
.button-primary { color: white; background: var(--green); }
.button-primary:hover:not(:disabled) { background: #116651; }
.button-secondary { border-color: #cad6ce; color: #24352c; background: white; }
.button-secondary:hover:not(:disabled) { background: #f4f7f4; }
.button-danger { border-color: #e6bfbb; color: var(--red); background: #fff; }
.button-danger:hover:not(:disabled) { background: var(--red-pale); }
.button-quiet { color: #52645a; background: transparent; }
.button-quiet:hover:not(:disabled) { background: #edf2ee; }
.button-small { min-height: 29px; padding: 0 9px; font-size: 11px; }
.page-content { flex: 1; min-height: 0; overflow: auto; padding: 27px 34px 38px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); margin-bottom: 31px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; }
.stat { min-height: 91px; padding: 15px 18px 13px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat-label { color: var(--muted); font-size: 11px; }
.stat-value { margin-top: 8px; color: #1f3329; font-size: 25px; font-weight: 630; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-hint { margin-top: 6px; color: #829087; font-size: 10px; }
.content-section { margin-bottom: 31px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-heading h2 { margin: 0; font-size: 14px; font-weight: 650; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.section-heading > div:first-child { min-width: 0; }
.section-meta { color: var(--muted); font-size: 11px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th { height: 36px; padding: 0 13px; border-bottom: 1px solid var(--line); color: #738078; background: #f8faf8; font-size: 10px; font-weight: 600; white-space: nowrap; }
.data-table td { height: 55px; padding: 9px 13px; border-bottom: 1px solid #edf1ee; color: #425149; font-size: 11px; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #f8fbf9; }
.task-title { display: block; max-width: 420px; overflow: hidden; border: 0; padding: 0; color: #1d3027; background: transparent; font-size: 12px; font-weight: 600; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.task-title:hover { color: var(--green); }
.task-id { display: block; margin-top: 4px; color: #87928b; font-size: 9px; font-variant-numeric: tabular-nums; }
.status { display: inline-flex; align-items: center; gap: 6px; color: #526259; font-size: 10px; white-space: nowrap; }
.status::before { width: 6px; height: 6px; border-radius: 50%; background: #98a69d; content: ""; }
.status-pending_approval { color: var(--amber); }
.status-pending_approval::before { background: #dc9c42; }
.status-queued { color: var(--steel); }
.status-queued::before { background: #6f8da7; }
.status-running { color: var(--green); }
.status-running::before { background: #39a47f; }
.status-cancelling { color: var(--amber); }
.status-cancelling::before { background: #dc9c42; }
.status-ready_for_review { color: var(--green); }
.status-ready_for_review::before { background: #39a47f; }
.status-failed { color: var(--red); }
.status-failed::before { background: #d5675e; }
.status-interrupted { color: var(--amber); }
.status-interrupted::before { background: #dc9c42; }
.status-cancelled, .status-closed { color: #76827b; }
.empty-state { padding: 42px 20px; border: 1px dashed #cbd6cf; border-radius: 6px; color: var(--muted); background: #fafcfa; text-align: center; }
.empty-state strong { display: block; margin-bottom: 7px; color: #33463b; font-size: 13px; }
.empty-state p { max-width: 470px; margin: 0 auto 16px; font-size: 11px; line-height: 1.6; }
.empty-inline { padding: 21px 12px; color: var(--muted); font-size: 11px; text-align: center; }

.form-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(240px, .85fr); gap: 36px; align-items: start; }
.form-section { min-width: 0; padding: 0; }
.form-section h2 { margin: 0 0 5px; font-size: 15px; font-weight: 650; }
.form-intro { margin: 0 0 23px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.form-field { display: grid; gap: 7px; margin-bottom: 18px; }
.form-field label, .field-label { color: #33443a; font-size: 11px; font-weight: 600; }
.field-help { color: #79867e; font-size: 10px; line-height: 1.55; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #ccd8d0;
  border-radius: 5px;
  color: #26352d;
  background: #fff;
  font-size: 12px;
}
.form-field input, .form-field select { min-height: 37px; }
.form-field textarea { min-height: 194px; resize: vertical; line-height: 1.6; }
.form-field .short-textarea { min-height: 72px; }
.form-field input::placeholder, .form-field textarea::placeholder { color: #9ba69f; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.notice {
  margin: 0 0 17px;
  padding: 10px 12px;
  border-left: 3px solid #85ae98;
  color: #526258;
  background: #eaf3ed;
  font-size: 10px;
  line-height: 1.55;
}
.notice.warning { border-color: #dda95e; color: #76511f; background: #fff5e6; }
.notice.error { border-color: #d47269; color: #853b36; background: #fff0ed; }
.definition-list { margin: 0; border-top: 1px solid var(--line); }
.definition-row { display: grid; grid-template-columns: minmax(95px, .45fr) 1fr; gap: 15px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 11px; line-height: 1.55; }
.definition-row dt { color: #718077; }
.definition-row dd { margin: 0; color: #34463c; overflow-wrap: anywhere; }
.form-aside { padding-top: 3px; }
.aside-title { margin: 0 0 12px; font-size: 12px; font-weight: 650; }
.step-list { margin: 0; padding: 0; list-style: none; counter-reset: steps; }
.step-list li { position: relative; min-height: 51px; padding: 0 0 14px 31px; color: #46574d; font-size: 11px; line-height: 1.55; counter-increment: steps; }
.step-list li::before { position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid #c4d6ca; border-radius: 50%; color: #28735c; content: counter(steps); font-size: 9px; }
.step-list strong { display: block; margin-bottom: 2px; color: #2c4035; font-size: 11px; }

.ticket-toolbar { display: flex; align-items: center; gap: 5px; margin-bottom: 12px; }
.filter-button { min-height: 28px; padding: 0 10px; border: 1px solid transparent; border-radius: 4px; color: #637169; background: transparent; font-size: 10px; }
.filter-button:hover { background: #e9efeb; }
.filter-button.is-active { border-color: #d5e3da; color: #1d6e57; background: white; }
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr); gap: 18px; align-items: start; }
.ticket-detail { min-width: 0; border: 1px solid var(--line); border-radius: 6px; background: white; }
.detail-header { padding: 15px 16px 13px; border-bottom: 1px solid var(--line); }
.detail-header h2 { margin: 0 0 5px; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.detail-meta { color: var(--muted); font-size: 10px; line-height: 1.6; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.detail-body { padding: 15px 16px; }
.detail-label { margin: 0 0 6px; color: #758178; font-size: 9px; font-weight: 700; text-transform: uppercase; }
.prompt-text { max-height: 180px; overflow: auto; margin: 0; color: #37483e; font-size: 11px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-block { margin-bottom: 17px; }
.path-line { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; color: #42544a; font-family: "Cascadia Code", Consolas, monospace; font-size: 9px; line-height: 1.55; overflow-wrap: anywhere; }
.timeline { display: grid; gap: 0; margin: 4px 0 0; padding: 0; list-style: none; }
.timeline li { position: relative; padding: 0 0 14px 17px; border-left: 1px solid #dce6df; }
.timeline li:last-child { padding-bottom: 0; border-left-color: transparent; }
.timeline li::before { position: absolute; top: 3px; left: -4px; width: 7px; height: 7px; border-radius: 50%; background: #6f9b83; content: ""; }
.timeline-title { color: #34473c; font-size: 10px; font-weight: 600; }
.timeline-detail { margin-top: 3px; color: #718077; font-size: 9px; line-height: 1.5; overflow-wrap: anywhere; }
.timeline-time { margin-top: 3px; color: #99a39d; font-size: 9px; }
.answer-box { max-height: 200px; overflow: auto; padding: 10px; border: 1px solid #e0e8e3; border-radius: 4px; color: #36473d; background: #f8faf8; font-size: 10px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.table-action-cell { white-space: nowrap; }

.project-row, .source-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 15px; align-items: center; padding: 13px 14px; border-bottom: 1px solid #e8eeea; background: white; }
.project-row:last-child, .source-row:last-child { border-bottom: 0; }
.project-name { color: #26392f; font-size: 12px; font-weight: 600; }
.project-path { margin-top: 4px; color: #7a877f; font-family: "Cascadia Code", Consolas, monospace; font-size: 9px; overflow-wrap: anywhere; }
.source-main { display: flex; align-items: center; gap: 11px; min-width: 0; }
.source-mark { display: grid; place-items: center; width: 31px; height: 31px; border: 1px solid #d8e3dc; border-radius: 5px; color: #3d6a55; background: #f6faf7; font-size: 9px; font-weight: 700; }
.source-description { margin-top: 4px; color: #78847d; font-size: 10px; line-height: 1.45; }
.source-state { color: #5c7164; font-size: 10px; white-space: nowrap; }
.source-state.is-disabled { color: #929b95; }
.disabled-note { padding: 12px 14px; border-top: 1px solid var(--line); color: #76837b; background: #fafcfa; font-size: 10px; line-height: 1.55; }
.policy-form { max-width: 770px; }
.policy-group { padding: 17px 0 18px; border-top: 1px solid var(--line); }
.policy-group:last-of-type { border-bottom: 1px solid var(--line); }
.policy-group h2 { margin: 0 0 5px; font-size: 13px; }
.policy-group > p { max-width: 640px; margin: 0 0 13px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.check-row { display: flex; align-items: flex-start; gap: 9px; max-width: 600px; color: #34463b; font-size: 11px; line-height: 1.55; }
.check-row input { width: 15px; height: 15px; margin: 1px 0 0; accent-color: var(--green); }
.runtime-field { display: flex; align-items: center; gap: 8px; }
.runtime-field input { width: 100px; min-height: 35px; padding: 7px 9px; border: 1px solid #ccd8d0; border-radius: 5px; background: white; }
.runtime-field span { color: var(--muted); font-size: 10px; }
.policy-warning { max-width: 620px; margin: 14px 0 0; padding: 11px 12px; border-left: 3px solid #daa04c; color: #70501e; background: #fff5e6; font-size: 10px; line-height: 1.55; }
.saved-at { margin-left: 9px; color: #718077; font-size: 10px; }
.inline-link { border: 0; padding: 0; color: #14745e; background: transparent; font-size: 10px; text-decoration: underline; text-underline-offset: 2px; }
.toast-region { position: fixed; z-index: 5; right: 20px; bottom: 18px; display: grid; gap: 8px; pointer-events: none; }
.toast { max-width: min(420px, calc(100vw - 40px)); padding: 10px 13px; border: 1px solid #c7d9ce; border-radius: 5px; color: #23392e; background: white; box-shadow: 0 5px 20px #1d2b2518; font-size: 11px; line-height: 1.5; }
.toast.is-error { border-color: #e2b4af; color: #7d342e; }
.loading-state { padding: 50px 20px; color: #738077; text-align: center; font-size: 12px; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 205px minmax(0, 1fr); }
  .page-header { padding-right: 24px; padding-left: 24px; }
  .page-content { padding-right: 24px; padding-left: 24px; }
  .form-layout { grid-template-columns: minmax(0, 1.25fr) minmax(215px, .75fr); gap: 24px; }
  .ticket-layout { grid-template-columns: minmax(0, 1fr); }
  .ticket-detail { max-width: none; }
}

@media (max-width: 700px) {
  body { height: 100dvh; }
  .app-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); height: 100dvh; }
  .sidebar { display: block; padding: 10px 12px 8px; }
  .brand { padding: 0 2px 9px; }
  .brand-mark { width: 30px; height: 30px; flex-basis: 30px; }
  .brand-name { display: flex; align-items: baseline; gap: 6px; font-size: 12px; }
  .brand-name span { font-size: 10px; }
  .navigation { flex-direction: row; gap: 3px; overflow-x: auto; padding-bottom: 2px; }
  .nav-label { display: none; }
  .nav-item { flex: 0 0 auto; width: auto; min-height: 34px; gap: 6px; padding: 0 9px; font-size: 10px; }
  .nav-glyph { display: none; }
  .sidebar-footer { display: none; }
  .main-area { min-height: 0; }
  .page-header { min-height: 83px; padding: 15px 16px; gap: 12px; }
  .eyebrow { margin-bottom: 5px; font-size: 8px; }
  h1 { font-size: 18px; }
  .page-header p { max-width: 54vw; font-size: 10px; line-height: 1.4; }
  .header-actions { gap: 7px; }
  .policy-chip { display: none; }
  .button { min-height: 32px; padding: 0 10px; font-size: 10px; }
  .page-content { padding: 18px 14px 27px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 24px; }
  .stat { min-height: 75px; padding: 12px; border-bottom: 1px solid var(--line); }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(3), .stat:nth-child(4) { border-bottom: 0; }
  .stat-value { font-size: 21px; }
  .form-layout { grid-template-columns: minmax(0, 1fr); gap: 23px; }
  .form-aside { padding-top: 17px; border-top: 1px solid var(--line); }
  .form-field textarea { min-height: 165px; }
  .table-wrap { border-radius: 5px; }
  .data-table { min-width: 610px; }
  .project-row, .source-row { grid-template-columns: minmax(0, 1fr) auto; padding: 11px; }
  .section-heading { align-items: flex-start; }
  .definition-row { grid-template-columns: 90px minmax(0, 1fr); }
  .task-title { max-width: 230px; }
}
