:root {
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --surface-soft: #f2f2f7;
  --surface-raised: #fbfbfd;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --muted-2: #86868b;
  --line: rgba(60, 60, 67, 0.16);
  --line-strong: rgba(60, 60, 67, 0.28);
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-soft: #e8f2ff;
  --warn: #b25e09;
  --danger: #c4212f;
  --ok: #248a3d;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.06);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Arial, "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

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

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 13px;
  color: var(--ink);
  background: var(--surface-solid);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

button:hover {
  border-color: var(--line-strong);
  background: #fbfbfd;
}

button:active {
  transform: translateY(1px);
  box-shadow: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(0, 113, 227, 0.24);
  outline-offset: 2px;
}

.primary {
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(0, 113, 227, 0.2);
}

.primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
  color: var(--ink);
  background: var(--surface-solid);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.02);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--line-strong);
}

textarea {
  min-height: 104px;
  resize: vertical;
  line-height: 1.45;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  background: #fbfbfd;
}

td {
  font-size: 13px;
  line-height: 1.42;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  border-right: 1px solid var(--line);
  padding: 18px;
  background: rgba(246, 246, 248, 0.86);
  backdrop-filter: saturate(160%) blur(20px);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 700;
  background: #1d1d1f;
  box-shadow: 0 8px 20px rgba(29, 29, 31, 0.18);
}

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

.brand strong {
  font-size: 15px;
  font-weight: 700;
}

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

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

.nav-item {
  justify-content: flex-start;
  width: 100%;
  min-height: 40px;
  border-color: transparent;
  padding: 9px 11px;
  text-align: left;
  color: #3a3a3c;
  background: transparent;
  box-shadow: none;
}

.nav-item:hover {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.72);
}

.nav-item.active {
  border-color: rgba(0, 113, 227, 0.18);
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(0, 113, 227, 0.04);
}

.sidebar-footer {
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
}

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

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.section {
  display: none;
}

.section.active {
  display: grid;
  gap: 16px;
}

.dashboard-section {
  gap: 18px;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 16px;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.dashboard-hero h2 {
  margin: 5px 0 8px;
  font-size: 32px;
  line-height: 1.12;
}

.dashboard-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid rgba(0, 113, 227, 0.16);
  border-radius: 999px;
  padding: 2px 9px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 700;
}

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

.hero-kpi {
  display: grid;
  align-content: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfbfd;
}

.hero-kpi span,
.hero-kpi small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-kpi strong {
  font-size: 26px;
  line-height: 1;
}

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

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

.customer-layout {
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, 0.8fr);
}

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

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

.panel-title h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

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

.dashboard-panel {
  align-self: stretch;
}

.span-2 {
  grid-column: span 2;
}

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

.board-metrics {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  background: var(--surface-solid);
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
}

.metric small {
  display: block;
  overflow: hidden;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric.highlight {
  border-color: rgba(0, 113, 227, 0.22);
  background: #f5f9ff;
}

.metric.highlight strong {
  color: var(--accent);
}

.metric.warn {
  border-color: rgba(178, 94, 9, 0.22);
  background: #fff9f1;
}

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

.toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 180px 90px;
  gap: 10px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-solid);
}

.table-wrap table {
  min-width: 720px;
}

.click-row {
  cursor: pointer;
}

.click-row:hover td {
  background: #f5f9ff;
}

.pill,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  max-width: 100%;
  border: 1px solid rgba(36, 138, 61, 0.18);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--ok);
  background: #eef8f1;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pill.warn {
  border-color: rgba(178, 94, 9, 0.22);
  color: var(--warn);
  background: #fff5e8;
}

.pill.danger {
  border-color: rgba(196, 33, 47, 0.2);
  color: var(--danger);
  background: #fff1f2;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.empty {
  display: grid;
  min-height: 170px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: #fbfbfd;
  text-align: center;
}

.detail-panel {
  align-self: start;
}

