:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #18212f;
  --muted: #6c7688;
  --line: #dfe5ef;
  --blue: #2563eb;
  --cyan: #0891b2;
  --green: #059669;
  --amber: #d97706;
  --red: #dc2626;
  --violet: #7c3aed;
  --shadow: 0 18px 40px rgba(24, 33, 47, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(10, 18, 32, 0.82), rgba(10, 18, 32, 0.42) 44%, rgba(10, 18, 32, 0.2)),
    url("/static/assets/login-bg.jpg") center / cover no-repeat,
    var(--bg);
}

.login-hero {
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  align-items: center;
  gap: 48px;
}

.login-copy {
  color: #ffffff;
  padding: 20px;
}

.login-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.12);
  color: #dbeafe;
  font-weight: 700;
}

.login-copy h1 {
  max-width: 720px;
  margin: 18px 0 0;
  font-size: 46px;
  line-height: 1.12;
  letter-spacing: 0;
}

.login-copy p {
  max-width: 620px;
  margin: 16px 0 0;
  color: #dbe4f0;
  font-size: 16px;
  line-height: 1.8;
}

.login-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.login-pills span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 13px;
  background: rgba(255, 255, 255, 0.14);
  color: #eef6ff;
  backdrop-filter: blur(10px);
}

.login-box {
  width: min(430px, 100%);
  padding: 30px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(3, 10, 24, 0.28);
  backdrop-filter: blur(18px);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #111827;
  color: #ffffff;
  font-weight: 800;
}

.login-brand h1,
.login-brand h2,
.title h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.login-brand p,
.title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.login-submit {
  width: 100%;
  margin-top: 6px;
  background: linear-gradient(135deg, #2563eb, #0f766e);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px 18px;
  background: linear-gradient(180deg, #111827, #172033 72%, #0f172a);
  color: #f8fafc;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px;
}

.brand .brand-mark {
  background: #f8fafc;
  color: #111827;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand span {
  display: block;
  color: #a9b4c5;
  font-size: 12px;
  margin-top: 3px;
}

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

.nav button {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  padding: 0 12px;
  color: #cbd5e1;
  background: transparent;
  text-align: left;
}

.nav button.active,
.nav button:hover {
  color: #ffffff;
  background: #253044;
}

.nav-icon,
.btn-icon,
.metric-icon,
.event-dot {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

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

.sidebar-card span {
  color: #a9b4c5;
  font-size: 12px;
}

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

.sidebar-user {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 14px;
  display: grid;
  gap: 8px;
}

.sidebar-user strong {
  font-size: 14px;
}

.sidebar-user span {
  color: #a9b4c5;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 251, 0.94);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 5;
}

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

.search {
  width: min(360px, 32vw);
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel);
}

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

.content {
  min-width: 0;
  padding: 22px 26px 30px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.primary,
.ghost,
.icon-btn,
.btn {
  min-height: 40px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  padding: 0 14px;
}

.primary {
  background: linear-gradient(135deg, var(--blue), #1d4ed8);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

.primary.danger,
.danger {
  background: var(--red);
  color: #ffffff;
}

.ghost,
.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.ghost:hover,
.btn:hover,
.icon-btn:hover {
  border-color: rgba(37, 99, 235, 0.32);
  box-shadow: 0 8px 20px rgba(24, 33, 47, 0.08);
}

.icon-btn {
  width: 40px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

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

.metric {
  min-height: 128px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 16px;
  box-shadow: 0 12px 28px rgba(24, 33, 47, 0.05);
  position: relative;
  overflow: hidden;
}

.metric::after {
  content: "";
  position: absolute;
  inset: auto -30px -42px auto;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.08);
}

.metric-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.metric-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: #ffffff;
}

.metric-value {
  margin-top: 18px;
  font-size: 27px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.metric-foot {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.75fr);
  gap: 16px;
  align-items: start;
}

.layout > *,
.detail-layout > *,
.report-grid > *,
.field-grid > *,
.credit-kpis > *,
.credit-summary > *,
.form > * {
  min-width: 0;
}

.panel {
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 12px 26px rgba(24, 33, 47, 0.05);
}

.panel-head {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
}

.panel-body {
  padding: 16px;
}

.table-wrap {
  overflow: auto;
}

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

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

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

td.wrap {
  white-space: normal;
  min-width: 180px;
}

tr[data-id] {
  cursor: pointer;
}

tr[data-id]:hover,
tr.selected {
  background: #f8fbff;
}

.person {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.person strong {
  display: block;
}

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

.tag,
.stage,
.risk,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
  background: #eef2ff;
  color: #34404a;
}

.stage {
  background: #eef6ff;
  color: #1d4ed8;
}

.risk.low,
.badge.ok,
.badge.counted {
  background: #dcfce7;
  color: #166534;
}

.risk.mid,
.badge.review {
  background: #fef3c7;
  color: #92400e;
}

.risk.high,
.badge.stop {
  background: #fee2e2;
  color: #991b1b;
}

.money {
  font-weight: 800;
  color: #0f766e;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.segmented button {
  height: 34px;
  padding: 0 11px;
  color: var(--muted);
  background: transparent;
  border-right: 1px solid var(--line);
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: #eaf1ff;
  color: var(--blue);
}

.mini-input,
.filters select,
.field input,
.field select,
.field textarea,
.upload-strip select,
.upload-strip input,
.form input,
.form select,
.form textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 8px 10px;
  outline: none;
}

.mini-input {
  width: 150px;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.mini-input:focus,
.filters select:focus,
.upload-strip select:focus,
.upload-strip input:focus,
.search:focus-within,
.form input:focus,
.form select:focus,
.form textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
  min-width: 0;
}

.profile {
  padding: 16px;
  min-width: 0;
  max-width: 100%;
}

.profile-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.profile-top h3 {
  margin: 0;
  font-size: 22px;
}

.profile-top p {
  margin: 5px 0 0;
  color: var(--muted);
}

.profile-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  min-width: 0;
}

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

.field-card,
.query-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 12px;
}

.field-card span,
.query-card span,
.field label {
  color: var(--muted);
  font-size: 13px;
}

.field-card strong,
.query-card strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  min-width: 0;
}

