:root {
  --bg: #fff7f7;
  --surface: #ffffff;
  --surface-alt: #fff1f1;
  --text: #20231f;
  --muted: #6f6666;
  --line: #ead7d7;
  --green: #e60012;
  --green-dark: #a9000d;
  --red: #e60012;
  --amber: #ffc107;
  --amber-dark: #9a6b00;
  --blush: #fff1f1;
  --ink: #263238;
  --shadow: 0 12px 32px rgba(100, 18, 24, 0.08);
  --radius: 8px;
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 24px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  border-top: 4px solid var(--red);
  backdrop-filter: blur(12px);
}

.brand-block h1,
.brand-block p {
  margin: 0;
}

.brand-block h1 {
  font-size: 26px;
  line-height: 1.25;
}

.brand-block p:last-child {
  margin-top: 6px;
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

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

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

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(40, 125, 74, 0.14);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px 24px 28px;
}

.side-panel,
.workspace {
  min-width: 0;
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 14px;
}

.panel-block,
.board-panel,
.lead-workbench,
.detail-panel,
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-block {
  padding: 16px;
}

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

.section-heading h2,
.section-heading h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.section-heading h3 {
  font-size: 16px;
}

.section-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.section-heading.compact {
  margin: 6px 0 12px;
}

.stack-form,
.panel-block {
  display: grid;
  gap: 12px;
}

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

.primary,
.secondary,
.ghost,
.icon-button,
.text-button {
  border: 0;
  border-radius: var(--radius);
  font-weight: 800;
}

.primary {
  background: var(--green);
  color: #fff;
  padding: 11px 14px;
}

.primary:hover {
  background: var(--green-dark);
}

.secondary {
  background: var(--blush);
  color: var(--green-dark);
  padding: 10px 14px;
}

.ghost {
  background: var(--surface-alt);
  color: var(--ink);
  padding: 8px 10px;
}

.ghost.small {
  align-self: start;
}

.icon-button {
  width: 42px;
  height: 42px;
  background: var(--ink);
  color: #fff;
  font-size: 20px;
  line-height: 1;
}

.text-button {
  padding: 0;
  background: transparent;
  color: var(--green-dark);
  text-align: left;
}

.wide {
  width: 100%;
}

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

.workspace {
  display: grid;
  gap: 16px;
}

.login-screen {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 108px);
  padding: 24px;
}

.login-box {
  display: grid;
  gap: 14px;
  width: min(100%, 420px);
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-box h2,
.login-box p {
  margin: 0;
}

.login-box p {
  color: var(--muted);
  line-height: 1.55;
}

.login-notice {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: #fff8ed;
  color: #8b520b;
  border: 1px solid #efd8b4;
  font-weight: 700;
}

.notice {
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.notice.success {
  border-color: rgba(40, 125, 74, 0.28);
  background: #edf7ef;
  color: var(--green-dark);
}

.notice.error {
  border-color: rgba(211, 61, 47, 0.32);
  background: #fff0ee;
  color: #9d241b;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
}

.metric {
  display: grid;
  gap: 8px;
  padding: 16px;
}

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

.metric strong {
  font-size: 32px;
  line-height: 1;
}

.metric small {
  color: var(--muted);
}

.metric.warning strong {
  color: var(--amber-dark);
}

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

.board-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 14px;
}

.board-panel,
.lead-workbench {
  padding: 16px;
}

.table-scroll {
  overflow: auto;
}

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

td strong,
td span,
td small {
  display: block;
}

td small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.muted-cell {
  color: var(--muted);
  text-align: center;
}

.rate {
  font-weight: 900;
}

.mini-alert {
  display: inline-block;
  margin-top: 5px;
  padding: 3px 6px;
  border-radius: 999px;
  background: #fff1dd;
  color: #8b520b;
  font-size: 12px;
}

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

.pipeline-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
}

.pipeline-row span,
.pipeline-row strong {
  position: relative;
  z-index: 1;
}

.pipeline-row i {
  position: absolute;
  inset: 0 auto 0 0;
  background: rgba(230, 0, 18, 0.12);
}

.due-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.due-list h3 {
  margin: 0 0 2px;
  font-size: 15px;
}

.due-item {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 1px solid #efd8b4;
  border-radius: var(--radius);
  background: #fff8ed;
  color: var(--text);
  padding: 9px 10px;
  text-align: left;
}

