:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --text: #1f2937;
  --heading: #111827;
  --muted: #667085;
  --line: #d9e1ec;
  --line-soft: #edf1f5;
  --primary: #1677ff;
  --primary-dark: #0958d9;
  --primary-soft: #e8f3ff;
  --green: #16a34a;
  --green-soft: #eaf7ef;
  --red: #d92d20;
  --red-soft: #fff1f0;
  --orange: #b86e00;
  --orange-soft: #fff7e6;
  --shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1280px;
  color: var(--text);
  background: var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

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

.app-header,
.trend-header {
  display: flex;
  align-items: center;
  min-height: 58px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}

.app-header h1,
.trend-header h1 {
  margin: 0;
  color: var(--heading);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
}

.app-header h1::before,
.trend-header h1::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 18px;
  margin-right: 10px;
  vertical-align: -3px;
  border-radius: 2px;
  background: var(--primary);
}

.app-shell,
.trend-shell {
  padding: 16px;
}

.period-bar,
.table-section,
.chart-card,
.trend-topbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.period-bar,
.trend-topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
}

.period-bar label {
  margin-right: 8px;
  color: var(--heading);
  font-size: 14px;
  font-weight: 600;
}

.period-bar select {
  min-width: 300px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid #c9d3e2;
  border-radius: 4px;
  background: #fff;
  color: var(--text);
}

.period-status,
.trend-status {
  flex: 1;
  color: var(--muted);
  font-size: 13px;
}

.trend-period-bar { flex-wrap: wrap; }
.trend-search { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: 8px; }
.trend-search input { min-width: 180px; flex: 1; height: 34px; padding: 0 10px; border: 1px solid #c9d3e2; border-radius: 4px; }
.trend-period-bar .period-status { order: 1; flex-basis: 100%; }
.record-source { display: block; margin-top: 4px; font-size: 12px; font-weight: 400; line-height: 1.4; color: #52627a; white-space: normal; }

.primary-btn,
.back-link,
.chart-btn,
.detail-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.primary-btn {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
}

.primary-btn:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

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

.back-link {
  height: 34px;
  padding: 0 12px;
  border: 1px solid #c9d3e2;
  background: #fff;
  color: var(--text);
}

.back-link:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.chart-btn {
  height: 28px;
  padding: 0 6px;
  border: 1px solid #b7d4ff;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  white-space: nowrap;
}

.chart-btn:hover {
  border-color: var(--primary);
  background: #dcecff;
}

.detail-btn {
  height: 26px;
  padding: 0 8px;
  border: 1px solid #d0d7e2;
  background: #fff;
  color: #344054;
  font-size: 12px;
}

.detail-btn:hover {
  color: var(--primary-dark);
  border-color: #9ec5ff;
  background: #f3f8ff;
}

.app-header-secure {
  align-items: flex-start;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 14px 20px;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.user-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}

.text-link,
.text-button {
  color: var(--primary-dark);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
}

.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.text-link:hover,
.text-button:hover {
  color: var(--primary);
}

.security-tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border: 1px solid #f6c28b;
  border-radius: 4px;
  background: #fff7ed;
  color: #9a5300;
  font-size: 12px;
  font-weight: 700;
}

.scope-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.security-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #f4d4b0;
  border-left: 4px solid #d97706;
  border-radius: 6px;
  background: #fff8ef;
}

.security-notice p {
  margin: 0;
  color: #475467;
  font-size: 12px;
  line-height: 1.65;
}

.notice-label {
  flex: 0 0 auto;
  margin-top: 1px;
  padding: 2px 7px;
  border-radius: 4px;
  background: #fff;
  color: #9a5300;
  font-size: 12px;
  font-weight: 700;
}

.table-section {
  margin-top: 14px;
  overflow: hidden;
}

.section-head,
.chart-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.section-head h2,
.chart-card-head h2 {
  margin: 0;
  color: var(--heading);
  font-size: 16px;
  font-weight: 700;
}

.section-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.summary-cards {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.summary-card-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}

.summary-card {
  min-height: 54px;
  padding: 9px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--surface-2);
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-card strong {
  display: block;
  margin-top: 4px;
  color: var(--heading);
  font-size: 18px;
  line-height: 1.2;
}

