:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #697586;
  --line: #d9dee7;
  --accent: #1677ff;
  --accent-strong: #0f5fc9;
  --success-bg: #e9f8ef;
  --success-text: #176b3a;
  --error-bg: #fdeceb;
  --error-text: #a1281f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
  padding: 0 32px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 20px;
  font-weight: 700;
}

.subbrand {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nav a,
.secondary-action,
.reset-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.nav a {
  padding: 9px 13px;
  border-radius: 6px;
}

.nav a.active {
  background: #eaf2ff;
  color: var(--accent-strong);
}

.user-badge {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.shell {
  width: min(1280px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.messages {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.message {
  padding: 12px 14px;
  border-radius: 6px;
  font-weight: 600;
}

.message.success {
  background: var(--success-bg);
  color: var(--success-text);
}

.message.error {
  background: var(--error-bg);
  color: var(--error-text);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  margin-bottom: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-head.compact {
  margin-bottom: 12px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

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

.login-panel {
  width: min(420px, 100%);
  margin: 40px auto;
}

.entry-form {
  display: grid;
  gap: 18px;
}

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

.form-grid.fixed {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.form-grid.metrics {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.filter-form {
  grid-template-columns: repeat(5, minmax(150px, 1fr)) auto auto;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 3px solid #d9eaff;
}

.readonly-value {
  min-height: 40px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #f5f7fa;
  color: var(--text);
  font-weight: 700;
}

.note-field {
  width: 100%;
}

.actions {
  display: flex;
  justify-content: flex-end;
}

.inline-actions {
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.inline-actions form {
  margin: 0;
}

.split-actions {
  justify-content: space-between;
}

button,
.secondary-action {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  cursor: pointer;
  font: inherit;
}

button {
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

button:hover {
  background: var(--accent-strong);
}

.danger-button {
  background: #e5483f;
}

.danger-button:hover {
  background: #b92f28;
}

.small-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.secondary-action {
  display: inline-flex;
  align-items: center;
  background: #eaf2ff;
}

.reset-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-card {
  min-height: 86px;
  padding: 15px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  align-content: space-between;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.metric-card strong {
  margin-top: 10px;
  font-size: 24px;
  line-height: 1.1;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.compact-table {
  margin-top: 12px;
}

.compact-table table {
  min-width: 520px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
  background: #ffffff;
}

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

th {
  background: #f1f4f8;
  color: #445160;
  font-size: 13px;
  font-weight: 700;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.empty-line {
  color: var(--muted);
  padding: 12px 0;
}

.cell-note {
  margin-top: 3px;
  color: #8a5a00;
  font-size: 12px;
  font-weight: 700;
}

.action-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.reset-password-form input {
  width: 150px;
  min-height: 30px;
  padding: 5px 8px;
}

.role-form select {
  width: 120px;
  min-height: 30px;
  padding: 5px 8px;
}

.small-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 18px;
}

.admin-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
}

.admin-link-card {
  display: grid;
  gap: 6px;
  min-height: 76px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--text);
  text-decoration: none;
}

.admin-link-card:hover {
  border-color: #b8cfff;
  background: #f4f8ff;
}

.admin-link-card strong {
  color: var(--accent-strong);
}

.admin-link-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.mini-form {
  display: grid;
  gap: 12px;
}

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

.checkbox-line input {
  width: 18px;
  min-height: 18px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px 16px;
}

.command-permission-grid {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  margin-bottom: 8px;
}

.command-permission-option span {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 500;
}

.report-choice-grid,
.project-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
}

.report-choice-card,
.project-status-grid > div {
  display: grid;
  gap: 6px;
  min-height: 76px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.report-choice-card {
  color: var(--text);
  text-decoration: none;
}

.report-choice-card:hover {
  border-color: #b8cfff;
  background: #f4f8ff;
}

.report-choice-card strong,
.project-status-grid strong {
  color: var(--accent-strong);
}

.report-choice-card span,
.project-status-grid span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.report-subform {
  margin-top: 16px;
}

.report-preview {
  margin: 14px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--text);
  line-height: 1.7;
  white-space: pre-wrap;
}

.command-list {
  display: grid;
  gap: 10px;
}

.command-list div {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
}

.command-list strong {
  width: 120px;
  color: var(--accent-strong);
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.ok {
  background: var(--success-bg);
  color: var(--success-text);
}

.status-pill.warn {
  background: #fff3d7;
  color: #8a5a00;
}

.admin-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.admin-list-row {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
}

.admin-list-row span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.admin-channel-form {
  grid-template-columns: repeat(3, minmax(160px, 1fr)) auto;
  margin-bottom: 18px;
}

.account-form {
  grid-template-columns: repeat(5, minmax(140px, 1fr)) auto;
  margin-bottom: 18px;
}

.recharge-filter {
  grid-template-columns: repeat(3, minmax(150px, 1fr)) auto auto;
}

.recharge-entry-form {
  grid-template-columns: 180px 180px 180px minmax(240px, 1fr) auto;
}

.report-cost-form {
  grid-template-columns: 220px auto;
}

.recharge-admin-summary {
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  margin-bottom: 16px;
}

.recharge-edit-table {
  min-width: 760px;
}

.recharge-edit-table th,
.recharge-edit-table td {
  text-align: center;
  vertical-align: middle;
}

.recharge-edit-table tfoot td {
  background: #f1f4f8;
  font-weight: 800;
}

.recharge-amount-input {
  width: 128px;
  min-height: 34px;
  padding: 5px 8px;
  text-align: right;
}

.recharge-row-form {
  display: inline-flex;
  justify-content: center;
  margin: 0;
}

.recharge-report-table {
  min-width: 1320px;
  border-collapse: collapse;
  table-layout: fixed;
}

.recharge-report-table th,
.recharge-report-table td {
  height: 36px;
  padding: 7px 8px;
  border: 1px solid #111827;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

.recharge-report-table thead th {
  background: #b8c9eb;
  color: #0b1220;
  font-size: 14px;
}

.recharge-report-table .recharge-report-title th {
  height: 34px;
  background: #8ea4cc;
  color: #000000;
  font-size: 18px;
  font-weight: 800;
}

.recharge-report-table .finance-head,
.recharge-report-table .finance-cell {
  background: #f7dfc3;
}

.recharge-report-table tbody td {
  background: #ffffff;
  color: #000000;
}

.recharge-report-table tbody td.finance-cell {
  background: #f7dfc3;
}

.recharge-report-table tfoot td {
  background: #d7e4f7;
  font-weight: 800;
}

.recharge-report-table tfoot td.finance-cell {
  background: #f4d5b5;
}

.recharge-report-table .negative {
  color: #a1281f;
}

.recharge-inline-form {
  justify-content: center;
}

.recharge-inline-form input {
  width: 96px;
  min-height: 30px;
  padding: 4px 7px;
  text-align: right;
}

.data-table {
  min-width: 760px;
}

.event-text {
  white-space: normal;
  line-height: 1.45;
}

.log-table {
  min-width: 1500px;
}

.log-table details {
  max-width: 360px;
}

.log-table summary {
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

.log-data {
  max-height: 240px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f9fc;
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

@media (max-width: 920px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .shell {
    width: min(100% - 20px, 1280px);
    margin-top: 14px;
  }

  .form-grid.fixed,
    .form-grid.metrics,
    .filter-form,
    .admin-grid,
    .admin-links,
    .admin-channel-form,
    .account-form,
    .report-cost-form,
    .report-choice-grid,
    .project-status-grid,
    .summary-grid {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
