:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --panel: #ffffff;
  --ink: #1d2520;
  --muted: #66736b;
  --line: #dbe1dc;
  --accent: #246b5a;
  --accent-strong: #174a3e;
  --accent-soft: #e4f2ed;
  --blue: #315b8f;
  --amber: #9b6518;
  --amber-soft: #fff0d8;
  --red: #a13f3f;
  --red-soft: #fde7e7;
  --shadow: 0 14px 40px rgba(29, 37, 32, 0.08);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(36, 107, 90, 0.08), transparent 260px),
    var(--bg);
  color: var(--ink);
}

.auth-pending .app-shell,
.is-logged-out .app-shell {
  display: none;
}

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

.is-authenticated .login-screen {
  display: none;
}

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

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 4px;
}

.login-brand h1,
.login-brand p,
.login-message {
  margin: 0;
}

.login-brand h1 {
  font-size: 28px;
  line-height: 1.1;
}

.login-brand p,
.login-message {
  color: var(--muted);
}

.login-message.is-error {
  color: var(--red);
}

body.role-teacher [data-permission="finance"],
body.role-teacher [data-permission="payments"],
body.role-teacher [data-permission="student-management"],
body.role-teacher [data-permission="settings"],
body.role-partner [data-permission="settings"] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible {
  outline: 3px solid rgba(36, 107, 90, 0.24);
  outline-offset: 2px;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 88px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand h1,
.brand p,
.view-head h2,
.view-head p,
.panel h3 {
  margin: 0;
}

.brand h1 {
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.1;
  letter-spacing: 0;
}

.brand p,
.view-head p {
  color: var(--muted);
  margin-top: 6px;
}

.brand-logo {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border: 1px solid rgba(29, 37, 32, 0.12);
  border-radius: 50%;
  object-fit: cover;
  background: #f7bf36;
  box-shadow: 0 8px 22px rgba(29, 37, 32, 0.12);
}

.login-logo {
  width: 64px;
  height: 64px;
}

.topbar-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

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

.topbar-meta span,
.user-badge,
.pill,
.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  white-space: nowrap;
}

.user-badge {
  color: var(--ink);
  background: var(--accent-soft);
  border-color: rgba(36, 107, 90, 0.2);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 22px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab.is-active {
  background: var(--ink);
  color: #fff;
}

.tab-icon {
  width: 22px;
  text-align: center;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.view-head,
.section-tools,
.record-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.checkin-sticky-panel {
  display: contents;
}

.view-head h2 {
  font-size: clamp(22px, 2.5vw, 30px);
  letter-spacing: 0;
}

.toolbar,
.record-controls,
.section-tools {
  flex-wrap: wrap;
}

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.field,
.search-field {
  display: grid;
  gap: 6px;
}

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

.field input,
.field select,
.field textarea,
.search-field input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.field textarea {
  min-height: 84px;
  padding: 10px 12px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(36, 107, 90, 0.12);
}

.field.compact {
  min-width: 170px;
}

.student-status-tools {
  display: grid;
  gap: 6px;
}

.student-status-tools > span {
  color: var(--muted);
  font-size: 13px;
}

.search-field {
  position: relative;
  flex: 1 1 280px;
}

.search-field span {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-field input {
  padding-left: 34px;
}

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

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

.kpi strong {
  display: block;
  font-size: 30px;
  line-height: 1.1;
  margin-bottom: 8px;
}

.kpi span {
  color: var(--muted);
}

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

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

.student-card {
  display: grid;
  gap: 14px;
  min-height: 202px;
  padding: 16px;
}

.student-card.is-checked {
  border-color: rgba(36, 107, 90, 0.38);
  background: linear-gradient(180deg, rgba(228, 242, 237, 0.62), #fff 86px);
}

.student-card.needs-attention:not(.is-checked) {
  border-color: rgba(155, 101, 24, 0.34);
}

.student-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.student-name {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
}

.student-meta {
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.35;
}

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

.lesson-balance div {
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fafbf9;
}

.lesson-balance strong {
  display: block;
  font-size: 20px;
}

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

.card-actions,
.row-actions,
.button-stack {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.primary,
.secondary,
.danger,
.icon-button,
.file-button,
.row-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border-radius: 6px;
  padding: 0 13px;
  font-weight: 800;
  white-space: nowrap;
}

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

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

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

.secondary,
.row-action {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.secondary:hover,
.row-action:hover,
.icon-button:hover,
.file-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.danger {
  border: 1px solid rgba(161, 63, 63, 0.28);
  background: var(--red-soft);
  color: var(--red);
}

.icon-button {
  width: 42px;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 18px;
}

.checked {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.warn {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: rgba(155, 101, 24, 0.26);
}

.negative {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(161, 63, 63, 0.28);
}

.muted,
.status-chip.muted {
  background: #eef1ef;
  color: #68736d;
  border-color: rgba(104, 115, 109, 0.24);
}

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

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

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

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

td strong {
  display: block;
}

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

.segmented {
  display: inline-flex;
  gap: 4px;
  min-height: 40px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.segmented button {
  min-width: 76px;
  border-radius: 6px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented button.is-active {
  background: var(--ink);
  color: #fff;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.summary-strip div {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.summary-strip strong {
  display: block;
  font-size: 22px;
}

.summary-strip span {
  color: var(--muted);
}

.payment-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(150px, 0.9fr) minmax(180px, 1fr) minmax(120px, 0.7fr) minmax(110px, 0.6fr) auto;
  align-items: end;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 16px;
}

.payment-panel h3,
.payment-panel p {
  margin: 0;
}

.payment-panel h3 {
  font-size: 18px;
}

.payment-panel p {
  color: var(--muted);
  margin-top: 4px;
}

.payment-total {
  min-height: 40px;
  display: grid;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbf9;
  padding: 6px 10px;
}

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

.payment-total strong {
  font-size: 18px;
}

.payment-split-preview {
  min-height: 40px;
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
}

.payment-split-preview strong {
  color: var(--ink);
  font-size: 13px;
}

.payment-ledger {
  margin-top: 18px;
}

.finance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.finance-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}

.finance-panel .mini-table-wrap {
  box-shadow: none;
}

.finance-trend {
  display: grid;
  gap: 10px;
}

.trend-row {
  display: grid;
  grid-template-columns: 88px minmax(120px, 1fr) 150px;
  align-items: center;
  gap: 10px;
}

.trend-row span {
  color: var(--muted);
}

.trend-row strong {
  text-align: right;
}

.trend-bars {
  display: grid;
  gap: 5px;
}

.trend-bars i {
  display: block;
  height: 9px;
  border-radius: 999px;
}

.cash-bar {
  background: var(--accent);
}

.earned-bar {
  background: var(--blue);
}

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

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

.balance-row strong,
.balance-row span {
  display: block;
}

.balance-row div span {
  color: var(--muted);
  margin-top: 3px;
}

.student-detail-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-top: 16px;
}

.student-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.student-detail-head h3,
.student-detail-head p,
.mini-head h4,
.student-notes p {
  margin: 0;
}

.student-detail-head h3 {
  font-size: 24px;
}

.student-detail-head p,
.student-notes {
  color: var(--muted);
  margin-top: 4px;
}

.student-profile-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.student-profile-grid div {
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbf9;
  padding: 10px;
}

.student-profile-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.student-profile-grid strong {
  font-size: 18px;
}

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

.text-warn {
  color: var(--amber);
}

.student-notes {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  padding: 10px;
  margin-bottom: 14px;
}

.student-notes strong {
  display: inline-block;
  color: var(--ink);
  margin-right: 8px;
}

.settlement-summary {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  padding: 12px;
  margin-bottom: 14px;
}

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

.settlement-grid div,
.settlement-preview div {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  padding: 10px;
  min-width: 0;
}

.settlement-grid span,
.settlement-preview span,
.settlement-preview em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.settlement-grid strong,
.settlement-preview strong {
  display: block;
  margin: 5px 0 3px;
}

.settlement-grid .negative,
.settlement-preview .negative {
  color: var(--red);
}

.settlement-grid .warn {
  color: var(--amber);
}

.settlement-grid .checked {
  color: var(--green);
}

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

.mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

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

.mini-head h4 {
  font-size: 17px;
}

.mini-head span {
  color: var(--muted);
}

.student-month-controls {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 10px;
}

.month-summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.month-summary-row span,
.balance-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 4px 10px;
  white-space: nowrap;
}

.balance-chip {
  min-height: 26px;
  font-size: 12px;
  font-weight: 800;
}

.warn-chip {
  background: var(--amber-soft);
  border-color: rgba(155, 101, 24, 0.26);
  color: var(--amber);
}

.danger-chip {
  background: var(--red-soft);
  border-color: rgba(161, 63, 63, 0.28);
  color: var(--red);
}

.mini-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mini-table-wrap table {
  min-width: 620px;
}

.timeline-panel {
  margin-top: 16px;
}

.cycle-panel {
  margin-top: 16px;
}

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

.cycle-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

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

.cycle-head strong,
.cycle-head span {
  display: block;
}

.cycle-head span {
  color: var(--muted);
  margin-top: 4px;
}

.cycle-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.cycle-stats span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fafbf9;
  padding: 4px 10px;
}

.cycle-records {
  display: grid;
  gap: 6px;
}

.cycle-records div {
  display: grid;
  grid-template-columns: 120px 90px auto;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbf9;
  padding: 6px 8px;
}

.cycle-records span,
.cycle-records em {
  color: var(--muted);
  font-style: normal;
}

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

.timeline-item {
  display: grid;
  grid-template-columns: 120px 88px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbf9;
  padding: 9px 10px;
}

.timeline-item.payment {
  border-left: 4px solid var(--blue);
}

.timeline-item.attendance {
  border-left: 4px solid var(--accent);
}

.timeline-date {
  color: var(--muted);
}

.timeline-item em {
  color: var(--muted);
  font-style: normal;
}

.calendar-controls {
  align-items: flex-end;
}

.month-switcher {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.calendar-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.calendar-weekdays span {
  min-height: 38px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-day {
  min-height: 112px;
  display: grid;
  align-content: start;
  gap: 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 10px;
  text-align: left;
}

.calendar-day:nth-child(7n) {
  border-right: 0;
}

.calendar-day:nth-last-child(-n + 7) {
  border-bottom: 0;
}

.calendar-day:hover {
  background: #f8fbf9;
}

.calendar-day.is-outside {
  background: #f4f6f4;
  color: #96a199;
}

.calendar-day.is-today .day-number {
  border-color: var(--blue);
  color: var(--blue);
}

.calendar-day.is-selected {
  background: var(--ink);
  color: #fff;
}

.calendar-day.is-selected .day-number,
.calendar-day.is-selected .day-count,
.calendar-day.is-selected .day-names,
.calendar-day.is-selected .day-empty {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.46);
}

.calendar-day.has-records {
  box-shadow: inset 0 4px 0 var(--accent);
}

.day-number {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 900;
}

.day-count {
  font-weight: 900;
  color: var(--accent-strong);
}

.day-names,
.day-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin: 20px 0 10px;
}

.detail-head h3,
.detail-head p {
  margin: 0;
}

.detail-head h3 {
  font-size: 22px;
}

.detail-head p {
  color: var(--muted);
  margin-top: 4px;
}

.history-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

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

.editor-head h3,
.editor-head p {
  margin: 0;
}

.editor-head h3 {
  font-size: 18px;
}

.editor-head p {
  color: var(--muted);
  margin-top: 4px;
}

.history-search {
  max-width: 360px;
}

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

.history-student-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fafbf9;
}

.history-student-row strong {
  display: block;
  font-size: 16px;
}

.history-student-row span {
  color: var(--muted);
}

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

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

.course-panel,
.settlement-panel,
.holiday-settings-panel,
.user-panel,
.request-panel,
.audit-panel {
  grid-column: 1 / -1;
}

.company-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.company-balance-grid,
.capital-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.company-balance-grid div,
.capital-summary-grid div {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  padding: 12px;
}

.company-balance-grid strong,
.company-balance-grid span,
.capital-summary-grid strong,
.capital-summary-grid span {
  display: block;
}

.company-balance-grid strong,
.capital-summary-grid strong {
  font-size: 22px;
}

.company-balance-grid span,
.capital-summary-grid span {
  color: var(--muted);
  margin-top: 5px;
}

.capital-table-wrap {
  margin-top: 10px;
}

.company-ledger-month-summary {
  margin-bottom: 12px;
}

.company-calendar-panel {
  margin-bottom: 0;
}

.company-calendar-day {
  min-height: 124px;
}

.company-day-income,
.company-day-expense,
.company-day-net {
  display: block;
  font-size: 12px;
  line-height: 1.28;
}

.company-day-income {
  color: var(--accent-strong);
  font-weight: 800;
}

.company-day-expense {
  color: var(--red);
  font-weight: 800;
}

.company-day-net {
  color: var(--muted);
}

.calendar-day.is-selected .company-day-income,
.calendar-day.is-selected .company-day-expense,
.calendar-day.is-selected .company-day-net {
  color: #fff;
}

.company-ledger-detail-head {
  margin-top: 16px;
}

.company-transaction-grid {
  display: grid;
  grid-template-columns: minmax(140px, 0.8fr) minmax(120px, 0.7fr) minmax(130px, 0.7fr) minmax(160px, 1fr) minmax(220px, 1.4fr) auto;
  gap: 10px;
  align-items: end;
}

.company-transaction-note {
  min-width: 0;
}

.company-ledger-table-wrap td strong,
.company-ledger-table-wrap td span {
  display: block;
}

.company-ledger-table-wrap td span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.money-positive {
  color: var(--accent-strong);
  font-weight: 900;
}

.money-negative {
  color: var(--red);
  font-weight: 900;
}

.panel-head,
.user-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-head {
  margin-bottom: 14px;
}

.panel-head h3,
.panel-head p {
  margin: 0;
}

.panel-head p,
.user-actions span {
  color: var(--muted);
}

.backup-status {
  margin: 12px 0 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
  line-height: 1.45;
}

.course-table-wrap,
.user-table-wrap,
.request-table-wrap,
.customization-table-wrap,
.audit-table-wrap {
  max-height: 420px;
}

.course-table th,
.course-table td,
.user-table th,
.user-table td,
.request-table th,
.request-table td,
.customization-table th,
.customization-table td,
.audit-table th,
.audit-table td {
  min-width: 128px;
}

.customization-table th:nth-child(2),
.customization-table td:nth-child(2) {
  min-width: 150px;
}

.customization-table th:nth-child(3),
.customization-table td:nth-child(3) {
  min-width: 280px;
}

.audit-table th:nth-child(4),
.audit-table td:nth-child(4) {
  min-width: 280px;
}

.audit-table th:last-child,
.audit-table td:last-child {
  min-width: 170px;
}

.table-input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  outline: none;
}

.table-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(36, 107, 90, 0.12);
}

