:root {
  --ink: #14212f;
  --muted: #5b6b7e;
  --line: #d8e2ed;
  --surface: #ffffff;
  --page: #f4f7fb;
  --accent: #1964af;
  --accent-strong: #0f4c87;
  --accent-soft: #e4eefb;
  --accent-softer: #eef4fc;
  --warn: #b45309;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --shadow: 0 14px 40px rgba(10, 40, 80, 0.08);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family:
    Inter, "Hind Siliguri", "Noto Sans Bengali", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

/* ---------- layout ---------- */

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

.sidebar {
  background: linear-gradient(180deg, #0d2440, #123257);
  color: #e7eff9;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 22px;
  overflow: hidden;
}

.brand-logo {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 10px;
  object-fit: cover;
  background: #ffffff;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.25;
}

.brand p {
  color: #9fc3ec;
  font-size: 13px;
}

.brand-center {
  justify-content: center;
  text-align: left;
}

/* ---------- nav ---------- */

.nav-tabs {
  display: grid;
  gap: 4px;
  overflow-y: auto;
  min-height: 0;
  padding-right: 2px;
}

.nav-tab,
.primary-btn,
.secondary-btn,
.danger-btn,
.small-btn,
.logout-btn {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  min-height: 44px;
}

.nav-tab {
  text-align: left;
  color: #cfdef2;
  background: transparent;
  padding: 11px 12px;
  font-weight: 600;
  width: 100%;
}

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

/* ---------- sidebar footer / user box ---------- */

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
  flex: 0 0 auto;
  overflow-y: auto;
  max-height: 45vh;
}

.user-box {
  display: grid;
  gap: 8px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  padding: 12px;
}

.user-badge {
  display: grid;
  gap: 2px;
  padding: 2px 2px 4px;
}

.user-badge strong {
  display: block;
  font-size: 15px;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-badge span {
  color: #9fc3ec;
  font-size: 12px;
  text-transform: capitalize;
}

.logout-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-weight: 700;
  padding: 9px 12px;
  width: 100%;
  min-height: 40px;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ---------- mobile top bar (mobile only) ---------- */

.mobile-bar {
  display: none;
}

/* ---------- content ---------- */

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

.content-inner {
  max-width: 1200px;
  margin: 0 auto;
}

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

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  margin: 0 0 4px;
}

.topbar h2 {
  font-size: 32px;
  line-height: 1.15;
}

.today-card {
  display: grid;
  gap: 3px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 170px;
  box-shadow: var(--shadow);
}

.today-card span,
.metric > span,
.metric-body span,
.empty-state,
label {
  color: var(--muted);
}

.today-card strong {
  font-size: 15px;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

/* ---------- cards & metrics ---------- */

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

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

.metric {
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}

.metric:hover,
.metric:focus-visible {
  transform: translateY(-2px);
}

.metric-icon {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
}

.metric-icon svg {
  width: 22px;
  height: 22px;
}

.metric-blue .metric-icon {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.metric-amber .metric-icon {
  background: #fef3c7;
  color: var(--warn);
}

.metric-green .metric-icon {
  background: #dcfce7;
  color: #15803d;
}

.metric-red .metric-icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.metric-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.metric strong {
  font-size: 28px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

/* Money / summary values must never break onto a second line. Columns and
   font size shrink on small screens instead (see the media queries below). */
.home-card strong,
.home-periods strong,
.home-finance-highlight strong,
.home-summary-card strong,
.metric strong,
.student-metrics strong,
.fee-stats-bar strong,
.money-today-grid strong,
.money-balance-bar strong,
.report-overview strong,
.report-metrics strong {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
}

.dashboard-grid,
.work-grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-gap,
.work-gap {
  margin-top: 16px;
}

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

.panel-header h3 {
  position: relative;
  padding-left: 14px;
}

.panel-header h3::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), #4a90d9);
}

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

/* ---------- forms ---------- */

.form-panel {
  display: grid;
  align-content: start;
  gap: 13px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  min-height: 44px;
  padding: 9px 11px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
}

.primary-btn {
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  padding: 11px 14px;
  width: 100%;
}

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

.primary-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.secondary-btn {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
  padding: 11px 14px;
}

.secondary-btn:hover {
  background: #d5e4f8;
}

.danger-btn {
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 800;
  padding: 11px 14px;
}

.form-actions {
  display: flex;
  gap: 10px;
}

.form-actions .primary-btn,
.form-actions .secondary-btn {
  flex: 1;
}

.file-btn {
  display: grid;
  place-items: center;
  text-align: center;
  min-height: 40px;
  cursor: pointer;
}

.link-btn {
  background: none;
  border: 0;
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  text-align: center;
  padding: 6px;
  min-height: 36px;
}

.link-btn:hover {
  text-decoration: underline;
}

.field-with-btn {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.field-with-btn label {
  flex: 1;
}

.same-btn {
  min-height: 44px;
  margin-bottom: 0;
}

.perm-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin: 0;
  display: grid;
  gap: 8px;
  min-width: 0;
}

.perm-box legend {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  padding: 0 6px;
}

.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.days-grid {
  grid-template-columns: repeat(4, 1fr);
}

.check-line {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  font-weight: 600 !important;
  color: var(--ink) !important;
  cursor: pointer;
}

.check-line input {
  width: auto;
  min-height: auto;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

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

/* ---------- course picker (multi-enroll, dropdown style) ---------- */

.course-drop {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.course-drop[open] {
  border-color: var(--accent);
}

.course-drop summary {
  padding: 12px;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}

.course-drop summary::-webkit-details-marker {
  display: none;
}

.course-drop summary::after {
  content: "▾";
  color: var(--muted);
  transition: transform 0.2s ease;
}

.course-drop[open] summary::after {
  transform: rotate(180deg);
}

.course-pick-box {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.course-pick {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fbfcfe;
}

.course-pick.picked {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.course-pick .check-line {
  font-size: 13px;
  min-width: 0;
}

.course-pick .check-line span.badge {
  margin-left: 6px;
}

.course-pick input[type="number"] {
  width: 110px;
  min-height: 38px;
  flex: 0 0 auto;
  text-align: right;
  font-weight: 700;
}

.course-pick input[type="number"]:disabled {
  background: #eef2f7;
  color: var(--muted);
}

/* ---------- admission box ---------- */

.admission-box {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 10px;
  background: var(--accent-softer);
}

.admission-note {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.admission-note strong {
  color: var(--accent-strong);
  font-size: 16px;
}

/* ---------- class buttons (attendance) ---------- */

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

.class-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  padding: 14px;
  cursor: pointer;
  text-align: left;
  min-height: 56px;
}

.class-btn:hover,
.class-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.class-btn.active {
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.class-btn strong {
  display: block;
}

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

.attendance-days { display: grid; gap: 8px; }

.attendance-day {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
}

.attendance-day:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.attendance-day strong { min-width: 104px; }
.attendance-day span { color: var(--muted); font-size: 13px; }

/* ---------- chips ---------- */

.chips-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: #fbfcfe;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.chip em {
  font-style: normal;
  color: var(--muted);
  font-size: 12px;
}

.chip button {
  border: 0;
  background: #eef2f7;
  color: var(--muted);
  width: 24px;
  height: 24px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.chip button:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.chip-add-form {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.chip-add-form input {
  flex: 1;
  min-width: 0;
}

.chip-add-form .secondary-btn {
  width: auto;
  flex: 0 0 auto;
}

/* ---------- fee collection bar ---------- */

.fee-collect-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.fee-collect-main {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

.fee-collect-label {
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}

#feeCollectTotal {
  font-size: 32px;
  line-height: 1.1;
  color: var(--accent-strong);
}

.fee-collect-count {
  color: var(--muted);
  font-size: 13px;
}

.fee-collect-tools {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.fee-scope-label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
}

.fee-scope-label input {
  min-height: 44px;
}

/* ---------- dues register ---------- */

.due-grid {
  align-items: start;
}

.due-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.due-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
  flex-wrap: wrap;
}

.due-row.paid {
  opacity: 0.75;
}

.due-row.paid .due-info strong {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.due-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.due-info strong {
  display: block;
}

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

/* ---------- bank ---------- */

.bank-grid {
  align-items: start;
}

.bank-side {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.bank-opening {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--accent-softer);
}

#bankBalance {
  font-size: 16px;
}

/* ---------- payroll ---------- */

.payroll-card {
  cursor: default;
}

.pay-form {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr auto;
  gap: 10px;
  align-items: start;
}

.pay-form .primary-btn {
  width: auto;
}

/* ---------- settings ---------- */

.branding-form,
.admission-form {
  display: grid;
  gap: 12px;
  max-width: 480px;
}

.logo-preview-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-preview-row .secondary-btn {
  width: auto;
}

.offering-form {
  display: grid;
  gap: 12px;
}

.user-form-inner {
  max-width: 560px;
}

.user-form-inner h4 {
  margin: 0;
}

/* ---------- tables & lists ---------- */

.search-input {
  max-width: 240px;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  font-size: 14px;
}

.compact-list,
.attendance-list,
.batch-grid {
  display: grid;
  gap: 10px;
}

.compact-item,
.batch-card,
.attendance-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
  min-width: 0;
}

.compact-item,
.attendance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compact-item strong,
.batch-card strong,
.attendance-row strong {
  display: block;
}

.compact-item span,
.batch-card span,
.attendance-row span {
  color: var(--muted);
  font-size: 13px;
}

.compact-item > div,
.attendance-row > div {
  min-width: 0;
}

.batch-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.batch-card p {
  margin: 6px 0 10px;
  font-size: 13px;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  min-height: 28px;
  padding: 4px 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  flex: 0 0 auto;
}

.badge.due {
  background: #fef3c7;
  color: var(--warn);
}

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

.small-btn {
  background: #eef2f7;
  color: #334155;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  min-height: 40px;
}

.small-btn.present {
  background: var(--accent);
  color: #ffffff;
}

.small-btn.absent {
  background: var(--danger-soft);
  color: var(--danger);
}

.wa-link {
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 12px;
  text-decoration: none;
}

.wa-link:hover {
  text-decoration: underline;
}

.inline-tools {
  display: flex;
  gap: 10px;
  align-items: center;
}

.inline-tools input,
.inline-tools select,
#feeFilter,
#moneyFilter {
  width: auto;
  min-width: 150px;
}

.attendance-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.attendance-actions .secondary-btn,
.attendance-actions .primary-btn {
  padding: 11px 14px;
  width: auto;
  flex: 1;
  min-width: 140px;
}

/* ---------- charts ---------- */

.bar-chart {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 130px 1fr 90px;
  align-items: center;
  gap: 10px;
}

.bar-label {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  height: 18px;
  border-radius: 999px;
  background: #eef2f7;
  overflow: hidden;
  min-width: 0;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #4a90d9);
  min-width: 4px;
}

.bar-value {
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
}

/* ---------- login ---------- */

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

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
}

.login-card .brand {
  margin-bottom: 6px;
}

.login-card .brand h1 {
  color: var(--ink);
}

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

.login-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.login-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- toast & boot overlay ---------- */

.boot-overlay {
  position: fixed;
  inset: 0;
  background: var(--page);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 90;
  font-weight: 700;
  color: var(--accent-strong);
}

.boot-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: boot-spin 0.85s linear infinite;
}

@keyframes boot-spin {
  to { transform: rotate(360deg); }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: #0d2440;
  color: #ffffff;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- responsive ---------- */

.topbar-side {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent-strong);
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
  padding: 9px 16px;
  min-height: 40px;
  cursor: pointer;
  box-shadow: var(--shadow);
  white-space: nowrap;
}

.lang-btn:hover {
  border-color: var(--accent);
}

.filter-tools {
  flex-wrap: wrap;
}

.filter-tools .search-input {
  min-width: 150px;
}

#moneyMonth,
#moneyDay {
  width: auto;
  min-width: 140px;
}

@media (max-width: 1100px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .work-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 940px) {
  .app-shell {
    grid-template-columns: 1fr;
    display: block;
  }

  .mobile-bar {
    display: grid;
    grid-template-columns: 1fr minmax(0, auto) 1fr;
    align-items: center;
    gap: 10px;
    background: #0d2440;
    color: #ffffff;
    padding: 9px 12px;
    min-height: 58px;
    position: sticky;
    top: 0;
    z-index: 40;
  }

  .bar-side {
    width: 6px;
  }

  .mobile-brand-name {
    justify-self: center;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.2px;
    max-width: 56vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-bar-title {
    justify-self: end;
    max-width: 36vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #9fc3ec;
    font-size: 12.5px;
    font-weight: 700;
    text-align: right;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    padding: 6px 12px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 85vw);
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    z-index: 60;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    border-radius: 0 14px 14px 0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .brand-desktop {
    padding-right: 40px;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 30, 55, 0.5);
    z-index: 55;
  }

  .nav-tabs {
    display: grid;
    gap: 6px;
    overflow: visible;
  }

  .sidebar-footer {
    max-height: none;
    overflow: visible;
  }

  .nav-tab {
    white-space: normal;
  }

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

  .today-card {
    width: 100%;
  }
}

@media (max-width: 620px) {
  .content {
    padding: 12px;
  }

  .sidebar {
    padding: 16px;
  }

  .topbar {
    gap: 12px;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .topbar-side {
    width: 100%;
    justify-content: space-between;
  }

  .today-card {
    flex: 1;
  }

  input,
  select {
    min-height: 46px;
    font-size: 16px;
  }

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

  .metric {
    padding: 12px;
    gap: 10px;
  }

  .metric-icon {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
    border-radius: 10px;
  }

  .metric-icon svg {
    width: 18px;
    height: 18px;
  }

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

  .panel {
    padding: 14px;
  }

  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-tools {
    width: 100%;
  }

  .filter-tools .search-input,
  .filter-tools select,
  .filter-tools input {
    width: 100%;
    min-width: 0;
    flex: 1 1 100%;
  }

  #moneyMonth,
  #moneyDay {
    width: 100%;
    min-width: 0;
  }

  .search-input {
    max-width: none;
    width: 100%;
  }

  .fee-collect-bar {
    flex-direction: column;
    align-items: stretch;
  }

  #feeCollectTotal {
    font-size: 26px;
  }

  .fee-collect-tools {
    width: 100%;
  }

  .fee-scope-label {
    flex: 1 1 100%;
  }

  .form-row,
  .due-form-row,
  .pay-form {
    grid-template-columns: 1fr;
  }

  .pay-form .primary-btn {
    width: 100%;
  }

  .course-pick {
    flex-direction: column;
    align-items: stretch;
  }

  .course-pick input[type="number"] {
    width: 100%;
  }

  .due-row .inline-tools {
    width: 100%;
  }

  .due-row .small-btn {
    flex: 1;
  }

  .compact-item,
  .attendance-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .days-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .bar-row {
    grid-template-columns: 90px 1fr 72px;
    gap: 8px;
  }

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

  .form-actions {
    flex-direction: column;
  }

  td .inline-tools {
    flex-direction: column;
    align-items: stretch;
  }

  td .small-btn {
    width: 100%;
  }

  .chip-add-form {
    flex-wrap: wrap;
  }

  .chip-add-form input {
    flex: 1 1 100%;
  }

  /* mobile: table -> card list */
  .table-wrap {
    overflow-x: visible;
  }

  table {
    min-width: 0;
  }

  table thead {
    display: none;
  }

  table,
  table tbody,
  table tr,
  table td {
    display: block;
    width: 100%;
  }

  table tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 6px 12px;
    background: #fbfcfe;
  }

  table td {
    border-bottom: 1px dashed var(--line);
    padding: 8px 0;
    font-size: 14px;
  }

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

  table td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 2px;
  }

  table td:last-child::before {
    display: none;
  }

  .login-wrap {
    padding: 16px;
  }
}

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

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

  .bar-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .bar-value {
    text-align: left;
  }
}

