:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f4f7;
  --ink: #20262e;
  --muted: #697481;
  --line: #dfe5ea;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #c27803;
  --danger: #c2410c;
  --ok: #15803d;
  --shadow: 0 18px 45px rgba(32, 38, 46, 0.12);
}

* {
  box-sizing: border-box;
}

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

body.auth-locked .app-shell {
  display: none;
}

body:not(.auth-locked) .login-screen {
  display: none;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(15, 23, 42, 0.74), rgba(15, 23, 42, 0.78)),
    url("./assets/office_meeting.jpg") center / cover no-repeat;
}

.login-panel {
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.login-panel .brand-mark {
  margin-bottom: 18px;
  color: #ffffff;
}

.login-panel h1 {
  margin: 6px 0 10px;
  font-size: 30px;
}

.login-panel p {
  margin: 0 0 20px;
  color: var(--muted);
}

.login-panel .primary-button {
  width: 100%;
  justify-content: center;
}

.login-panel .sync-status {
  margin-top: 14px;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 18px;
  background: #172026;
  color: #f8fafc;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 4px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  font-size: 22px;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: #aebbc6;
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 7px;
}

.nav-item {
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d5dde5;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.role-card {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.login-card {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.login-card strong,
.login-card span {
  display: block;
}

.login-card strong {
  color: #ffffff;
  font-size: 14px;
}

.login-card span {
  margin: 4px 0 10px;
  color: #aebbc6;
  font-size: 12px;
  line-height: 1.5;
}

.role-card label {
  display: block;
  margin-bottom: 8px;
  color: #c9d4de;
  font-size: 13px;
}

.role-card select,
.role-card p {
  width: 100%;
}

.role-card select {
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #22303a;
  color: #ffffff;
}

.role-card p {
  margin: 10px 0 0;
  color: #aebbc6;
  font-size: 12px;
  line-height: 1.6;
}

.role-card .button-row {
  gap: 8px;
}

.role-card .button-row.compact button {
  min-height: 32px;
  padding: 7px 10px;
}

.main {
  min-width: 0;
  padding: 28px;
}

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

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.2;
}

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

.topbar-actions,
.board-toolbar,
.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.primary-button,
.ghost-button,
.icon-button {
  min-height: 38px;
  border-radius: 8px;
}

.primary-button {
  border: 0;
  padding: 0 16px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

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

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

.danger-button:hover {
  background: #9a3412;
}

.ghost-button {
  border: 1px solid var(--line);
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
}

.icon-button {
  width: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 22px;
  align-items: center;
  margin-bottom: 20px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-strip > div {
  padding: 26px;
}

.hero-strip h2 {
  margin-bottom: 10px;
  font-size: 24px;
}

.hero-strip p:last-child {
  margin: 0;
  color: var(--muted);
}

.hero-strip img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

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

.metric-card,
.panel,
.table-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(32, 38, 46, 0.06);
}

.metric-card {
  padding: 18px;
}

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

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

.metric-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.two-column,
.section-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.report-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(32, 38, 46, 0.06);
}

.report-actions h2 {
  margin: 0;
}

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

.report-actions input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

.panel {
  padding: 18px;
}

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

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

.reminder-list,
.compact-list,
.timeline,
.bar-list {
  display: grid;
  gap: 10px;
}

.reminder-item,
.compact-item,
.timeline-item {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.reminder-item.overdue {
  border-color: rgba(194, 65, 12, 0.35);
  background: #fff7ed;
}

.reminder-item.today {
  border-color: rgba(15, 118, 110, 0.32);
  background: #f0fdfa;
}

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

.item-title {
  font-weight: 800;
}

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

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: #36424e;
  font-size: 12px;
  font-weight: 700;
}

.pill.hot {
  background: #fef3c7;
  color: #92400e;
}

.pill.good {
  background: #dcfce7;
  color: #166534;
}

.pill.warn {
  background: #ffedd5;
  color: #9a3412;
}

.duplicate-alert {
  padding: 12px;
  border: 1px solid rgba(194, 65, 12, 0.35);
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 13px;
  line-height: 1.5;
}

.duplicate-alert strong {
  color: #7c2d12;
}

.board-toolbar {
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  color: var(--muted);
  font-size: 13px;
}

.board-toolbar select,
.board-toolbar input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.board-toolbar select {
  padding: 0 34px 0 10px;
}

.board-toolbar input {
  flex: 1;
  min-width: 220px;
  padding: 0 12px;
}

.kanban {
  display: grid;
  grid-auto-columns: 288px;
  grid-auto-flow: column;
  gap: 14px;
  min-height: 540px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.stage-column {
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef3f6;
}

.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.stage-header strong {
  font-size: 14px;
}

.stage-body {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 180px;
  overflow-y: auto;
  padding: 12px;
}

.stage-body.drag-over {
  background: rgba(15, 118, 110, 0.08);
}

.lead-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(32, 38, 46, 0.06);
}

.lead-card:active {
  cursor: grabbing;
}

.lead-card h3 {
  margin-bottom: 6px;
  font-size: 16px;
}

.lead-card p {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
}

.lead-card button,
.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 800;
}

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

.table-card {
  overflow: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.stack-form {
  display: grid;
  gap: 13px;
}

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

.stack-form .inline-check {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
}

.inline-check input {
  width: auto;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.sync-status {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.sync-status.good {
  border-color: rgba(21, 128, 61, 0.28);
  background: #f0fdf4;
  color: #166534;
}

.sync-status.warn {
  border-color: rgba(194, 65, 12, 0.3);
  background: #fff7ed;
  color: #9a3412;
}

.stack-form input,
.stack-form select,
.stack-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

.stack-form input,
.stack-form select {
  min-height: 40px;
  padding: 0 11px;
}

.stack-form textarea {
  resize: vertical;
  padding: 10px 11px;
}

.form-row > label {
  flex: 1;
}

.timeline-item {
  position: relative;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 18px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

.bar-item {
  display: grid;
  gap: 6px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(23, 32, 38, 0.28);
}

.customer-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 30;
  width: min(520px, 100vw);
  height: 100vh;
  overflow-y: auto;
  padding: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.drawer-header,
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.detail-box {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.detail-box span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.detail-section {
  margin-top: 18px;
}

.role-permission-grid,
.staff-list {
  display: grid;
  gap: 10px;
}

.permission-card,
.staff-item {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.permission-card h3 {
  margin: 0 0 8px;
}

.staff-list {
  margin-top: 16px;
}

.lark-user-picker {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.staff-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.staff-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

dialog {
  width: min(680px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(23, 32, 38, 0.36);
}

.modal-form {
  padding: 22px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 6px 0 0;
  padding: 0;
}

.restricted {
  position: relative;
  opacity: 0.45;
  pointer-events: none;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .metrics-grid,
  .two-column,
  .section-grid,
  .hero-strip {
    grid-template-columns: 1fr;
  }

  .hero-strip img {
    height: 220px;
  }
}

@media (max-width: 680px) {
  .main,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .topbar-actions,
  .report-actions,
  .form-row {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-list,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

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