:root {
  --bg: #f6f7f8;
  --surface: #ffffff;
  --text: #17191c;
  --muted: #68707a;
  --line: #dde1e6;
  --line-strong: #c8ced6;
  --accent: #2563eb;
  --positive: #15803d;
  --negative: #b42318;
  --revoked: #8a8f98;
  --shadow: 0 8px 24px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 64px;
  padding: 12px 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar form {
  margin: 0;
}

.topbar-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

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

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

.page {
  margin: 0 auto;
  max-width: 1280px;
  padding: 28px;
}

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

.section-head h1 {
  font-size: 28px;
  line-height: 1.2;
  margin: 0;
  overflow-wrap: anywhere;
}

.section-head p {
  color: var(--muted);
  margin: 8px 0 0;
}

.summary-pill,
.share-badge {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 8px 12px;
  white-space: nowrap;
}

.table-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.data-table {
  border-collapse: collapse;
  min-width: 960px;
  width: 100%;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  background: #fafafa;
  color: #4b5563;
  font-size: 12px;
  font-weight: 700;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.group-link {
  color: var(--accent);
  display: inline-block;
  font-weight: 700;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.muted {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.money {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}

.positive {
  color: var(--positive);
}

.negative {
  color: var(--negative);
}

.ghost-button,
.small-button,
.remark-form button,
.filters button,
.login-form button {
  background: var(--text);
  border: 1px solid var(--text);
  border-radius: 8px;
  color: white;
  cursor: pointer;
  display: inline-flex;
  font-size: 14px;
  font-weight: 700;
  justify-content: center;
  line-height: 1;
  min-height: 40px;
  padding: 10px 13px;
  text-align: center;
}

.ghost-button {
  background: var(--surface);
  color: var(--text);
}

.small-button {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text);
  white-space: nowrap;
}

.small-button.copied {
  border-color: var(--positive);
  color: var(--positive);
}

.login-wrap {
  display: grid;
  min-height: calc(100vh - 120px);
  place-items: center;
}

.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 380px;
  padding: 28px;
  width: 100%;
}

.login-panel h1 {
  font-size: 26px;
  margin: 0 0 8px;
}

.login-panel p {
  color: var(--muted);
  margin: 0 0 22px;
}

.login-form,
.remark-form,
.filters {
  display: grid;
  gap: 10px;
}

.login-form label,
.remark-form label,
.filters label {
  color: #4b5563;
  font-size: 12px;
  font-weight: 700;
}

.login-form input,
.remark-form input,
.filters input,
.filters select {
  background: white;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  min-height: 40px;
  min-width: 0;
  padding: 8px 10px;
  width: 100%;
}

.error {
  background: #fef3f2;
  border: 1px solid #fecdca;
  border-radius: 8px;
  color: var(--negative);
  margin-bottom: 14px;
  padding: 10px 12px;
}

.notice {
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 10px 12px;
}

.notice.success {
  background: #ecfdf3;
  border: 1px solid #abefc6;
  color: var(--positive);
}

.remark-form {
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  grid-template-columns: minmax(180px, 1fr) auto;
  margin-bottom: 16px;
  padding: 16px;
}

.remark-form label {
  grid-column: 1 / -1;
}

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

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 8px;
}

.metric strong {
  display: block;
  font-size: 24px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.filters {
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 18px;
  padding: 16px;
}

.filters label {
  display: grid;
  gap: 6px;
}

.day-block {
  margin-bottom: 18px;
}

.day-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 0 0 8px;
}

.day-head h2 {
  font-size: 18px;
  margin: 0;
}

.entry-table td {
  font-size: 14px;
}

.expr,
.period {
  font-family: Consolas, "Microsoft YaHei", monospace;
  overflow-wrap: anywhere;
}

.period {
  color: var(--muted);
  font-size: 12px;
  min-width: 190px;
}

.status {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  white-space: nowrap;
}

.status.active {
  background: #ecfdf3;
  color: var(--positive);
}

.status.revoked {
  background: #f2f4f7;
  color: var(--revoked);
}

.revoked-row td {
  color: var(--revoked);
  text-decoration: line-through;
}

.revoked-row .status {
  text-decoration: none;
}

.empty {
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  padding: 28px;
  text-align: center;
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    gap: 10px;
    padding: 10px 16px;
  }

  .page {
    padding: 18px 14px;
  }

  .section-head {
    display: grid;
    gap: 10px;
  }

  .section-head h1 {
    font-size: 24px;
  }

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

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

  .remark-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .topbar {
    display: grid;
    min-height: auto;
  }

  .topbar-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .topbar-actions form,
  .topbar-actions .ghost-button,
  .topbar-actions .share-badge {
    width: 100%;
  }

  .brand {
    font-size: 17px;
  }

  .subtitle {
    font-size: 12px;
  }

  .summary-pill,
  .share-badge {
    justify-self: start;
  }

  .table-shell {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
  }

  .data-table,
  .data-table thead,
  .data-table tbody,
  .data-table tr,
  .data-table th,
  .data-table td {
    display: block;
    min-width: 0;
    width: 100%;
  }

  .data-table thead {
    display: none;
  }

  .data-table tr {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 10px;
    overflow: hidden;
  }

  .data-table td {
    align-items: start;
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(88px, 34%) minmax(0, 1fr);
    padding: 11px 12px;
    text-align: right;
  }

  .data-table td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 12px;
    font-weight: 700;
    text-align: left;
  }

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

  .data-table td:first-child::before {
    display: block;
    margin-bottom: 6px;
  }

  .data-table tr:last-child td,
  .data-table td:last-child {
    border-bottom: 0;
  }

  .data-table .small-button {
    justify-self: end;
    min-width: 112px;
  }

  .entry-table td {
    font-size: 14px;
  }

  .entry-table .expr,
  .entry-table .period {
    text-align: right;
  }

  .period {
    min-width: 0;
  }

  .metric-grid {
    gap: 10px;
  }

  .metric {
    padding: 14px;
  }

  .filters,
  .remark-form {
    box-shadow: none;
    padding: 14px;
  }

  .filters button,
  .remark-form button,
  .login-form button {
    width: 100%;
  }

  .login-wrap {
    align-items: start;
    min-height: auto;
    padding-top: 28px;
  }

  .login-panel {
    box-shadow: none;
    padding: 22px;
  }
}

@media (max-width: 520px) {
  html {
    font-size: 14px;
  }

  .page {
    padding: 14px 10px 24px;
  }

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

  .metric strong {
    font-size: 22px;
  }

  .section-head h1 {
    font-size: 22px;
  }

  .day-head {
    align-items: flex-start;
    gap: 8px;
  }

  .data-table td {
    grid-template-columns: minmax(74px, 32%) minmax(0, 1fr);
  }
}
