:root {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Microsoft YaHei", system-ui, sans-serif;
  color: #1d1d1f;
  background: #f5f5f7;
  --bg: #f5f5f7;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-solid: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --soft: #f2f2f7;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.14);
  --brand: #0071e3;
  --brand-deep: #0057b8;
  --green: #0f766e;
  --danger: #d70015;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.08);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255,255,255,.84), rgba(245,245,247,.96) 46%, #f5f5f7),
    radial-gradient(circle at 50% -12%, rgba(0, 113, 227, .18), transparent 34%);
  -webkit-font-smoothing: antialiased;
}

button,
input { font: inherit; }

button {
  min-height: 40px;
  border: 0;
  border-radius: 980px;
  padding: 0 18px;
  color: #fff;
  background: var(--brand);
  font-weight: 700;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}

button:hover {
  background: var(--brand-deep);
  transform: translateY(-1px);
}

button.ghost {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: none;
}

button.ghost:hover {
  background: #f8f8fb;
}

.hidden { display: none !important; }
.boss-shell { min-height: 100vh; }

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(145deg, #1d1d1f, #3a3a3c);
  font-weight: 850;
  letter-spacing: -0.04em;
}

.brand-row strong,
.brand-row small {
  display: block;
}

.brand-row strong { letter-spacing: -0.02em; }
.brand-row small,
.eyebrow,
.hint,
.metric small,
.item small,
.topbar p,
td small {
  color: var(--muted);
}

.eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(360px, 430px);
  gap: 56px;
  align-items: center;
  width: min(1180px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 56px 0;
}

.login-copy {
  padding: 18px 0;
}

.hero-kicker {
  margin: 74px 0 12px;
  color: var(--brand);
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.login-copy h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(46px, 7vw, 86px);
  line-height: .98;
  letter-spacing: -0.06em;
  font-weight: 850;
}

.hero-lead {
  max-width: 620px;
  margin: 26px 0 0;
  color: var(--muted);
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.45;
  letter-spacing: -0.02em;
}

.login-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 34px;
}

.login-highlights span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 980px;
  background: rgba(255, 255, 255, .68);
  color: #424245;
  font-size: 13px;
  font-weight: 700;
}

.login-card {
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.login-card h2 {
  margin: 8px 0 22px;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: -4px 0 22px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 980px;
  background: #ececf1;
}

.auth-switch button {
  min-height: 34px;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  border-radius: 980px;
}

.auth-switch button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .08);
}

label {
  display: grid;
  gap: 8px;
  margin: 15px 0;
  color: #424245;
  font-size: 13px;
  font-weight: 750;
}

input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 0 14px;
  outline: none;
  background: rgba(255, 255, 255, .92);
}

input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, .13);
}

#auth-submit {
  width: 100%;
  margin-top: 6px;
  min-height: 46px;
}

.hint {
  min-height: 22px;
  color: var(--danger);
  font-size: 13px;
}

.auth-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

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

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

.sidebar .brand-row {
  margin-bottom: 24px;
  padding: 0 6px;
}

.nav-group {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.nav-group > span {
  padding: 0 8px;
  color: #86868b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
}

.nav,
.logout {
  width: 100%;
  justify-content: flex-start;
  min-height: 42px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  text-align: left;
  box-shadow: none;
  border-radius: 14px;
  position: relative;
}

.nav.active,
.nav:hover {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .05);
}

.nav.active::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: var(--brand);
}

.nav i {
  position: absolute;
  right: 12px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--danger);
  transform: translateY(-50%);
}

.logout {
  margin-top: auto;
  color: var(--danger);
}

.content {
  min-width: 0;
  padding: 30px 34px 42px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  min-height: 92px;
  margin-bottom: 22px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, .78);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(22px);
}

.topbar h1 {
  margin: 4px 0 4px;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: -0.045em;
}

.topbar p {
  margin: 0;
}

.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 720px;
}

.top-select,
.mini-select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 980px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  outline: none;
}

.top-actions button,
.top-actions .top-select {
  flex: 0 0 auto;
}

.panel-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.metric,
.panel,
.item,
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel-solid);
  box-shadow: var(--shadow-soft);
}

.metric {
  min-height: 136px;
  padding: 18px;
}

.metric-card {
  display: grid;
  gap: 9px;
  width: 100%;
  min-height: 174px;
  color: var(--ink);
  text-align: left;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 22px;
  cursor: pointer;
}

.metric-card:hover {
  background: #fff;
  border-color: rgba(0, 113, 227, .24);
  box-shadow: 0 18px 42px rgba(0, 113, 227, .08);
}