.table-input:read-only,
.table-input:disabled {
  background: #f3f5f1;
  color: var(--muted);
}

.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  color: var(--muted);
}

.switch-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.user-actions {
  margin-top: 14px;
}

.panel {
  padding: 18px;
}

.add-student-panel {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr 0.8fr 0.9fr;
  align-items: end;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px;
}

.add-student-panel .panel-head {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.add-student-panel .panel-head p {
  margin-top: 3px;
}

.add-student-panel .form-row {
  display: contents;
}

.add-student-panel .field {
  min-width: 0;
}

.add-student-panel > .primary {
  min-height: 40px;
}

.panel h3 {
  font-size: 18px;
  margin-bottom: 16px;
}

.panel form,
.panel {
  min-width: 0;
}

.panel .field,
#settingsForm .field,
#addStudentForm .field {
  margin-bottom: 12px;
}

.add-student-panel .field {
  margin-bottom: 0;
}

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

.file-button {
  position: relative;
  border: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.button-stack {
  align-items: stretch;
  flex-direction: column;
}

.button-stack > * {
  width: 100%;
}

.data-note {
  margin: 18px 0 0;
}

.data-note div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.data-note dt,
.data-note dd {
  margin: 0;
}

.data-note dt {
  color: var(--muted);
}

.profile-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(29, 37, 32, 0.34);
}

.profile-card {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 20px;
}

.profile-head,
.profile-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.profile-head {
  margin-bottom: 16px;
}

.profile-head h2,
.profile-head p,
.profile-message {
  margin: 0;
}

.profile-head h2 {
  font-size: 24px;
}

.profile-head p,
.profile-message {
  color: var(--muted);
}

.profile-message.is-error {
  color: var(--red);
}

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

.profile-password {
  display: grid;
  gap: 12px;
  margin-top: 4px;
}

.profile-appearance,
.profile-pet {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 12px;
}

.profile-section-head h3 {
  margin: 0;
  font-size: 17px;
}

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

.theme-choice {
  display: grid;
  justify-items: stretch;
  gap: 8px;
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px;
  font-weight: 800;
  text-align: left;
}

.theme-choice:hover,
.theme-choice.is-active {
  border-color: var(--brand-cyan);
  background: #f3fbfd;
}

.theme-choice.is-active {
  box-shadow: 0 0 0 3px rgba(40, 169, 209, 0.13);
}

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

.theme-preview i {
  height: 28px;
  border: 1px solid rgba(21, 26, 24, 0.16);
  border-radius: 5px;
}

.custom-theme-builder,
.custom-pet-builder {
  display: grid;
  gap: 12px;
  border: 1px dashed rgba(40, 169, 209, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 12px;
}

.custom-theme-prompt textarea {
  font-size: 14px;
  line-height: 1.5;
}

.custom-upload-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.custom-image-preview {
  width: 112px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(244, 189, 52, 0.18), rgba(40, 169, 209, 0.16)),
    #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.custom-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.custom-pet-preview {
  border-radius: 18px;
}

.custom-upload-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.custom-upload-status {
  color: var(--muted);
  font-size: 12px;
}

