:root {
  --bg: #f5f7f4;
  --panel: #ffffff;
  --ink: #18211d;
  --muted: #65706b;
  --line: #dfe5df;
  --nav: #22312a;
  --accent: #2f7d61;
  --accent-strong: #206149;
  --blue: #315f9b;
  --danger: #b94a48;
  --danger-strong: #973634;
  --warn: #a46721;
  --shadow: 0 18px 50px rgba(25, 39, 31, 0.08);
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

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

button {
  cursor: pointer;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-card .brand-mark {
  width: 52px;
  height: 52px;
}

.login-tip {
  margin-top: 0;
  font-size: 13px;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}

.sidebar {
  background: var(--nav);
  color: #f7fbf8;
  padding: 22px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #f2c14f;
  color: #1b211e;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.66);
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 7px;
  padding: 11px 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.74);
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.content {
  min-width: 0;
  padding: 28px;
}

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

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

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

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(128px, 1fr));
  gap: 12px;
}

.compact-metrics {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.inner-metrics {
  padding: 18px;
  box-shadow: none;
}

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

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

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

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-head {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

#reports {
  gap: 14px;
}

#reports > .panel {
  overflow: hidden;
}

#reports .panel-head {
  min-height: 64px;
  padding: 14px 20px;
  background: #fbfcfb;
}

#reports .panel-head h2 {
  font-size: 19px;
  line-height: 1.3;
}

#reports .panel-subtitle {
  margin-top: 5px;
  color: var(--accent-strong);
  font-weight: 700;
}

#reports .table-wrap {
  background: #fff;
}

#reports .report-table {
  min-width: 0;
}

#reports .report-table th,
#reports .report-table td {
  padding: 12px 16px;
  vertical-align: middle;
}

#reports .report-table th {
  height: 48px;
  color: #5d7066;
  font-weight: 800;
  background: #f6f9f6;
}

#reports .report-table tbody tr:last-child td {
  border-bottom: 0;
}

#reports .report-type-table {
  table-layout: fixed;
}

#reports .report-type-table th:first-child,
#reports .report-type-table td:first-child {
  width: 30%;
  text-align: left;
}

#reports .report-type-table th:not(:first-child),
#reports .report-type-table td:not(:first-child),
#reports .report-partner-table th:not(:first-child),
#reports .report-partner-table td:not(:first-child) {
  text-align: right;
}

#reports .report-type-table .summary-row td {
  background: #eef5f0;
  color: var(--ink);
  font-weight: 800;
}

#reports .report-partner-table {
  table-layout: fixed;
}

#reports .report-partner-table th:first-child,
#reports .report-partner-table td:first-child {
  width: 34%;
  text-align: left;
}

#reports .report-class-table {
  min-width: 1040px;
}

#reports .report-class-table th:nth-child(1) {
  width: 17%;
}

#reports .report-class-table th:nth-child(2) {
  width: 12%;
}

#reports .report-class-table th:nth-child(5) {
  width: 25%;
}

#reports .report-class-table th:nth-child(n+7),
#reports .report-class-table td:nth-child(n+7) {
  text-align: right;
}

#reports .report-renewal-table,
#reports .report-transaction-table {
  min-width: 980px;
}

#reports .report-finance-table {
  min-width: 860px;
}

#reports .report-finance-table th:nth-child(7),
#reports .report-finance-table td:nth-child(7) {
  text-align: right;
}

#reimbursements {
  gap: 14px;
}

#reimbursements > .panel {
  overflow: hidden;
}

#reimbursements .panel-head {
  min-height: 64px;
  padding: 14px 20px;
  background: #fbfcfb;
}

#reimbursements .panel-head h2 {
  font-size: 19px;
  line-height: 1.3;
}

.reimbursement-metrics {
  padding: 18px;
}

.reimbursement-table {
  min-width: 1120px;
}

.reimbursement-table th,
.reimbursement-table td {
  vertical-align: middle;
}

.reimbursement-table th:nth-child(4),
.reimbursement-table td:nth-child(4) {
  text-align: right;
}

.reimbursement-table th:last-child,
.reimbursement-table td:last-child {
  text-align: right;
}

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

.report-actions label {
  min-width: 130px;
}

.report-actions input {
  min-height: 38px;
}

.student-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.student-tab {
  position: relative;
  min-height: 56px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  font-weight: 800;
}

.student-tab::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 72px;
  height: 4px;
  border-radius: 4px 4px 0 0;
  background: transparent;
  transform: translateX(-50%);
}