.due-item small {
  color: #8b520b;
}

.empty-inline {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}

.workbench-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.workbench-head h2,
.workbench-head p {
  margin: 0;
}

.workbench-head p {
  margin-top: 5px;
  color: var(--muted);
}

.filter-row {
  display: grid;
  grid-template-columns: 150px 150px minmax(180px, 230px);
  gap: 10px;
  align-items: end;
}

.split-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 440px);
  gap: 14px;
}

.lead-table-shell {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.lead-table {
  min-width: 760px;
}

.lead-table tbody tr {
  cursor: pointer;
}

.lead-table tbody tr:hover,
.lead-table tbody tr.is-active {
  background: #f1f7f2;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef1ee;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status-new,
.status-assigned {
  background: #e9eef8;
  color: #294b7a;
}

.status-no_answer {
  background: #fff2df;
  color: #8b520b;
}

.status-contacted,
.status-interested {
  background: #fff1f1;
  color: var(--green-dark);
}

.status-not_interested,
.status-lost {
  background: #f3eeee;
  color: #7c3832;
}

.status-presentation_booked,
.status-presentation_done {
  background: #fff7dc;
  color: #7a5300;
}

.status-won {
  background: #ffe2e4;
  color: var(--green-dark);
}

.overdue {
  color: var(--red);
  font-weight: 900;
}

.detail-panel {
  min-width: 0;
  padding: 16px;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.detail-head h2 {
  margin: 8px 0 4px;
  font-size: 22px;
}

.detail-head p {
  margin: 0;
  color: var(--muted);
}

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

.lead-facts div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
}

.lead-facts div.wide {
  grid-column: 1 / -1;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

dd {
  margin: 4px 0 0;
  line-height: 1.45;
}

.control-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.activity-form {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-alt);
  border: 1px solid var(--line);
}

.timeline {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.timeline-item {
  display: grid;
  gap: 6px;
  padding: 11px;
  border-left: 3px solid var(--green);
  background: #fff;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.target-dashboard {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
  gap: 14px;
}

.guidance-panel,
.target-panel,
.improvement-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.guidance-panel {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  border-color: #f1c4c8;
}

.guidance-panel h2,
.guidance-panel p {
  margin: 0;
}

.guidance-panel h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.guidance-panel p {
  color: var(--text);
  line-height: 1.65;
}

.guidance-panel ul {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.bit-mark {
  display: grid;
  grid-template-columns: repeat(2, 20px);
  grid-auto-rows: 20px;
  gap: 5px;
}

.bit-mark i {
  display: block;
  border-radius: 4px;
  background: var(--red);
}

.bit-mark i:nth-child(2),
.bit-mark i:nth-child(3) {
  background: var(--amber);
}

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

.target-card {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.target-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.target-head span {
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
}

.target-number {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.target-number b {
  color: var(--red);
  font-size: 30px;
  line-height: 1;
}

.target-card p,
.target-card small {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.progress-track {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #f1dddd;
}

.progress-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--amber));
}

.report-item {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.report-item + .report-item {
  margin-top: 10px;
}

.report-item p,
.report-item small {
  margin: 0;
}

.report-item small {
  color: var(--muted);
}

.timeline-item div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.timeline-item p,
.timeline-item small {
  margin: 0;
}

.timeline-item time,
.timeline-item small {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 240px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--text);
  font-size: 18px;
}

@media (max-width: 1180px) {
  .app-shell,
  .board-grid,
  .split-view,
  .target-dashboard {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-grid,
  .target-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }
}

@media (max-width: 860px) {
  .topbar {
    position: static;
    display: grid;
    padding: 16px;
  }

  .app-shell {
    padding: 14px;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

  .metric-grid,
  .target-grid,
  .filter-row,
  .form-grid,
  .lead-facts,
  .control-strip {
    grid-template-columns: 1fr;
  }

  .workbench-head {
    display: grid;
  }

  .topbar-controls {
    align-items: stretch;
  }

  .topbar-controls label {
    min-width: 150px;
    flex: 1;
  }
}

@media (max-width: 560px) {
  .brand-block h1 {
    font-size: 22px;
  }

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

  .panel-block,
  .board-panel,
  .lead-workbench,
  .detail-panel,
  .metric {
    box-shadow: none;
  }
}