.summary-line {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.view-toolbar-main,
.view-toggle {
  display: flex;
  align-items: center;
}

.view-toolbar-main {
  min-width: 0;
  gap: 10px;
}

.view-toggle {
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid #b9c7d8;
  border-radius: 5px;
  background: #fff;
}

.view-toolbar-label {
  color: var(--heading);
  font-size: 12px;
  font-weight: 700;
}

.view-toggle-btn {
  min-width: 80px;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-right: 1px solid #d6deea;
  background: #fff;
  color: #475467;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.view-toggle-btn:last-child {
  border-right: 0;
}

.view-toggle-btn.is-active {
  background: var(--primary);
  color: #fff;
}

.view-mode-hint,
.scroll-tip {
  color: var(--muted);
  font-size: 12px;
}

.scroll-tip {
  flex: 0 0 auto;
}

.table-wrap {
  max-height: calc(100vh - 470px);
  overflow: auto;
}

#keywordTable {
  min-width: 1760px;
}

#keywordTable.view-mode-work {
  min-width: 1180px;
}

#keywordTable.view-mode-work .secondary-column {
  display: none;
}

.table-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.pager-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pager-actions select,
.pager-actions button {
  height: 30px;
  border: 1px solid #c9d3e2;
  border-radius: 4px;
  background: #fff;
  color: var(--heading);
  font: inherit;
}

.pager-actions select {
  padding: 0 24px 0 8px;
}

.pager-actions button {
  min-width: 64px;
  padding: 0 10px;
  cursor: pointer;
}

.pager-actions button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.pager-actions button:disabled {
  color: #98a2b3;
  background: var(--surface-3);
  cursor: not-allowed;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

th,
td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 3;
  color: #344054;
  background: #f2f5f9;
  border-bottom: 1px solid #cfd8e5;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

th:not([data-sort]) {
  cursor: default;
}

th.sort-asc::after {
  content: " ↑";
  color: var(--primary);
}

th.sort-desc::after {
  content: " ↓";
  color: var(--primary);
}

tbody tr {
  background: #fff;
}

tbody tr:nth-child(even) {
  background: #fbfcfe;
}

tbody tr:hover {
  background: #f3f8ff;
}

tbody tr.is-disabled {
  color: #8a94a6;
  background: #f7f8fa;
}

.empty-cell {
  height: 110px;
  text-align: center;
  color: var(--muted);
}

.table-state::before {
  display: block;
  margin-bottom: 6px;
  color: var(--primary);
  font-weight: 700;
}

.table-state-loading::before {
  content: "数据读取中";
}

.table-state-empty::before {
  content: "暂无数据";
  color: var(--muted);
}

.table-state-error::before {
  content: "读取失败";
  color: var(--red);
}

#keywordTable .sticky-sequence,
#keywordTable .sticky-keyword {
  position: sticky;
}

#keywordTable .sticky-sequence {
  left: 0;
  width: 86px;
  min-width: 86px;
  max-width: 86px;
}

#keywordTable .sticky-keyword {
  left: 86px;
  width: 180px;
  min-width: 180px;
  max-width: 180px;
  overflow: hidden;
  border-right: 1px solid var(--line);
  text-overflow: ellipsis;
}

#keywordTable th.sticky-sequence,
#keywordTable th.sticky-keyword {
  z-index: 6;
  background: #f2f5f9;
}

#keywordTable td.sticky-sequence,
#keywordTable td.sticky-keyword {
  z-index: 2;
  background: #fff;
}

#keywordTable tbody tr:nth-child(even) td.sticky-sequence,
#keywordTable tbody tr:nth-child(even) td.sticky-keyword {
  background: #fbfcfe;
}

#keywordTable tbody tr:hover td.sticky-sequence,
#keywordTable tbody tr:hover td.sticky-keyword {
  background: #f3f8ff;
}

#keywordTable tbody tr.is-disabled td.sticky-sequence,
#keywordTable tbody tr.is-disabled td.sticky-keyword {
  background: #f7f8fa;
}

.keyword-cell {
  color: var(--heading);
  font-weight: 600;
}

.sequence-cell {
  min-width: 76px;
}

.sequence-check {
  gap: 7px;
}

.sequence-number {
  min-width: 34px;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
}

.index-cell {
  min-width: 74px;
  text-align: right;
}

.commerce-cell {
  min-width: 88px;
  text-align: right;
}

.chart-cell {
  width: 52px;
  text-align: center;
}