.detail-section {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.detail-section h3 {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.kv {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 8px;
  font-size: 13px;
}

.kv span:first-child {
  color: var(--muted);
}

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

.form-grid textarea {
  grid-column: span 3;
  min-height: 76px;
}

.form-grid button {
  align-self: stretch;
}

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

.field-label {
  display: block;
  margin: 8px 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.checkbox input {
  width: 16px;
  min-height: auto;
  accent-color: var(--accent);
}

.csv-input {
  min-height: 260px;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 12px;
}

.result-box {
  overflow: auto;
  min-height: 92px;
  margin: 12px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: #3a3a3c;
  background: #fbfbfd;
  white-space: pre-wrap;
}

.bar-list,
.compact-list,
.task-list,
.settings-list,
.prompt-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.funnel-list,
.rank-list,
.content-metrics,
.donut-board {
  display: grid;
  gap: 10px;
}

.funnel-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #fbfbfd;
}

.funnel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.funnel-head span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.funnel-track,
.rank-track {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #e5e5ea;
}

.funnel-fill,
.rank-track div {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.rank-track div.warn {
  background: var(--warn);
}

.rank-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfbfd;
}

.rank-index {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 700;
}

.rank-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.rank-main strong,
.rank-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-main small {
  color: var(--muted);
  font-size: 12px;
}

.rank-item b {
  font-size: 14px;
}

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

.content-metric {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfbfd;
}

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

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

.content-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #fbfbfd;
}

.content-item strong,
.content-item p {
  overflow: hidden;
  text-overflow: ellipsis;
}

.content-item p {
  display: -webkit-box;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.donut-board {
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: center;
}

.donut {
  display: grid;
  place-items: center;
  align-content: center;
  width: 132px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #ffffff 0 58%, transparent 59%),
    conic-gradient(var(--accent) 0 var(--done), #e5e5ea var(--done) 360deg);
}

.donut strong {
  font-size: 28px;
  line-height: 1;
}

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

.donut-meta {
  display: grid;
  gap: 8px;
}

.donut-meta div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.donut-meta div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.donut-meta strong {
  color: var(--ink);
}

.ai-empty {
  display: grid;
  gap: 6px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: #fbfbfd;
}

.ai-empty strong {
  color: var(--ink);
}

.list-item,
.task-item,
.setting-item,
.prompt-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: var(--surface-raised);
}

.list-item strong,
.task-item strong,
.prompt-item strong {
  display: block;
  margin-bottom: 5px;
}

.list-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.setting-item {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 90px 90px 86px;
  align-items: center;
  gap: 8px;
}

.switch {
  position: relative;
  width: 46px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #d1d1d6;
  box-shadow: none;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  transition: left 0.14s ease;
}

.switch.on {
  border-color: var(--ok);
  background: var(--ok);
}

.switch.on::after {
  left: 25px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid rgba(0, 113, 227, 0.2);
  border-radius: 8px;
  padding: 12px 14px;
  color: #063b72;
  background: #f0f7ff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

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

.login-page {
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}

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

.login-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 24px;
}

.login-panel h1 {
  margin: 0 0 18px;
  font-size: 28px;
  font-weight: 700;
}

.login-form {
  display: grid;
  gap: 14px;
}

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

.login-form button {
  margin-top: 4px;
}

.login-error {
  margin-bottom: 14px;
  border: 1px solid rgba(196, 33, 47, 0.2);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--danger);
  background: #fff1f2;
  font-size: 13px;
}

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

  .hero-kpis {
    grid-column: 1 / -1;
  }

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

  .grid.two,
  .customer-layout {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .nav-item {
    justify-content: center;
    min-height: 38px;
    padding: 8px 6px;
    text-align: center;
  }

  .content {
    padding: 16px;
  }

  .dashboard-hero,
  .dashboard-grid,
  .hero-kpis,
  .donut-board {
    grid-template-columns: 1fr;
  }

  .dashboard-hero h2 {
    font-size: 26px;
  }

  .span-2 {
    grid-column: span 1;
  }

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

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions button {
    flex: 1 1 120px;
  }

  .metric-grid,
  .board-metrics,
  .toolbar,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid textarea {
    grid-column: auto;
  }

  .setting-item {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 90px minmax(0, 1fr) 36px;
  }
}
