:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --line: #e7ebf2;
  --text: #1f2a37;
  --muted: #667085;
  --brand: #07c160;
  --danger: #e5484d;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f0f7ff 0%, var(--bg) 160px);
}

.topbar {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 24px 12px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.topbar h1 { margin: 0; font-size: 24px; }

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

body.auth-locked .menu-bar,
body.auth-locked .layout,
body.auth-locked .topbar {
  display: none;
}

body:not(.auth-locked) .login-page {
  display: none !important;
}

body.auth-locked {
  overflow: hidden;
  min-height: 100vh;
}

.menu-bar {
  width: min(1600px, calc(100vw - 32px));
  margin: 0 auto 12px;
  display: flex;
  gap: 10px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 10px 2px 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, #f0f7ff 0%, var(--bg) 100%);
}

.menu-item {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
}

.menu-item.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.layout {
  width: min(1600px, calc(100vw - 32px));
  margin: 0 auto 24px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

.menu-panel { display: none; }
body[data-active-menu="dashboard"] .menu-panel[data-section="dashboard"] { display: block; }
body[data-active-menu="user"] .menu-panel[data-section="user"] { display: block; }
body[data-active-menu="service"] .menu-panel[data-section="service"] { display: block; }
body[data-active-menu="cobuild"] .menu-panel[data-section="cobuild"] { display: block; }
body[data-active-menu="config"] .menu-panel[data-section="config"] { display: block; }
.menu-panel.is-hidden { display: none !important; }
.is-hidden { display: none !important; }

.log-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 30;
}

.log-modal.is-hidden { display: none; }

.log-modal-card {
  width: min(900px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 16px;
}

.modal-card {
  width: min(980px, calc(100vw - 24px));
}

.compact-modal-card {
  width: min(840px, calc(100vw - 24px));
}

.login-page {
  min-height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(7, 193, 96, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(24, 160, 251, 0.12), transparent 32%),
    linear-gradient(180deg, #eef8ff 0%, #f6f8fb 48%, #edf6f1 100%);
}

body.auth-locked .login-page {
  display: flex;
}

.login-page-card {
  width: min(460px, calc(100vw - 24px));
  padding: 32px 28px 28px;
  border-radius: 22px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border: 1px solid rgba(231, 235, 242, 0.9);
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.16);
}

.login-page-logo {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 24px;
  display: block;
  margin-bottom: 18px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.12);
}

.login-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(7, 193, 96, 0.1);
  color: #0b8a4b;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 14px;
}

.login-title {
  margin: 0 0 8px;
  font-size: 28px;
}