.num,
.date-main {
  font-variant-numeric: tabular-nums;
}

.strong-num,
.date-main {
  color: var(--heading);
  font-weight: 700;
}

.distance-now,
.remaining-good {
  color: #0f6b3c;
  background: var(--green-soft);
  border-radius: 4px;
}

.distance-near {
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-radius: 4px;
}

.distance-warm,
.remaining-warn {
  color: #8a4b00;
  background: var(--orange-soft);
  border-radius: 4px;
}

.distance-watch {
  color: #475467;
  background: #eef2f7;
  border-radius: 4px;
}

.distance-far {
  color: #667085;
}

.remaining-danger {
  color: #b42318;
  background: var(--red-soft);
  border-radius: 4px;
}

.remaining-ended {
  color: #667085;
  background: var(--surface-3);
  border-radius: 4px;
}

.date-main {
  min-width: 116px;
}

.explain-cell {
  max-width: 260px;
  min-width: 220px;
  color: #475467;
  line-height: 1.45;
  white-space: normal;
}

.sub {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.value-sub {
  color: #667085;
}

.status-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: #14532d;
  font-weight: 600;
}

.status-check.compact {
  justify-content: center;
  width: 28px;
}

.status-check input {
  width: 15px;
  height: 15px;
  accent-color: var(--green);
}

.note-input {
  width: 112px;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid #c9d3e2;
  border-radius: 4px;
  resize: vertical;
  background: #fff;
}