.custom-color-grid,
.custom-pet-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.custom-pet-fields {
  grid-template-columns: minmax(130px, 0.8fr) minmax(180px, 1.2fr) auto;
}

.custom-review-preview {
  display: flex;
  gap: 8px;
}

.custom-review-preview > div {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.custom-review-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.custom-review-swatches {
  width: 100%;
  padding: 5px;
}

.custom-review-swatches i {
  height: 46px;
}

.custom-review-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.custom-review-detail {
  display: grid;
  gap: 4px;
}

.custom-review-detail span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

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

.color-field input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 3px;
}

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

.pet-choice {
  display: grid;
  justify-items: center;
  gap: 7px;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 6px;
  font-weight: 800;
}

.pet-choice:hover,
.pet-choice.is-active {
  border-color: var(--brand-cyan);
  background: #f3fbfd;
}

.pet-choice.is-active {
  box-shadow: 0 0 0 3px rgba(40, 169, 209, 0.13);
}

.profile-actions {
  align-items: center;
  margin-top: 16px;
}

.hidden {
  display: none !important;
}

.empty-state {
  grid-column: 1 / -1;
  min-height: 120px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.62);
}

.studio-pet {
  position: fixed;
  right: 22px;
  bottom: 24px;
  z-index: 34;
  display: grid;
  justify-items: end;
  gap: 10px;
  width: min(310px, calc(100vw - 32px));
  pointer-events: none;
  touch-action: auto;
}

.pet-bubble {
  display: grid;
  gap: 10px;
  width: 100%;
  border: 1px solid rgba(40, 169, 209, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 40px rgba(21, 26, 24, 0.16);
  padding: 12px;
  transform-origin: right bottom;
  transition: opacity 0.16s ease, transform 0.16s ease;
  backdrop-filter: blur(10px);
  pointer-events: auto;
  touch-action: pan-y;
}

.pet-bubble strong,
.pet-bubble p {
  margin: 0;
}

.pet-bubble p {
  color: var(--muted);
  line-height: 1.45;
  margin-top: 4px;
}

.pet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.pet-avatar {
  position: relative;
  width: 92px;
  height: 102px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
  cursor: grab;
  animation: petFloat 3.8s ease-in-out infinite;
  pointer-events: auto;
  touch-action: none;
}

.pet-avatar::after {
  content: "";
  position: absolute;
  left: 21px;
  right: 21px;
  bottom: 0;
  height: 9px;
  border-radius: 999px;
  background: rgba(21, 26, 24, 0.14);
  filter: blur(2px);
  animation: petShadow 3.2s ease-in-out infinite;
}

.pet-avatar:active,
.studio-pet.is-moving .pet-avatar {
  cursor: grabbing;
}

.pet-character,
.pet-face,
.pet-body,
.pet-ear,
.pet-arm,
.pet-foot {
  position: absolute;
  display: block;
}

.pet-character {
  inset: 0;
  transform-origin: center bottom;
  filter: drop-shadow(0 16px 18px rgba(21, 26, 24, 0.16));
  translate: 0 0;
  rotate: -1deg;
  animation: petIdle 3.2s ease-in-out infinite;
}

.pet-face {
  left: 15px;
  top: 4px;
  width: 62px;
  height: 58px;
  border: 3px solid #171716;
  border-radius: 47% 47% 44% 44%;
  background:
    radial-gradient(circle at 25% 24%, rgba(255, 255, 255, 0.7) 0 8px, transparent 9px),
    var(--brand-yellow);
  z-index: 3;
  animation: petHeadBob 3.2s ease-in-out infinite;
}

.pet-ear {
  top: 4px;
  width: 24px;
  height: 26px;
  border: 3px solid #171716;
  background: var(--brand-yellow);
  z-index: 2;
}

.pet-ear-left {
  left: 14px;
  border-radius: 18px 8px 12px 10px;
  transform: rotate(-18deg);
}

.pet-ear-right {
  right: 14px;
  border-radius: 8px 18px 10px 12px;
  transform: rotate(18deg);
}

.pet-eye {
  position: absolute;
  top: 23px;
  width: 8px;
  height: 10px;
  border-radius: 999px;
  background: #171716;
  animation: petBlink 5.2s ease-in-out infinite;
}

.pet-eye-left {
  left: 18px;
}

.pet-eye-right {
  right: 18px;
}

.pet-cheek {
  position: absolute;
  top: 34px;
  width: 10px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 92, 113, 0.52);
}

.pet-cheek-left {
  left: 9px;
}

.pet-cheek-right {
  right: 9px;
}

.pet-mouth {
  position: absolute;
  left: 50%;
  top: 34px;
  width: 12px;
  height: 7px;
  border-bottom: 3px solid #171716;
  border-radius: 0 0 999px 999px;
  transform: translateX(-50%);
}

.pet-badge {
  position: absolute;
  left: 50%;
  bottom: -11px;
  min-width: 30px;
  height: 19px;
  display: grid;
  place-items: center;
  border: 2px solid #171716;
  border-radius: 999px;
  background: #fff;
  color: #171716;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  transform: translateX(-50%);
}

.pet-body {
  left: 21px;
  top: 52px;
  width: 50px;
  height: 42px;
  border: 3px solid #171716;
  border-radius: 24px 24px 18px 18px;
  background: var(--brand-yellow);
  z-index: 1;
}

.pet-belly {
  position: absolute;
  left: 50%;
  top: 14px;
  width: 25px;
  height: 20px;
  border: 2px solid rgba(23, 23, 22, 0.88);
  border-radius: 999px;
  background: var(--brand-cyan);
  transform: translateX(-50%);
}

.pet-arm {
  top: 61px;
  width: 18px;
  height: 25px;
  border: 3px solid #171716;
  border-radius: 999px;
  background: var(--brand-yellow);
  z-index: 0;
}

.pet-arm-left {
  left: 13px;
  transform: rotate(24deg);
  animation: petWaveLeft 3.8s ease-in-out infinite;
}

.pet-arm-right {
  right: 13px;
  transform: rotate(-24deg);
  animation: petWaveRight 4.2s ease-in-out infinite;
}

.pet-foot {
  top: 88px;
  width: 22px;
  height: 12px;
  border: 3px solid #171716;
  border-radius: 999px;
  background: #fff;
  z-index: 4;
}

.pet-foot-left {
  left: 24px;
  animation: petStepLeft 3.2s ease-in-out infinite;
}

.pet-foot-right {
  right: 24px;
  animation: petStepRight 3.2s ease-in-out infinite;
}

.pet-spark {
  position: absolute;
  right: 12px;
  top: 9px;
  width: 13px;
  height: 13px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--brand-cyan);
  box-shadow: 0 0 0 2px rgba(40, 169, 209, 0.16);
  z-index: 5;
  animation: petSparkPulse 2.4s ease-in-out infinite;
}

.pet-sprite,
.pet-choice-sprite {
  --pet-pixel: 6px;
  display: grid;
  gap: 0;
  image-rendering: pixelated;
  transform-origin: center bottom;
}

.pet-sprite {
  position: absolute;
  right: 8px;
  bottom: 5px;
  padding: 7px;
  border: 3px solid #171716;
  border-radius: 6px;
  background: #fff8dc;
  box-shadow:
    inset 0 -6px 0 rgba(23, 23, 22, 0.08),
    0 10px 0 rgba(23, 23, 22, 0.08);
  animation: petIdle 3.2s steps(2, end) infinite;
}

.pet-choice-sprite {
  --pet-pixel: 3px;
  padding: 4px;
  border: 2px solid #171716;
  border-radius: 4px;
  background: #fff8dc;
}

.pet-sprite.has-custom-image,
.pet-choice-sprite.has-custom-image {
  display: block;
  overflow: hidden;
  image-rendering: auto;
}

.pet-sprite.has-custom-image {
  width: 82px;
  height: 82px;
  right: 5px;
  bottom: 8px;
  border-radius: 18px;
  background: #fff;
}

.pet-choice-sprite.has-custom-image {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: #fff;
}

.pet-sprite.has-custom-image img,
.pet-choice-sprite.has-custom-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pet-pixel {
  width: var(--pet-pixel);
  height: var(--pet-pixel);
}

.studio-pet.is-happy .pet-character {
  animation: petHappy 0.82s ease both;
}

.studio-pet.is-happy .pet-sprite {
  animation: petHappy 0.82s steps(4, end) both;
}

.studio-pet.is-happy .pet-arm-left {
  animation: petCheerLeft 0.82s ease both;
}

.studio-pet.is-happy .pet-arm-right {
  animation: petCheerRight 0.82s ease both;
}

.studio-pet.is-worried .pet-character {
  animation: petWiggle 0.68s ease both;
}

.studio-pet.is-worried .pet-sprite {
  animation: petWiggle 0.68s steps(4, end) both;
}

.studio-pet.is-chatty .pet-character {
  animation: petChatty 0.86s ease both;
}

.studio-pet.is-chatty .pet-sprite {
  animation: petChatty 0.86s steps(3, end) both;
}

