/* Shared CRM components: the same blue glass language on every screen. */
:root {
  color-scheme: light;
  --crm-ink: #243a56;
  --crm-muted: #526b89;
  --crm-blue: #286bd8;
  --crm-line: #d4e1ef;
  --crm-focus: #77a9f0;
  --crm-glass: linear-gradient(145deg, #fffffff0, #f9fbffbf);
  --crm-shadow: 0 18px 42px -30px #3d619e66, 0 3px 10px -7px #3d619e33, inset 0 1px 0 #fff;
}
.panel, .stat, .hero, .modal {
  border: 1px solid #fffffff0;
  background: var(--crm-glass);
  box-shadow: var(--crm-shadow);
}
.panel, .stat, .hero { backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.hero { background: linear-gradient(125deg, #dcecffd9, #e7f2fac9); }
.modal { background: linear-gradient(145deg, #fff, #f2f7fe); box-shadow: 0 30px 85px -25px #243f694d, inset 0 1px 0 #fff; }
.modal-backdrop { background: #243a5642; }
.button {
  min-height: 43px;
  padding: 11px 16px;
  border: 1px solid #d8e5f4;
  border-radius: 12px;
  color: #426994;
  font-size: 13px;
  line-height: 1.4;
  background: linear-gradient(145deg, #fff, #f4f8ff);
  box-shadow: inset 0 1px 0 #fff, 0 5px 15px -12px #365a99;
}
.button.primary {
  border-color: #3979df;
  background: linear-gradient(155deg, #326dce, #286bd8);
  box-shadow: inset 0 1px 0 #ffffff66, 0 7px 17px -10px #215fb8;
}
.button.ghost { border-color: #d4e1ef; background: #ffffff40; box-shadow: inset 0 1px 0 #ffffff80; }
.button.danger { color: #a63f4e; border-color: #efd2da; background: linear-gradient(145deg, #fffafa, #fff1f3); }
.button.small { min-height: 36px; font-size: 12px; }
.button:not(:disabled):hover { filter: none; box-shadow: inset 0 1px 0 #fff, 0 7px 18px -11px #365a9966; }
.button.primary:not(:disabled):hover { background: linear-gradient(155deg, #2d68cb, #2465cf); box-shadow: inset 0 1px 0 #ffffff66, 0 9px 19px -10px #215fb880; }
.button:disabled { opacity: .65; }
.field { gap: 8px; margin-bottom: 19px; color: #405a76; font-size: 14px; line-height: 1.5; font-weight: 500; }
.field input, .field select, .field textarea, .search {
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid var(--crm-line);
  border-radius: 12px;
  background: #ffffffd4;
  box-shadow: inset 0 1px 3px #304f7605, 0 1px 0 #ffffffb3;
  color: var(--crm-ink);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.4;
}
.field textarea { min-height: 115px; line-height: 1.65; }
.field input::placeholder, .field textarea::placeholder, .search::placeholder { color: var(--crm-muted); opacity: 1; }
.field input:hover, .field select:hover, .field textarea:hover, .search:hover { border-color: #b5cce6; }
.field input:focus, .field select:focus, .field textarea:focus, .search:focus {
  border-color: #77a9eb;
  outline: 3px solid #77a9f026;
  outline-offset: 2px;
  background-color: #fff;
}
.field input:disabled, .field select:disabled, .field textarea:disabled { background: #edf3fb; color: #7388a1; cursor: not-allowed; }
.field > small { color: var(--crm-muted); font-size: 12px; line-height: 1.6; }
.field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23667c95' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-position: right 14px center;
  background-repeat: no-repeat;
  background-size: 16px;
}
.field select[multiple] { background-image: none; padding-right: 14px; min-height: 120px; }
.field select option { color: var(--crm-ink); background: #f9fbff; }
.field input[type='date'], .field input[type='time'], .field input[type='datetime-local'] { min-width: 0; max-width: 100%; }
.field input::-webkit-calendar-picker-indicator { cursor: pointer; padding: 3px; opacity: .58; }
.field input[type='checkbox'], .check-row input[type='checkbox'] { width: 18px; height: 18px; min-height: 18px; margin: 0; padding: 0; flex: 0 0 18px; accent-color: var(--crm-blue); border-radius: 5px; }
input[type='radio'] { accent-color: var(--crm-blue); }
.check-row { color: #405a76; font-size: 14px; line-height: 1.65; }
.check-row input { margin-top: 2px; }
.field input[type='file'] { padding: 6px; font-size: 13px; color: var(--crm-muted); }
input[type='file']::file-selector-button {
  margin-right: 12px;
  padding: 9px 12px;
  border: 1px solid #cbdcf3;
  border-radius: 8px;
  color: #3369ad;
  background: linear-gradient(145deg, #f8fbff, #eaf2ff);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--crm-focus); outline-offset: 3px; }
.profile-card { padding-bottom: 22px; border-bottom: 1px solid #dce6f28c; }
.profile-card .avatar.large { border: 1px solid #fff; background: linear-gradient(145deg, #e9f2ff, #ccdef7); box-shadow: 0 9px 22px -15px #436aa766, inset 0 1px 0 #fff; }
.hint, .error-box { font-size: 13px; line-height: 1.65; }
.hint { border: 1px solid #dce9fa; background: #edf4fec9; }
.error-box { border: 1px solid #f0d8df; background: #fff1f3; }
.form-error:empty { display: none; }
.modal .subtext, .install-note { font-size: 13px; line-height: 1.75; }

/* The native file input remains focusable inside its visible label. */
.photo-field { min-width: 0; margin: 0 0 22px; padding: 0; border: 0; }
.photo-label { display: block; margin-bottom: 9px; color: #405a76; font-size: 14px; line-height: 1.5; font-weight: 500; }
.photo-picker { display: flex; align-items: flex-start; gap: 16px; min-width: 0; padding: 17px; border: 1px solid #d5e3f2; border-radius: 15px; background: linear-gradient(145deg, #ffffffde, #edf5ff85); box-shadow: inset 0 1px 0 #fff; }
.photo-preview { position: relative; display: flex; align-items: center; justify-content: center; flex: 0 0 64px; width: 64px; height: 64px; overflow: hidden; border: 1px solid #fff; border-radius: 17px; color: #7395c0; background: linear-gradient(145deg, #eaf3ff, #d8e7fa); box-shadow: 0 4px 13px -10px #436aa780, inset 0 1px 0 #ffffff80; }
.photo-preview svg { width: 27px; height: 27px; }
.photo-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-details { flex: 1; min-width: 0; padding-top: 1px; }
.photo-title { display: block; color: var(--crm-ink); font-size: 14px; font-weight: 550; line-height: 1.5; }
.photo-filename { display: block; margin-top: 4px; color: var(--crm-muted); font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.photo-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin-top: 12px; }
.photo-choose { position: relative; display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 8px 11px; border: 1px solid #cbdcf3; border-radius: 9px; color: #3369ad; font-size: 12px; font-weight: 550; line-height: 1.5; background: linear-gradient(145deg, #fff, #edf4ff); box-shadow: inset 0 1px 0 #fff; cursor: pointer; }
.photo-choose:hover { background: #eaf2ff; border-color: #a9c7ed; }
.photo-choose:focus-within { outline: 3px solid var(--crm-focus); outline-offset: 3px; }
.photo-choose .photo-input { position: absolute; width: 1px; min-width: 1px; height: 1px; min-height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.photo-clear { display: inline-flex; align-items: center; min-height: 38px; padding: 6px 2px; border: 0; border-radius: 6px; background: transparent; box-shadow: none; color: #526b89; font-size: 12px; line-height: 1.5; }
.photo-clear:hover { color: #286bd8; text-decoration: underline; text-underline-offset: 3px; }
.photo-help { margin: 9px 2px 0; color: var(--crm-muted); font-size: 12px; line-height: 1.65; }
.photo-error { margin: 9px 0 0; padding: 10px 12px; border: 1px solid #efd8df; border-radius: 10px; color: #a24450; background: #fff1f3; font-size: 13px; line-height: 1.55; }
.photo-preview [hidden], .photo-clear[hidden], .photo-error[hidden], .photo-help[hidden] { display: none; }
@media (max-width: 720px) {
  .field { font-size: 14px; }
  .field input, .field select, .field textarea, .search { min-height: 46px; padding: 12px; font-size: 16px; }
  .field select { padding-right: 39px; }
  .field input[type='checkbox'] { min-height: 18px; padding: 0; }
  .field input[type='file'] { padding: 6px; font-size: 13px; }
  .photo-picker { gap: 13px; padding: 14px; }
  .photo-preview { flex-basis: 58px; width: 58px; height: 58px; border-radius: 15px; }
  .photo-choose { min-height: 42px; }
  .photo-clear { min-height: 42px; }
  .modal .subtext, .install-note { font-size: 13px; }
}
@media (prefers-reduced-motion: no-preference) {
  .field input, .field select, .field textarea, .search, .photo-choose { transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease; }
}
@media (forced-colors: active) {
  .field select { appearance: auto; -webkit-appearance: auto; background-image: none; }
  .photo-choose { border-color: ButtonText; }
  .photo-choose:focus-within { outline-color: Highlight; }
}

/* User-provided names must wrap without widening cards or mobile layouts. */
.main, .topbar, .topbar > *, .profile-card, .person-info, .panel, .hero, .modal { min-width: 0; }
h1, h2, h3, .profile-card, .person-info, .subtext, .notice-body { overflow-wrap: anywhere; }
.photo-choose { max-width: 100%; text-align: center; }
.top-actions, .profile-button, .profile-button > span { min-width: 0; }
.profile-button > span:first-child { max-width: 180px; }
.profile-button b, .profile-button small { overflow-wrap: anywhere; }
.profile-button .avatar { flex-shrink: 0; }
.breadcrumb { flex-wrap: wrap; align-items: center; color: var(--crm-muted); }
.breadcrumb #sync-status { margin-left: auto; }
.schedule-child-filter { margin: 0; min-width: 180px; max-width: 100%; }
.schedule-child-filter select { min-width: 0; width: 100%; }
.lesson-children { display: block; margin-top: 5px; color: var(--crm-muted); font-size: 12px; line-height: 1.5; }
.nav-count { margin-left: auto; display: inline-flex; align-items: center; justify-content: center; min-width: 21px; padding: 2px 6px; border-radius: 9px; background: #dfebff; color: #235cae; font-size: 11px; line-height: 1.5; }
@media (max-width: 720px) {
  .schedule-child-filter { flex-basis: 100%; }
  .breadcrumb #sync-status { margin-left: 0; }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer .button { max-width: 100%; white-space: normal; }
}
@media (max-width: 360px) { .photo-picker { flex-direction: column; } }

/* Attendance and family accounts use the same readable glass components. */
.finance-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; margin-bottom: 22px; }
.finance-toolbar .field { flex: 1 1 190px; margin: 0; min-width: 0; }
.finance-toolbar select { width: 100%; min-width: 0; }
.pass-card { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.pass-cards { margin-bottom: 20px; }
.finance-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.finance-balance { display: grid; gap: 10px; padding-top: 16px; border-top: 1px solid #dbe5f0; font-variant-numeric: tabular-nums; }
.finance-balance .between { gap: 12px; }
.pass-card h3, .pass-card p, .payment-row, .attendance-row { overflow-wrap: anywhere; }
.finance-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.finance-metrics > * { min-width: 0; padding: 14px; border: 1px solid #ffffffed; border-radius: 13px; background: #edf4fb9c; }
.finance-metrics b, .finance-metrics strong { display: block; color: var(--crm-ink); font-size: 22px; line-height: 1.3; font-variant-numeric: tabular-nums; letter-spacing: -.4px; }
.finance-metrics small { display: block; margin-top: 5px; }
.payment-history, .attendance-roster { display: grid; gap: 0; }
.payment-row, .attendance-row { min-width: 0; padding: 18px 0; border-bottom: 1px solid #dbe5f0; }
.payment-row:last-child, .attendance-row:last-child { border-bottom: 0; }
.payment-row { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.payment-row > div { min-width: 0; }
.payment-row b { display: block; font-variant-numeric: tabular-nums; }
.payment-row small { display: block; margin-top: 5px; }
.attendance-history-row { padding: 16px 0; border-bottom: 1px solid #dbe5f0; overflow-wrap: anywhere; }
.attendance-history-row:last-child { padding-bottom: 0; border-bottom: 0; }
.attendance-history-row .between { align-items: flex-start; flex-wrap: wrap; gap: 12px; }
.attendance-history-row b, .attendance-history-row small { display: block; }
.attendance-history-row small { margin-top: 5px; }
.attendance-history-row .install-note { margin-top: 9px; }
.attendance-controls { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin-top: 13px; }
.attendance-controls .field { flex: 1 1 150px; min-width: 0; margin: 0; }
.attendance-controls select { width: 100%; min-width: 0; }
.attendance-row .form-error { margin-top: 10px; }
.coverage-warning { padding: 12px 14px; border: 1px solid #e8d7ac; border-radius: 12px; background: #fff8e8; color: #795824; font-size: 13px; line-height: 1.6; }
.finance-empty { padding: 28px 18px; color: var(--crm-muted); font-size: 14px; line-height: 1.7; text-align: center; }
.pass-card .row-actions { flex-wrap: wrap; }
@media (max-width: 720px) {
  .finance-toolbar { gap: 12px; }
  .finance-summary { grid-template-columns: 1fr; }
  .finance-toolbar .field { flex-basis: 100%; }
  .finance-metrics { gap: 9px; grid-template-columns: repeat(2, minmax(0,1fr)); }
  .finance-metrics > * { padding: 12px; }
  .finance-metrics b, .finance-metrics strong { font-size: 21px; }
  .attendance-controls { align-items: stretch; }
  .attendance-controls .field { flex-basis: 100%; }
  .attendance-controls .button { width: 100%; }
}