.manual-meta {
  max-width: 124px;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-input:focus,
.period-bar select:focus {
  outline: 2px solid rgba(22, 119, 255, 0.14);
  border-color: var(--primary);
}

.level {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.phase,
.heat,
.direction,
.valley,
.action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
}

.priority {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 24px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 800;
}

.priority-s {
  color: #b42318;
  background: var(--red-soft);
}

.priority-a {
  color: #8a4b00;
  background: var(--orange-soft);
}

.priority-b {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.priority-c {
  color: #0f6b3c;
  background: var(--green-soft);
}

.priority-d,
.priority-- {
  color: #667085;
  background: var(--surface-3);
}

.phase-active {
  color: #0f6b3c;
  background: var(--green-soft);
}

.phase-early-end,
.phase-ended,
.phase-after-peak {
  color: #8a4b00;
  background: var(--orange-soft);
}

.phase-near {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.phase-warm {
  color: #8a4b00;
  background: var(--orange-soft);
}

.phase-watch,
.phase-far,
.phase-empty,
.heat-normal,
.heat-empty {
  color: #667085;
  background: var(--surface-3);
}

.heat-hot {
  color: #b42318;
  background: var(--red-soft);
}

.heat-warm {
  color: #8a4b00;
  background: var(--orange-soft);
}

.heat-rise {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.heat-cold {
  color: #475467;
  background: #eef2f7;
}

.heat-deep-cold {
  color: #667085;
  background: #e5e7eb;
}

.direction-up {
  color: #0f6b3c;
  background: var(--green-soft);
}

.direction-flat {
  color: #667085;
  background: var(--surface-3);
}

.direction-down {
  color: #8a4b00;
  background: var(--orange-soft);
}

.valley-active {
  color: #475467;
  background: #eef2f7;
}

.valley-recent,
.action-warm {
  color: #0f6b3c;
  background: var(--green-soft);
}

.valley-future {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.valley-past {
  color: #8a4b00;
  background: var(--orange-soft);
}

.valley-old,
.valley-empty {
  color: #667085;
  background: var(--surface-3);
}

.action-strong {
  color: #b42318;
  background: var(--red-soft);
}

.action-follow {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.action-tail {
  color: #8a4b00;
  background: var(--orange-soft);
}

.action-watch {
  color: #0f6b3c;
  background: var(--green-soft);
}

.action-pause,
.action-skip,
.action-empty {
  color: #667085;
  background: var(--surface-3);
}

.action-warn {
  color: #8a4b00;
  background: var(--orange-soft);
}

.level-strong {
  color: #0f6b3c;
  background: var(--green-soft);
}

.level-medium {
  color: #8a4b00;
  background: var(--orange-soft);
}

.level-weak,
.level-empty {
  color: #667085;
  background: var(--surface-3);
}

.error {
  color: var(--red);
  font-weight: 700;
}

.detail-row td {
  padding: 0;
  background: #fff;
}

.detail-row:hover td {
  background: #fff;
}

.detail-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 10px 14px;
  padding: 12px 16px 14px 58px;
  border-bottom: 1px solid var(--line-soft);
  background: #fbfcfe;
}

.detail-item {
  min-width: 0;
}

.detail-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
}

.detail-item strong {
  display: block;
  color: var(--heading);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
  white-space: normal;
}

.trend-title-block {
  flex: 1;
  min-width: 0;
}

.trend-title-block h2 {
  margin: 0 0 4px;
  color: var(--heading);
  font-size: 18px;
  font-weight: 700;
}

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

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

.chart-card {
  overflow: hidden;
  min-height: 410px;
}

.chart-card-head {
  background: var(--surface);
}

.chart-card-head h2::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 8px;
  vertical-align: 2px;
  border-radius: 50%;
  background: var(--primary);
}

.chart {
  width: 100%;
  height: 356px;
}

.auth-page {
  min-width: 0;
  min-height: 100vh;
  background: #eef3f9;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  padding: 32px 18px;
  place-items: center;
}

.auth-card {
  width: min(440px, 100%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.1);
}

.auth-heading {
  padding: 28px 30px 22px;
  border-bottom: 1px solid var(--line-soft);
}

.auth-heading h1 {
  margin: 14px 0 8px;
  color: var(--heading);
  font-size: 24px;
}

.auth-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.auth-form {
  display: grid;
  gap: 16px;
  padding: 24px 30px 30px;
}

.auth-form label,
.inline-form label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 600;
}

.auth-form input,
.inline-form input,
.inline-form select {
  height: 38px;
  padding: 0 10px;
  border: 1px solid #c9d3e2;
  border-radius: 4px;
  background: #fff;
  color: var(--heading);
}

.auth-submit {
  width: 100%;
  height: 40px;
  margin-top: 2px;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.admin-shell {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.admin-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.workflow-page {
  min-width: 0;
}

.workflow-page .trend-header {
  gap: 18px;
}

.workflow-page .user-tools {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.workflow-current-nav {
  color: var(--heading);
  font-weight: 800;
  cursor: default;
}

.workflow-shell {
  width: min(1180px, calc(100% - 32px));
  max-width: 1180px;
  margin-inline: auto;
}

.workflow-dispatch-form {
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) minmax(8rem, 0.5fr) minmax(10rem, 0.6fr);
  gap: 1rem;
  align-items: end;
}

.workflow-dispatch-form label {
  display: grid;
  gap: 0.4rem;
}

.workflow-dispatch-title,
.workflow-dispatch-description {
  grid-column: 1 / -1;
}

.workflow-dispatch-form textarea {
  resize: vertical;
}

@media (max-width: 800px) {
  .workflow-dispatch-form {
    grid-template-columns: 1fr;
  }

  .workflow-dispatch-title,
  .workflow-dispatch-description {
    grid-column: auto;
  }
}

.workflow-shell .admin-card {
  padding: 16px;
}

.workflow-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.workflow-toolbar h2,
.workflow-task-head h3 {
  margin: 0 0 6px;
}

.workflow-toolbar p,
.workflow-description,
.workflow-task-meta {
  margin: 0;
  color: #5f6b7a;
}

.workflow-task-list {
  display: grid;
  gap: 14px;
  min-height: 150px;
}

.workflow-task-card {
  border: 1px solid #dfe5ec;
  border-radius: 10px;
  padding: 18px;
  background: #fff;
  box-shadow: 0 5px 18px rgba(36, 51, 70, 0.06);
}

.workflow-task-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.workflow-description {
  margin-top: 12px;
  color: #25313c;
  white-space: pre-wrap;
}

.workflow-task-meta {
  margin-top: 8px;
  font-size: 13px;
}

.workflow-task-version {
  padding-top: 10px;
  border-top: 1px solid #edf0f4;
}

.workflow-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.workflow-fact {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f6f8fb;
}

.workflow-fact-label,
.workflow-fact-value {
  display: block;
}

.workflow-fact-label {
  margin-bottom: 4px;
  color: #687587;
  font-size: 12px;
}

.workflow-fact-value {
  overflow-wrap: anywhere;
  color: #25313c;
}

.workflow-priority-high .workflow-fact-value { color: #a34700; }
.workflow-priority-urgent .workflow-fact-value,
.workflow-overdue .workflow-fact-value { color: #b42318; }

.workflow-status {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 10px;
  font-weight: 700;
  background: #eef2f6;
}

.workflow-status-pending { background: #eef2f6; color: #44546a; }
.workflow-status-in_progress { background: #e8f1ff; color: #1f61b6; }
.workflow-status-blocked { background: #fff0e6; color: #a34700; }
.workflow-status-completed { background: #e8f7ee; color: #18763a; }

.workflow-actions {
  display: grid;
  grid-template-columns: minmax(130px, 180px) minmax(240px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}

.workflow-actions input,
.workflow-actions select {
  min-height: 40px;
  border: 1px solid #cfd7e2;
  border-radius: 6px;
  padding: 0 10px;
}

.workflow-locked,
.workflow-empty {
  color: #687587;
}

.workflow-action-message {
  min-height: 20px;
  margin-top: 8px;
}

.workflow-action-message.success {
  color: #18763a;
}

.workflow-state-panel {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 36px 18px;
  border: 1px dashed #cfd7e2;
  border-radius: 10px;
  color: #526174;
  text-align: center;
  background: #fafbfd;
}

.workflow-state-panel p {
  margin: 0;
}

.workflow-state-error {
  border-color: #efb2ad;
  background: #fff7f6;
}

.workflow-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #dce6f4;
  border-top-color: #2f6edb;
  border-radius: 50%;
  animation: workflow-spin 0.8s linear infinite;
}

@keyframes workflow-spin {
  to { transform: rotate(360deg); }
}

.workflow-timeline {
  margin: 16px 0 0;
  padding: 14px 16px;
  border-radius: 8px;
  background: #f6f8fb;
  color: #405064;
}

.workflow-timeline h4 {
  margin: 0 0 10px;
  color: #25313c;
}

.workflow-timeline-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
}

@media (max-width: 820px) {
  .workflow-page .trend-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .workflow-page .user-tools {
    justify-content: flex-start;
  }

  .workflow-shell {
    width: min(100% - 20px, 1180px);
  }

  .workflow-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workflow-actions {
    grid-template-columns: 1fr;
  }

  .workflow-task-head {
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .workflow-facts {
    grid-template-columns: 1fr;
  }
}

.inline-form {
  display: flex;
  align-items: end;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.inline-form label {
  min-width: 190px;
}

.inline-form label:nth-child(3) {
  min-width: 130px;
}

.inline-form .primary-btn {
  flex: 0 0 auto;
  margin-bottom: 1px;
}

.admin-table-wrap {
  overflow: auto;
}

.audit-table-wrap {
  max-height: 520px;
}

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

.admin-actions button,
.secondary-btn {
  height: 30px;
  padding: 0 10px;
  border: 1px solid #c9d3e2;
  border-radius: 4px;
  background: #fff;
  color: #344054;
  cursor: pointer;
}

.admin-actions button:hover,
.secondary-btn:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.audit-detail {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-controls,
.calendar-info {
  display: flex;
  align-items: end;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.calendar-controls label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--heading);
  font-size: 12px;
  font-weight: 700;
}

.calendar-controls select,
.calendar-controls input {
  height: 34px;
  padding: 0 10px;
  border: 1px solid #c9d3e2;
  border-radius: 4px;
  background: #fff;
  color: var(--text);
}

.calendar-controls select {
  min-width: 250px;
}

.calendar-controls input {
  min-width: 220px;
}

.calendar-controls select:focus,
.calendar-controls input:focus {
  outline: 2px solid rgba(22, 119, 255, 0.14);
  border-color: var(--primary);
}

.calendar-info {
  align-items: center;
  margin-top: 10px;
  box-shadow: none;
}

.heat-legend {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.legend-gradient {
  display: inline-block;
  width: 150px;
  height: 14px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 999px;
  background: linear-gradient(90deg, #16a34a 0%, #facc15 50%, #dc2626 100%);
}

.stable-swatch {
  display: inline-block;
  width: 18px;
  height: 14px;
  margin-left: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  background: #e5e7eb;
}

.calendar-table-section {
  margin-top: 10px;
}

.calendar-table-wrap {
  max-height: calc(100vh - 430px);
}

.category-calendar-table {
  min-width: 1900px;
}

.category-calendar-table th,
.category-calendar-table td {
  text-align: center;
}

.category-calendar-table th:nth-child(2),
.category-calendar-table td:nth-child(2) {
  text-align: left;
}

.category-calendar-table > thead > tr > th:first-child,
.category-calendar-table > tbody > tr.category-row > td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 70px;
  min-width: 70px;
  background: inherit;
}

.category-calendar-table > thead > tr > th:nth-child(2),
.category-calendar-table > tbody > tr.category-row > td:nth-child(2) {
  position: sticky;
  left: 70px;
  z-index: 2;
  width: 230px;
  min-width: 230px;
  border-right: 1px solid var(--line);
  background: inherit;
}

.category-calendar-table > thead > tr > th:first-child,
.category-calendar-table > thead > tr > th:nth-child(2) {
  z-index: 5;
  background: #f2f5f9;
}

.category-name-cell .sub {
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.heatmap-cell {
  min-width: 58px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.category-calendar-table .calendar-volume-value {
  min-width: 108px;
  font-weight: 700;
  color: #344054;
  font-variant-numeric: tabular-nums;
}

.selected-month-header {
  color: #fff;
  background: var(--primary-dark);
}

.selected-month-cell {
  box-shadow: inset 0 0 0 3px #1677ff;
}

.calendar-pattern {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.pattern-stable {
  color: #475467;
  background: #e5e7eb;
}

.pattern-sustained {
  color: #9f1239;
  background: #ffe4e6;
}

.pattern-multiple {
  color: #9a5300;
  background: #fff7e6;
}

.pattern-single {
  color: #0958d9;
  background: #e8f3ff;
}

.category-detail-row > td {
  padding: 0;
  background: #eef5ff;
  white-space: normal;
}

.category-detail-panel {
  padding: 14px 16px 16px;
  border-top: 1px solid #bfdbfe;
  border-bottom: 1px solid #bfdbfe;
}

.category-detail-title {
  margin-bottom: 10px;
  color: var(--heading);
  font-size: 13px;
  font-weight: 700;
}

.category-detail-loading {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.keyword-calendar-wrap {
  max-height: 430px;
  overflow: auto;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
}

.keyword-calendar-table {
  min-width: 1350px;
}

.keyword-calendar-table th,
.keyword-calendar-table td {
  text-align: center;
}

.keyword-calendar-table th:first-child,
.keyword-calendar-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 190px;
  text-align: left;
  background: inherit;
}

.keyword-calendar-table th:first-child {
  z-index: 4;
  background: #f2f5f9;
}

@media (max-width: 1300px) {
  body:not(.keyword-dashboard-page) {
    min-width: 1100px;
  }
}

.keyword-dashboard-page {
  min-width: 0;
}

@media (max-width: 900px) {
  .keyword-dashboard-page .app-header-secure {
    padding: 12px;
  }

  .keyword-dashboard-page .title-row,
  .keyword-dashboard-page .period-bar,
  .keyword-dashboard-page .view-toolbar,
  .keyword-dashboard-page .table-pager {
    align-items: flex-start;
    flex-direction: column;
  }

  .keyword-dashboard-page .user-tools {
    flex-wrap: wrap;
    margin-left: 0;
  }

  .keyword-dashboard-page .app-shell {
    padding: 10px;
  }

  .keyword-dashboard-page .period-bar {
    gap: 10px;
  }

  .keyword-dashboard-page .period-bar > div:first-child,
  .keyword-dashboard-page .period-bar select,
  .keyword-dashboard-page .period-bar .primary-btn,
  .keyword-dashboard-page .view-toolbar-main {
    width: 100%;
  }

  .keyword-dashboard-page .summary-card-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .keyword-dashboard-page .view-toolbar-main {
    flex-wrap: wrap;
  }

  .keyword-dashboard-page .scroll-tip {
    white-space: normal;
  }

  .keyword-dashboard-page .table-wrap {
    max-height: calc(100vh - 520px);
    min-height: 340px;
  }

  .keyword-dashboard-page .table-pager {
    gap: 8px;
  }
}

@media (max-width: 560px) {
  .keyword-dashboard-page .security-notice {
    flex-direction: column;
  }

  .keyword-dashboard-page .summary-card-row {
    grid-template-columns: 1fr;
  }

  .keyword-dashboard-page .view-mode-hint {
    width: 100%;
  }

  .keyword-dashboard-page .pager-actions {
    flex-wrap: wrap;
  }
}
