:root {
  --bg: #f7f5ed;
  --surface: #fffefa;
  --surface-muted: #f0eee8;
  --ink: #12120f;
  --muted: #72736d;
  --line: #dad7cd;
  --green: #557f58;
  --green-dark: #3f6645;
  --red: #b44848;
  --shadow: 0 8px 26px rgba(26, 29, 24, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(260px, 430px) minmax(320px, 420px);
  align-items: center;
  justify-content: center;
  gap: 72px;
  padding: 40px;
}

.auth-copy h1 {
  margin: 0;
  color: #161713;
  font-family: "STKaiti", "KaiTi", "FangSong", "Songti SC", "SimSun", serif;
  font-size: clamp(38px, 3.8vw, 54px);
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.32;
}

.auth-copy h1 span {
  display: block;
  white-space: nowrap;
}

.auth-card,
.left-panel,
.todo-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card {
  padding: 24px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 22px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.tabs button {
  height: 38px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  font-weight: 700;
}

.tabs button.active {
  background: var(--surface);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.08);
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  font-weight: 700;
}

label strong {
  color: var(--red);
}

.email-field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid #cfcac0;
  border-radius: 6px;
  background: var(--surface);
}

.email-field:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(85, 127, 88, 0.16);
}

.email-field input {
  border: 0;
  box-shadow: none;
}

.email-field input:focus {
  box-shadow: none;
}

.email-field span {
  padding: 0 12px;
  color: #555852;
  font-weight: 800;
  border-left: 1px solid var(--line);
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -4px 0 16px;
  color: #555852;
  font-weight: 700;
}

.remember-row input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--green);
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfcac0;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 12px;
  outline: 0;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(85, 127, 88, 0.16);
}

.primary-btn,
.ghost-btn,
.danger-btn {
  min-height: 44px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 20px;
  font-weight: 800;
}

.primary-btn {
  width: 100%;
  background: var(--green);
  color: white;
}

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

.ghost-btn {
  background: transparent;
  color: #333630;
  border-color: var(--line);
}

.danger-btn {
  background: #fff3f1;
  color: var(--red);
  border-color: #e7c5c0;
}

.small-btn {
  min-height: 34px;
  padding: 0 12px;
}

.form-error {
  min-height: 20px;
  margin: -4px 0 14px;
  color: var(--red);
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 78px;
  padding: 0 32px;
  background: rgba(255, 254, 250, 0.94);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 12px rgba(42, 43, 38, 0.08);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  display: inline;
  margin: 0;
  font-size: 28px;
}

.topbar div span {
  margin-left: 12px;
  color: #7a806f;
  font-weight: 800;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar nav .primary-btn {
  width: auto;
}

#userEmail {
  color: #444842;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
  padding: 24px 32px 48px;
}

.left-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  position: sticky;
  top: 98px;
}

.panel-block {
  min-width: 0;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.metric {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 0;
  padding: 10px 6px;
  background: #fbfaf5;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.metric strong {
  color: var(--green);
  font-size: 28px;
  line-height: 1;
}

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

.funnel h2,
.insight-panel h2,
.todo-panel h2 {
  margin: 0 0 12px;
  color: #777970;
  font-size: 16px;
}

.funnel-item {
  display: grid;
  grid-template-columns: 66px 1fr 22px;
  align-items: center;
  gap: 8px;
  margin: 7px 0;
}

.funnel-item span:first-child {
  color: #595d56;
  font-size: 13px;
  text-align: right;
}

.track {
  height: 5px;
  overflow: hidden;
  background: #dfddd7;
  border-radius: 999px;
}

.bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
}

.funnel-item strong {
  font-size: 16px;
}

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

.insight-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  width: 100%;
  padding: 0 12px;
  text-align: left;
  background: #fbfaf5;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.insight-item:not(:disabled):hover,
.insight-item:not(:disabled):focus {
  border-color: var(--green);
  outline: 0;
}

.insight-item:disabled {
  cursor: default;
  opacity: 0.58;
}

.insight-item span {
  color: #555852;
  font-weight: 700;
}

.insight-item strong {
  color: var(--green-dark);
  font-size: 18px;
}

.todo-panel {
  position: sticky;
  top: 98px;
  height: calc(100vh - 122px);
  margin: 0;
  padding: 16px;
  overflow: hidden;
}

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

.todo-panel h2 {
  margin: 0;
}

.todo-panel header span {
  display: grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  color: var(--green-dark);
  background: #edf3ea;
  border: 1px solid #c9dcc6;
  border-radius: 999px;
  font-weight: 800;
}

.todo-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 190px);
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-color: #b8b4a9 #ece9e1;
  scrollbar-width: thin;
}

.todo-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  text-align: left;
  background: #fbfaf5;
  border: 1px solid var(--line);
  border-left: 5px solid var(--todo-color, var(--green));
  border-radius: 8px;
}

.todo-item:hover,
.todo-item:focus {
  border-color: var(--green);
  outline: 0;
}

.todo-item time {
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}

.todo-item strong {
  color: var(--ink);
}

.todo-item span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.todo-item.completed {
  color: #8b8c86;
  background: #eeece6;
}

.todo-item.completed strong,
.todo-item.completed span,
.todo-item.completed time {
  color: #8b8c86;
  text-decoration: line-through;
}

.todo-item[data-tone="default"] {
  --todo-color: #557f58;
}

.todo-item[data-tone="written"] {
  --todo-color: #2d74da;
}

.todo-item[data-tone="interview"] {
  --todo-color: #da8500;
}

.todo-item[data-tone="offer"] {
  --todo-color: #089053;
}

.todo-item[data-tone="overdue"] {
  --todo-color: #b44848;
}