.studio-pet.is-chatty .pet-mouth {
  animation: petTalk 0.86s ease both;
}

.pet-avatar:hover .pet-character {
  rotate: 2deg;
  translate: 0 -3px;
}

.studio-pet.is-collapsed .pet-bubble {
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
}

.studio-pet.is-dragged {
  right: auto;
  bottom: auto;
}

.quick-undo:not(.hidden) + .studio-pet:not(.is-dragged) {
  bottom: 98px;
}

@keyframes petFloat {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-5px);
  }
}

@keyframes petIdle {
  0%,
  100% {
    translate: 0 0;
    rotate: -1.5deg;
  }

  30% {
    translate: 0 -2px;
    rotate: 1deg;
  }

  62% {
    translate: 0 1px;
    rotate: 2deg;
  }
}

@keyframes petHeadBob {
  0%,
  100% {
    translate: 0 0;
  }

  42% {
    translate: 0 -2px;
  }

  70% {
    translate: 1px 0;
  }
}

@keyframes petShadow {
  0%,
  100% {
    transform: scaleX(1);
    opacity: 0.72;
  }

  50% {
    transform: scaleX(0.82);
    opacity: 0.46;
  }
}

@keyframes petBlink {
  0%,
  92%,
  100% {
    transform: scaleY(1);
  }

  95% {
    transform: scaleY(0.12);
  }
}

@keyframes petWaveLeft {
  0%,
  100% {
    transform: rotate(24deg);
  }

  50% {
    transform: rotate(38deg) translateY(-2px);
  }
}

@keyframes petWaveRight {
  0%,
  100% {
    transform: rotate(-24deg);
  }

  50% {
    transform: rotate(-35deg) translateY(-1px);
  }
}

@keyframes petStepLeft {
  0%,
  100% {
    transform: translateY(0) rotate(0);
  }

  45% {
    transform: translateY(-2px) rotate(-7deg);
  }
}

@keyframes petStepRight {
  0%,
  100% {
    transform: translateY(-1px) rotate(0);
  }

  55% {
    transform: translateY(1px) rotate(7deg);
  }
}

@keyframes petSparkPulse {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.22);
  }
}

@keyframes petHappy {
  0% {
    translate: 0 0;
    rotate: 0deg;
  }

  34% {
    translate: 0 -12px;
    rotate: -8deg;
  }

  62% {
    translate: 0 2px;
    rotate: 7deg;
  }

  100% {
    translate: 0 0;
    rotate: -1deg;
  }
}

@keyframes petCheerLeft {
  0%,
  100% {
    transform: rotate(24deg);
  }

  35%,
  70% {
    transform: rotate(76deg) translateY(-8px);
  }
}

@keyframes petCheerRight {
  0%,
  100% {
    transform: rotate(-24deg);
  }

  35%,
  70% {
    transform: rotate(-76deg) translateY(-8px);
  }
}

@keyframes petWiggle {
  0%,
  100% {
    translate: 0 0;
    rotate: 0deg;
  }

  25% {
    translate: -4px 0;
    rotate: -8deg;
  }

  50% {
    translate: 4px 0;
    rotate: 8deg;
  }

  75% {
    translate: -2px 0;
    rotate: -5deg;
  }
}

@keyframes petChatty {
  0%,
  100% {
    translate: 0 0;
    rotate: -1deg;
  }

  45% {
    translate: 0 -5px;
    rotate: 4deg;
  }
}

@keyframes petTalk {
  0%,
  100% {
    height: 7px;
  }

  35%,
  70% {
    height: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pet-avatar,
  .pet-avatar::after,
  .pet-sprite,
  .pet-character,
  .pet-face,
  .pet-eye,
  .pet-arm-left,
  .pet-arm-right,
  .pet-foot-left,
  .pet-foot-right,
  .pet-spark {
    animation: none !important;
  }
}

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

.toast.is-visible {
  display: flex;
}

.quick-undo {
  position: fixed;
  left: 20px;
  right: 20px;
  bottom: 18px;
  z-index: 32;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  max-width: 560px;
  margin: 0 auto;
  border: 1px solid rgba(36, 107, 90, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 42px rgba(29, 37, 32, 0.18);
  padding: 12px;
}

.quick-undo strong,
.quick-undo span {
  display: block;
}

.quick-undo span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

@media (max-width: 960px) {
  .kpi-grid,
  .summary-strip,
  .student-profile-grid,
  .company-balance-grid,
  .capital-summary-grid,
  .settlement-grid,
  .settlement-preview,
  .payment-panel,
  .add-student-panel,
  .company-transaction-grid,
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 680px) {
  body {
    padding-bottom: 72px;
  }

  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 14px;
  }

  .topbar,
  .view-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-meta,
  .topbar-account {
    justify-content: flex-start;
  }

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

  .add-student-panel {
    grid-template-columns: 1fr;
  }

  .add-student-panel > .primary {
    width: 100%;
  }

  #checkinView .checkin-sticky-panel {
    position: sticky;
    top: 0;
    z-index: 18;
    display: block;
    margin: 0 -10px 12px;
    border: 1px solid rgba(219, 225, 220, 0.96);
    border-radius: 8px;
    background: rgba(246, 247, 245, 0.94);
    box-shadow: 0 12px 28px rgba(29, 37, 32, 0.08);
    padding: 10px;
    backdrop-filter: blur(10px);
  }

  #checkinView .view-head {
    gap: 10px;
    margin-bottom: 10px;
  }

  #checkinView .view-head h2 {
    font-size: 22px;
  }

  #checkinView .toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) 46px;
    align-items: end;
    width: 100%;
  }

  #checkinView .toolbar .field.compact {
    min-width: 0;
  }

  #checkinView .toolbar .icon-button {
    width: 46px;
    min-height: 44px;
  }

  #checkinView .section-tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    margin-bottom: 0;
  }

  #checkinView .search-field {
    min-width: 0;
    flex-basis: auto;
  }

  #checkinView .section-tools .secondary {
    min-height: 44px;
    padding: 0 10px;
  }

  .kpi-grid,
  .summary-strip,
  .student-profile-grid,
  .company-balance-grid,
  .capital-summary-grid,
  .settlement-grid,
  .settlement-preview,
  .payment-panel,
  .company-transaction-grid,
  .settings-grid,
  .student-grid,
  .student-detail-grid,
  .finance-grid,
  .lesson-balance {
    grid-template-columns: 1fr;
  }

  #checkinView .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
  }

  #checkinView .kpi {
    min-height: 66px;
    padding: 10px;
  }

  #checkinView .kpi strong {
    font-size: 24px;
    margin-bottom: 2px;
  }

  #checkinView .student-grid {
    gap: 8px;
  }

  #checkinView .student-card {
    min-height: 0;
    gap: 10px;
    padding: 12px;
  }

  #checkinView .student-card-head {
    align-items: center;
  }

  #checkinView .student-name {
    font-size: 18px;
  }

  #checkinView .student-meta {
    font-size: 13px;
  }

  #checkinView .lesson-balance {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  #checkinView .lesson-balance div {
    min-height: 48px;
    padding: 7px;
  }

  #checkinView .lesson-balance strong {
    font-size: 17px;
  }

  #checkinView .lesson-balance span {
    font-size: 11px;
  }

  #checkinView .card-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  #checkinView .student-card:not(.is-checked) .card-actions {
    grid-template-columns: 1fr;
  }

  #checkinView .card-actions button {
    min-height: 48px;
    width: 100%;
    font-size: 15px;
  }

  #checkinView .card-actions .primary {
    grid-column: 1 / -1;
  }

  .quick-undo {
    left: 10px;
    right: 10px;
    bottom: 10px;
    padding: 10px;
  }

  .quick-undo .compact-button {
    min-height: 42px;
    padding: 0 14px;
  }

  .record-controls,
  .section-tools,
  .profile-head,
  .profile-actions,
  .editor-head {
    align-items: stretch;
    flex-direction: column;
  }

  .month-switcher {
    width: 100%;
  }

  .segmented,
  .field.compact {
    width: 100%;
  }

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

  .segmented button {
    flex: 1;
  }

  .calendar-weekdays span {
    min-height: 32px;
    font-size: 12px;
  }

  .calendar-day {
    min-height: 82px;
    padding: 7px;
    gap: 5px;
  }

  .day-number {
    width: 26px;
    height: 26px;
  }

  .day-count,
  .day-names,
  .day-empty {
    font-size: 11px;
  }

  .history-search {
    max-width: none;
  }

  .history-student-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .history-status,
  .history-actions {
    justify-content: flex-start;
  }

  .student-month-controls {
    align-items: stretch;
  }

  .student-detail-head {
    flex-direction: column;
  }

  .cycle-head,
  .mini-head,
  .mini-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .cycle-records div {
    grid-template-columns: 1fr;
  }

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

  .trend-row {
    grid-template-columns: 1fr;
  }

  .trend-row strong {
    text-align: left;
  }
}

