:root {
  --rose: #b86d79;
  --rose-deep: #984f5d;
  --rose-soft: #f7e9ec;
  --ink: #201a1c;
  --muted: #756a6d;
  --line: #eadde0;
  --canvas: #f8f5f5;
  --white: #fff;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-family: Arial, Helvetica, sans-serif; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.eyebrow { margin: 0 0 5px; color: var(--rose-deep); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 286px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 18px; border-right: 1px solid var(--line); background: var(--white); box-shadow: 10px 0 32px rgba(59,33,39,.035); }
.brand-panel { display: grid; gap: 10px; padding: 0 4px 22px; border-bottom: 1px solid var(--line); }
.brand-logo { width: 174px; height: 78px; display: block; object-fit: contain; }
.brand-panel h1 { margin: 0; font-size: 16px; line-height: 1.25; }
.mobile-menu-button { display: none; }
.sidebar-body { min-height: 0; flex: 1; display: flex; flex-direction: column; }
.sidebar-nav { padding: 20px 0 14px; }
.nav-item, .module-item { width: 100%; display: flex; align-items: center; gap: 11px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); text-align: left; font-weight: 700; }
.nav-item { padding: 12px 14px; }
.nav-item.active, .module-item.active { background: var(--rose-soft); color: var(--rose-deep); }
.nav-icon { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 8px; background: var(--white); }
.modules-heading { display: flex; align-items: center; justify-content: space-between; margin: 4px 6px 10px; color: #95888c; font-size: 11px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.icon-button { width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 9px; background: var(--white); color: var(--rose-deep); font-size: 20px; line-height: 1; }
.module-list { min-height: 0; display: grid; align-content: start; gap: 6px; margin-bottom: 14px; overflow-y: auto; }
.module-item { padding: 11px 12px; border: 1px solid transparent; color: #5f5558; font-size: 13px; }
.module-item:hover { background: #fcf7f8; }
.module-item.active { border-color: #ecd6db; }
.module-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #d9b7be; }
.module-item.active .module-dot { background: var(--rose); box-shadow: 0 0 0 4px rgba(184,109,121,.13); }
.sidebar-loading { padding: 18px 8px; color: #998d90; font-size: 12px; }
.empty-modules { margin: 5px 0 14px; padding: 26px 16px; border: 1px dashed #ddc8cd; border-radius: 14px; background: #fdfafb; text-align: center; }
.empty-plus { width: 34px; height: 34px; display: grid; place-items: center; margin: 0 auto 10px; border-radius: 50%; background: var(--rose-soft); color: var(--rose-deep); font-size: 22px; }
.empty-modules p { margin: 0 0 5px; font-size: 13px; font-weight: 800; }
.empty-modules span { color: #998d90; font-size: 11px; line-height: 1.5; }
.add-module-button { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 14px; border: 0; border-radius: 12px; background: var(--rose); color: var(--white); font-size: 13px; font-weight: 800; box-shadow: 0 8px 22px rgba(184,109,121,.24); }
.add-module-button span { font-size: 19px; line-height: 0; }
.logout-button { margin-top: auto; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--white); color: #76696c; font-size: 12px; font-weight: 800; text-align: center; }
.sidebar-note { margin: 10px 0 0; color: #a19497; font-size: 10px; text-align: center; }

.workspace { min-width: 0; padding: 34px 42px 54px; }
.topbar { max-width: 1500px; min-height: 65px; display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 0 auto 28px; }
.topbar h2 { margin: 0; font-size: clamp(28px,3vw,38px); letter-spacing: -.035em; overflow-wrap: anywhere; }
.header-actions, .section-actions, .modal-actions { display: flex; align-items: center; gap: 9px; }
.primary-button, .secondary-button, .danger-button, .confirm-delete-button { min-height: 39px; padding: 9px 14px; border-radius: 10px; font-size: 12px; font-weight: 800; }
.primary-button { border: 1px solid var(--rose); background: var(--rose); color: var(--white); box-shadow: 0 7px 18px rgba(184,109,121,.19); }
.primary-button span { margin-right: 4px; font-size: 18px; line-height: 0; }
.secondary-button { border: 1px solid var(--line); background: var(--white); color: #685b5e; }
.danger-button { border: 1px solid #f0d7dc; background: #fff7f8; color: #a14354; }
.confirm-delete-button { border: 1px solid #aa3c50; background: #aa3c50; color: var(--white); }

.loading-card, .error-card, .content-empty { min-height: 420px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; border: 1px solid var(--line); border-radius: 20px; background: var(--white); color: var(--muted); text-align: center; }
.error-card { color: #a14354; }
.content-empty h3 { margin: 2px 0 9px; color: var(--ink); font-size: 28px; }
.content-empty > p:not(.eyebrow) { max-width: 460px; margin: 0 0 23px; line-height: 1.6; }
.placeholder-mark { width: 72px; height: 72px; display: grid; place-items: center; margin-bottom: 18px; border-radius: 22px; background: var(--rose); color: var(--white); font-size: 34px; }
.placeholder-mark.small { width: 54px; height: 54px; border-radius: 17px; font-size: 28px; }

.dashboard-view, .records-view { max-width: 1500px; margin: 0 auto; }
.dashboard-heading-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 18px; padding: 22px 24px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(135deg,#fff 0%,#fff8f9 100%); box-shadow: 0 12px 34px rgba(55,35,40,.04); }
.dashboard-heading-card h3, .dashboard-panel-heading h3 { margin: 0; letter-spacing: -.025em; }
.dashboard-heading-card h3 { font-size: 24px; }
.dashboard-heading-card > div > p:last-child { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.month-filter { min-width: 290px; }
.month-filter label { display: block; margin: 0 0 6px; color: #75686c; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.month-filter > div { display: flex; gap: 8px; }
.month-filter input, .month-filter button { min-height: 42px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); color: var(--ink); }
.month-filter input { min-width: 160px; padding: 8px 11px; outline: none; }
.month-filter button { padding: 8px 11px; color: var(--rose-deep); font-size: 11px; font-weight: 800; }
.dashboard-stats { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
.dashboard-stats article { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--white); box-shadow: 0 10px 28px rgba(55,35,40,.035); }
.dashboard-stats span, .dashboard-stats small { display: block; }
.dashboard-stats span { color: var(--rose-deep); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.dashboard-stats strong { display: block; margin: 8px 0 7px; font-size: clamp(22px,2.2vw,30px); letter-spacing: -.035em; overflow-wrap: anywhere; }
.dashboard-stats small { color: var(--muted); font-size: 11px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.45fr) minmax(300px,.8fr); gap: 18px; align-items: start; }
.dashboard-panel { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--white); box-shadow: 0 12px 34px rgba(55,35,40,.04); }
.dashboard-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 19px 20px; border-bottom: 1px solid var(--line); }
.dashboard-panel-heading h3 { font-size: 18px; }
.dashboard-panel-heading > span { padding: 6px 9px; border-radius: 999px; background: var(--rose-soft); color: var(--rose-deep); font-size: 10px; font-weight: 800; }
.dashboard-table-scroll { width: 100%; overflow-x: auto; }
.dashboard-table { width: 100%; min-width: 620px; border-collapse: collapse; }
.dashboard-table th, .dashboard-table td { padding: 13px 14px; border-bottom: 1px solid #f0e6e8; text-align: right; font-size: 11px; }
.dashboard-table th { background: #fcf9fa; color: #817478; font-size: 9px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.dashboard-table th:first-child, .dashboard-table td:first-child { text-align: left; }
.dashboard-table td:first-child { color: #51474a; font-weight: 800; }
.dashboard-table tbody tr:last-child td { border-bottom: 0; }
.recent-record-list { display: grid; }
.recent-record-list article { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 18px; border-bottom: 1px solid #f0e6e8; }
.recent-record-list article:last-child { border-bottom: 0; }
.recent-record-name, .recent-record-amount { min-width: 0; display: grid; gap: 4px; }
.recent-record-name strong, .recent-record-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-record-name strong, .recent-record-amount strong { font-size: 12px; }
.recent-record-name span, .recent-record-amount span { color: var(--muted); font-size: 10px; }
.recent-record-amount { flex: 0 0 auto; text-align: right; }
.recent-record-amount strong { color: var(--rose-deep); }
.dashboard-empty { min-height: 150px; display: grid; place-items: center; padding: 30px; color: var(--muted); font-size: 12px; text-align: center; }

.module-summary { display: flex; align-items: stretch; gap: 12px; margin-bottom: 22px; }
.module-summary > div { min-width: 126px; display: grid; padding: 14px 17px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); }
.module-summary strong { font-size: 24px; line-height: 1; }
.module-summary span { margin-top: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.module-summary .primary-button { margin-left: auto; align-self: center; }
.section-stack { display: grid; gap: 22px; }
.section-insert-button { justify-self: center; min-height: 36px; padding: 8px 14px; border: 1px dashed #d2a5ae; border-radius: 999px; background: #fffafb; color: var(--rose-deep); font-size: 11px; font-weight: 800; }
.section-insert-button span { margin-right: 4px; font-size: 17px; }
.record-section { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--white); box-shadow: 0 12px 34px rgba(55,35,40,.045); }
.section-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.section-header h3 { margin: 0; font-size: 21px; letter-spacing: -.02em; overflow-wrap: anywhere; }
.section-move-controls { display: flex; gap: 5px; margin-right: 3px; }
.section-move-controls button { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: #fcf9fa; color: var(--rose-deep); font-size: 17px; font-weight: 800; }
.section-move-controls button:disabled { cursor: not-allowed; opacity: .35; }
.table-scroll { width: 100%; overflow-x: hidden; }
.records-table { width: 100%; min-width: 0; table-layout: fixed; border-collapse: collapse; }
.records-table th:nth-child(1) { width: 14%; }
.records-table th:nth-child(2) { width: 19%; }
.records-table th:nth-child(3), .records-table th:nth-child(4), .records-table th:nth-child(5) { width: 12%; }
.records-table th:nth-child(6) { width: 25%; }
.records-table th:nth-child(7) { width: 6%; }
.records-table th, .records-table td { padding: 11px 10px; border-bottom: 1px solid #f0e6e8; text-align: left; vertical-align: middle; }
.records-table th { background: #fcf9fa; color: #817478; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.records-table th:first-child, .records-table td:first-child { padding-left: 20px; }
.records-table th:last-child, .records-table td:last-child { padding-right: 18px; }
.records-table input, .records-table textarea { width: 100%; min-width: 0; min-height: 38px; padding: 8px 9px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink); font-size: 12px; outline: none; }
.records-table input:hover, .records-table textarea:hover { border-color: #eee0e3; background: #fdfafa; }
.records-table input:focus, .records-table textarea:focus { border-color: #d49ca6; background: var(--white); box-shadow: 0 0 0 3px rgba(184,109,121,.11); }
.records-table textarea { resize: vertical; }
.money-input { min-width: 0; display: flex; align-items: center; border-radius: 8px; }
.money-input span { margin-right: -5px; color: #92868a; font-size: 12px; }
.money-input input { min-width: 0; padding-left: 9px; }
.row-delete { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid #efdde1; border-radius: 8px; background: #fff9fa; color: #a14354; font-size: 20px; line-height: 1; }
.empty-table { height: 90px; color: #9a8e91; font-size: 12px; text-align: center !important; }
.records-table tfoot td { border-bottom: 0; background: #f8ecef; color: #7f4050; font-size: 12px; font-weight: 800; }
.add-row-button { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 14px 20px 18px; padding: 9px 13px; border: 1px dashed #d5a9b1; border-radius: 10px; background: #fffafb; color: var(--rose-deep); font-size: 12px; font-weight: 800; }
.add-row-button span { font-size: 18px; line-height: 0; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(36,23,27,.44); backdrop-filter: blur(4px); }
.modal-card { width: min(430px,100%); padding: 30px; border: 1px solid #ecdde0; border-radius: 20px; background: var(--white); box-shadow: 0 28px 70px rgba(39,23,28,.2); }
.modal-icon { width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 17px; border-radius: 14px; background: var(--rose-soft); color: var(--rose-deep); font-size: 26px; }
.modal-icon.danger { background: #fbe9ed; color: #aa3c50; font-weight: 800; }
.modal-card h3 { margin: 0 0 20px; font-size: 26px; letter-spacing: -.03em; }
.modal-card label { display: block; margin-bottom: 7px; color: #6f6265; font-size: 11px; font-weight: 800; }
.modal-card > input { width: 100%; min-height: 46px; padding: 11px 13px; border: 1px solid #dfcfd2; border-radius: 10px; outline: none; }
.modal-card > input:focus { border-color: var(--rose); box-shadow: 0 0 0 3px rgba(184,109,121,.12); }
.modal-copy { margin: -8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.modal-copy + label { margin-top: 16px; }
.modal-actions { justify-content: flex-end; margin-top: 22px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 60; max-width: min(390px,calc(100vw - 32px)); padding: 13px 17px; border: 1px solid #ddc0c6; border-radius: 12px; background: #3a2a2e; color: var(--white); font-size: 12px; font-weight: 700; box-shadow: 0 14px 36px rgba(35,21,25,.2); }

.login-body { background: linear-gradient(135deg,#faf7f7,#f4e9eb); }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(440px,100%); padding: 34px; border: 1px solid var(--line); border-radius: 24px; background: var(--white); box-shadow: 0 28px 75px rgba(66,38,45,.13); }
.login-card > img { width: 210px; height: 105px; display: block; margin: 0 auto 22px; object-fit: contain; }
.login-card h1 { margin: 0; font-size: 32px; letter-spacing: -.035em; }
.login-copy { margin: 10px 0 24px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.login-form { display: grid; gap: 9px; }
.login-form label { color: #6f6265; font-size: 11px; font-weight: 800; }
.login-form input { width: 100%; min-height: 46px; padding: 11px 13px; border: 1px solid #dfcfd2; border-radius: 10px; outline: none; }
.login-form input:focus { border-color: var(--rose); box-shadow: 0 0 0 3px rgba(184,109,121,.12); }
.login-form button, .setup-link { min-height: 46px; display: grid; place-items: center; margin-top: 8px; padding: 11px 14px; border: 0; border-radius: 11px; background: var(--rose); color: var(--white); font-weight: 800; }
.login-error, .setup-success { margin: 6px 0; padding: 10px 12px; border-radius: 9px; font-size: 12px; }
.login-error { background: #fff0f2; color: #a14354; }
.setup-success { background: #eef8f1; color: #357448; }
.login-footer { margin: 22px 0 0; color: #9e9295; font-size: 10px; text-align: center; }
.setup-card strong { color: var(--ink); }

@media (max-width: 1100px) {
  .workspace { padding-inline: 22px; }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; padding: 15px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand-panel { grid-template-columns: 110px 1fr auto; align-items: center; padding-bottom: 14px; }
  .brand-logo { width: 110px; height: 56px; }
  .mobile-menu-button { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--white); color: var(--rose-deep); font-size: 20px; }
  .sidebar-body { display: none; }
  .sidebar.open .sidebar-body { display: flex; max-height: 70vh; padding-top: 4px; }
  .workspace { padding: 24px 16px 34px; }
  .topbar { align-items: flex-start; }
  .header-actions { flex-wrap: wrap; justify-content: flex-end; }
  .dashboard-heading-card { align-items: flex-start; flex-direction: column; }
  .month-filter { width: 100%; min-width: 0; }
  .month-filter input { flex: 1; min-width: 0; }
  .dashboard-stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .module-summary { flex-wrap: wrap; }
  .module-summary > div { flex: 1; }
  .module-summary .primary-button { width: 100%; margin-left: 0; }
  .section-header { align-items: flex-start; flex-direction: column; gap: 14px; padding: 18px; }
  .section-actions { width: 100%; flex-wrap: wrap; }
  .section-actions .secondary-button, .section-actions .danger-button { flex: 1 1 110px; }
  .table-scroll { padding: 14px; overflow: visible; }
  .records-table { display: block; border-collapse: separate; }
  .records-table thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
  .records-table tbody, .records-table tfoot { display: block; }
  .records-table tbody { display: grid; gap: 12px; }
  .records-table .record-data-row { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); box-shadow: 0 7px 18px rgba(55,35,40,.04); }
  .records-table .record-data-row td { min-width: 0; display: block; padding: 0; border: 0; }
  .records-table .record-data-row td::before, .records-table tfoot td[data-label]::before { content: attr(data-label); display: block; margin: 0 0 5px 2px; color: #817478; font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
  .records-table input, .records-table textarea { border-color: #eee0e3; background: #fdfafa; }
  .money-input { position: relative; }
  .money-input span { position: absolute; left: 10px; z-index: 1; margin: 0; }
  .money-input input { padding-left: 24px; }
  .row-actions-cell { align-self: end; }
  .row-delete { width: 100%; height: 38px; }
  .records-table .empty-record-row { grid-template-columns: 1fr; padding: 0; border: 0; background: transparent; box-shadow: none; }
  .records-table .empty-record-row::after { content: "No student rows yet. Use the plus button below."; min-height: 90px; display: grid; place-items: center; padding: 24px 16px; border: 1px dashed var(--line); border-radius: 14px; color: #9a8e91; font-size: 12px; text-align: center; }
  .empty-table { display: none !important; }
  .records-table tfoot { margin-top: 14px; }
  .records-table tfoot tr { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 1px; overflow: hidden; border: 1px solid #ead7dc; border-radius: 13px; background: #ead7dc; }
  .records-table tfoot td { min-width: 0; display: block; padding: 12px 10px; border: 0; text-align: center; }
  .records-table tfoot .total-heading { grid-column: 1/-1; padding: 11px 12px; text-align: left; }
  .records-table tfoot .total-spacer { display: none; }
  .add-row-button { width: calc(100% - 28px); min-height: 44px; margin: 0 14px 16px; }
}

@media (max-width: 520px) {
  .brand-panel { grid-template-columns: 86px 1fr auto; }
  .brand-logo { width: 86px; height: 52px; }
  .brand-panel h1 { font-size: 14px; }
  .topbar { flex-direction: column; }
  .header-actions { width: 100%; justify-content: flex-start; }
  .workspace { padding: 19px 10px 28px; }
  .dashboard-heading-card { padding: 18px; }
  .month-filter > div { align-items: stretch; flex-direction: column; }
  .dashboard-stats { grid-template-columns: 1fr; }
  .dashboard-stats article { padding: 16px; }
  .dashboard-table { min-width: 560px; }
  .section-stack { gap: 16px; }
  .record-section { border-radius: 14px; }
  .section-header { padding: 16px 14px; }
  .section-actions { display: grid; grid-template-columns: auto 1fr 1fr; }
  .section-actions .secondary-button, .section-actions .danger-button { width: 100%; padding-inline: 9px; }
  .table-scroll { padding: 10px; }
  .records-table .record-data-row { grid-template-columns: 1fr; padding: 13px; }
  .records-table tfoot tr { grid-template-columns: 1fr; }
  .records-table tfoot .total-heading { grid-column: auto; }
  .records-table tfoot td, .records-table tfoot .total-heading { text-align: left; }
  .add-row-button { width: calc(100% - 20px); margin: 0 10px 12px; }
  .section-insert-button { width: min(100%,220px); }
  .modal-card, .login-card { padding: 24px; }
}
