:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #1b2533;
  --muted: #657386;
  --line: #dde3ea;
  --primary: #146b5f;
  --primary-strong: #0d4f46;
  --blue: #2563eb;
  --amber: #b7791f;
  --red: #c24136;
  --green: #15803d;
  --shadow: 0 18px 45px rgba(24, 39, 75, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

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

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

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 26px 18px;
  border-right: 1px solid var(--line);
  background: #10231f;
  color: #eef7f4;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
  background: #e4b84a;
  color: #10231f;
  font-size: 24px;
  font-weight: 900;
}

.brand h1 {
  margin: 0;
  font-size: 19px;
}

.brand p,
.user-card p {
  margin: 4px 0 0;
  color: rgba(238, 247, 244, 0.68);
  font-size: 12px;
}

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

.nav-item {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: rgba(238, 247, 244, 0.82);
  text-align: left;
}

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

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

.user-card label {
  display: block;
  margin-bottom: 8px;
  color: rgba(238, 247, 244, 0.82);
  font-size: 13px;
}

.user-card select {
  width: 100%;
  height: 38px;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
}

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

.topbar,
.panel-header,
.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

h2,
h3 {
  margin: 0;
}

h2 {
  font-size: 28px;
}

h3 {
  font-size: 20px;
}

.top-actions,
.filters,
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.table-button,
.icon-button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

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

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

.ghost-button,
.table-button {
  padding: 0 12px;
}

.table-button {
  min-height: 30px;
  font-size: 13px;
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 24px;
}

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

.metric-card,
.panel,
.modal {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.metric-card {
  padding: 16px;
}

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

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

.metric-card span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.panel {
  overflow: hidden;
}

.panel-header {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.filters select {
  height: 36px;
  min-width: 128px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

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

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

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

td {
  font-size: 14px;
}

.customer-name {
  font-weight: 900;
}

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

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

.badge.success {
  background: #dcfce7;
  color: var(--green);
}

.badge.info {
  background: #dbeafe;
  color: var(--blue);
}

.badge.warning {
  background: #fef3c7;
  color: var(--amber);
}

.badge.danger {
  background: #fee2e2;
  color: var(--red);
}

.badge.neutral {
  background: #e5e7eb;
  color: #475569;
}

.task-list,
.settings-grid,
.timeline {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.admin-settings {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.task-card,
.settings-card,
.timeline-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

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

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-form input {
  width: 220px;
  margin-top: 0;
}

.option-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 8px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.option-pill button {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #eef2f7;
  color: var(--muted);
}

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

.task-card strong,
.settings-card strong,
.timeline-item strong {
  display: block;
  margin-bottom: 6px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.48);
  z-index: 20;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(720px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 20px;
  box-shadow: var(--shadow);
}

.large-modal {
  width: min(920px, 100%);
}

.login-panel {
  width: min(420px, 100%);
}

.login-hint {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

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

.one-column {
  grid-template-columns: 1fr;
}

.full-span {
  grid-column: 1 / -1;
}

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

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

input,
select {
  height: 40px;
  padding: 0 10px;
}

textarea {
  min-height: 86px;
  padding: 10px;
  resize: vertical;
}

.switch {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.switch input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.duplicate-box {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 14px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #10231f;
  color: #ffffff;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 30;
}

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

.empty-state {
  padding: 42px 18px;
  color: var(--muted);
  text-align: center;
}

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

  .sidebar {
    position: static;
  }

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

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .rule-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

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

  .top-actions,
  .filters,
  .inline-form {
    width: 100%;
  }

  .top-actions button,
  .filters select,
  .inline-form input,
  .inline-form button {
    width: 100%;
  }

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