.metric-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.metric-top b {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.metric-top em {
  flex: 0 0 auto;
  max-width: 112px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f5f5f7;
  color: #86868b;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
}

.metric-top em[data-tone="up"] {
  color: #047857;
  background: rgba(16, 185, 129, .12);
}

.metric-top em[data-tone="down"] {
  color: #b45309;
  background: rgba(245, 158, 11, .14);
}

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

.metric strong {
  display: block;
  font-size: 36px;
  line-height: 1;
  letter-spacing: -0.05em;
}

.metric strong small {
  margin-left: 2px;
  color: var(--muted);
  font-size: 15px;
  letter-spacing: 0;
}

.metric-desc {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.metric-link {
  color: var(--brand) !important;
  font-size: 12px !important;
  font-weight: 800 !important;
}

.sparkline {
  width: 100%;
  height: 32px;
  color: rgba(0, 113, 227, .72);
}

.metric small {
  line-height: 1.5;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr);
  gap: 18px;
}

.panel {
  padding: 20px;
}

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

.panel-head h2 {
  margin: 5px 0 0;
  font-size: 21px;
  letter-spacing: -0.03em;
}

.list {
  display: grid;
  gap: 12px;
}

.item {
  padding: 16px;
  box-shadow: none;
}

.item strong,
.item small {
  display: block;
}

.item p {
  margin: 9px 0;
  color: #424245;
  line-height: 1.65;
}

.text-link {
  display: inline;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: var(--brand);
  background: transparent;
  box-shadow: none;
  font-weight: 800;
  text-align: left;
}

.text-link:hover {
  background: transparent;
  color: var(--brand-deep);
  transform: none;
}

.report-item,
.memory-item {
  display: grid;
  gap: 12px;
}

.report-head {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.report-head > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.risk-badge,
.knowledge-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-style: normal;
  font-weight: 850;
}

.risk-badge[data-risk="low"] {
  color: #047857;
  background: rgba(16, 185, 129, .12);
}

.risk-badge[data-risk="medium"] {
  color: #b45309;
  background: rgba(245, 158, 11, .16);
}

.risk-badge[data-risk="high"] {
  color: #b91c1c;
  background: rgba(239, 68, 68, .14);
}

.knowledge-tag {
  color: #1d4ed8;
  background: rgba(0, 113, 227, .10);
}

.report-stats,
.drawer-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.report-stats span,
.drawer-stats span {
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfbfd;
}

.report-stats span[data-risk="high"] {
  border-color: rgba(239, 68, 68, .24);
  background: rgba(239, 68, 68, .08);
}

.report-stats b,
.drawer-stats b {
  display: block;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.2;
}

.report-stats small,
.drawer-stats small {
  color: var(--muted);
  font-size: 11px;
}

.report-detail {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfbfd;
}

.report-detail summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.report-detail small {
  margin-top: 7px;
}

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

.item-actions button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

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

.kv-grid span {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfbfd;
}

.kv-grid b,
.kv-grid em {
  display: block;
}

.kv-grid b {
  color: var(--muted);
  font-size: 11px;
}

.kv-grid em {
  margin-top: 3px;
  color: var(--ink);
  font-size: 13px;
  font-style: normal;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.customer-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.customer-fields span,
.employee-stats span {
  display: inline-flex;
  gap: 6px;
  max-width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 980px;
  color: #424245;
  background: #f8f8fb;
  font-size: 12px;
}

.customer-fields b {
  color: var(--muted);
}

.employee-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.employee-card {
  display: grid;
  gap: 13px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.employee-card.active,
.employee-card:hover {
  border-color: rgba(0, 113, 227, .32);
  box-shadow: 0 16px 42px rgba(0, 113, 227, .10);
}

.employee-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.employee-card-head strong {
  display: block;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.employee-card p {
  margin: 0;
  color: #424245;
  line-height: 1.65;
}

.employee-pill {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 980px;
  color: var(--brand);
  background: rgba(0, 113, 227, .10);
  font-size: 12px;
  font-weight: 850;
}

.employee-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.employee-stats b {
  color: var(--ink);
  font-size: 16px;
}

.employee-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.employee-actions button {
  min-height: 36px;
  padding: 0 13px;
  font-size: 13px;
}

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

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

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

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

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

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

td strong,
td small {
  display: block;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  padding: 13px 16px;
  border-radius: 16px;
  color: #fff;
  background: #1d1d1f;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
}

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

.toast[data-type="error"] {
  background: var(--danger);
}

.employee-drawer[hidden] {
  display: none !important;
}

.employee-drawer {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .18);
  backdrop-filter: blur(3px);
}

.drawer-panel {
  position: absolute;
  top: 18px;
  right: 18px;
  bottom: 18px;
  width: min(520px, calc(100vw - 36px));
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 26px 80px rgba(0, 0, 0, .18);
  backdrop-filter: blur(22px);
}

.drawer-panel h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.04em;
}

.drawer-panel h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.drawer-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  color: var(--ink);
  background: #f5f5f7;
}

.drawer-section {
  display: grid;
  gap: 10px;
}

@media (max-width: 1080px) {
  .login-view {
    grid-template-columns: 1fr;
    gap: 30px;
  }
  .hero-kicker {
    margin-top: 42px;
  }
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .split-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .login-view {
    width: min(100vw - 24px, 520px);
    padding: 26px 0;
  }
  .login-card {
    padding: 24px;
    border-radius: 22px;
  }
  .dashboard {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
  }
  .metrics {
    grid-template-columns: 1fr;
  }
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .report-stats,
  .drawer-stats,
  .kv-grid {
    grid-template-columns: 1fr;
  }
  .content {
    padding: 18px 14px 30px;
  }
}
