:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #1d1f23;
  --muted: #69717c;
  --line: #d8dce2;
  --line-strong: #b8bec7;
  --brand: #f2a313;
  --brand-ink: #7a4d00;
  --critical: #b42318;
  --critical-soft: #fff0ee;
  --acquisition: #177245;
  --distribution: #1e5ea9;
  --trading: #a04c00;
  --management: #66508f;
  --event: #8a6200;
  --system: #3b6570;
  --success: #277248;
  --warning: #9b6500;
  --shadow: 0 14px 40px rgba(28, 32, 39, 0.15);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

[hidden] { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f4f5f7;
}

.login-panel {
  width: min(420px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--brand);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-logo {
  width: 64px;
  height: 64px;
  margin-bottom: 18px;
  object-fit: contain;
}

.login-panel h1 { margin: 5px 0 10px; font-size: 26px; }
.login-panel p { margin: 0 0 22px; color: var(--muted); line-height: 1.65; }

.primary-command,
.secondary-command,
.primary-inline-command {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 4px;
  font-weight: 700;
}

.primary-command {
  width: 100%;
  border: 1px solid #d58a00;
  background: var(--brand);
  color: #231600;
}

.secondary-command {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.primary-inline-command {
  border: 1px solid #d58a00;
  background: var(--brand);
  color: #231600;
}

.dev-login {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.dev-login label { grid-column: 1 / -1; color: var(--muted); font-size: 12px; font-weight: 700; }
.dev-login select { min-height: 42px; border: 1px solid var(--line); background: var(--surface); padding: 0 10px; }
.login-status { min-height: 20px; margin-top: 12px; color: var(--critical); font-size: 12px; }

button,
input,
select,
textarea { font: inherit; letter-spacing: 0; }

button,
select { cursor: pointer; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(242, 163, 19, 0.28);
  outline-offset: 2px;
}

.app-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 86px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand-block,
.topbar-actions,
.week-picker,
.toolbar,
.filters,
.item-meta,
.dialog-tags,
.decision-row { display: flex; align-items: center; }

.brand-block { gap: 13px; min-width: 0; }

.brand-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  flex: 0 0 auto;
}

.eyebrow,
.week-label,
.dialog-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 2px 0 0;
  font-size: 22px;
  line-height: 1.2;
}

.topbar-actions { gap: 10px; }
.user-menu { display: flex; align-items: center; gap: 8px; }
.user-menu > span { max-width: 140px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.week-picker {
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.week-picker span {
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.week-picker select,
.filters select {
  min-height: 38px;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 0 32px 0 10px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.icon-button:hover { background: var(--surface-2); }

.summary-band {
  padding: 24px 28px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

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

.week-heading p {
  max-width: 900px;
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.source-line {
  max-width: 420px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: right;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border: 1px solid var(--line);
}

.metric {
  min-width: 0;
  padding: 13px 15px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.metric:last-child { border-right: 0; }

.metric strong {
  display: block;
  margin-bottom: 5px;
  font-size: 24px;
  line-height: 1;
}

.metric span { color: var(--muted); font-size: 12px; }
.metric.is-alert strong { color: var(--critical); }

.view-tabs {
  display: flex;
  gap: 0;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.view-tab {
  min-height: 48px;
  padding: 0 17px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.view-tab:hover { color: var(--text); }

.view-tab.is-active {
  border-bottom-color: var(--brand);
  color: var(--text);
  font-weight: 700;
}

.view-tab span {
  display: inline-block;
  min-width: 20px;
  margin-left: 4px;
  color: var(--muted);
  font-size: 12px;
}

.view-tab[data-view="missing"] span:not(:empty) { color: var(--critical); }

.toolbar {
  justify-content: space-between;
  gap: 14px;
  padding: 16px 28px;
}

.search-field {
  display: flex;
  align-items: center;
  flex: 1 1 420px;
  max-width: 620px;
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.search-field span {
  padding-left: 12px;
  color: var(--muted);
  font-size: 20px;
}

.search-field input {
  width: 100%;
  min-height: 38px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0 12px 0 8px;
}

.search-field input:focus { outline: 0; }
.filters { gap: 8px; flex: 0 0 auto; }

.filters select {
  min-height: 40px;
  border: 1px solid var(--line);
}

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
  padding: 0 28px 32px;
}

.lane {
  min-width: 0;
  border-top: 3px solid var(--line-strong);
}

.lane[data-tone="critical"] { border-top-color: var(--critical); }
.lane[data-tone="action"] { border-top-color: var(--distribution); }
.lane[data-tone="waiting"] { border-top-color: var(--event); }
.lane[data-tone="done"] { border-top-color: var(--success); }
.lane[data-tone="hold"] { border-top-color: var(--warning); }

.lane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
  padding: 9px 3px 7px;
}

.lane-header h2 {
  margin: 0;
  font-size: 16px;
}

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

.lane-list {
  display: grid;
  gap: 9px;
}

.work-item {
  position: relative;
  width: 100%;
  min-height: 148px;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.work-item:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.work-item[data-priority="P0"] {
  border-left: 4px solid var(--critical);
  background: var(--critical-soft);
}

.work-item-open {
  display: block;
  width: 100%;
  min-height: 116px;
  padding: 13px 14px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.work-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.work-item h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.priority {
  flex: 0 0 auto;
  color: var(--critical);
  font-size: 11px;
  font-weight: 800;
}

.work-item p {
  display: -webkit-box;
  margin: 9px 0 12px;
  overflow: hidden;
  color: var(--muted);
  line-height: 1.55;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.item-meta {
  flex-wrap: wrap;
  gap: 5px 11px;
  color: var(--muted);
  font-size: 11px;
}

.source-chip {
  max-width: 132px;
  overflow: hidden;
  color: var(--system);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
}

.quick-actions button {
  min-height: 34px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.quick-actions button:last-child { border-right: 0; }
.quick-actions button[data-priority-action="P0"]:hover { background: var(--critical-soft); color: var(--critical); }
.quick-actions button[data-priority-action="P1"]:hover { background: #eef4fb; color: var(--distribution); }
.quick-actions button[data-priority-action="P2"]:hover { background: var(--surface-2); color: var(--text); }
.quick-actions button[data-card-command]:hover { background: #eef4fb; color: var(--system); }
.quick-actions button[data-quick-action="closed"]:hover { background: #e9f5ee; color: var(--success); }
.quick-actions button[data-quick-action="hold"]:hover { background: #fff4dc; color: var(--warning); }

.manage-hint {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-left: auto;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--success);
  font-size: 11px;
  font-weight: 900;
}

.business { font-weight: 800; }
.business[data-business="引进"] { color: var(--acquisition); }
.business[data-business="分销"] { color: var(--distribution); }
.business[data-business="交易"] { color: var(--trading); }
.business[data-business="管理"] { color: var(--management); }
.business[data-business="活动"] { color: var(--event); }
.business[data-business="系统"] { color: var(--system); }
.is-overdue { color: var(--critical); font-weight: 700; }

.decision-mark {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 52px;
  padding: 4px 7px;
  border-bottom-left-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.decision-mark[data-action="closed"] { background: #e9f5ee; color: var(--success); }
.decision-mark[data-action="keep"] { background: #e9f0fa; color: var(--distribution); }
.decision-mark[data-action="hold"] { background: #fff4dc; color: var(--warning); }

.empty-state {
  grid-column: 1 / -1;
  padding: 64px 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}

.history-list {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
}

.history-row {
  display: grid;
  grid-template-columns: 190px 1fr 100px;
  gap: 18px;
  align-items: center;
  padding: 15px 4px;
  border-bottom: 1px solid var(--line);
}

.history-row strong { font-size: 14px; }
.history-row p { margin: 3px 0 0; color: var(--muted); line-height: 1.5; }
.history-row span { color: var(--muted); font-size: 12px; text-align: right; }

.detail-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.detail-dialog::backdrop { background: rgba(20, 22, 26, 0.48); }
.dialog-frame { margin: 0; }

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 4px 0 0;
  font-size: 22px;
  line-height: 1.35;
}

.dialog-content {
  max-height: calc(100vh - 240px);
  overflow: auto;
  padding: 20px 24px;
}

.dialog-tags { flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }

.tag {
  padding: 4px 7px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.detail-section { margin-top: 20px; }
.detail-section:first-of-type { margin-top: 0; }

.detail-section h3 {
  margin: 0 0 7px;
  font-size: 13px;
}

.detail-section p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  white-space: pre-line;
}

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

.detail-field span { display: block; color: var(--muted); font-size: 11px; }
.detail-field strong { display: block; margin-top: 3px; font-size: 13px; line-height: 1.45; }

.dialog-actions {
  padding: 14px 24px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.decision-row { gap: 8px; flex-wrap: wrap; }

.decision-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}

.decision-button:hover { background: var(--surface-2); }
.decision-button[data-action="keep"] { border-color: #8bb2df; color: var(--distribution); }
.decision-button[data-action="closed"] { border-color: #80b994; color: var(--success); }
.decision-button[data-action="hold"] { border-color: #dbb466; color: var(--warning); }

.decision-note {
  width: 100%;
  min-height: 72px;
  margin-top: 10px;
  padding: 9px 10px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}

.collaboration-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.collaboration-panel label { color: var(--muted); font-size: 11px; font-weight: 700; }
.collaboration-panel select { width: 100%; min-height: 38px; margin-top: 5px; border: 1px solid var(--line); background: var(--surface); padding: 0 9px; }
.collaboration-panel .decision-note { grid-column: 1 / -1; margin-top: 4px; }
.collaboration-panel .comment-command { grid-column: 1 / -1; justify-self: start; }

.access-panel {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.access-panel .viewer-options {
  grid-column: 1 / -1;
}

.compact-dialog { width: min(680px, calc(100vw - 32px)); }

.task-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px 16px;
}

.task-form-grid label,
.command-content label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.task-form-grid input,
.task-form-grid select,
.task-form-grid textarea,
.command-content textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}

.task-form-grid textarea,
.command-content textarea {
  min-height: 84px;
  resize: vertical;
}

.field-wide { grid-column: 1 / -1; }

.viewer-fieldset {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
}

.viewer-fieldset legend {
  padding: 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.viewer-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.viewer-option {
  display: inline-flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 6px !important;
  color: var(--text) !important;
  font-size: 12px !important;
  font-weight: 500 !important;
}

.viewer-option input {
  width: 16px;
  min-height: 16px;
  margin: 0;
}

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

.command-content {
  display: grid;
  gap: 14px;
}

.command-results {
  display: grid;
  gap: 8px;
}

.command-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 10px 11px;
  border-left: 3px solid var(--line-strong);
  background: var(--surface-2);
  font-size: 12px;
}

.command-result span { color: var(--muted); text-align: right; }
.command-result.is-success { border-left-color: var(--success); }
.command-result.is-warning { border-left-color: var(--warning); }

.activity-log {
  grid-column: 1 / -1;
  max-height: 190px;
  overflow: auto;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.activity-entry { padding: 9px 0; border-bottom: 1px solid var(--line); line-height: 1.5; }
.activity-entry strong { color: var(--text); }
.activity-entry time { display: block; margin-top: 2px; font-size: 10px; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 44px));
  padding: 11px 14px;
  background: #202327;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1040px) {
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric:nth-child(3) { border-right: 0; }
  .metric:nth-child(-n + 3) { border-bottom: 1px solid var(--line); }
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .topbar,
  .week-heading,
  .toolbar { align-items: stretch; flex-direction: column; }
  .topbar { padding: 12px 16px; }
  .topbar-actions { justify-content: space-between; }
  .user-menu > span { display: none; }
  .summary-band { padding: 20px 16px 16px; }
  .source-line { max-width: none; text-align: left; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { border-bottom: 1px solid var(--line); }
  .metric:nth-child(2n) { border-right: 0; }
  .metric:nth-child(3) { border-right: 1px solid var(--line); }
  .view-tabs { padding: 0 16px; }
  .view-tab { flex: 1 0 auto; }
  .toolbar { padding: 14px 16px; }
  .search-field { flex-basis: auto; max-width: none; }
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters select { width: 100%; padding-left: 7px; padding-right: 20px; }
  .board { grid-template-columns: 1fr; padding: 0 16px 24px; }
  .work-item { min-height: 0; }
  .history-row { grid-template-columns: 1fr; gap: 5px; }
  .history-row span { text-align: left; }
  .detail-grid { grid-template-columns: 1fr; }
  .dialog-header,
  .dialog-content,
  .dialog-actions { padding-left: 18px; padding-right: 18px; }
  .collaboration-panel { grid-template-columns: 1fr; }
  .collaboration-panel .decision-note,
  .collaboration-panel .comment-command { grid-column: 1; }
  .access-panel { grid-template-columns: 1fr; }
  .access-panel .viewer-options { grid-column: 1; }
}

@media (max-width: 430px) {
  .brand-logo { width: 42px; height: 42px; }
  h1 { font-size: 19px; }
  .topbar-actions { align-items: stretch; flex-wrap: wrap; }
  .week-picker { flex: 1 0 100%; }
  .week-picker select { width: 100%; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: 1fr; }
  .task-form-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: 1; }
  .command-result { grid-template-columns: 1fr; }
  .command-result span { text-align: left; }
  .dialog-header h2 { font-size: 19px; }
}
