:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef4f8;
  --ink: #18212f;
  --muted: #667085;
  --line: #d8e0ea;
  --blue: #1f4e79;
  --green: #2f855a;
  --amber: #b7791f;
  --red: #b42318;
  --blue-soft: #e8f1f7;
  --green-soft: #e8f6ef;
  --amber-soft: #fff5dc;
  --red-soft: #fdeceb;
  --shadow: 0 12px 30px rgba(24, 33, 47, 0.08);
}

* {
  box-sizing: border-box;
}

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

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(240, 244, 249, 0.97);
}

.auth-gate.hidden {
  display: none;
}

.auth-panel {
  width: min(420px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-panel h1 {
  margin: 4px 0 8px;
  font-size: 26px;
}

.auth-copy {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.6;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form button {
  min-height: 42px;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.auth-form .ghost-btn {
  background: var(--blue-soft);
  color: var(--blue);
}

.auth-message {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--red);
  font-size: 13px;
}

.sync-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.sync-status.synced {
  color: var(--green);
}

.sync-status.error {
  color: var(--red);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 17px;
}

.top-actions,
.date-chip,
.tabs,
.section-head {
  display: flex;
  align-items: center;
}

.control-strip {
  display: none;
}

.top-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.date-chip,
.control-strip label {
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.weekday-chip {
  min-width: 44px;
  color: var(--blue);
  font-size: 13px;
  white-space: nowrap;
}

input,
select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  min-width: 0;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(31, 78, 121, 0.18);
  border-color: var(--blue);
}

.date-chip input {
  width: 150px;
}

.icon-btn,
.ghost-btn,
.entry-form button {
  height: 38px;
  border-radius: 6px;
  font-weight: 800;
}

.icon-btn {
  width: 38px;
  background: var(--blue);
  color: #fff;
}

.ghost-btn {
  padding: 0 12px;
  background: #edf2f7;
  color: var(--blue);
}

.entry-form button {
  padding: 0 18px;
  background: var(--green);
  color: #fff;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.metric {
  min-height: 112px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.metric strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 34px;
  line-height: 1;
}

.metric.good {
  border-left-color: var(--green);
}

.metric.warning {
  border-left-color: var(--amber);
}

.metric.danger {
  border-left-color: var(--red);
}

.metric-action {
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.metric-action:hover,
.metric-action:focus {
  border-color: rgba(31, 78, 121, 0.45);
  box-shadow: 0 16px 34px rgba(24, 33, 47, 0.13);
  outline: none;
  transform: translateY(-1px);
}

.control-strip {
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.control-strip label {
  flex: 1 1 170px;
}

.control-strip input {
  width: 100%;
}

.tabs {
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.tab {
  min-width: 112px;
  height: 40px;
  border-radius: 6px;
  background: #e6ebf2;
  color: var(--ink);
  font-weight: 800;
}

.tab.active {
  background: var(--blue);
  color: #fff;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  gap: 12px;
  margin-bottom: 12px;
}

.section-band {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.section-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.flow-list {
  margin: 0;
  padding-left: 24px;
}

.flow-list li {
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.flow-list strong {
  display: block;
  margin-bottom: 3px;
}

.due-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.due-item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
}

.due-item b {
  display: block;
  margin-bottom: 4px;
}

.bucket-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.bucket {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 108px;
  background: var(--surface-2);
}

.bucket h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.bucket p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 13px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-weight: 800;
  font-size: 13px;
}

.muted-text {
  color: var(--muted);
  font-size: 13px;
}

.entry-form {
  display: grid;
  grid-template-columns: 110px 140px minmax(260px, 1fr) 90px 90px 84px;
  gap: 8px;
  margin: 0 0 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.entry-form.wide {
  grid-template-columns: 148px minmax(120px, 0.75fr) minmax(140px, 1fr) minmax(120px, 0.8fr) minmax(120px, 0.8fr) minmax(150px, 1fr) minmax(120px, 0.7fr) 76px;
}

.entry-form.wide input,
.entry-form.wide select,
.entry-form.wide button {
  width: 100%;
  font-size: 13px;
}

.filter-bar {
  display: grid;
  grid-template-columns: 116px 132px 132px minmax(170px, 240px) 76px;
  gap: 8px;
  margin: -4px 0 12px;
  padding: 0 12px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

.filter-bar.has-paste {
  grid-template-columns: 116px 126px minmax(165px, 220px) 116px 120px minmax(430px, 0.9fr) 150px;
}

.filter-bar.review-filter {
  grid-template-columns: 116px minmax(180px, 260px) 116px 120px 176px;
}

.sync-review-btn {
  margin-left: 22px;
  white-space: nowrap;
}

.filter-bar input,
.filter-bar select,
.filter-bar button,
.filter-bar textarea {
  width: 100%;
  height: 38px;
  font-size: 13px;
}

.filter-bar textarea {
  resize: none;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  font: inherit;
  font-size: 13px;
  line-height: 18px;
}

.filter-bar button {
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.filter-bar .paste-apply {
  background: var(--green);
}

.table-wrap {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  min-width: 56px;
  resize: horizontal;
  overflow: hidden;
  user-select: none;
}

.col-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}

.col-resizer::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 3px;
  width: 1px;
  height: calc(100% - 16px);
  background: rgba(255, 255, 255, 0.42);
}

td {
  background: #fff;
}

tr:hover td {
  background: #f8fbfd;
}

.cell-input {
  width: 100%;
  min-width: 120px;
  height: 34px;
}

.action-input {
  min-width: 480px;
}

.task-action-copy {
  min-width: 460px;
  max-width: 780px;
  line-height: 1.7;
  color: var(--ink);
}

.task-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  color: #e94c61;
}

.task-alert span {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #e94c61;
}

.compact-input {
  min-width: 108px;
  max-width: 118px;
}

.keyword-name-input,
.next-step-input {
  min-width: 210px;
}

.note-input {
  min-width: 180px;
}

.campaign-input,
.reason-input {
  min-width: 180px;
}

.target-input {
  min-width: 120px;
}

.action-detail-input {
  min-width: 150px;
}

.money-input {
  min-width: 96px;
}

.effect-input {
  min-width: 220px;
}

.summary-cell {
  min-width: 260px;
  max-width: 420px;
  line-height: 1.6;
  white-space: normal;
}

.progress-cell {
  min-width: 360px;
  max-width: 560px;
  color: var(--muted);
}

.status-select {
  min-width: 96px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.tag.good {
  color: var(--green);
  background: var(--green-soft);
}

.tag.warning {
  color: var(--amber);
  background: var(--amber-soft);
}

.tag.danger {
  color: var(--red);
  background: var(--red-soft);
}

.tag.neutral {
  color: var(--blue);
  background: var(--blue-soft);
}

.decision-select {
  width: 150px;
  min-width: 138px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.decision-select.good {
  color: var(--green);
  background: var(--green-soft);
}

.decision-select.warning {
  color: var(--amber);
  background: var(--amber-soft);
}

.decision-select.danger {
  color: var(--red);
  background: var(--red-soft);
}

.decision-select.neutral {
  color: var(--blue);
  background: var(--blue-soft);
}

.decision-select.archived {
  color: var(--muted);
  background: #eef0f3;
}

.action-chip {
  border: 0;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.action-chip:hover,
.action-chip:focus {
  box-shadow: 0 6px 14px rgba(24, 33, 47, 0.14);
  outline: none;
  transform: translateY(-1px);
}

.applied-mark {
  display: inline-block;
  margin-left: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.row-btn {
  min-width: 34px;
  height: 32px;
  border-radius: 6px;
  background: #edf2f7;
  color: var(--red);
  font-weight: 900;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.copy-row-btn {
  min-width: 48px;
  color: var(--blue);
}

.attachment-actions {
  display: flex;
  min-width: 118px;
  align-items: center;
  gap: 5px;
}

.attachment-upload,
.attachment-name,
.attachment-remove {
  min-height: 32px;
  padding: 6px 9px;
  border: 0;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.attachment-upload {
  flex: 0 0 auto;
  background: var(--blue-soft);
  color: var(--blue);
}

.attachment-upload input {
  display: none;
}

.attachment-name {
  max-width: 160px;
  overflow: hidden;
  background: var(--green-soft);
  color: var(--green);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-remove {
  min-width: 30px;
  padding: 0;
  background: var(--red-soft);
  color: var(--red);
}

.evidence-cell {
  display: flex;
  min-width: 170px;
  align-items: center;
  gap: 8px;
}

.evidence-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.evidence-thumb-wrap {
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
}

.evidence-thumb {
  display: block;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 5px;
  object-fit: cover;
}

.evidence-preview {
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.evidence-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  line-height: 18px;
}

.evidence-upload {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 6px 9px;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.evidence-input {
  display: none;
}

.modal-open {
  overflow: hidden;
}

.evidence-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(12, 20, 31, 0.88);
}

.evidence-modal.show {
  display: flex;
}

.evidence-modal-image {
  display: block;
  max-width: calc(100vw - 80px);
  max-height: calc(100vh - 80px);
  object-fit: contain;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.42);
}

.evidence-modal-close {
  position: fixed;
  top: 18px;
  right: 22px;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-size: 28px;
  line-height: 42px;
  cursor: pointer;
}

.link-btn {
  min-height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 800;
}

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

.plan-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px;
  gap: 8px;
  margin-bottom: 12px;
}

.plan-form input {
  width: 100%;
  min-width: 0;
}

.plan-form button {
  min-height: 38px;
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
}

.plan-list {
  display: grid;
  gap: 8px;
}

.plan-item {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) minmax(118px, auto) 38px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.plan-item .status-select {
  width: 100%;
  min-width: 0;
}

.plan-text-input {
  width: 100%;
  min-width: 0;
}

.plan-item.completed .plan-text-input {
  color: var(--red);
  text-decoration: line-through;
  text-decoration-color: var(--red);
  text-decoration-thickness: 2px;
}

.empty-plan {
  padding: 28px 12px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  min-width: 240px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1080px) {
  .summary-grid,
  .split-layout,
  .bucket-grid,
  .plan-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .entry-form,
  .entry-form.wide,
  .filter-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .app-shell {
    width: min(100vw - 20px, 1480px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
  }

  h1 {
    font-size: 23px;
  }

  .summary-grid,
  .split-layout,
  .bucket-grid,
  .plan-layout,
  .entry-form,
  .entry-form.wide,
  .filter-bar {
    grid-template-columns: 1fr;
  }

  .plan-item {
    grid-template-columns: 108px minmax(0, 1fr);
  }

  .date-chip input {
    width: 136px;
  }
}