.student-tab.active {
  color: var(--accent-strong);
}

.student-tab.active::after {
  background: var(--accent);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  padding: 18px;
}

.form-grid.compact {
  grid-template-columns: 180px minmax(220px, 1fr) auto;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.field-block {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.wide {
  grid-column: span 2;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfd8d1;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(47, 125, 97, 0.22);
  border-color: var(--accent);
}

textarea {
  min-height: 170px;
  line-height: 1.5;
  resize: vertical;
}

.compact-textarea {
  min-height: 76px;
}

.inline-select {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 220px;
}

.inline-select select {
  min-width: 130px;
  flex: 1;
}

.inline-select .small-action {
  flex: 0 0 auto;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  color: var(--ink);
}

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

.primary-btn,
.ghost-btn,
.danger-btn,
.link-btn {
  min-height: 42px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 9px 14px;
  font-weight: 700;
}

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

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

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

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

.ghost-btn {
  background: #eef3ef;
  color: var(--ink);
  border-color: var(--line);
}

.ghost-btn:hover {
  background: #e2ebe5;
}

.link-btn {
  min-height: auto;
  background: transparent;
  color: var(--blue);
  padding: 4px 0;
}

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

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
}

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

.pagination-page {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  color: var(--muted);
  font-size: 13px;
}

.pagination-actions {
  display: flex;
  gap: 8px;
}

.pagination-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.detail-table {
  border-top: 1px solid var(--line);
}

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

.edit-table input,
.edit-table select {
  min-width: 130px;
}

.edit-table .small-action {
  min-height: 36px;
  padding: 7px 10px;
}

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

th {
  color: var(--muted);
  font-size: 13px;
  background: #fafcfa;
}

tbody tr:hover {
  background: #f8fbf8;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  background: #eef3ef;
  color: var(--muted);
  padding: 4px 10px;
  font-size: 13px;
}

.pill.warn {
  background: #fff1da;
  color: var(--warn);
}

.pill.danger {
  background: #fde8e7;
  color: var(--danger);
}

.pill.student-type.type-partner {
  background: #dbeafe;
  color: #1d4ed8;
}

.pill.student-type.type-internal {
  background: #ede9fe;
  color: #6d28d9;
}

.pill.student-type.type-special {
  background: #fef3c7;
  color: #92400e;
}

.status-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-options label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 9px;
  color: var(--ink);
  background: #fff;
}

.status-options input {
  width: 14px;
  min-height: 14px;
}

.deduct-input {
  width: 92px;
  min-width: 92px;
}

.weekday-options {
  display: grid;
  grid-template-columns: repeat(7, minmax(42px, 1fr));
  gap: 8px;
}

.weekday-options button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.weekday-options button:hover,
.weekday-options button.selected {
  border-color: var(--accent);
  background: #e8f3ed;
  color: var(--accent-strong);
}

.date-marks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 18px 14px;
}

.date-chip {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 700;
}

.date-chip.active {
  border-color: var(--accent);
  background: #e8f3ed;
  color: var(--accent-strong);
}

.date-chip small {
  margin-left: 6px;
  color: var(--muted);
  font-weight: 600;
}

.calendar-picker {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.calendar-head strong {
  color: var(--ink);
}

.calendar-nav {
  display: flex;
  gap: 6px;
}

.calendar-nav button,
.calendar-day {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fbf8;
  color: var(--ink);
  font-weight: 700;
}

.calendar-nav button {
  min-width: 40px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(34px, 1fr));
  gap: 6px;
}

.calendar-weekday {
  min-height: 24px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.calendar-day {
  background: #fff;
}

.calendar-day:hover,
.calendar-day.selected {
  border-color: var(--accent);
  background: #e8f3ed;
  color: var(--accent-strong);
}

.calendar-day.muted {
  border-color: transparent;
  background: transparent;
  color: transparent;
  pointer-events: none;
}

.calendar-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 30px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px 18px;
}

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

.import-form {
  display: grid;
}

.paste-area {
  padding: 0 18px 4px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  border-radius: 8px;
  background: #18211d;
  color: #fff;
  padding: 12px 14px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .metrics {
    grid-template-columns: repeat(3, minmax(128px, 1fr));
  }

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

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

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 14px;
  }

  .brand {
    margin-bottom: 12px;
  }

  .nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-item {
    flex: 0 0 auto;
    width: auto;
  }

  .content {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
  }

  .metrics,
  .form-grid,
  .form-grid.compact {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: auto;
  }
}