/* Visual refresh: cleaner internal dashboard styling. */
:root {
  --bg: #f4f6f7;
  --panel: #ffffff;
  --ink: #151a18;
  --muted: #66706b;
  --line: #dde4e1;
  --accent: #16755f;
  --accent-strong: #0e5344;
  --accent-soft: #e7f4ef;
  --brand-yellow: #f4bd34;
  --brand-yellow-soft: #fff4d6;
  --brand-cyan: #28a9d1;
  --blue: #2f5f93;
  --amber: #986115;
  --amber-soft: #fff2d7;
  --red: #b43d3d;
  --red-soft: #ffe6e6;
  --shadow: 0 10px 30px rgba(21, 26, 24, 0.07);
  --shadow-soft: 0 1px 0 rgba(21, 26, 24, 0.04);
}

body {
  background:
    linear-gradient(180deg, rgba(244, 189, 52, 0.18), rgba(244, 246, 247, 0) 210px),
    linear-gradient(90deg, rgba(40, 169, 209, 0.08), rgba(255, 255, 255, 0) 44%),
    var(--bg);
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.app-shell {
  width: min(1240px, calc(100% - 36px));
  padding-top: 22px;
}

.topbar {
  min-height: 82px;
  border: 1px solid rgba(221, 228, 225, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow-soft);
  padding: 14px 16px;
  backdrop-filter: blur(12px);
}

.brand-logo {
  border: 2px solid rgba(21, 26, 24, 0.1);
  box-shadow: 0 10px 22px rgba(244, 189, 52, 0.25);
}

.brand h1 {
  font-size: 32px;
}

.brand p,
.view-head p,
.panel-head p,
.student-meta,
.mini-head span {
  color: var(--muted);
}

.topbar-meta span,
.user-badge,
.pill,
.status-chip,
.month-summary-row span,
.balance-chip,
.cycle-stats span {
  min-height: 30px;
  border-color: rgba(221, 228, 225, 0.9);
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.user-badge {
  color: var(--ink);
  border-color: rgba(40, 169, 209, 0.28);
  background: #eef9fc;
}

.tabs {
  position: sticky;
  top: 10px;
  z-index: 20;
  gap: 4px;
  margin: 14px 0 24px;
  padding: 5px;
  border-color: rgba(221, 228, 225, 0.9);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

.tab {
  min-height: 46px;
  border-radius: 6px;
  color: #4f5b55;
}

.tab:hover {
  background: #f6f8f7;
  color: var(--ink);
}

.tab.is-active {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 8px 20px rgba(21, 26, 24, 0.16);
}

.tab.is-active .tab-icon {
  color: var(--brand-yellow);
}

.view-head h2 {
  font-size: 28px;
}

.field input,
.field select,
.field textarea,
.search-field input,
.table-input {
  border-color: #d8dfdc;
  border-radius: 6px;
  background: #fff;
}

.field input:hover,
.field select:hover,
.field textarea:hover,
.search-field input:hover,
.table-input:hover {
  border-color: #c5d0cb;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-field input:focus,
.table-input:focus {
  border-color: var(--brand-cyan);
  box-shadow: 0 0 0 3px rgba(40, 169, 209, 0.16);
}

.kpi,
.student-card,
.panel,
.payment-panel,
.finance-panel,
.student-detail-panel,
.calendar-panel,
.table-wrap,
.mini-table-wrap,
.profile-card,
.login-card {
  border-color: rgba(221, 228, 225, 0.94);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kpi {
  min-height: 92px;
  border-left: 4px solid var(--brand-yellow);
  background: linear-gradient(180deg, #fff, #fbfcfb);
}

.kpi strong {
  color: var(--ink);
  font-size: 28px;
}

.student-grid {
  gap: 14px;
}

.student-card {
  position: relative;
  overflow: hidden;
  gap: 15px;
  border-left: 4px solid transparent;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.student-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(21, 26, 24, 0.1);
}

.student-card.is-checked {
  border-color: rgba(22, 117, 95, 0.36);
  border-left-color: var(--accent);
  background: linear-gradient(180deg, rgba(231, 244, 239, 0.8), #fff 92px);
}

.student-card.needs-attention:not(.is-checked) {
  border-color: rgba(152, 97, 21, 0.32);
  border-left-color: var(--brand-yellow);
}

.student-card.negative-balance:not(.is-checked),
.student-card.needs-attention.negative-balance:not(.is-checked) {
  border-left-color: var(--red);
}

.student-name {
  color: var(--ink);
}

.lesson-balance div,
.student-profile-grid div,
.payment-total,
.balance-row,
.cycle-records div,
.timeline-item,
.student-notes {
  border-color: #e1e7e4;
  background: #fbfcfc;
  box-shadow: var(--shadow-soft);
}

.lesson-balance strong,
.student-profile-grid strong {
  color: var(--ink);
}

.primary,
.secondary,
.danger,
.icon-button,
.file-button,
.row-action {
  border-radius: 6px;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, transform 0.14s ease;
}

.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px rgba(22, 117, 95, 0.18);
}

.primary:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.primary.checked {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 8px 20px rgba(21, 26, 24, 0.14);
}

.secondary,
.row-action,
.icon-button,
.file-button {
  background: #fff;
  color: var(--ink);
}

.secondary:hover,
.row-action:hover,
.icon-button:hover,
.file-button:hover {
  border-color: var(--brand-cyan);
  color: #0d5e75;
  background: #f3fbfd;
}

.danger:hover {
  background: #ffdada;
}

.checked,
.status-chip.checked {
  border-color: rgba(22, 117, 95, 0.24);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.warn,
.warn-chip {
  border-color: rgba(244, 189, 52, 0.42);
  background: var(--brand-yellow-soft);
  color: var(--amber);
}

.negative,
.danger-chip {
  border-color: rgba(180, 61, 61, 0.24);
  background: var(--red-soft);
  color: var(--red);
}

.trial {
  border-color: rgba(40, 169, 209, 0.28);
  background: rgba(40, 169, 209, 0.12);
  color: #0d5e75;
}

.table-wrap,
.mini-table-wrap {
  background: #fff;
}

th {
  background: #f8faf9;
  color: #59645f;
  font-weight: 800;
}

td {
  background: #fff;
}

tbody tr:hover td {
  background: #fbfcfc;
}

.segmented {
  background: #fff;
}

.segmented button.is-active {
  background: var(--ink);
  color: #fff;
}

.calendar-day {
  border-radius: 6px;
}

.calendar-day.has-records {
  border-color: rgba(40, 169, 209, 0.26);
  background: #f3fbfd;
}

.day-number {
  background: #fff;
}

.history-student-row,
.cycle-card {
  border-color: #e1e7e4;
  box-shadow: var(--shadow-soft);
}

.login-screen {
  background:
    linear-gradient(180deg, rgba(244, 189, 52, 0.18), rgba(244, 246, 247, 0) 42%),
    var(--bg);
}

.login-card {
  border-top: 4px solid var(--brand-yellow);
}

.profile-modal {
  backdrop-filter: blur(6px);
}

.quick-undo {
  border-color: rgba(40, 169, 209, 0.28);
  border-radius: 8px;
}

@media (max-width: 680px) {
  body {
    padding-bottom: 92px;
  }

  .app-shell {
    width: min(100% - 18px, 1240px);
    padding-top: 10px;
  }

  .topbar {
    padding: 12px;
  }

  .brand h1 {
    font-size: 25px;
  }

  .brand-logo {
    width: 48px;
    height: 48px;
  }

  .topbar-meta span,
  .user-badge {
    min-height: 26px;
    font-size: 12px;
  }

  .tabs {
    position: fixed;
    left: 10px;
    right: 10px;
    top: auto;
    bottom: 10px;
    z-index: 40;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin: 0;
    padding: 5px;
    border-radius: 8px;
    box-shadow: 0 16px 42px rgba(21, 26, 24, 0.2);
  }

  .tab {
    min-height: 54px;
    flex-direction: column;
    gap: 3px;
    font-size: 12px;
    line-height: 1.1;
  }

  .tab-icon {
    width: auto;
    font-size: 16px;
  }

  #checkinView .checkin-sticky-panel {
    top: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
  }

  #checkinView .section-tools {
    grid-template-columns: 1fr;
  }

  #checkinView .section-tools .secondary {
    width: 100%;
  }

  #checkinView .student-card {
    border-left-width: 5px;
  }

  #checkinView .card-actions button {
    min-height: 52px;
  }

  .quick-undo {
    bottom: 78px;
  }

  .studio-pet {
    right: 12px;
    bottom: 86px;
    width: min(290px, calc(100vw - 24px));
  }

  .pet-avatar {
    width: 78px;
    height: 86px;
  }

  .pet-sprite {
    --pet-pixel: 5px;
    right: 5px;
    bottom: 3px;
    padding: 5px;
  }

  .pet-bubble {
    padding: 11px;
  }

  .pet-bubble p {
    font-size: 13px;
  }

  .quick-undo:not(.hidden) + .studio-pet:not(.is-dragged) {
    bottom: 150px;
  }

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

/* Interface polish pass: tighter, calmer daily-use surfaces. */
.app-shell {
  padding-bottom: 64px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  align-items: center;
}

.topbar-meta {
  padding: 4px;
  border: 1px solid rgba(221, 228, 225, 0.82);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
}

.topbar-meta span {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.topbar-account {
  padding-left: 12px;
  border-left: 1px solid rgba(221, 228, 225, 0.9);
}

.view-head {
  padding: 2px 0 4px;
}

.toolbar {
  padding: 6px;
  border: 1px solid rgba(221, 228, 225, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.toolbar .field.compact {
  min-width: 160px;
}

.section-tools {
  align-items: stretch;
}

.search-field input {
  min-height: 44px;
}

.section-tools .secondary,
.toolbar .icon-button {
  min-height: 44px;
}

.kpi {
  display: grid;
  align-content: center;
  min-height: 86px;
}

.kpi span {
  font-size: 13px;
}

.student-card {
  min-height: 214px;
  padding: 18px;
}

.student-card.is-trial {
  border-left: 5px solid var(--brand-cyan);
}

.student-card-head {
  min-height: 48px;
}

.status-chip {
  font-weight: 800;
}

.lesson-balance div {
  display: grid;
  align-content: center;
}

.card-actions {
  margin-top: 2px;
}

.card-actions .primary {
  min-width: 92px;
}

.table-wrap,
.mini-table-wrap {
  scrollbar-width: thin;
  scrollbar-color: rgba(102, 112, 107, 0.42) transparent;
}

.table-wrap::-webkit-scrollbar,
.mini-table-wrap::-webkit-scrollbar {
  height: 9px;
}

.table-wrap::-webkit-scrollbar-thumb,
.mini-table-wrap::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(102, 112, 107, 0.32);
}

.table-wrap th,
.mini-table-wrap th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.profile-modal {
  padding: 16px;
}

.profile-card {
  width: min(720px, 100%);
  border-top: 4px solid var(--brand-yellow);
}

.profile-head {
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.profile-grid {
  margin-top: 16px;
}

.profile-password {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 14px;
}

.profile-appearance,
.profile-pet {
  background:
    linear-gradient(180deg, rgba(255, 244, 214, 0.62), rgba(255, 255, 255, 0.82)),
    #fff;
}

.profile-appearance {
  background:
    linear-gradient(180deg, rgba(40, 169, 209, 0.08), rgba(255, 255, 255, 0.82)),
    #fff;
}

.profile-pet-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.profile-pet-head::after {
  content: "每个账号可以选自己的默认桌宠";
  color: var(--muted);
  font-size: 12px;
}

.profile-appearance .profile-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.profile-appearance .profile-section-head::after {
  content: "每个账号可以选自己的界面风格";
  color: var(--muted);
  font-size: 12px;
}

.theme-choice {
  position: relative;
  overflow: hidden;
}

.theme-choice.is-active::before {
  content: "已选";
  position: absolute;
  right: 7px;
  top: 7px;
  z-index: 2;
  min-height: 20px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(22, 117, 95, 0.22);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 0 7px;
  font-size: 11px;
  font-weight: 900;
}

.pet-choice {
  position: relative;
  min-height: 104px;
  overflow: hidden;
}

.pet-choice::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 8px;
  height: 7px;
  border-radius: 999px;
  background: rgba(21, 26, 24, 0.08);
}

.pet-choice > span {
  position: relative;
  z-index: 1;
}

.pet-choice.is-active::before {
  content: "已选";
  position: absolute;
  right: 7px;
  top: 7px;
  z-index: 2;
  min-height: 20px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(22, 117, 95, 0.22);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 0 7px;
  font-size: 11px;
  font-weight: 900;
}

.profile-actions {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.login-card {
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 62px;
  background: linear-gradient(90deg, rgba(244, 189, 52, 0.18), rgba(40, 169, 209, 0.08));
  pointer-events: none;
}

.login-card > * {
  position: relative;
}

body.theme-cute {
  --bg: #fff7fb;
  --panel: #ffffff;
  --ink: #241923;
  --muted: #7f6675;
  --line: #eed7e5;
  --accent: #d95793;
  --accent-strong: #9e3269;
  --accent-soft: #ffe5f1;
  --brand-yellow: #ffd26e;
  --brand-yellow-soft: #fff3d5;
  --brand-cyan: #8bd7ff;
  --shadow: 0 12px 32px rgba(112, 65, 92, 0.1);
}

body.theme-watercolor {
  --bg: #f3fafb;
  --panel: #ffffff;
  --ink: #18272a;
  --muted: #60777b;
  --line: #d5e8e8;
  --accent: #287b89;
  --accent-strong: #17535d;
  --accent-soft: #e0f3f5;
  --brand-yellow: #f7d88c;
  --brand-yellow-soft: #fff5d7;
  --brand-cyan: #63bdd5;
  --shadow: 0 12px 32px rgba(52, 105, 116, 0.1);
}

body.theme-noir {
  --bg: #181817;
  --panel: #242423;
  --ink: #f6f0df;
  --muted: #b8ad98;
  --line: #44413a;
  --accent: #d7a63e;
  --accent-strong: #efc65d;
  --accent-soft: #3a301b;
  --brand-yellow: #d7a63e;
  --brand-yellow-soft: #3a301b;
  --brand-cyan: #50b7cc;
  --blue: #68b4d8;
  --amber: #edc15d;
  --red: #ff8b8b;
  --red-soft: #422525;
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.34);
  color-scheme: dark;
}

body.theme-cute {
  background:
    linear-gradient(180deg, rgba(255, 183, 207, 0.26), rgba(255, 247, 251, 0) 220px),
    linear-gradient(90deg, rgba(139, 215, 255, 0.16), rgba(255, 255, 255, 0) 48%),
    var(--bg);
}

body.theme-watercolor {
  background:
    linear-gradient(180deg, rgba(99, 189, 213, 0.18), rgba(243, 250, 251, 0) 230px),
    linear-gradient(120deg, rgba(247, 216, 140, 0.14), rgba(191, 232, 213, 0.18) 55%, rgba(255, 255, 255, 0) 85%),
    var(--bg);
}

body.theme-custom {
  --bg: var(--custom-bg, #f4f6f7);
  --panel: var(--custom-panel, #ffffff);
  --ink: var(--custom-ink, #151a18);
  --muted: var(--custom-muted, #66706b);
  --line: var(--custom-line, #dde4e1);
  --accent: var(--custom-primary, #16755f);
  --accent-strong: var(--custom-primary-strong, #0e5344);
  --accent-soft: var(--custom-accent-soft, #e7f4ef);
  --brand-yellow: var(--custom-accent, #f4bd34);
  --brand-yellow-soft: var(--custom-accent-soft, #fff4d6);
  --brand-cyan: var(--custom-primary, #28a9d1);
  --blue: var(--custom-primary, #2f5f93);
  --amber: var(--custom-accent, #986115);
  --shadow: var(--custom-shadow, 0 10px 30px rgba(21, 26, 24, 0.07));
  background-color: var(--bg);
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.36) 260px, rgba(255, 255, 255, 0.82)),
    linear-gradient(120deg, color-mix(in srgb, var(--custom-primary, #16755f) 20%, transparent), transparent 58%),
    var(--custom-background-image, none);
  background-position: center top, center top, center;
  background-size: auto, auto, cover;
  background-repeat: no-repeat;
  background-attachment: fixed, fixed, fixed;
}

body.theme-noir {
  background:
    linear-gradient(180deg, rgba(215, 166, 62, 0.15), rgba(24, 24, 23, 0) 220px),
    radial-gradient(circle at 16% 8%, rgba(80, 183, 204, 0.12), transparent 30%),
    var(--bg);
}

body.theme-noir .topbar,
body.theme-noir .tabs,
body.theme-noir .toolbar,
body.theme-noir .student-card,
body.theme-noir .panel,
body.theme-noir .payment-panel,
body.theme-noir .finance-panel,
body.theme-noir .student-detail-panel,
body.theme-noir .calendar-panel,
body.theme-noir .table-wrap,
body.theme-noir .mini-table-wrap,
body.theme-noir .profile-card,
body.theme-noir .login-card,
body.theme-noir .pet-bubble {
  background: rgba(36, 36, 35, 0.94);
}

body.theme-noir .field input,
body.theme-noir .field select,
body.theme-noir .field textarea,
body.theme-noir .search-field input,
body.theme-noir .table-input,
body.theme-noir .secondary,
body.theme-noir .row-action,
body.theme-noir .icon-button,
body.theme-noir .file-button,
body.theme-noir td,
body.theme-noir .theme-choice,
body.theme-noir .pet-choice,
body.theme-noir .lesson-balance div,
body.theme-noir .student-profile-grid div,
body.theme-noir .payment-total,
body.theme-noir .balance-row,
body.theme-noir .company-balance-grid div,
body.theme-noir .capital-summary-grid div,
body.theme-noir .settlement-grid div,
body.theme-noir .settlement-preview div,
body.theme-noir .cycle-records div,
body.theme-noir .timeline-item,
body.theme-noir .student-notes,
body.theme-noir .profile-appearance,
body.theme-noir .profile-pet,
body.theme-noir .custom-theme-builder,
body.theme-noir .custom-pet-builder,
body.theme-noir .custom-image-preview,
body.theme-noir .custom-review-preview > div,
body.theme-noir .color-field input {
  background: #242423;
  color: var(--ink);
}

body.theme-noir th,
body.theme-noir tbody tr:hover td {
  background: #2d2d2b;
}

body.theme-noir .topbar-meta,
body.theme-noir .topbar-meta span,
body.theme-noir .user-badge,
body.theme-noir .status-chip,
body.theme-noir .month-summary-row span,
body.theme-noir .balance-chip {
  background: rgba(36, 36, 35, 0.78);
  color: var(--ink);
}

body.theme-noir .tab:hover,
body.theme-noir .theme-choice:hover,
body.theme-noir .theme-choice.is-active,
body.theme-noir .pet-choice:hover,
body.theme-noir .pet-choice.is-active {
  background: #302f2c;
}

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

  .topbar-meta,
  .topbar-account {
    justify-content: flex-start;
  }

  .topbar-account {
    padding-left: 0;
    border-left: 0;
  }

  .profile-password {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .topbar {
    gap: 12px;
  }

  .topbar-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, max-content));
  }

  .topbar-account {
    display: grid;
    grid-template-columns: 1fr auto auto;
    width: 100%;
  }

  .topbar-account .user-badge {
    justify-content: center;
  }

  .toolbar {
    padding: 0;
    border: 0;
    background: transparent;
  }

  .student-card {
    min-height: 0;
    padding: 14px;
  }

  .profile-modal {
    align-items: end;
    padding: 8px;
  }

  .profile-card {
    width: 100%;
    max-height: min(92vh, 820px);
    border-radius: 8px 8px 0 0;
  }

  .profile-head,
  .profile-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .profile-pet-head {
    display: block;
  }

  .profile-pet-head::after {
    display: block;
    margin-top: 4px;
  }

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

  .custom-upload-row,
  .custom-color-grid,
  .custom-pet-fields {
    grid-template-columns: 1fr;
  }

  .custom-image-preview {
    width: 100%;
    max-width: 180px;
  }

  .custom-upload-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Product UI pass: app-like layout and cleaner daily-use surfaces. */
:root {
  --surface: #ffffff;
  --surface-soft: #f9fbfa;
  --surface-warm: #fff9e8;
  --ink-soft: #303a35;
  --ring: rgba(40, 169, 209, 0.18);
  --card-shadow: 0 18px 45px rgba(21, 26, 24, 0.08);
  --raised-shadow: 0 24px 60px rgba(21, 26, 24, 0.12);
}

body {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 248, 225, 0.86), rgba(244, 246, 247, 0.38) 250px, var(--bg) 620px),
    linear-gradient(90deg, rgba(40, 169, 209, 0.08), transparent 46%),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(21, 26, 24, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(21, 26, 24, 0.03) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.32), transparent 58%);
}

.login-screen {
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(255, 249, 232, 0.78), rgba(244, 246, 247, 0.84)),
    var(--bg);
}

.login-card {
  width: min(458px, 100%);
  gap: 18px;
  border: 1px solid rgba(221, 228, 225, 0.96);
  border-top: 0;
  box-shadow: 0 24px 70px rgba(21, 26, 24, 0.12);
  padding: 28px;
}

.login-card::before {
  height: 70px;
  background:
    linear-gradient(90deg, rgba(244, 189, 52, 0.28), rgba(40, 169, 209, 0.12)),
    var(--surface);
}

.login-brand {
  align-items: center;
  padding-bottom: 8px;
}

.login-brand h1 {
  font-size: 30px;
}

.login-logo {
  width: 68px;
  height: 68px;
}

.field span,
.search-field span {
  font-weight: 700;
}

.field input,
.field select,
.field textarea,
.search-field input,
.table-input {
  min-height: 42px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-field input:focus,
.table-input:focus {
  box-shadow: 0 0 0 4px var(--ring);
}

.primary,
.secondary,
.danger,
.icon-button,
.file-button,
.row-action {
  min-height: 40px;
  transition:
    transform 0.14s ease,
    border-color 0.14s ease,
    background-color 0.14s ease,
    color 0.14s ease,
    box-shadow 0.14s ease;
}

.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 10px 22px rgba(22, 117, 95, 0.2);
}

.primary:hover {
  box-shadow: 0 13px 28px rgba(22, 117, 95, 0.24);
  transform: translateY(-1px);
}

.secondary,
.row-action,
.icon-button,
.file-button {
  background: rgba(255, 255, 255, 0.92);
}

.secondary:hover,
.row-action:hover,
.icon-button:hover,
.file-button:hover {
  box-shadow: 0 8px 18px rgba(21, 26, 24, 0.07);
  transform: translateY(-1px);
}

.topbar {
  border-color: rgba(221, 228, 225, 0.98);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.74)),
    var(--surface);
  box-shadow: var(--card-shadow);
}

.brand h1 {
  color: var(--ink);
  letter-spacing: 0;
}

.brand p {
  color: var(--muted);
}

.brand-logo {
  background: var(--brand-yellow);
  box-shadow: 0 12px 28px rgba(244, 189, 52, 0.3);
}

.tabs {
  border-color: rgba(221, 228, 225, 0.96);
  box-shadow: var(--card-shadow);
}

.tab {
  position: relative;
  font-size: 15px;
}

.tab-icon {
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(21, 26, 24, 0.05);
}

.tab.is-active .tab-icon {
  background: rgba(244, 189, 52, 0.18);
}

.view-head {
  min-height: 54px;
  margin-bottom: 18px;
}

.view-head h2 {
  color: var(--ink);
  font-size: 30px;
}

.toolbar,
.section-tools,
.record-controls {
  gap: 10px;
}

.toolbar {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(249, 251, 250, 0.82)),
    var(--surface);
}

.kpi-grid {
  gap: 14px;
}

.kpi,
.student-card,
.panel,
.payment-panel,
.finance-panel,
.student-detail-panel,
.calendar-panel,
.table-wrap,
.mini-table-wrap {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(253, 254, 253, 0.96)),
    var(--surface);
  box-shadow: var(--card-shadow);
}

.kpi {
  position: relative;
  overflow: hidden;
  border-left: 0;
}

.kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(180deg, var(--brand-yellow), var(--brand-cyan));
}

.kpi strong {
  font-size: 31px;
}

.student-card {
  border-left-width: 0;
  box-shadow: 0 12px 32px rgba(21, 26, 24, 0.07);
}

.student-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: rgba(221, 228, 225, 0.95);
}

.student-card.is-checked::before {
  background: var(--accent);
}

.student-card.needs-attention:not(.is-checked)::before {
  background: var(--brand-yellow);
}

.student-card.negative-balance:not(.is-checked)::before,
.student-card.needs-attention.negative-balance:not(.is-checked)::before {
  background: var(--red);
}

.student-card:hover {
  box-shadow: var(--raised-shadow);
}

.lesson-balance div,
.student-profile-grid div,
.payment-total,
.balance-row,
.cycle-records div,
.timeline-item,
.student-notes {
  background: var(--surface-soft);
}

.lesson-balance strong {
  color: var(--ink);
}

.status-chip,
.user-badge,
.pill,
.balance-chip {
  font-weight: 800;
}

.table-wrap,
.mini-table-wrap {
  border-radius: 8px;
}

th {
  color: var(--ink-soft);
  font-weight: 900;
}

td {
  color: var(--ink);
}

tbody tr {
  transition: background-color 0.12s ease;
}

tbody tr:hover td {
  background: rgba(244, 189, 52, 0.07);
}

.segmented {
  background: rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.segmented button.is-active {
  background: linear-gradient(135deg, var(--ink), #2f3834);
}

.calendar-day {
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.calendar-day:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(21, 26, 24, 0.08);
}

.calendar-day.is-selected {
  box-shadow: 0 12px 28px rgba(22, 117, 95, 0.18);
}

.quick-undo {
  box-shadow: 0 18px 44px rgba(21, 26, 24, 0.18);
}

.toast {
  box-shadow: 0 16px 38px rgba(21, 26, 24, 0.2);
}

.holiday-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.holiday-panel,
.holiday-enrollment-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(253, 254, 253, 0.96)),
    var(--surface);
  box-shadow: var(--card-shadow);
  padding: 16px;
}

.holiday-enrollment-panel {
  display: grid;
  grid-template-columns: minmax(190px, 1.2fr) repeat(3, minmax(130px, 1fr));
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
}

.holiday-enrollment-panel h3,
.holiday-enrollment-panel p {
  margin: 0;
}

.holiday-enrollment-panel p {
  color: var(--muted);
  margin-top: 4px;
}

.holiday-checkin-list,
.holiday-week-list {
  display: grid;
  gap: 10px;
}

.holiday-student-card,
.holiday-week-row {
  display: grid;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.holiday-student-card {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.holiday-student-card.is-checked {
  border-color: rgba(22, 117, 95, 0.24);
  background: linear-gradient(180deg, rgba(231, 244, 239, 0.8), #fff);
}

.holiday-student-card strong,
.holiday-week-row strong {
  display: block;
  font-size: 17px;
}

.holiday-student-card span:not(.status-chip),
.holiday-week-row span:not(.status-chip) {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

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

.holiday-week-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.holiday-week-badges {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.holiday-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(142px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

@media (min-width: 1060px) {
  .app-shell {
    width: min(1360px, calc(100% - 44px));
    display: grid;
    grid-template-columns: 218px minmax(0, 1fr);
    grid-template-areas:
      "topbar topbar"
      "tabs main";
    column-gap: 18px;
    row-gap: 16px;
    align-items: start;
  }

  .topbar {
    grid-area: topbar;
  }

  .tabs {
    grid-area: tabs;
    position: sticky;
    top: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-self: start;
    margin: 0;
    padding: 10px;
  }

  .tab {
    justify-content: flex-start;
    min-height: 52px;
    padding: 0 14px;
  }

  .tab-icon {
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
  }

  main {
    grid-area: main;
    min-width: 0;
  }

  .checkin-sticky-panel {
    display: block;
    position: sticky;
    top: 18px;
    z-index: 15;
    margin-bottom: 16px;
    border: 1px solid rgba(221, 228, 225, 0.9);
    border-radius: 8px;
    background: rgba(244, 246, 247, 0.88);
    box-shadow: 0 14px 34px rgba(21, 26, 24, 0.08);
    padding: 14px;
    backdrop-filter: blur(14px);
  }

  #checkinView .view-head {
    margin-bottom: 12px;
  }

  #checkinView .section-tools {
    margin-bottom: 0;
  }
}

@media (max-width: 1059px) {
  .tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  body {
    padding-bottom: 96px;
  }

  .app-shell {
    width: min(100% - 18px, 1180px);
  }

  .topbar {
    padding: 12px;
  }

  .brand {
    width: 100%;
  }

  .brand h1 {
    font-size: 24px;
  }

  .brand-logo {
    width: 48px;
    height: 48px;
  }

  .topbar-meta {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar-meta span {
    justify-content: center;
    min-width: 0;
  }

  .tabs {
    position: fixed;
    left: 9px;
    right: 9px;
    bottom: 9px;
    top: auto;
    z-index: 70;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    margin: 0;
    padding: 6px;
    border-radius: 8px;
  }

  .tab {
    min-height: 58px;
    flex-direction: column;
    gap: 3px;
    padding: 4px 2px;
    font-size: 12px;
    line-height: 1.1;
  }

  .tab-icon {
    width: 24px;
    height: 24px;
  }

  .view-head h2 {
    font-size: 24px;
  }

  #checkinView .checkin-sticky-panel {
    top: 0;
    border-radius: 8px;
    background: rgba(244, 246, 247, 0.94);
  }

  #checkinView .toolbar {
    gap: 7px;
  }

  #checkinView .section-tools {
    grid-template-columns: 1fr;
  }

  #checkinView .section-tools .secondary {
    width: 100%;
  }

  #checkinView .card-actions button {
    min-height: 50px;
  }

  .quick-undo {
    bottom: 86px;
  }

  .studio-pet {
    right: 10px;
    bottom: 96px;
  }

  .quick-undo:not(.hidden) + .studio-pet:not(.is-dragged) {
    bottom: 168px;
  }

  .login-card {
    padding: 24px;
  }
}

body.theme-noir::before {
  background:
    linear-gradient(90deg, rgba(246, 240, 223, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(246, 240, 223, 0.03) 1px, transparent 1px);
  background-size: 44px 44px;
}

/* Mobile check-in ergonomics: bigger targets, clearer feedback, less thumb travel. */
.tab,
.primary,
.secondary,
.danger,
.icon-button,
.file-button,
.row-action {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.primary:active,
.secondary:active,
.danger:active,
.icon-button:active,
.file-button:active,
.row-action:active,
.primary.is-tapping,
.secondary.is-tapping,
.danger.is-tapping,
.icon-button.is-tapping,
.file-button.is-tapping,
.row-action.is-tapping {
  transform: translateY(1px) scale(0.985);
}

#checkinView .card-actions .primary:not(.checked) {
  background: linear-gradient(135deg, #118765, #0d5f4c);
}

#checkinView .card-actions .primary.checked {
  border: 1px solid rgba(22, 117, 95, 0.22);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: none;
}

#checkinView .card-actions .secondary[data-action="undo"],
#quickUndoBar [data-action="quick-undo"] {
  border-color: rgba(180, 61, 61, 0.24);
  color: var(--red);
}

@media (hover: none), (pointer: coarse) {
  .student-card:hover,
  .calendar-day:hover,
  .primary:hover,
  .secondary:hover,
  .danger:hover,
  .icon-button:hover,
  .file-button:hover,
  .row-action:hover {
    transform: none;
  }
}

@media (max-width: 760px) {
  #checkinView .checkin-sticky-panel {
    margin: 0 -9px 12px;
    padding: 9px;
  }

  #checkinView .view-head {
    gap: 8px;
    margin-bottom: 8px;
  }

  #checkinView .view-head h2 {
    font-size: 22px;
  }

  #checkinSubtitle {
    display: inline-flex;
    width: fit-content;
    min-height: 28px;
    align-items: center;
    border: 1px solid rgba(221, 228, 225, 0.9);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.78);
    padding: 3px 9px;
    font-size: 12px;
  }

  #checkinView .toolbar {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr) 48px;
    gap: 7px;
    padding: 6px;
  }

  #checkinView .toolbar .field span {
    font-size: 12px;
  }

  #checkinView .toolbar .field input,
  #checkinView .toolbar .field select,
  #checkinView .toolbar .icon-button {
    min-height: 46px;
  }

  #checkinView .section-tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 52px;
    gap: 8px;
  }

  #checkinView .section-tools .secondary {
    width: 52px;
    min-height: 46px;
    padding: 0;
    font-size: 0;
  }

  #checkinView .section-tools .secondary span {
    font-size: 18px;
  }

  #checkinView .search-field input {
    min-height: 46px;
    font-size: 16px;
  }

  #checkinView .kpi-grid {
    gap: 7px;
    margin-bottom: 8px;
  }

  #checkinView .kpi {
    min-height: 58px;
    padding: 9px 10px 9px 14px;
  }

  #checkinView .kpi strong {
    font-size: 22px;
  }

  #checkinView .kpi span {
    font-size: 12px;
  }

  #checkinView .student-grid {
    gap: 10px;
  }

  #checkinView .student-card {
    scroll-margin-top: 188px;
    gap: 11px;
    padding: 14px;
    touch-action: pan-y;
  }

  #checkinView .student-card-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    min-height: 0;
  }

  #checkinView .student-name {
    font-size: 19px;
    line-height: 1.15;
  }

  #checkinView .student-meta {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    font-size: 12px;
  }

  #checkinView .status-chip {
    min-height: 34px;
    align-self: start;
    justify-content: center;
    padding: 5px 9px;
    font-size: 12px;
  }

  #checkinView .lesson-balance {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #checkinView .lesson-balance div {
    min-height: 46px;
    padding: 6px;
  }

  #checkinView .lesson-balance strong {
    font-size: 18px;
  }

  #checkinView .card-actions {
    gap: 8px;
  }

  #checkinView .card-actions button {
    min-height: 54px;
    font-size: 15px;
  }

  #checkinView .student-card:not(.is-checked) .card-actions .primary {
    min-height: 58px;
    font-size: 17px;
  }

  #checkinView .student-card.is-checked .card-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #checkinView .student-card.is-checked .card-actions .primary {
    min-height: 46px;
    grid-column: 1 / -1;
  }

  .quick-undo {
    grid-template-columns: minmax(0, 1fr) 88px;
    bottom: 84px;
    border-radius: 8px;
  }

  .quick-undo .compact-button {
    min-height: 46px;
  }
}

@media (max-width: 960px) {
  .holiday-grid,
  .holiday-enrollment-panel,
  .holiday-settings-grid {
    grid-template-columns: 1fr;
  }

  .holiday-student-card,
  .holiday-week-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .holiday-card-actions,
  .holiday-week-badges {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  #holidayView .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr 48px 52px;
    width: 100%;
  }

  #holidayView .toolbar .secondary {
    width: 52px;
    padding: 0;
    font-size: 0;
  }

  #holidayView .toolbar .secondary span {
    font-size: 18px;
  }

  .holiday-panel,
  .holiday-enrollment-panel {
    padding: 14px;
  }

  .holiday-card-actions button,
  .holiday-enrollment-panel .primary {
    width: 100%;
    min-height: 52px;
  }
}

@media (min-width: 761px) and (max-width: 1059px) {
  .tabs {
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  }
}

@media (max-width: 760px) {
  .tabs {
    display: flex;
  }

  .tab {
    flex: 1 1 0;
    min-width: 0;
    font-size: 11px;
  }
}
