:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f8f9fb;
  --surface-muted: #f2f4f7;
  --ink: #171a20;
  --muted: #626b79;
  --subtle: #9198a3;
  --line: #e7eaf0;
  --line-strong: #d8dde6;
  --brand: #007aff;
  --brand-strong: #0066d6;
  --brand-soft: #eef6ff;
  --funnel-fill: #a9cbe8;
  --funnel-fill-soft: #cfe2f3;
  --funnel-track: #eef2f6;
  --accent: #c94b57;
  --accent-soft: #fff1f2;
  --success: #237a57;
  --warning: #9a6a1f;
  --danger: #bd3d3d;
  --radius: 8px;
  --shadow: 0 12px 28px rgba(22, 28, 38, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1120px;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.is-hidden {
  display: none !important;
}

.login-screen {
  display: grid;
  grid-template-columns: minmax(560px, 1fr) 440px;
  gap: 44px;
  align-items: center;
  min-height: 100vh;
  padding: 56px;
  background: linear-gradient(135deg, #fbfcfd 0%, #f4f6f8 54%, #f7f1f2 100%);
}

.login-visual {
  position: relative;
  min-height: 620px;
  padding: 36px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(22, 28, 38, 0.08);
}

.login-visual::after {
  position: absolute;
  right: 34px;
  bottom: 34px;
  width: 240px;
  height: 250px;
  background: url("./assets/miaonian-logo.png") center / contain no-repeat;
  content: "";
  opacity: 0.08;
  pointer-events: none;
}

.login-brand,
.brand,
.topbar-actions,
.toolbar,
.filter-group,
.segmented,
.panel-head,
.row-actions,
.entity,
.login-card-head,
.login-options,
.funnel-meta,
.bar-meta,
.task-item,
.compact-item,
.audit-item,
.admin-item {
  display: flex;
  align-items: center;
}

.login-brand,
.brand {
  gap: 12px;
}

.login-brand img,
.login-card-head img,
.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 10px 24px rgba(22, 28, 38, 0.08);
}

.login-brand img,
.login-card-head img {
  display: block;
  padding: 4px;
  object-fit: contain;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 16px;
}

.brand-mark img {
  display: block;
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  margin: 4px;
  object-fit: contain;
}

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

.login-brand strong,
.brand strong {
  font-size: 16px;
}

.login-brand span,
.brand span,
.eyebrow,
.panel p,
.section-head p,
.sidebar-card p,
.login-card p,
.login-copy p {
  color: var(--muted);
}

.login-copy {
  max-width: 680px;
  margin-top: 122px;
}

.login-copy h1 {
  max-width: 620px;
  margin: 0 0 18px;
  font-size: 58px;
  line-height: 1.08;
  letter-spacing: 0;
}

.login-copy p {
  max-width: 520px;
  margin: 0;
  font-size: 18px;
  line-height: 1.7;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-funnel-card {
  position: absolute;
  left: 34px;
  bottom: 34px;
  width: 360px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.login-funnel-card span,
.metric-card span,
.mini-panel span,
.compact-item span,
.admin-item span,
.audit-item span,
.task-item span {
  color: var(--muted);
  font-size: 13px;
}

.login-funnel-card strong {
  display: block;
  margin-top: 6px;
}

.mini-funnel {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.mini-funnel i {
  display: block;
  height: 10px;
  border-radius: 999px;
  background: var(--funnel-fill);
}

.login-card {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 22px 54px rgba(22, 28, 38, 0.1);
}

.login-card-head {
  gap: 14px;
  margin-bottom: 28px;
}

.login-card h2 {
  margin: 0 0 6px;
  font-size: 26px;
}

.login-card p {
  margin: 0;
  line-height: 1.6;
}

.form-field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

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

.form-field input,
.totp-card input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: var(--surface);
  color: var(--ink);
}

.form-field input:focus,
.totp-card input:focus,
.search input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(49, 95, 143, 0.12);
}

.login-options {
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 22px;
  color: var(--muted);
  font-size: 13px;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--brand);
}

.login-submit {
  width: 100%;
  min-height: 48px;
}

.login-hint {
  margin-top: 14px !important;
  color: var(--subtle) !important;
  font-size: 12px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100vh;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
}

.nav-list {
  display: grid;
  gap: 6px;
  overflow-y: auto;
  padding-right: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-item.child {
  margin-left: 30px;
  width: calc(100% - 30px);
  min-height: 36px;
  font-size: 13px;
}

.nav-item.group {
  margin-top: 8px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 800;
  cursor: default;
}

.nav-item.active,
.nav-item:not(.group):hover {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  font-weight: 700;
}

.sidebar-card {
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.sidebar-card strong {
  display: block;
  margin-bottom: 8px;
}

.sidebar-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
}

.main {
  padding: 28px;
}

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

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

h1 {
  margin-bottom: 0;
  font-size: 32px;
  line-height: 1.18;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 6px;
  font-size: 24px;
}

h3 {
  margin-bottom: 4px;
  font-size: 17px;
}

.topbar-actions {
  justify-content: flex-end;
  gap: 10px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 340px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--subtle);
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.icon-button,
.primary-button,
.ghost-button,
.danger-button,
.chip,
.segmented button,
.admin-badge {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  font-size: 18px;
}

.primary-button,
.danger-button,
.ghost-button {
  padding: 0 18px;
  font-weight: 700;
}

.primary-button {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

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

.danger-button {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.ghost-button {
  background: var(--surface);
}

.ghost-button:hover,
.icon-button:hover {
  background: var(--surface-soft);
}

.chip,
.segmented button {
  padding: 0 14px;
  color: var(--muted);
}

.chip.active,
.segmented button.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
}

.admin-badge {
  gap: 8px;
  padding: 0 14px;
  box-shadow: none;
}

.admin-badge span,
.admin-badge strong {
  display: block;
}

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

.view {
  display: block;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.section-head p {
  margin-bottom: 0;
}

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

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

.metric-card {
  padding: 18px;
}

.metric-card strong {
  display: block;
  margin: 10px 0 6px;
  font-size: 26px;
  letter-spacing: 0;
}

.metric-card em,
.mini-panel em {
  color: var(--success);
  font-style: normal;
  font-size: 13px;
}

.content-grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.two-column {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
}

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

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

.panel {
  padding: 18px;
}

.panel-head {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-head p {
  margin-bottom: 0;
  font-size: 13px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status.positive,
.status.normal,
.status.success,
.status.enabled {
  background: #edf7f2;
  color: var(--success);
}

.status.warning,
.status.review,
.status.pending {
  background: #fff7e8;
  color: var(--warning);
}

.status.danger,
.status.risk,
.status.reported,
.status.failed,
.status.disabled {
  background: #fff0f0;
  color: var(--danger);
}

.funnel,
.agent-bars,
.compact-list,
.audit-list,
.permission-matrix,
.event-list,
.timeline {
  display: grid;
  gap: 12px;
}

.funnel-row,
.bar-row {
  display: grid;
  gap: 7px;
}

.funnel-meta,
.bar-meta,
.task-item,
.compact-item,
.audit-item,
.admin-item {
  justify-content: space-between;
  gap: 14px;
}

.funnel-meta strong,
.bar-meta strong {
  font-weight: 650;
}

.funnel-meta span,
.bar-meta span {
  color: var(--muted);
  font-size: 13px;
}

.track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--funnel-track);
}

.fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--funnel-fill-soft), var(--funnel-fill));
}

.task-list {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.task-item,
.compact-item,
.audit-item,
.admin-item,
.event-item,
.timeline-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.compact-item,
.admin-item,
.audit-item {
  width: 100%;
  text-align: left;
}

.compact-item div,
.admin-item div,
.audit-item div,
.event-item div,
.timeline-item div {
  min-width: 0;
}

.compact-item strong,
.admin-item strong,
.audit-item strong,
.event-item strong,
.timeline-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.table-panel {
  padding: 0;
  overflow: hidden;
}

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

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

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

td {
  font-size: 14px;
}

tr:last-child td {
  border-bottom: 0;
}

.entity {
  gap: 10px;
  min-width: 0;
}

.avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 800;
}

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

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

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.mini-panel {
  display: grid;
  gap: 8px;
}

.mini-panel strong {
  font-size: 24px;
}

.permission-row {
  display: grid;
  grid-template-columns: 120px repeat(7, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
}

.permission-row strong,
.permission-cell {
  min-height: 36px;
  padding: 8px;
  border-radius: 10px;
  background: var(--surface-soft);
  text-align: center;
  font-size: 12px;
}

.permission-cell.enabled {
  background: #edf7f2;
  color: var(--success);
  font-weight: 800;
}

.step-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.step-card strong {
  display: block;
  margin-bottom: 8px;
}

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

.drawer,
.totp-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 20;
  background: rgba(18, 24, 38, 0.28);
}

.drawer.open,
.totp-modal.open {
  display: flex;
}

.drawer {
  justify-content: flex-end;
}

.drawer-panel {
  position: relative;
  width: min(560px, 100%);
  height: 100%;
  padding: 28px;
  overflow-y: auto;
  background: var(--surface);
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.16);
}

.drawer-close,
.totp-close {
  position: absolute;
  top: 20px;
  right: 20px;
}

.drawer h2 {
  padding-right: 48px;
}

.detail-block {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.detail-block h3 {
  margin-bottom: 10px;
}

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

.detail-kv {
  padding: 12px;
  border-radius: 12px;
  background: var(--surface);
}

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

.totp-modal {
  align-items: center;
  justify-content: center;
}

.totp-card {
  position: relative;
  width: 390px;
  padding: 30px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 30px 90px rgba(18, 24, 38, 0.22);
  text-align: center;
}

.totp-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-size: 24px;
  font-weight: 900;
}

.totp-card input {
  margin: 14px 0;
  text-align: center;
  font-size: 22px;
  letter-spacing: 0.18em;
}

@media (max-width: 1180px) {
  .metric-grid,
  .stats-row,
  .three-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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