/* ---------- home summary ---------- */

.home-finance-panel { padding: 18px; background: #eff5fc; }
.home-finance-highlight { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.home-finance-highlight > div { display: grid; gap: 4px; padding: 14px; border-radius: 14px; background: #fff0d8; }
.home-finance-highlight > div + div { background: #e5f5e9; }
.home-finance-highlight span, .home-periods span { color: var(--muted); }
.home-finance-highlight strong { color: #28803b; font-size: 24px; }
.home-periods { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 12px; padding: 12px 4px 2px; border-top: 1px solid var(--line); }
.home-periods > div { display: grid; justify-items: center; gap: 3px; }
.home-periods > div + div { border-left: 1px solid var(--line); }
.home-periods strong { font-size: 17px; }
.home-summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.home-summary-card { display: grid; gap: 2px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.home-summary-card strong { color: var(--accent); font-size: 22px; }
.home-summary-card span { color: var(--muted); }
.home-shortcuts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 18px 0; }
.home-shortcuts button { min-height: 64px; border: 0; border-radius: 14px; background: #218b82; color: white; font-weight: 700; cursor: pointer; }
.home-shortcuts button:nth-child(2) { background: #3a984f; }
.home-shortcuts button:nth-child(3) { background: #ed7542; }
.home-shortcuts button:nth-child(4) { background: #276cad; }

/* ---------- fee detail and receipt ---------- */

.fee-student-list { display: grid; gap: 12px; }
.fee-student-card { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid #c5cbd0; border-radius: 18px; background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; }
.fee-student-card:hover { border-color: var(--accent); background: var(--accent-softer); }
.fee-student-copy { display: grid; gap: 2px; min-width: 0; flex: 1; }
.fee-student-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; }
.fee-student-copy span { color: var(--muted); }
.fee-student-balance { margin-left: auto; }

.app-dialog { width: min(620px, calc(100vw - 28px)); max-height: min(90dvh, 900px); overflow: auto; padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: #eaf2fb; color: var(--ink); box-shadow: 0 24px 80px rgba(10, 30, 50, .3); }
.app-dialog::backdrop { background: rgba(15, 24, 34, .42); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.dialog-heading h2 { margin: 0; font-size: 22px; }
.fee-detail-student { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; background: var(--surface); }
.fee-detail-student > div:last-child { display: grid; gap: 3px; }
.fee-detail-section { margin-top: 20px; }
.fee-detail-section h3, .fee-collection-form h3 { margin: 0 0 10px; }
.fee-course-row, .fee-course-total { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.fee-course-total { border-top: 1px solid var(--line); border-bottom: 0; }
.fee-collection-form { display: grid; gap: 14px; margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.fee-amount-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; }
.discount-option { display: flex; align-items: center; gap: 8px; min-height: 48px; }
.discount-option input { width: 20px; height: 20px; }
.discount-preview { margin: -4px 0 0; padding: 10px 12px; border-radius: 8px; background: #e5f5e9; color: #205f31; font-weight: 700; }
.fee-history-list { display: grid; gap: 8px; }
.fee-history-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.fee-history-item > div { display: grid; gap: 3px; }
.fee-history-item span { color: var(--muted); font-size: 14px; }
.confirm-dialog { max-width: 460px; }
.confirm-dialog h2 { margin-top: 0; }
.receipt-dialog { width: min(780px, calc(100vw - 24px)); }
.receipt-paper { width: 100%; margin: 14px auto; padding: 28px 32px; background: #fff; color: #111; font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }
.receipt-paper header { display: grid; text-align: center; gap: 4px; font-family: system-ui, sans-serif; }
.receipt-paper header strong { font-size: 24px; }
.receipt-paper p { margin: 10px 0; }
.receipt-paper hr { border: 0; border-top: 1px dashed #777; }
.receipt-paper dl { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; margin: 12px 0; }
.receipt-paper dt, .receipt-paper dd { margin: 0; }
.receipt-paper dd { font-weight: 700; text-align: right; }
.receipt-thanks { text-align: center; }

/* ---------- student cards ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.student-metrics article {
  min-height: 84px;
  display: grid;
  place-content: center;
  gap: 2px;
  text-align: center;
  background: #e3e7e9;
  border-radius: 16px;
}

.student-metrics strong { font-size: 24px; line-height: 1.1; }
.student-metrics article:nth-child(2) strong { color: #318044; }
.student-metrics article:nth-child(3) strong { color: #2584c9; }
.student-metrics span { color: var(--muted); }

.student-tools {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.student-status-filter {
  justify-self: end;
  display: inline-flex;
  border: 2px solid #7c8790;
  border-radius: 999px;
  overflow: hidden;
}

.status-filter {
  min-height: 44px;
  padding: 8px 18px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.status-filter + .status-filter { border-left: 1px solid #aab1b5; }
.status-filter.active { background: #cbe8d0; color: #184e26; }
.student-search-label, .student-search-label input { width: 100%; }
.student-form { margin-bottom: 14px; }
.student-id-display { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); font-weight: 700; }

.student-cards { display: grid; gap: 12px; }
.student-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid #c5cbd0;
  border-radius: 18px;
  background: var(--surface);
}

.student-card-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.student-card-leading-actions { display: grid; gap: 2px; margin-inline-start: -8px; }
.student-card-leading-actions .icon-action { width: 44px; height: 44px; }
.student-avatar { width: 58px; height: 58px; flex: 0 0 58px; display: grid; place-items: center; border-radius: 50%; background: #e3e5e7; font-size: 24px; font-weight: 800; }
.student-card-copy { display: grid; gap: 2px; min-width: 0; flex: 1; }
.student-card-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; font-weight: 700; }
.student-card-copy span { color: #48515a; }
.student-card-actions { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.student-card-actions .wa-link { margin-right: auto; }
.icon-action { width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); font-size: 25px; cursor: pointer; }
.icon-action:hover { background: var(--accent-soft); }
.icon-action.delete-action { color: var(--danger); }

@media (max-width: 380px) {
  .student-metrics { gap: 6px; }
  .student-metrics article { min-height: 72px; }
  .student-metrics strong { font-size: 20px; }
  .student-metrics span { font-size: 13px; }
  .student-card-main { gap: 6px; }
  .student-card-leading-actions { margin-inline-start: -10px; }
  .student-card-leading-actions .icon-action { width: 40px; height: 44px; }
  .student-avatar { width: 44px; height: 44px; flex-basis: 44px; }
  .student-card-copy strong { font-size: 15px; }
}

/* ---------- mobile primary navigation ---------- */

.mobile-bottom-nav { display: none; }

/* The bottom bar belongs to the signed-in shell only. */
body:has(.app-shell[hidden]) .mobile-bottom-nav,
body:has(#bootOverlay:not([hidden])) .mobile-bottom-nav { display: none !important; }
.reminder-list { display: grid; gap: 10px; }
.reminder-card { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.reminder-card > div:nth-child(2) { display: grid; gap: 2px; flex: 1 1 140px; min-width: 0; }
.reminder-card > div:nth-child(2) span { color: var(--muted); }
.report-hero { color: #fff; background: linear-gradient(120deg, #1766ad, #103250); }
.report-hero .muted-note, .report-hero p { color: #d6e7fa; }
.report-overview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.report-overview > div { display: grid; gap: 4px; }
.report-overview span { color: #d6e7fa; }
.report-overview strong { font-size: 22px; }
.report-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.report-metrics article { display: grid; gap: 6px; }
.report-metrics strong { font-size: 22px; }
.more-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }

@media (max-width: 940px) {
  .app-shell { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .mobile-bottom-nav { position: fixed; inset-inline: 0; bottom: 0; z-index: 50; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #edf4fb; }
  .mobile-bottom-nav button { min-width: 0; min-height: 58px; display: grid; align-content: center; justify-items: center; gap: 2px; border: 0; border-radius: 999px; background: transparent; color: #444d57; font-size: 12px; font-weight: 700; cursor: pointer; }
  .mobile-bottom-nav button span:first-child { font-size: 22px; line-height: 1; }
  .mobile-bottom-nav button.active { background: #c9e9d0; color: #1763a8; }
  .report-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-metrics { grid-template-columns: 1fr 1fr; }
  .topbar { display: none; }
}

@media (max-width: 620px) {
  .content { padding-bottom: 20px; }
  .panel h3, .panel-header h3 { font-size: 16px; }
  .panel h4 { font-size: 15px; }
  body { font-size: 15px; }
  .badge { font-size: 11.5px; }
  .compact-item strong { font-size: 15px; }
  .home-shortcuts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-summary-card { padding: 12px; }
  .home-summary-card strong { font-size: 19px; white-space: nowrap; }
  .student-tools { padding: 12px; }
  .student-status-filter { justify-self: start; }
  .app-dialog { padding: 16px; }
  .fee-amount-row { grid-template-columns: minmax(0, 1fr) auto; }
  .receipt-paper { width: 100%; }
  .report-overview strong { font-size: 16px; white-space: nowrap; }
  .report-metrics strong { font-size: 16px; white-space: nowrap; }
}

@media print {
  .app-shell,
  .mobile-bottom-nav,
  #bootOverlay,
  #toast,
  #discountConfirmDialog,
  #studentDetailPage,
  #feeDetailPage {
    display: none !important;
  }

  #receiptDialog[open] {
    position: static;
    display: block;
    width: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    overflow: visible;
    background: #fff;
    box-shadow: none;
  }

  #receiptDialog[open] .receipt-actions {
    display: none !important;
  }

  .receipt-paper {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 24px 28px;
    font-size: 14px;
    line-height: 1.6;
  }

  .receipt-paper header strong { font-size: 24px; }
  .receipt-paper dl { gap: 5px 12px; }

  @page {
    size: letter portrait;
    margin: 0.6in;
  }
}

/* ---------- detail pages / overlays ---------- */

.page-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--page);
  padding: 14px 14px calc(24px + env(safe-area-inset-bottom));
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.detail-header h3 { margin: 0; font-size: 20px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.detail-back {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 20px;
  cursor: pointer;
}

/* ---------- students polish ---------- */

.student-metrics article { background: var(--accent-softer); border: 1px solid var(--accent-soft); }
.student-metrics article.metric-active { background: #e5f5e9; border-color: #c9e9d0; }
.student-metrics article.metric-new { background: #e8f1fc; border-color: #cfe3f8; }
.student-metrics article.metric-active strong { color: #28803b; }
.student-metrics article.metric-new strong { color: #1c66ad; }

.status-filter {
  min-height: 36px;
  padding: 5px 14px;
  font-size: 13px;
}

.student-card-side { display: grid; justify-items: end; gap: 6px; margin-left: auto; }
.student-card-tools { display: flex; gap: 4px; }
.student-card-tools .icon-action { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.student-card-tools .icon-action svg { width: 18px; height: 18px; }
.student-card-tools .edit-action { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-softer); }
.student-card-tools .delete-action { color: var(--danger); }
.student-card-copy strong { white-space: normal; overflow-wrap: anywhere; }
.admitted-line { font-size: 12px; color: var(--muted); }

.contact-link {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 0;
  cursor: pointer;
}

.contact-link svg { width: 20px; height: 20px; }
.contact-link.chat { background: #e2f6e9; color: #1f9d55; }
.contact-link.call { background: #e5f0fd; color: #1c66ad; }
.contact-link.guardian { background: #fdeeda; color: #b45309; }

/* ---------- fees polish ---------- */

.fee-stats-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.fee-stats-bar article {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.fee-stats-bar span { color: var(--muted); font-size: 13px; }
.fee-stats-bar strong { font-size: 20px; }
.fee-stats-bar .stat-today { background: #e5f5e9; border-color: #c9e9d0; }
.fee-stats-bar .stat-month { background: var(--accent-softer); border-color: var(--accent-soft); }

.fee-student-copy strong { font-size: 16px; }
.fee-student-copy span { font-size: 12.5px; }
.fee-student-card .student-avatar { width: 44px; height: 44px; flex: 0 0 44px; font-size: 18px; }

.fee-detail-page-body { display: grid; gap: 14px; }
.receipt-tools { display: flex; gap: 6px; }
.receipt-tools .small-btn { min-height: 34px; padding: 4px 10px; }

/* ---------- accounts ---------- */

.money-today-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.money-today-grid article {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #e5f5e9;
}

.money-today-grid article.cost { background: #fdeeed; border-color: #f7d4d0; }
.money-today-grid article.net { background: var(--accent-softer); border-color: var(--accent-soft); }
.money-today-grid span { color: var(--muted); font-size: 13px; }
.money-today-grid strong { font-size: 20px; }
.money-today-grid article.cost strong { color: var(--danger); }

.money-balance-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  background: #0d2440;
  color: #ffffff;
  border: 0;
  margin-bottom: 14px;
}

.money-balance-bar span { color: #9fc3ec; }
.money-balance-bar strong { font-size: 26px; color: #ffffff; }
.money-balance-bar .muted-note { color: #c7d8eb; }

.entry-type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--page);
}

.entry-type-toggle button {
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}

.entry-type-toggle button.active { background: #e5f5e9; color: #28803b; }
.entry-type-toggle button:nth-child(2).active { background: #fdeeed; color: var(--danger); }

/* ---------- reports ---------- */

.period-picker { display: grid; gap: 8px; justify-items: end; }
.period-chips { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--page); }
.period-chips button { min-height: 34px; padding: 4px 16px; border: 0; border-radius: 999px; background: transparent; font-weight: 700; color: var(--muted); cursor: pointer; }
.period-chips button.active { background: #1c66ad; color: #fff; }
.report-hero input[type="date"], .report-hero input[type="month"] { max-width: 180px; }

.report-charts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.report-chart-card h3 { margin: 0 0 10px; font-size: 15px; }
.donut-wrap { display: grid; justify-items: center; gap: 10px; }
.donut { width: min(150px, 100%); }
.donut svg { width: 100%; height: auto; transform: rotate(-90deg); }
.donut text { font-size: 15px; font-weight: 800; fill: var(--ink); }
.donut .donut-sub { font-size: 11px; font-weight: 600; fill: var(--muted); }
.donut-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; width: 100%; }
.donut-legend li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.donut-legend .dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; }

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

/* ---------- ideas ---------- */

.idea-form { display: grid; gap: 12px; }
.idea-form textarea { min-height: 74px; resize: vertical; }
.idea-label-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.idea-cards { display: grid; gap: 12px; }
.idea-card { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.idea-card p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: #33404d; }
.idea-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.idea-card-head strong { font-size: 16px; }
.idea-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12.5px; }
.idea-label-select select { min-height: 32px; padding: 4px 8px; font-size: 13px; }

/* ---------- attendance ---------- */

.attendance-filters { flex-wrap: wrap; }
.year-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.year-chip { min-height: 34px; padding: 5px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 700; font-size: 13px; color: var(--muted); cursor: pointer; }
.year-chip.active { background: #1c66ad; border-color: #1c66ad; color: #fff; }
.attendance-calls { display: flex; gap: 6px; }
.attendance-row { align-items: center; }
.reminder-clear { width: 40px; height: 40px; flex: 0 0 40px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; }
.reminder-clear:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- more / account ---------- */

.account-box { display: grid; gap: 12px; }
.account-row { display: flex; align-items: center; gap: 12px; }
.account-row > div:last-child { display: grid; gap: 2px; }
.account-row span { color: var(--muted); }
.more-account-btn { justify-self: start; }

/* ---------- bottom nav svg ---------- */

#mobileBottomNav svg { width: 23px; height: 23px; }

@media (max-width: 620px) {
  .fee-stats-bar { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .fee-stats-bar article { padding: 10px; }
  .fee-stats-bar strong { font-size: 15px; white-space: nowrap; }
  .fee-stats-bar span { font-size: 11.5px; }
  .money-today-grid { gap: 6px; }
  .money-today-grid article { padding: 10px; }
  .money-today-grid strong { font-size: 15px; white-space: nowrap; }
  .money-balance-bar strong { font-size: 20px; white-space: nowrap; }
  .report-charts { grid-template-columns: 1fr; }
  .donut { width: min(140px, 60%); }
  .page-overlay { padding: 12px 12px calc(20px + env(safe-area-inset-bottom)); }
  .detail-header h3 { font-size: 17px; }
  .student-card-tools .icon-action { width: 34px; height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- subjects: course includes, filters, home cards ---------- */

.dup-warning {
  margin: -4px 0 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #fde2a8;
  background: #fdf4dd;
  color: var(--warn);
  font-size: 13px;
  font-weight: 700;
}

.course-includes {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.sub-panel {
  margin: 4px 0 0;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--page);
}

.student-card-courses {
  font-size: 12px;
  color: var(--accent-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-error-note {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #f7d4d0;
  background: #fdeeed;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

.subject-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.subject-card {
  display: grid;
  gap: 4px;
  text-align: left;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  min-height: 84px;
  box-shadow: var(--shadow);
}

.subject-card:hover,
.subject-card:focus-visible {
  border-color: var(--accent);
  background: var(--accent-softer);
}

.subject-card-type {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
}

.subject-card strong {
  font-size: 15px;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.subject-card-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-strong);
}

@media (max-width: 620px) {
  .subject-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .subject-card { padding: 12px; min-height: 76px; }
}

html, body { overflow-x: clip; }

.topbar { margin-bottom: 16px; }
.topbar h2 { font-size: 26px; }

/* ---------- scan admission form ---------- */

.scan-status {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--page);
  color: var(--ink);
}

.scan-status.working {
  border-color: var(--accent-soft);
  background: var(--accent-softer);
  color: var(--accent-strong);
}

.scan-status.working::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border-radius: 50%;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: boot-spin 0.8s linear infinite;
}

.scan-status.ok {
  border-color: #c9e9d0;
  background: #e5f5e9;
  color: #21703a;
}

.scan-status.ok::before { content: "✓"; font-weight: 800; }

.scan-status.fail {
  border-color: #f7d4d0;
  background: #fdeeed;
  color: var(--danger);
}

.scan-status.fail::before { content: "!"; font-weight: 800; }

/* ---------- student form: courses & packages picker ---------- */

.course-pick-section {
  border: 2px solid var(--accent);
  border-radius: 14px;
  background: var(--accent-softer);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.course-pick-title {
  margin: 0;
  font-weight: 800;
  font-size: 14px;
  color: var(--ink);
}

.course-pick-hint {
  color: var(--danger);
  font-weight: 700;
  font-size: 12px;
}

.course-pick-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.picker-tab {
  min-height: 48px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-weight: 800;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
}

.picker-tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.course-pick-group {
  display: grid;
  gap: 6px;
  align-content: start;
}

.course-pick-group[hidden] { display: none !important; }

.course-pick-group h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
}

.course-pick-group .course-pick-box {
  max-height: 180px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

@media (max-width: 620px) {
  .course-pick-group .course-pick-box { max-height: 150px; }
}

/* ---------- required field stars ---------- */

.req-star {
  color: var(--danger);
  font-style: normal;
  font-weight: 800;
  margin-left: 2px;
}

/* ---------- home finance cards ---------- */

.home-finance-panel {
  background: linear-gradient(135deg, #0d2440, #14568a);
  border: 0;
  color: #ffffff;
  border-radius: 18px;
}

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

.home-card {
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 6px;
  min-width: 0;
  align-content: start;
}

.home-card-students,
.home-card-in {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}

.home-card > div { display: grid; gap: 2px; min-width: 0; }

.home-card-students { background: linear-gradient(135deg, #2f8fe0, #1766ad); box-shadow: 0 10px 24px rgba(23, 102, 173, 0.35); }
.home-card-in { background: linear-gradient(135deg, #1f8a4c, #2f9e63); box-shadow: 0 10px 24px rgba(47, 158, 99, 0.35); }

.home-card-icon { display: inline-flex; }
.home-card-icon svg { width: 22px; height: 22px; }

.home-card strong { font-size: 22px; line-height: 1.15; color: #ffffff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-card span { color: rgba(255, 255, 255, 0.85); font-size: 12.5px; font-weight: 700; }

.home-periods {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.home-card-period {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

@media (max-width: 620px) {
  .home-card strong { font-size: 17px; }
  .home-card { padding: 12px; }
  .home-periods strong { font-size: 15px; }
}

@media (max-width: 420px) {
  /* Keep the home highlights side by side (Total due | Total collection,
     Today | This month | This year) — shrink text instead of stacking. */
  .home-card { padding: 10px 8px; gap: 4px; }
  .home-card strong { font-size: 15px; }
  .home-card span { font-size: 11px; }
  .home-card-icon svg { width: 18px; height: 18px; }
  .home-periods { gap: 6px; }
  .fee-stats-bar { gap: 6px; }
  .money-today-grid { gap: 6px; }
  .fee-stats-bar strong,
  .money-today-grid strong { font-size: 13.5px; }
}

@media (max-width: 360px) {
  .home-card strong { font-size: 14px; }
  .home-card span { font-size: 10.5px; }
  .home-card-icon svg { width: 16px; height: 16px; }
}

/* ---------- courses: top three + scrollable rest ---------- */

.course-top-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.course-top-grid .top-course {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent-softer), var(--surface));
  box-shadow: var(--shadow);
}

.course-scroll {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(230px, 300px);
  gap: 12px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding-bottom: 8px;
}

@media (max-width: 620px) {
  .course-top-grid { grid-template-columns: 1fr; }
}

/* ---------- reminder cards ---------- */

.reminder-card {
  border-inline-start: 4px solid var(--accent);
  border-radius: 14px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
  min-width: 0;
}

.reminder-card.reminder-due { border-inline-start-color: #e08a3c; }
.reminder-card.reminder-birthday { border-inline-start-color: #2f9e63; }

.reminder-copy { min-width: 0; flex: 1 1 120px; }

.reminder-card strong {
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reminder-copy span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reminder-card .badge { flex: 0 0 auto; }

@media (max-width: 400px) {
  .reminder-card { padding: 10px; gap: 8px; }
  .reminder-card strong { font-size: 13px; }
  .reminder-card .student-avatar { width: 38px; height: 38px; flex-basis: 38px; font-size: 16px; }
}

/* ---------- admin tools toggle (More) ---------- */

.admin-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
  padding: 12px;
  min-height: 44px;
  cursor: pointer;
}

.admin-toggle:hover { border-color: var(--accent); }

.admin-chevron { transition: transform 0.2s ease; font-size: 12px; }

.admin-toggle[aria-expanded="true"] .admin-chevron { transform: rotate(180deg); }

.admin-tools-body { display: grid; gap: 10px; padding-top: 10px; }

input[readonly] { background: #eef2f7; color: var(--muted); }

/* ---------- trash (admin only) ---------- */

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

.trash-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.trash-row > div:first-child { display: grid; gap: 2px; min-width: 0; }
.trash-row strong { font-size: 15px; }
.trash-row span { color: var(--muted); font-size: 12.5px; }
.trash-row .inline-tools { display: flex; gap: 6px; flex: 0 0 auto; }
.trash-tools { margin-bottom: 10px; }

.small-btn.danger {
  color: var(--danger);
  background: #fdeeed;
  border: 1px solid #f7d4d0;
}

/* ---------- more: backup panel ---------- */

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.backup-actions > * {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 10px;
}

@media (max-width: 620px) {
  .backup-actions > * { flex-basis: 100%; }
}

/* ---------- attendance roster polish ---------- */

/* Roster rows mirror the Students tab card: card shell, avatar, details. */
.attendance-row {
  display: grid;
  gap: 10px;
  border: 1px solid #c5cbd0;
  border-radius: 18px;
  padding: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.attendance-row .student-card-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.attendance-row .student-avatar { width: 44px; height: 44px; flex: 0 0 44px; font-size: 18px; }
.attendance-row .student-card-copy { display: grid; gap: 2px; min-width: 0; flex: 1; }
.attendance-row .student-card-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.attendance-row .student-card-copy span { color: #48515a; font-size: 12.5px; }
.attendance-row .attendance-calls { display: flex; gap: 4px; flex: 0 0 auto; }
.attendance-row .small-btn { min-width: 64px; }

.payroll-side {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.payroll-tools {
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 620px) {
  .payroll-tools { justify-content: flex-start; }
  .payroll-side { justify-items: start; }
}

/* ---------- reports polish ---------- */

.report-overview > div {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 12px 14px;
}

.report-overview .stat-income { background: rgba(46, 158, 99, 0.24); border-color: rgba(120, 210, 160, 0.35); }
.report-overview .stat-expense { background: rgba(224, 138, 60, 0.22); border-color: rgba(235, 180, 130, 0.35); }
.report-overview .stat-net { background: rgba(255, 255, 255, 0.14); }
.report-overview .stat-bank { background: rgba(74, 127, 214, 0.22); border-color: rgba(150, 185, 235, 0.35); }

.report-metrics article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.report-metrics article:first-child strong { color: #21703a; }
.report-metrics article:nth-child(2) strong { color: #b45309; }

@media (max-width: 620px) {
  .period-picker { justify-items: stretch; width: 100%; }
  .period-chips { display: flex; flex-wrap: wrap; width: 100%; }
  .period-chips button { flex: 1 1 auto; }
  .report-hero input[type="date"],
  .report-hero input[type="month"],
  .report-hero input[type="number"] { max-width: none; width: 100%; }
}

/* ---------- students per course bars ---------- */

.fee-course-admission {
  border-top: 1px dashed var(--line);
  padding-top: 8px;
  margin-top: 4px;
  color: var(--accent-strong);
  font-weight: 700;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 38%) 1fr auto;
  gap: 10px;
  align-items: center;
}

.bar-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
}

.bar-value {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 44px;
  text-align: right;
}

/* ---------- due notes (Reminders + fee detail) ---------- */

.due-item {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.due-item .fee-student-card {
  border: 0;
  padding: 2px;
  background: transparent;
  box-shadow: none;
}

.due-note { display: grid; gap: 4px; }

.due-note span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.due-note input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  font-size: 13.5px;
  color: var(--ink);
}

.due-note input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

/* Fees list: name card row with a call button, badge may wrap when it lists months. */
.fee-card-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fee-card-row .fee-student-card {
  flex: 1;
  min-width: 0;
}

.fee-call { flex: 0 0 auto; }

.fee-badge-row { display: flex; }

.fee-badge-row .badge { white-space: normal; }

/* ---------- paid / unpaid badge (attendance + fees) ---------- */

.badge.pay-badge {
  min-height: 22px;
  padding: 2px 9px;
}

.badge.pay-badge.is-paid {
  background: #dcfce7;
  color: #15803d;
}

.badge.pay-badge.is-unpaid {
  background: #fee2e2;
  color: #b91c1c;
}

/* Attendance rows: keep the badge on its own small line under the name. */
.attendance-row .student-card-copy .badge.pay-badge {
  justify-self: start;
  font-size: 11px;
}

/* ---------- attendance year cards + drill-down pages ---------- */

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

.year-card {
  display: grid;
  gap: 4px;
  padding: 20px 18px;
  border: 1px solid #c5cbd0;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
  color: var(--ink);
}

.year-card:hover,
.year-card:focus-visible {
  border-color: var(--accent);
  background: var(--accent-softer);
  outline: none;
}

.year-card strong { font-size: 20px; }
.year-card span { color: var(--muted); font-size: 13px; }

.att-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.att-toolbar-bottom { margin: 12px 0 0; }
.att-toolbar .att-date { display: grid; gap: 4px; }
.att-toolbar .att-date span { font-size: 12px; color: var(--muted); }
.att-save { flex: 0 0 auto; }

.att-saved {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #e7f6ec;
  border: 1px solid #b7e2c6;
  color: #21703a;
  font-weight: 700;
}

@media (max-width: 620px) {
  .year-cards { grid-template-columns: 1fr; }
  .att-toolbar { align-items: stretch; }
  .att-toolbar .att-save { width: 100%; }
}

/* Roster cards stack cleanly on phones so name, contacts and the
   present/absent buttons never overflow the screen. */
@media (max-width: 620px) {
  .attendance-row { padding: 12px; }
  .attendance-row .student-card-main { flex-wrap: wrap; row-gap: 8px; }
  .attendance-row .student-avatar { width: 40px; height: 40px; flex-basis: 40px; font-size: 16px; }
  .attendance-row .student-card-copy { flex: 1 1 60%; }
  .attendance-row .student-card-copy strong { white-space: normal; overflow-wrap: anywhere; }
  .attendance-row .attendance-calls { margin-inline-start: auto; }
  .attendance-row .inline-tools.att-mark { flex: 1 1 100%; }
  .attendance-row .inline-tools.att-mark .small-btn { flex: 1; min-width: 0; }
}