.score-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
}

.score-line {
  height: 9px;
  overflow: hidden;
  border-radius: 99px;
  background: #e5e7eb;
  margin-top: 10px;
}

.score-line b {
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.timeline,
.file-list,
.task-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.event,
.doc-row,
.task {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
  transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.event:hover,
.doc-row:hover,
.task:hover,
.kanban-card:hover {
  border-color: rgba(37, 99, 235, 0.32);
  box-shadow: 0 10px 22px rgba(24, 33, 47, 0.06);
}

.event-dot,
.file-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #eef6ff;
  color: var(--blue);
  font-weight: 800;
}

.event strong,
.doc-row strong,
.task strong {
  display: block;
}

.event span,
.doc-row span,
.task span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.docs-panel {
  padding: 16px;
}

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

.query-card strong {
  font-size: 22px;
}

.upload-strip {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: 10px;
  margin: 12px 0;
  align-items: center;
}

.status-line {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.detail-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 12px 0;
}

.detail-table-wrap table {
  min-width: 920px;
}

.detail-table-wrap tfoot td {
  background: #f8fafc;
  font-weight: 800;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: 12px;
  overflow: auto;
  padding: 16px;
}

.lane {
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.lane-title {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 10px;
}

.kanban-card {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
}

.kanban-card:hover {
  border-color: var(--blue);
}

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.bars {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.bar-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 80px;
  gap: 10px;
  align-items: center;
}

.bar {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.bar b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.empty {
  padding: 34px 16px;
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 8px;
  background: #202b34;
  color: #ffffff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  z-index: 40;
}

.modal-layer {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(18, 31, 47, 0.45);
  z-index: 30;
}

.modal {
  width: min(780px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.compact-modal {
  width: min(620px, 100%);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
  font-size: 18px;
}

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

.form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
}

.form textarea {
  min-height: 90px;
  resize: vertical;
}

.wide {
  grid-column: 1 / -1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 16px 16px;
}

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

  .login-box {
    margin: 0 auto;
  }

  .login-copy h1 {
    font-size: 38px;
  }

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

  .layout,
  .detail-layout,
  .report-grid {
    grid-template-columns: minmax(0, 1fr);
  }

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

@media (max-width: 860px) {
  .app {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .sidebar {
    padding: 18px 12px;
    align-items: center;
  }

  .brand div:not(.brand-mark),
  .nav span,
  .sidebar-card,
  .sidebar-user span {
    display: none;
  }

  .sidebar-user {
    width: 48px;
  }

  .sidebar-user .ghost {
    width: 48px;
    min-height: 36px;
    padding: 0;
    font-size: 0;
  }

  .sidebar-user .ghost::before {
    font-size: 13px;
    font-weight: 800;
  }

  .sidebar-user .ghost[data-action="change-password"]::before {
    content: "密";
  }

  .sidebar-user .ghost[data-action="logout"]::before {
    content: "退";
  }

  .nav button {
    width: 48px;
    justify-content: center;
    padding: 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
  }

  .top-actions,
  .search {
    width: 100%;
  }

  .content {
    padding: 14px;
  }

  .table-wrap {
    overflow: visible;
  }

  .table-wrap table {
    min-width: 0;
    display: block;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tbody {
    display: grid;
    gap: 10px;
    padding: 12px;
  }

  .table-wrap tr[data-action] {
    display: grid;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #ffffff;
    box-shadow: 0 8px 18px rgba(24, 33, 47, 0.04);
  }

  .table-wrap td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0;
    border: 0;
    white-space: normal;
    text-align: right;
  }

  .table-wrap td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    flex: 0 0 auto;
  }

  .table-wrap td:first-child {
    display: block;
    text-align: left;
  }

  .table-wrap td:first-child::before {
    display: none;
  }

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

  .detail-table-wrap table {
    min-width: 920px;
    display: table;
  }

  .detail-table-wrap thead {
    display: table-header-group;
  }

  .detail-table-wrap tbody {
    display: table-row-group;
    padding: 0;
  }

  .detail-table-wrap tr {
    display: table-row;
    box-shadow: none;
  }

  .detail-table-wrap td,
  .detail-table-wrap th {
    display: table-cell;
    padding: 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
  }

  .detail-table-wrap td::before {
    content: none;
  }
}

@media (max-width: 640px) {
  .login-page {
    padding: 14px;
  }

  .login-copy {
    padding: 4px;
  }

  .login-copy h1 {
    font-size: 30px;
  }

  .login-copy p {
    font-size: 14px;
  }

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

  .sidebar {
    position: static;
    height: auto;
    align-items: stretch;
  }

  .brand div:not(.brand-mark),
  .nav span,
  .sidebar-user span {
    display: block;
  }

  .sidebar-user {
    width: auto;
  }

  .sidebar-user .ghost {
    width: auto;
    padding: 0 14px;
    font-size: 14px;
  }

  .sidebar-user .ghost::before {
    content: none;
  }

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

  .nav button {
    width: auto;
    padding: 0 10px;
    justify-content: flex-start;
  }

  .metrics,
  .field-grid,
  .credit-kpis,
  .credit-summary,
  .form,
  .upload-strip {
    grid-template-columns: minmax(0, 1fr);
  }

  .mini-input {
    width: 100%;
  }

  .profile-top {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .profile-actions {
    width: 100%;
    margin-left: 0;
  }

  .profile-actions .ghost,
  .profile-actions .primary {
    flex: 1 1 96px;
  }
}