.login-subtitle {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 18px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-field {
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
}

.login-field span {
  font-weight: 600;
}

.login-field .text-input {
  width: 100%;
  min-width: 0;
  height: 44px;
}

.login-actions {
  margin-top: 18px;
}

.login-actions .btn {
  min-width: 120px;
}

.login-hint {
  margin-top: 12px;
  min-height: 20px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.panel-header h2 { margin: 0; font-size: 18px; }

.auth-row,
.review-tools,
.config-tools {
  display: flex;
  gap: 10px;
  align-items: center;
}

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

.service-map-item {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid #e4ecf4;
  background: linear-gradient(180deg, #fbfdff 0%, #f4f9fd 100%);
}

.service-map-item strong {
  font-size: 15px;
}

.service-map-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.service-subsection {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #edf2f7;
}

.service-subsection:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

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

.service-subhead h3 {
  margin: 0;
  font-size: 17px;
}

.service-subtitle {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.service-subhead-inline {
  align-items: center;
}

.auth-row { margin-bottom: 8px; }

.text-input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 180px;
}

.mini-select { min-width: 120px; }
.keyword-input { min-width: 220px; }

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

.dashboard-copy-panel {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px dashed #cfe0ef;
  border-radius: 14px;
  background: linear-gradient(180deg, #fafdff 0%, #f4f9fd 100%);
}

.dashboard-copy-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.dashboard-copy-fields {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.dashboard-card,
.dashboard-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
}

.dashboard-card {
  padding: 16px;
  min-height: 116px;
}

.dashboard-card-label {
  color: var(--muted);
  font-size: 13px;
}

.dashboard-card-value {
  margin-top: 10px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.dashboard-card-hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.1fr 1.3fr;
  gap: 16px;
  margin-bottom: 16px;
}

.dashboard-grid:last-child {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 0;
}

.dashboard-panel {
  padding: 14px;
}

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

.dashboard-panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.dashboard-panel-head h3 {
  margin-bottom: 0;
}

.dashboard-todos {
  display: grid;
  gap: 10px;
}

.dashboard-todo {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f7fafc;
  border: 1px solid #e5edf5;
  cursor: pointer;
}

.dashboard-todo:hover {
  border-color: #c9dcef;
  background: #f2f8fd;
}

.dashboard-todo-main {
  display: grid;
  gap: 4px;
}

.dashboard-todo-label {
  font-weight: 700;
}

.dashboard-todo-hint {
  color: var(--muted);
  font-size: 12px;
}

.dashboard-todo-count {
  min-width: 42px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(7, 193, 96, 0.12);
  color: #0b8a4b;
  font-weight: 800;
}

.dashboard-todo-modal-count {
  margin-top: 8px;
  font-size: 36px;
  font-weight: 800;
  color: #0b8a4b;
}

.dashboard-todo-modal-detail {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.dashboard-todo-modal-distributions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dashboard-todo-distribution-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef6ff;
  color: #36506a;
  border: 1px solid #d6e6f7;
  font-size: 12px;
  font-weight: 700;
}

.dashboard-todo-record {
  padding: 12px;
  border-radius: 12px;
  background: #f7fafc;
  border: 1px solid #e5edf5;
  display: grid;
  gap: 8px;
  color: #36506a;
}

.dashboard-todo-record-title {
  font-size: 15px;
  font-weight: 800;
  color: #1f2a37;
}

.dashboard-todo-record-subtitle {
  color: var(--muted);
  font-size: 13px;
}

.dashboard-todo-record-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dashboard-todo-record-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #dfe8f0;
  font-size: 12px;
}

.dashboard-todo-record-tip {
  line-height: 1.7;
  color: #36506a;
}

.dashboard-community-cards {
  display: grid;
  gap: 12px;
}

.dashboard-community-card {
  border: 1px solid #e4ecf4;
  border-radius: 14px;
  background: #fbfdff;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.dashboard-community-card.is-empty {
  min-height: 120px;
  place-items: center;
}

.dashboard-community-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.dashboard-community-name {
  font-size: 16px;
  font-weight: 800;
}

.dashboard-community-meta {
  color: var(--muted);
  font-size: 12px;
}

.dashboard-community-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.dashboard-community-stat {
  padding: 10px 12px;
  border-radius: 12px;
  background: #f3f8fc;
  display: grid;
  gap: 6px;
}

.dashboard-community-stat-label {
  color: var(--muted);
  font-size: 12px;
}

.dashboard-community-stat-value {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.dashboard-community-bars {
  display: grid;
  gap: 10px;
}

.dashboard-bar-row {
  display: grid;
  grid-template-columns: 78px 1fr 64px;
  align-items: center;
  gap: 10px;
}

.dashboard-bar-label {
  color: var(--muted);
  font-size: 12px;
}

.dashboard-bar-track {
  position: relative;
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: #e9f0f5;
}

.dashboard-bar-fill {
  height: 100%;
  border-radius: inherit;
}

.dashboard-bar-fill.scale {
  background: linear-gradient(90deg, #0b8a4b 0%, #3bc177 100%);
}

.dashboard-bar-fill.ratio {
  background: linear-gradient(90deg, #1a8cff 0%, #5db1ff 100%);
}

.dashboard-bar-value {
  text-align: right;
  font-size: 12px;
  font-weight: 700;
  color: #36506a;
}

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

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

th, td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 10px 8px;
  white-space: nowrap;
  font-size: 14px;
}

th { color: var(--muted); font-weight: 600; }

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: rgba(7, 193, 96, 0.04);
}

.form-table {
  table-layout: fixed;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fcfdff;
}

.form-table th,
.form-table td {
  white-space: normal;
  vertical-align: top;
}

.form-table th {
  width: 120px;
  background: #f6f9fc;
}

.form-table td .text-input {
  width: 100%;
  min-width: 0;
}

.percent-slider-field {
  display: grid;
  gap: 4px;
}

.percent-slider-row {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  gap: 10px;
  align-items: center;
}

.percent-slider-input {
  width: 100%;
  margin: 0;
  accent-color: var(--brand);
  cursor: pointer;
}

.percent-step-btn {
  min-width: 40px;
  padding: 8px 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.percent-slider-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.percent-slider-value {
  display: inline-flex;
  align-items: center;
  min-width: 56px;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(7, 193, 96, 0.12);
  color: #0b8a4b;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.project-amount-formula {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #d9eadf;
  border-radius: 12px;
  background: linear-gradient(180deg, #fbfefc 0%, #f2f8f4 100%);
  color: #325144;
  font-size: 13px;
}

.project-amount-formula-label,
.project-amount-formula-op,
.project-amount-formula-eq {
  font-weight: 700;
}

.project-amount-term,
.project-amount-result {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #dbe9df;
}

.project-amount-result {
  background: rgba(7, 193, 96, 0.12);
  border-color: rgba(7, 193, 96, 0.24);
}

.project-amount-term strong,
.project-amount-result strong {
  color: #0b8a4b;
  font-size: 14px;
}

.rbac-option-grid {
  flex-wrap: wrap;
  row-gap: 8px;
}

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { border-color: var(--brand); background: var(--brand); color: #fff; }
.btn-danger { border-color: var(--danger); color: var(--danger); }

.config-tools { margin-bottom: 12px; }
.config-tools label { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}

.status-chip-muted {
  border: 1px solid #f2d4a5;
  background: #fff6e8;
  color: #9a5b00;
}

.status-chip-unread {
  border: 1px solid #b7d7ff;
  background: #edf6ff;
  color: #0b5cad;
}

.status-chip-read {
  border: 1px solid #cde8d4;
  background: #f2fbf5;
  color: #0b8a4b;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 16px;
  margin-bottom: 0;
}

.import-progress {
  width: min(560px, 100%);
}

.import-progress.is-hidden {
  display: none;
}

.import-progress-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e8eef6;
  overflow: hidden;
  margin-bottom: 8px;
}

.import-progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #07c160 0%, #18a0fb 100%);
  transition: width .2s ease;
}

.json-input {
  width: 100%;
  height: 240px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.hint { color: var(--muted); font-size: 13px; }

.config-editor-body {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafcff;
  padding: 12px;
  margin-bottom: 12px;
}

.config-empty {
  color: var(--muted);
  font-size: 14px;
  padding: 8px 4px;
}

.section-editor {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 12px;
  margin-bottom: 12px;
}

.section-editor:last-child {
  margin-bottom: 0;
}

.section-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.item-editor {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
}

.item-editor:last-child {
  margin-bottom: 0;
}

@media (min-width: 1100px) {
  .layout {
    grid-template-columns: 2fr 1fr;
    align-items: start;
  }
  #auth-panel { grid-column: 1 / -1; }
  .menu-panel[data-section="dashboard"] { grid-column: 1 / -1; }
  .menu-panel[data-section="user"] { grid-column: 1 / -1; }
  .menu-panel[data-section="service"] { grid-column: 1 / -1; }
  .menu-panel[data-section="cobuild"] { grid-column: 1 / -1; }
  .menu-panel[data-section="config"] { grid-column: 1 / -1; }
}

@media (max-width: 960px) {
  .dashboard-metrics,
  .dashboard-grid,
  .dashboard-grid:last-child,
  .dashboard-community-stats,
  .dashboard-copy-fields {
    grid-template-columns: 1fr;
  }

  .service-map {
    grid-template-columns: 1fr;
  }

  .dashboard-panel-head,
  .dashboard-community-header,
  .dashboard-bar-row,
  .service-subhead {
    display: grid;
    grid-template-columns: 1fr;
  }

  .dashboard-bar-value {
    text-align: left;
  }
}
