:root {
  color-scheme: light;
  --bg: #f7f9f8;
  --text: #17211d;
  --muted: #66736d;
  --line: #d7dfda;
  --surface: #ffffff;
  --teal: #167c78;
  --green: #2f8f46;
  --coral: #d84f4f;
  --yellow: #b88405;
  --ink: #23312b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

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

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

.login-panel label {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.top-actions {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.view-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 10px;
  padding: 14px 32px 0;
  background: linear-gradient(180deg, #f7f9f8 72%, rgba(247, 249, 248, 0));
}

.view-tab {
  min-width: 88px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  color: var(--ink);
  backdrop-filter: blur(10px);
}

.view-tab.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

.employee-switch {
  display: grid;
  gap: 6px;
  min-width: 180px;
  color: var(--muted);
  font-size: 13px;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 16px;
  background: var(--teal);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

button.secondary {
  background: #e7efec;
  color: var(--ink);
}

button.danger {
  background: var(--coral);
}

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

.layout {
  display: grid;
  gap: 20px;
  padding: 24px 32px 40px;
}

.screen {
  display: none;
  gap: 20px;
}

.screen.screen-active {
  display: grid;
}

.screen-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.screen-copy {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  text-align: right;
}

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

.metric {
  min-height: 96px;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

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

.accent-yellow {
  border-left-color: var(--yellow);
}

.accent-coral {
  border-left-color: var(--coral);
}

.accent-teal {
  border-left-color: var(--teal);
}

.pulse-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.pulse-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: linear-gradient(135deg, #ffffff, #f1f6f3);
}

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

.pulse-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1.05;
}

.pulse-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.pulse-card-strong {
  border-color: rgba(22, 124, 120, 0.18);
  background: linear-gradient(135deg, rgba(22, 124, 120, 0.12), rgba(255, 255, 255, 0.96));
}

.workspace,
.forms {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

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

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title {
  display: grid;
  gap: 4px;
}

.panel-heading span {
  color: var(--muted);
  font-size: 13px;
}

.panel-controls {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
}

.inline-field,
.filter-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.inline-field {
  min-width: 120px;
}

.inline-search {
  min-width: 220px;
}

.toolbar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px;
}

.panel-toolbar {
  margin-bottom: 14px;
}

.toolbar-wide {
  min-width: min(420px, 100%);
  flex: 1 1 300px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e9f2ef;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
}

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

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

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

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

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

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

.checkbox {
  display: flex !important;
  grid-column: 1 / -1;
  align-items: center;
  gap: 8px;
}

.checkbox input {
  width: auto;
}

form button {
  margin-top: 14px;
}

.event-list,
.lead-list,
.post-list {
  display: grid;
  gap: 10px;
}

.event,
.lead,
.post {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
}

.event strong,
.lead strong,
.post strong {
  display: block;
}

.meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.select-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.select-row input[type="checkbox"] {
  margin: 0;
}

.lead-active {
  border-color: rgba(22, 124, 120, 0.4);
  box-shadow: 0 0 0 1px rgba(22, 124, 120, 0.16);
}

.detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(23, 33, 29, 0.28);
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 21;
  display: grid;
  grid-template-rows: auto 1fr;
  width: min(480px, 100vw);
  height: 100vh;
  border-left: 1px solid var(--line);
  background: #ffffff;
  box-shadow: -12px 0 30px rgba(23, 33, 29, 0.12);
}

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

.detail-body {
  overflow-y: auto;
  padding: 18px 22px 24px;
}

.detail-stack {
  display: grid;
  gap: 16px;
}

.detail-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: #fbfdfc;
}

.detail-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.detail-pair {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 8px;
  margin-top: 8px;
  font-size: 13px;
}

.detail-pair strong {
  color: var(--ink);
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e9f2ef;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
}

.detail-tag-alert {
  background: #fdecec;
  color: var(--coral);
}

.detail-tag-warn {
  background: #fff3d8;
  color: var(--yellow);
}

.detail-tag-ok {
  background: #e8f5ec;
  color: var(--green);
}

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

.detail-link {
  color: var(--teal);
  text-decoration: none;
  word-break: break-all;
}

.detail-link:hover {
  text-decoration: underline;
}

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

.timeline-item {
  border-left: 3px solid rgba(22, 124, 120, 0.24);
  padding-left: 12px;
}

#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  min-height: 0;
  border-radius: 8px;
  padding: 0;
  background: var(--ink);
  color: #fff;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease, padding 160ms ease;
}

#toast.active {
  padding: 12px 14px;
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 960px) {
  .view-nav,
  .summary-grid,
  .pulse-grid,
  .workspace,
  .forms {
    grid-template-columns: 1fr;
  }

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

  .top-actions {
    align-items: stretch;
    justify-content: stretch;
  }

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

  .screen-copy {
    max-width: none;
    text-align: left;
  }

  .detail-drawer {
    width: min(560px, 100vw);
  }
}

@media (max-width: 560px) {
  .view-nav,
  .topbar,
  .layout {
    padding-left: 16px;
    padding-right: 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .panel-controls,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-field,
  .inline-search,
  .toolbar-wide {
    min-width: 0;
    width: 100%;
  }

  .detail-header {
    flex-direction: column;
    align-items: stretch;
  }

  .detail-pair {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

.verify-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 6px 0; font-size: 13px; color: var(--muted); }
.verify-row label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.verify-row input[type="checkbox"] { margin: 0; }
