:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #0f1b2d;
  --muted: #66758d;
  --line: #dde3ed;
  --nav: #151a23;
  --yellow: #f7c948;
  --yellow-soft: #fff6d8;
  --green: #0f9f6e;
  --red: #d64545;
  --blue: #2f6fed;
  --shadow: 0 18px 50px rgba(22, 28, 45, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Inter", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.research-group-link {
  color: #1266b0;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.research-group-link:hover,
.research-group-link:focus-visible { color: #084b87; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #151a23 0%, #212838 55%, #fff3c4 55%, #f8d661 100%);
}
.login-card {
  width: min(390px, calc(100vw - 32px));
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--yellow);
  display: grid;
  place-items: center;
  font-weight: 900;
}
.brand-logo {
  width: 128px;
  max-width: 100%;
  display: block;
}
.brand-logo-mark {
  width: 44px;
  height: 44px;
  object-fit: contain;
  display: block;
}
.brand-logo-plate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  padding: 0;
  border: 0;
}
.brand h1 { margin: 0; font-size: 20px; line-height: 1.15; }
.brand p { margin: 3px 0 0; color: var(--muted); }
.field { display: grid; gap: 5px; margin-bottom: 8px; }
.field label { font-weight: 700; font-size: 12px; }
.input, .select, .textarea {
  width: 100%;
  border: 1px solid #cfd7e3;
  background: #fff;
  border-radius: 6px;
  min-height: 34px;
  padding: 6px 10px;
  outline: none;
}
.textarea { min-height: 64px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(247, 201, 72, .22); }
.primary, .ghost, .danger, .small, .admin-action, .admin-danger {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 32px;
  padding: 6px 12px;
  font-weight: 800;
}
.primary { background: var(--yellow); color: #201600; }
.ghost { background: #fff; border-color: #cfd7e3; color: var(--ink); }
.danger { background: #fff1f0; border-color: #ffccc7; color: #b42318; }
.small { min-height: 28px; padding: 4px 9px; font-size: 12px; background: #fff; border-color: #cfd7e3; }
.admin-action {
  background: #eef6ff;
  border-color: #7db7ff;
  color: #075985;
}
.admin-danger {
  background: #fff0f6;
  border-color: #ff9ac2;
  color: #9f1239;
}
.admin-action:hover, .admin-danger:hover {
  filter: saturate(1.08);
}
.error { color: var(--red); min-height: 18px; font-size: 12px; }

.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side {
  background: var(--nav);
  color: #fff;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.side .brand { margin-bottom: 28px; }
.side .brand p { color: #c9d3e1; }
.menu { display: grid; gap: 5px; }
.menu button {
  text-align: left;
  border: 0;
  color: #eef4ff;
  background: transparent;
  border-radius: 7px;
  padding: 9px 12px;
  font-size: 14px;
}
.menu button.active { background: var(--yellow); color: #221800; font-weight: 900; }
.side-logout {
  margin-top: auto;
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(207, 215, 227, .38);
  border-radius: 7px;
  background: rgba(255, 255, 255, .06);
  color: #eef4ff;
  font-weight: 900;
  cursor: pointer;
}
.side-logout:hover { background: rgba(255, 255, 255, .12); }
.main { min-width: 0; }
.top {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.top h2 { margin: 0; font-size: 20px; line-height: 1.15; }
.top p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.content { padding: 18px 24px 42px; display: grid; gap: 12px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-select { max-width: 150px; }
.request-status-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.quick-filter-btn {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}
.quick-filter-btn.active {
  border-color: #d8a500;
  background: var(--yellow);
  color: #111827;
}
.overview-wrap {
  width: min(100%, 1360px);
  margin: 0 auto;
  display: grid;
  gap: 14px;
}
.is-loading .content { opacity: .96; }
.loading-line {
  height: 3px;
  border-radius: 999px;
  overflow: hidden;
  background: #fff5cf;
  position: relative;
}
.loading-line::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 42%;
  background: var(--yellow);
  animation: loading-slide 1s ease-in-out infinite;
}
.loading-card {
  display: flex;
  align-items: center;
  gap: 10px;
}
.loading-card p { margin: 2px 0 0; }
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #f3d47b;
  border-top-color: #9a6400;
  animation: spin .75s linear infinite;
  flex: 0 0 auto;
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
}
.skeleton {
  height: 64px;
  border-radius: 7px;
  background: linear-gradient(90deg, #eef2f7 0%, #fff8df 45%, #eef2f7 90%);
  background-size: 220% 100%;
  animation: skeleton 1.2s ease-in-out infinite;
  border: 1px solid var(--line);
}
@keyframes loading-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(240%); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes skeleton {
  0% { background-position: 120% 0; }
  100% { background-position: -120% 0; }
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.card-head h3 { margin: 0; font-size: 17px; }
.card-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.card-body { padding: 12px 16px; }
.overview-year-card {
  box-shadow: 0 10px 28px rgba(22, 28, 45, .05);
}
.overview-year-card .card-head { padding: 12px 16px; }
.overview-year-card .card-head h3 { font-size: 16px; }
.overview-year-card .card-head p { font-size: 12px; margin-top: 2px; }
.overview-year-card .card-body { padding: 12px 16px; }
.grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 10px; }
.overview-month-grid { gap: 12px; }
.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--yellow);
  border-radius: 7px;
  padding: 11px 14px;
}
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 5px; font-size: 20px; line-height: 1.18; }
.cost-management-page .cost-toolbar .select {
  flex: 1 1 320px;
  min-width: 220px;
}
.cost-management-page .card-body {
  display: grid;
  gap: 14px;
}
.cost-management-page .cost-setting-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: stretch;
}
.cost-management-page .cost-setting-grid .field {
  margin: 0;
  padding: 10px 12px;
  min-height: 74px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--yellow);
  border-radius: 7px;
  background: #fff;
}
.cost-management-page .cost-setting-grid .field label {
  color: #344256;
  font-size: 12px;
  font-weight: 800;
}
.cost-management-page .cost-setting-grid .readonly-box {
  min-height: 32px;
  display: flex;
  align-items: center;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
}
.cost-management-page .cost-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
}
.cost-management-page .cost-tabs .tab {
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid #cfd7e3;
  border-radius: 999px;
  background: #fff;
  color: #344256;
  font-weight: 800;
}
.cost-management-page .cost-tabs .tab.active {
  border-color: #86c232;
  background: #f0ffe2;
  color: #2f6f0d;
}
.cost-management-page .cost-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.cost-management-page .cost-summary-grid .cost-metric {
  min-width: 0;
  min-height: 86px;
}
.cost-management-page .cost-summary-grid .cost-metric strong {
  font-size: clamp(18px, 1.45vw, 27px);
  overflow-wrap: anywhere;
}
.metric-hero {
  min-height: 92px;
  display: grid;
  place-items: center;
  text-align: center;
  border-left-width: 0;
  border-top: 3px solid var(--yellow);
  background: linear-gradient(90deg, #fffdf3 0%, #ffffff 46%, #f7fff9 100%);
  padding: 16px 18px;
}
.metric-hero span {
  font-size: 13px;
  font-weight: 800;
}
.metric-hero strong {
  margin-top: 6px;
  font-size: 34px;
  letter-spacing: 0;
}
@media (max-width: 1420px) {
  .cost-management-page .cost-summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  }
}
@media (max-width: 920px) {
  .cost-management-page .cost-setting-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f8fafc; font-size: 12px; color: #344256; }
.partner-sub-row td {
  padding: 0 10px 10px;
  background: #fffdf5;
  white-space: normal;
}
.partner-sub-list { display: grid; gap: 8px; }
.partner-sub-item {
  display: grid;
  grid-template-columns: minmax(150px, 1.2fr) minmax(110px, .8fr) minmax(100px, .8fr) minmax(130px, .9fr) auto auto auto minmax(170px, 1fr);
  gap: 8px 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid #f3d47b;
  border-radius: 7px;
  background: #fffaf0;
}
.partner-sub-item span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 2px;
}
.partner-sub-item b {
  font-size: 13px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.partner-sub-actions { justify-content: flex-end; }
.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  background: #edf2f7;
  color: #344256;
}
.tag.ok { background: #e8fff4; color: var(--green); }
.tag.warn { background: var(--yellow-soft); color: #9a6400; }
.tag.info { background: #eef6ff; color: #1769aa; }
.tag.neutral { background: #eef1f5; color: #5b6675; }
.tag.bad { background: #fff1f0; color: var(--red); }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 12px; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.hint { color: var(--muted); font-size: 12px; }
.request-row, .partner-box {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  margin-bottom: 10px;
  background: #fff;
}
.project-line {
  display: grid;
  grid-template-columns: minmax(170px, 1.4fr) minmax(120px, 1fr) minmax(120px, .9fr) minmax(130px, .9fr) minmax(130px, .8fr) 58px;
  gap: 8px 10px;
  align-items: end;
}
.project-line .field { margin-bottom: 0; }
.project-line-action { justify-items: end; }
.project-line-action .small { width: 100%; }
.partner-box { background: #fffdf5; border-color: #f3d47b; }
.partner-line {
  display: grid;
  grid-template-columns: minmax(150px, 1.15fr) minmax(110px, .85fr) minmax(110px, .8fr) minmax(120px, .85fr) minmax(100px, .7fr) minmax(112px, .75fr) minmax(112px, .75fr);
  gap: 8px 10px;
  align-items: end;
}
.partner-line .field { margin-bottom: 0; }
.partner-line .file-label { min-height: 34px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.file-label {
  display: grid;
  place-items: center;
  min-height: 46px;
  border: 1px dashed #d8aa21;
  border-radius: 7px;
  background: #fffdf2;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  min-width: 0;
}
.file-label.has-file {
  border-color: #16a34a;
  background: #effdf5;
  color: #047857;
}
.file-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-label input {
  opacity: 0;
  position: absolute;
  width: 1px;
  height: 1px;
}
.file-actions {
  display: inline-grid;
  gap: 5px;
  max-width: 100%;
  min-width: 0;
  vertical-align: top;
}
.file-actions-name {
  color: #0f766e;
  font-weight: 900;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.file-actions-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.file-preview, .file-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid #cfd7e3;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}
.file-delete-admin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid #ff9ac2;
  border-radius: 6px;
  background: #fff0f6;
  color: #9f1239;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
  cursor: pointer;
}
.file-preview:hover, .file-download:hover {
  border-color: #d8aa21;
  background: #fffdf2;
  text-decoration: none;
}
.file-link {
  color: #0f766e;
  font-weight: 800;
  text-decoration: none;
}
.file-link:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.empty { padding: 22px; text-align: center; color: var(--muted); }
.file-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.file-preview-head b {
  min-width: 0;
  overflow-wrap: anywhere;
}
.file-preview-wrap {
  display: grid;
  place-items: center;
  min-height: 220px;
  max-height: 62vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
}
.file-preview-wrap img {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
}
.file-preview-wrap iframe {
  width: 100%;
  height: 60vh;
  border: 0;
  background: #fff;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 20, .45);
  display: grid;
  place-items: center;
  z-index: 20;
  padding: 14px;
}
.modal {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 28px);
  overflow-x: hidden;
  overflow-y: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0,0,0,.22);
}
.modal .card-head { position: sticky; top: 0; background: #fff; z-index: 1; }
.detail-list { display: grid; gap: 10px; }
.detail-item {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}
.detail-attachments {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: start;
}
.detail-statuses {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.detail-cell {
  min-width: 0;
  display: grid;
  gap: 3px;
}
.detail-cell span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.detail-cell b {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
  font-size: 14px;
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .side-logout { margin-top: 12px; }
  .grid, .form-grid { grid-template-columns: 1fr; }
  .project-line { grid-template-columns: 1fr; }
  .partner-line { grid-template-columns: 1fr; }
  .partner-sub-item { grid-template-columns: 1fr; }
  .partner-sub-actions { justify-content: flex-start; }
  .project-line-action { justify-items: stretch; }
  .span-2, .span-3 { grid-column: auto; }
  .top { position: static; height: auto; padding: 18px; align-items: flex-start; gap: 14px; }
  .content { padding: 18px; }
}

.profile-customer-table,.profile-partner-table,.profile-base-table,.profile-two-line-table {
  min-width: 0 !important;
  table-layout: auto;
  font-size: 12px;
}
.profile-customer-table th,.profile-customer-table td,
.profile-partner-table th,.profile-partner-table td {
  padding: 6px 8px;
  word-break: break-all;
}

.overdue-table th, .overdue-table td,
.request-table th, .request-table td,
.pl-table th, .pl-table td,
.project-sheet-table th, .project-sheet-table td {
  white-space: nowrap;
}

.customer-card-list {
  display: grid;
  gap: 12px;
  padding: 10px;
}
.customer-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.customer-card-main {
  border-bottom: 1px solid var(--line);
}
.profile-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.profile-section-head > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.profile-section-head strong {
  color: var(--ink);
  font-size: 13px;
}
.profile-section-head span {
  color: var(--muted);
  font-size: 12px;
}
.customer-info-head {
  background: #fff;
}
.profile-count {
  border: 1px solid #ead9a0;
  border-radius: 999px;
  background: #fff9e8;
  color: #8a6200 !important;
  padding: 3px 8px;
  white-space: nowrap;
}
.invoice-title-section {
  margin: 10px;
  border: 1px solid #ebe4d4;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  overflow: hidden;
  background: #fffcf5;
}
.invoice-title-head {
  padding: 9px 10px;
  background: #fff8e5;
}
.customer-card .profile-base-table,
.customer-card .profile-sub-table {
  width: 100%;
  min-width: 0;
  table-layout: auto;
}
.customer-card th,
.customer-card td {
  padding: 8px 10px;
}
.customer-title-pick-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 8px;
  padding: 8px;
  background: #fff;
}
.customer-title-name {
  font-weight: 800;
  margin-bottom: 6px;
}
.profile-pick-option {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 7px 8px;
  border-radius: 7px;
  cursor: pointer;
}
.profile-pick-option:hover,
.profile-pick-option.is-selected {
  background: #fff7db;
}
.profile-pick-option span {
  display: grid;
  gap: 2px;
}
.profile-pick-option small {
  color: var(--muted);
}
.no-wrap {
  flex-wrap: nowrap;
  white-space: nowrap;
}
