:root {
  --bg: #f7f8f5;
  --surface: #ffffff;
  --surface-soft: #f0f4f1;
  --ink: #1d2522;
  --muted: #657069;
  --line: #d8ded7;
  --primary: #166b5b;
  --primary-strong: #0d4c40;
  --accent: #b66d12;
  --danger: #b42318;
  --warn: #9a6700;
  --info: #1f5d99;
  --ok: #23714d;
  --shadow: 0 10px 24px rgba(29, 37, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}

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

button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: stretch;
}

.brand-panel,
.login-panel,
.panel,
.stat,
.mini-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand-panel {
  padding: 32px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 420px;
  background:
    linear-gradient(135deg, rgba(22, 107, 91, 0.09), transparent 44%),
    linear-gradient(315deg, rgba(182, 109, 18, 0.13), transparent 38%),
    #ffffff;
}

.brand-title {
  margin: 0;
  font-size: 34px;
  font-weight: 760;
}

.brand-subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.login-panel {
  padding: 24px;
  display: grid;
  gap: 16px;
  align-content: start;
}

.login-panel h2,
.panel h2,
.panel h3 {
  margin: 0;
}

.login-panel h2 {
  font-size: 22px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
  align-items: end;
}

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

.span-12 {
  grid-column: span 12;
}

.span-8 {
  grid-column: span 8;
}

.span-6 {
  grid-column: span 6;
}

.span-4 {
  grid-column: span 4;
}

.span-3 {
  grid-column: span 3;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  outline: none;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 107, 91, 0.14);
}

.btn {
  min-height: 38px;
  padding: 8px 14px;
  background: var(--surface-soft);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn.primary:hover {
  background: var(--primary-strong);
}

.btn.danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.btn.ghost {
  background: transparent;
}

.btn.small {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 13px;
}

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

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(247, 248, 245, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 20px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.app-title {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
  font-weight: 760;
  flex: 0 0 auto;
}

.title-text {
  min-width: 0;
}

.title-text strong {
  display: block;
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.title-text span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.month-control {
  width: 150px;
}

.content {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  gap: 16px;
}

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

.stat {
  padding: 14px;
  min-height: 96px;
  display: grid;
  align-content: space-between;
  box-shadow: none;
}

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

.stat-value {
  font-size: 28px;
  font-weight: 760;
}

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

.panel {
  box-shadow: none;
  overflow: hidden;
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

.panel-header h2 {
  font-size: 17px;
}

.panel-body {
  padding: 16px;
}

.split {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

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

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: #fbfcfa;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

td.num,
th.num {
  text-align: right;
}

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

.compact-table th,
.compact-table td {
  padding: 8px;
}

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

.text-danger {
  color: var(--danger);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}

.status.pending_leader {
  color: var(--warn);
  background: #fff2cc;
}

.status.pending_admin {
  color: var(--info);
  background: #e8f1fb;
}

.status.approved {
  color: var(--ok);
  background: #e8f4ec;
}

.status.rejected_by_leader,
.status.rejected_by_admin {
  color: var(--danger);
  background: #fde7e5;
}

.review-box {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto;
  gap: 8px;
  min-width: 360px;
}

.notice {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
}

.notice.error {
  color: var(--danger);
  border-color: #f2b8b5;
  background: #fff1f0;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 28px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  border: 1px solid var(--line);
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mini-card {
  box-shadow: none;
  padding: 12px;
}

.mini-card strong {
  display: block;
  font-size: 20px;
}

.mini-card span {
  color: var(--muted);
  font-size: 12px;
}

.rule-list {
  display: grid;
  gap: 8px;
}

.rule-picker {
  display: grid;
  gap: 10px;
}

.rule-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.rule-tab {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 5px 11px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}

.rule-tab.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.rule-results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.rule-choice {
  min-height: 76px;
  padding: 9px 10px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 5px;
}

.rule-choice.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 107, 91, 0.13);
}

.rule-choice-main {
  color: var(--ink);
  font-weight: 720;
  overflow-wrap: anywhere;
}

.rule-choice-meta {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.selected-rule {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(22, 107, 91, 0.35);
  background: #eef7f3;
}

.selected-rule strong,
.draft-item strong {
  display: block;
}

.selected-rule span,
.draft-item span,
.draft-header span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.selected-rule b {
  flex: 0 0 auto;
  color: var(--primary);
}

.rule-item {
  display: grid;
  grid-template-columns: 150px 130px minmax(260px, 1fr) 86px 76px;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.rule-item span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.rule-score {
  text-align: right;
  font-weight: 740;
}

.account-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.draft-panel {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.draft-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.draft-list {
  display: grid;
  gap: 8px;
}

.draft-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.draft-score {
  color: var(--primary);
  font-weight: 760;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

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

@media (max-width: 1100px) {
  .split,
  .account-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  .login-shell {
    grid-template-columns: 1fr;
  }

  .brand-panel {
    min-height: 260px;
  }

  .brand-title {
    font-size: 28px;
  }

  .topbar-inner {
    grid-template-columns: 1fr;
  }

  .top-actions {
    justify-content: flex-start;
  }

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

  .span-8,
  .span-6,
  .span-4,
  .span-3 {
    grid-column: span 12;
  }

  .review-box {
    grid-template-columns: 1fr;
    min-width: 260px;
  }

  .rule-results {
    grid-template-columns: 1fr;
  }

  .rule-item {
    grid-template-columns: 1fr;
  }

  .draft-header,
  .selected-rule {
    align-items: stretch;
    flex-direction: column;
  }

  .draft-item {
    grid-template-columns: 1fr;
  }

  .month-control {
    width: 100%;
  }
}