.todo-item[data-tone="done"] {
  --todo-color: #9a9b94;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  gap: 18px;
  padding: 0;
}

.column {
  min-height: 240px;
  overflow: hidden;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.column > header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  height: 58px;
  background: var(--surface);
  border-top: 4px solid var(--column-color);
  border-bottom: 1px solid var(--line);
}

.column h2 {
  margin: 0;
  font-size: 18px;
}

.count-badge {
  position: absolute;
  right: 18px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--column-color);
  background: color-mix(in srgb, var(--column-color), white 88%);
  border: 1px solid color-mix(in srgb, var(--column-color), white 65%);
  border-radius: 999px;
  font-weight: 800;
}

.cards {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 178px;
  padding: 12px;
}

.empty-state {
  align-self: center;
  justify-self: center;
  margin: 44px 0;
  color: #8b8c86;
  font-size: 15px;
}

.empty-state.compact {
  margin: 16px 0;
}

.application-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: 0 2px 8px rgba(20, 20, 16, 0.04);
}

.application-card:hover,
.application-card:focus {
  border-color: var(--column-color);
  outline: 0;
}

.application-card strong {
  overflow: hidden;
  font-size: 15px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.application-card p {
  overflow: hidden;
  margin: 0;
  color: #5b5e58;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-link {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--green-dark);
  text-decoration: none;
  background: #edf3ea;
  border: 1px solid #c9dcc6;
  border-radius: 6px;
  font-weight: 900;
}

.card-link:hover {
  background: #e1ecde;
}

.card-link.disabled {
  color: #aaa9a1;
  pointer-events: none;
  background: #f1efe8;
  border-color: var(--line);
}

dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(12, 14, 11, 0.28);
}

dialog::backdrop {
  background: rgba(20, 22, 18, 0.34);
}

#applicationForm {
  padding: 24px;
}

.help-content {
  padding: 24px;
}

.help-content header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.help-content h2 {
  margin: 0;
}

.help-content ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 22px;
  color: #3f433d;
  line-height: 1.75;
  font-weight: 700;
}

.invite-code-list {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
  padding-right: 4px;
}

.invite-code-row {
  display: grid;
  grid-template-columns: 150px minmax(120px, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: #fbfaf5;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.invite-code-row code {
  color: var(--green-dark);
  font-size: 14px;
  font-weight: 900;
}

.invite-code-row span {
  overflow: hidden;
  color: #555852;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invite-code-row.used {
  background: #eeece6;
  opacity: 0.72;
}

.invite-code-row.used code,
.invite-code-row.used span {
  color: #8b8c86;
  text-decoration: line-through;
}

#applicationForm header,
#applicationForm footer {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

#applicationForm header {
  margin-bottom: 20px;
}

#applicationForm header h2 {
  margin: 0;
}

#dialogSubTitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 700;
}

#applicationForm footer {
  grid-template-columns: auto auto 1fr auto auto;
  margin-top: 12px;
}

#applicationForm footer .primary-btn,
#applicationForm footer .ghost-btn,
#applicationForm footer .danger-btn {
  width: auto;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: #333;
  font-size: 24px;
  line-height: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 12px;
}

.section-title h3 {
  margin: 0;
  font-size: 16px;
}

.todo-editor {
  margin: 4px 0 16px;
}

#todoEditorList {
  display: grid;
  gap: 10px;
}

.todo-edit-row {
  display: grid;
  grid-template-columns: 34px 1fr 160px 36px;
  gap: 8px;
  align-items: center;
}

.todo-check {
  width: 30px;
  height: 30px;
  border: 1px solid #cfcac0;
  border-radius: 999px;
  background: var(--surface);
}

.todo-edit-row.completed .todo-check {
  background: var(--green);
  border-color: var(--green);
}

.todo-edit-row.completed .todo-check::after {
  content: "";
  display: block;
  width: 12px;
  height: 6px;
  margin: 8px auto 0;
  border-bottom: 2px solid white;
  border-left: 2px solid white;
  transform: rotate(-45deg);
}

.todo-edit-row.completed input {
  color: #8b8c86;
  text-decoration: line-through;
}

.job-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  color: var(--green-dark);
  text-decoration: none;
  background: #edf3ea;
  border: 1px solid #c9dcc6;
  border-radius: 6px;
  padding: 0 16px;
  font-weight: 800;
}

.job-link:hover {
  background: #e1ecde;
}

@media (max-width: 1180px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .left-panel,
  .todo-panel {
    position: static;
    height: auto;
  }

  .todo-list {
    max-height: 360px;
  }

  .board {
    grid-template-columns: repeat(2, minmax(250px, 1fr));
  }
}

@media (max-width: 760px) {
  .auth-shell {
    grid-template-columns: 1fr;
    align-content: center;
    gap: 28px;
    padding: 24px;
  }

  .auth-copy h1 {
    font-size: 34px;
  }

  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
  }

  .topbar h1 {
    display: block;
    font-size: 26px;
  }

  .topbar div span {
    display: block;
    margin: 4px 0 0;
  }

  .topbar nav {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
  }

  #userEmail {
    grid-column: 1 / -1;
  }

  .dashboard-layout {
    padding: 16px;
  }

  .left-panel,
  .todo-panel {
    padding: 18px;
  }

  .metric strong {
    font-size: 34px;
  }

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

  .column {
    min-height: 210px;
  }

  .form-grid,
  .todo-edit-row {
    grid-template-columns: 1fr;
  }

  .todo-check {
    width: 100%;
    border-radius: 6px;
  }

  #applicationForm footer {
    grid-template-columns: 1fr;
  }

  .invite-code-row {
    grid-template-columns: 1fr;
  }

  #applicationForm footer span {
    display: none;
  }
}
