:root {
  --shell-bg: #f5f7fb;
  --nav-bg: #001529;
  --border: #eef0f5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--shell-bg);
  color: rgba(0, 0, 0, 0.88);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

.admin-layout {
  min-height: 100vh;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #f5f7fb 0%, #e6f4ff 52%, #f6ffed 100%);
}

.login-panel {
  width: min(440px, 100%);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(0, 21, 41, 0.12);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  color: rgba(0, 0, 0, 0.88);
}

.login-brand .brand-subtitle {
  color: rgba(0, 0, 0, 0.45);
}

.login-hint {
  margin: 18px 0;
}

.brand {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #1677ff;
  font-weight: 700;
}

.brand-title {
  font-weight: 700;
  line-height: 18px;
}

.brand-subtitle {
  color: rgba(255, 255, 255, 0.58);
  font-size: 12px;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.workspace {
  padding: 16px 20px 28px;
}

.page-card {
  margin-bottom: 16px;
  border-radius: 8px;
}

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

.page-title h2 {
  margin: 0 0 4px;
  font-size: 22px;
}

.muted {
  color: rgba(0, 0, 0, 0.45);
}

.filter-card .ant-form-item {
  margin-bottom: 0;
}

.metric-row {
  margin-bottom: 16px;
}

.metric-card {
  min-height: 106px;
}

.metric-card .ant-statistic-title {
  margin-bottom: 6px;
}

.customer-shell {
  display: grid;
  grid-template-columns: minmax(330px, 390px) minmax(0, 1fr);
  gap: 16px;
}

.customer-list {
  max-height: calc(100vh - 272px);
  overflow: auto;
}

.customer-hit {
  width: 100%;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid #d9d9d9;
  border-radius: 8px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.customer-hit.active,
.customer-hit:hover {
  border-color: #1677ff;
  background: #e6f4ff;
}

.customer-hit strong,
.customer-hit span,
.customer-hit small {
  display: block;
}

.customer-hit span {
  margin-top: 4px;
}

.customer-hit small {
  margin-top: 4px;
  color: rgba(0, 0, 0, 0.45);
}

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

.recent-customer {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.recent-customer:hover {
  border-color: #1677ff;
  background: #f7fbff;
}

.recent-customer strong,
.recent-customer span,
.recent-customer small {
  display: block;
}

.recent-customer small {
  margin-top: 4px;
  color: rgba(0, 0, 0, 0.45);
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.account-card {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafafa;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.account-card:hover,
.account-card.active {
  border-color: #1677ff;
  background: #f7fbff;
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.08);
}

.account-card h4 {
  margin: 0 0 8px;
}

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

.story-card {
  min-height: 116px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafafa;
}

.story-card label {
  display: block;
  margin-bottom: 8px;
  color: rgba(0, 0, 0, 0.45);
  font-size: 12px;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  padding: 10px 12px;
  border-left: 3px solid #1677ff;
  border-radius: 6px;
  background: #f7fbff;
}

.timeline-item b,
.timeline-item span,
.timeline-item small {
  display: block;
}

.timeline-item span,
.timeline-item small {
  color: rgba(0, 0, 0, 0.55);
}

.source-note {
  margin-bottom: 16px;
}

.inline-detail {
  margin-top: 16px;
  border-color: #91caff;
}

.loan-stack {
  display: grid;
  gap: 16px;
}

.loan-instrument-card {
  border-color: #d6e4ff;
}

.auth-card-grid {
  display: grid;
  gap: 12px;
}

.auth-photo {
  width: 180px;
  height: 116px;
  display: grid;
  place-items: center;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #1677ff;
  background: linear-gradient(135deg, #e6f4ff, #f6ffed);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.upload-summary-list {
  display: grid;
  gap: 6px;
}

.upload-summary-item {
  min-width: 180px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f8fafc;
}

.upload-summary-preview,
.upload-summary-preview img,
.upload-summary-preview-unavailable {
  display: block;
  width: 140px;
  height: 94px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.upload-summary-preview img {
  object-fit: cover;
}

.upload-summary-preview-unavailable {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: 1px dashed #b7c7db;
  background: #edf3fa;
  color: rgba(0, 0, 0, 0.45);
  font-size: 12px;
  text-align: center;
}

.upload-summary-item span,
.upload-summary-item small {
  display: block;
  word-break: break-word;
}

.upload-summary-item span {
  color: rgba(0, 0, 0, 0.88);
  font-weight: 600;
}

.upload-summary-item small {
  color: rgba(0, 0, 0, 0.45);
  margin-top: 2px;
}

.store-editor-modal .ant-upload-wrapper .ant-upload-list-picture-card .ant-upload-list-item-container,
.store-editor-modal .ant-upload-wrapper.ant-upload-picture-card-wrapper .ant-upload.ant-upload-select,
.ant-modal .ant-upload-wrapper .ant-upload-list-picture-card .ant-upload-list-item-container,
.ant-modal .ant-upload-wrapper.ant-upload-picture-card-wrapper .ant-upload.ant-upload-select {
  width: 118px;
  height: 96px;
}

.ant-tabs-card > .ant-tabs-nav .ant-tabs-tab {
  border-radius: 8px 8px 0 0;
}

.ant-layout-sider {
  background: var(--nav-bg) !important;
}

.ant-modal-root .ant-modal-mask {
  z-index: 3000 !important;
}

.ant-modal-root .ant-modal-wrap {
  z-index: 3001 !important;
}

.ant-modal .ant-modal-content {
  background: #fff !important;
}

.ant-select-dropdown {
  z-index: 4000 !important;
}

.store-editor-modal .ant-modal-body {
  max-height: 68vh;
  overflow-y: auto;
  padding-right: 6px;
}

.store-editor-modal .ant-divider {
  margin: 12px 0 16px;
  color: rgba(0, 0, 0, 0.65);
  font-size: 14px;
}

@media (max-width: 1180px) {
  .customer-shell,
  .account-grid,
  .story-grid,
  .auth-card-grid {
    grid-template-columns: 1fr;
  }

  .customer-list {
    max-height: none;
  }
}

.relationship-tree-node {
  display: flex;
  min-width: 0;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 8px;
}

.relationship-tree-node > .ant-typography {
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ant-tree .ant-tree-node-content-wrapper {
  min-height: 40px;
  padding: 0 4px;
}

@media (max-width: 760px) {
  .ant-layout-sider {
    flex: 0 0 124px !important;
    width: 124px !important;
    min-width: 124px !important;
    max-width: 124px !important;
  }

  .brand {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    padding: 10px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
  }

  .brand-title {
    font-size: 13px;
  }

  .brand-subtitle {
    font-size: 11px;
  }

  .ant-menu-inline .ant-menu-item,
  .ant-menu-inline .ant-menu-submenu-title {
    width: calc(100% - 8px);
    margin-inline: 4px;
    padding-left: 12px !important;
    padding-right: 8px !important;
    font-size: 12px;
  }

  .ant-menu-item-group-title {
    padding-inline: 8px !important;
    font-size: 11px;
  }

  .topbar {
    height: auto;
    align-items: stretch;
    flex-direction: column;
    padding: 12px;
  }

  .workspace {
    padding: 12px;
  }

  .page-title {
    flex-direction: column;
  }

  .ant-modal {
    width: calc(100vw - 32px) !important;
    max-width: calc(100vw - 32px);
    margin: 12px auto;
  }

  .ant-modal .ant-modal-content {
    padding: 16px;
  }

  .ant-modal .ant-modal-body {
    max-height: 68vh;
    overflow-y: auto;
  }
}
