:root {
  color-scheme: light;
  --ink: #2c2a26;
  --muted: #7c776f;
  --line: #ddd8cf;
  --soft: #f7f5f0;
  --paper: #fffdf8;
  --sand: #d4cfc4;
  --taupe: #9d978c;
  --brand-gray: #b5b0a6;
  --brand-smoke: #ece9e2;
  --sage: #858b7c;
  --sage-2: #eceee6;
  --clay: #a87768;
  --amber: #a88954;
  --green: #63745b;
  --blue: #687a83;
  --shadow: 0 16px 42px rgba(54, 49, 42, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.82), rgba(247, 245, 240, 0.98)),
    radial-gradient(circle at 12% 0%, rgba(181, 176, 166, 0.2), transparent 32%),
    var(--soft);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

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

.app-shell.auth-locked {
  grid-template-columns: 1fr;
}

.app-shell.student-shell {
  grid-template-columns: 200px minmax(0, 1fr);
  max-width: 1320px;
  margin-inline: auto;
}

.app-shell.teacher-shell {
  grid-template-columns: 1fr;
  max-width: 1180px;
  margin-inline: auto;
}

.sidebar {
  background: rgba(255, 253, 248, 0.96);
  color: var(--ink);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  text-align: center;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--taupe);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 800;
}

.brand-logo {
  width: min(190px, 86%);
  height: auto;
  display: block;
  margin: 0 auto;
}

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

.brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.brand small {
  color: var(--muted);
  margin-top: 2px;
}

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

.nav button,
.ghost-button,
.mode-button,
.primary-button,
.soft-button,
.danger-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  min-height: 40px;
}

.nav button {
  width: 100%;
  color: var(--muted);
  background: transparent;
  text-align: left;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.nav-badge {
  background: var(--clay);
  color: #fff;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
  flex-shrink: 0;
}

.nav button.active,
.nav button:hover {
  background: var(--brand-smoke);
  color: var(--ink);
}

.sidebar-footer {
  display: none !important;
}

.ghost-button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 0 14px;
}

.workspace {
  min-width: 0;
}

.topbar {
  min-height: 92px;
  background: rgba(255, 253, 248, 0.92);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 32px;
}

.topbar-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-weight: 500;
  line-height: 1.15;
  margin: 0;
}

.mobile-menu-button,
.mobile-menu-backdrop {
  display: none;
}

.mobile-menu-button {
  min-height: 40px;
  width: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  font-size: 22px;
  line-height: 1;
}

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

.eyebrow {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 700;
  margin: 0 0 6px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--brand-smoke);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
}

.mode-button {
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
}

.mode-button.active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.content {
  padding: 28px 32px 48px;
}

.student-shell .content {
  /* workspace constrained by app-shell max-width */
}

.teacher-shell .content {
  max-width: 1180px;
  margin: 0 auto;
  width: 100%;
}

.login-wrap {
  min-height: calc(100vh - 150px);
  display: grid;
  place-items: center;
}

.public-home {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.public-hero {
  min-height: min(620px, calc(100vh - 180px));
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 20px;
  align-items: stretch;
}

.public-hero-copy,
.public-hero-visual {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 248, 0.92);
  box-shadow: var(--shadow);
}

.public-hero-copy {
  padding: clamp(28px, 5vw, 58px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}

.public-home-logo {
  width: min(240px, 72%);
  height: auto;
  margin-bottom: 10px;
}

.public-hero-copy h2 {
  max-width: 720px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 5vw, 58px);
  font-weight: 500;
  line-height: 1.03;
}

.public-hero-copy p:not(.eyebrow) {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.public-hero-visual {
  position: relative;
  overflow: hidden;
  min-height: 420px;
  background:
    linear-gradient(140deg, rgba(45, 42, 37, 0.76), rgba(157, 151, 140, 0.28)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='760' height='680' viewBox='0 0 760 680'%3E%3Crect width='760' height='680' fill='%23e4d5c7'/%3E%3Cpath d='M0 492 C124 392 260 496 380 390 C520 266 620 306 760 210 L760 680 L0 680 Z' fill='%23c7b29e' opacity='.9'/%3E%3Cpath d='M66 88 h114 M66 142 h114 M66 196 h114 M66 250 h114 M122 88 v226' stroke='%23f7f2ec' stroke-width='13' stroke-linecap='round' opacity='.38'/%3E%3Cpath d='M500 320 c-52 6-96 54-102 126 M500 320 c60 10 104 58 110 134 M500 320 c-36-62-22-122 28-184 M500 320 c-62-40-112-94-138-166' fill='none' stroke='%2363745b' stroke-width='20' stroke-linecap='round' opacity='.54'/%3E%3C/svg%3E");
  background-size: cover, cover;
  background-position: center;
}

.public-sello {
  position: absolute;
  inset: 8% auto auto 7%;
  width: min(520px, 88%);
  aspect-ratio: 1 / 1;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 22px 34px rgba(41, 37, 31, 0.28));
  transform-origin: 54% 50%;
}

.public-sello.core {
  opacity: 0.66;
  animation: ryoLogoSettle 1.5s cubic-bezier(0.34, 1.3, 0.64, 1) 0.1s both, ryoLogoFloat 10s ease-in-out 1.6s infinite;
}

.public-sello.echo-a {
  opacity: 0.1;
  transform: translate(-26px, 18px) scale(0.96) rotate(-4deg);
  animation: ryoLogoTraceA 1.25s ease-out both;
}

.public-sello.echo-b {
  opacity: 0.08;
  transform: translate(28px, -18px) scale(1.02) rotate(4deg);
  animation: ryoLogoTraceB 1.35s ease-out 0.1s both;
}

.public-section,
.public-contact {
  margin-top: 2px;
}

.section-heading {
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: 26px;
}

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

.public-class-card {
  min-height: 170px;
}

.public-class-card span {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--sage-2);
  color: #3f513b;
  font-weight: 800;
  font-size: 12px;
  margin-bottom: 18px;
}

.public-contact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.public-contact h2,
.public-contact p {
  margin: 0;
}

.public-contact p:not(.eyebrow) {
  max-width: 620px;
  color: var(--muted);
}

.login-panel {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  gap: 20px;
  align-items: stretch;
}

.login-copy {
  position: relative;
  overflow: hidden;
  min-height: 420px;
  border-radius: 8px;
  padding: 34px;
  color: #fffdf8;
  background:
    linear-gradient(110deg, rgba(45, 42, 37, 0.82), rgba(157, 151, 140, 0.34)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='520' viewBox='0 0 900 520'%3E%3Crect width='900' height='520' fill='%23ddc9b6'/%3E%3Crect x='0' y='0' width='900' height='520' fill='%23f4eee7' opacity='.32'/%3E%3Cpath d='M0 390 C190 290 315 435 490 306 C642 194 730 274 900 184 L900 520 L0 520 Z' fill='%23cbb39d'/%3E%3Crect x='70' y='58' width='132' height='288' rx='8' fill='%23fffaf4' opacity='.65'/%3E%3Cpath d='M90 82 h92 M90 132 h92 M90 182 h92 M90 232 h92 M90 282 h92 M136 82 v242' stroke='%23a9998a' stroke-width='5' opacity='.52'/%3E%3Cpath d='M720 256 c-42 4-82 48-86 112 M720 256 c56 8 92 46 98 118 M720 256 c-28-58-15-108 26-154 M720 256 c-52-38-94-84-118-142' fill='none' stroke='%235d754f' stroke-width='15' stroke-linecap='round' opacity='.72'/%3E%3C/svg%3E");
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.ryo-welcome-mark {
  position: absolute;
  inset: 12px 10px auto auto;
  width: min(430px, 72%);
  aspect-ratio: 1.25;
  pointer-events: none;
}

.ryo-welcome-mark img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: 54% 50%;
}

.ryo-mark-core {
  opacity: 0;
  filter: drop-shadow(0 18px 26px rgba(41, 37, 31, 0.22));
  transform: translateY(18px) scale(0.92) rotate(-2deg);
  animation: ryoLogoSettle 1.2s ease-out 0.28s forwards;
}

.ryo-mark-echo {
  opacity: 0;
  filter: blur(0.2px) drop-shadow(0 18px 28px rgba(41, 37, 31, 0.16));
  mix-blend-mode: multiply;
}

.ryo-mark-echo.echo-a {
  transform: translate(-42px, 18px) scale(0.84) rotate(-8deg);
  animation: ryoLogoTraceA 1.25s ease-out 0.02s forwards;
}

.ryo-mark-echo.echo-b {
  transform: translate(32px, -14px) scale(0.9) rotate(7deg);
  animation: ryoLogoTraceB 1.35s ease-out 0.12s forwards;
}

.login-copy h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 46px;
  font-weight: 500;
  letter-spacing: 0.04em;
  margin: 0 0 10px;
}

.login-copy p {
  max-width: 560px;
  margin: 0;
  color: rgba(255, 250, 244, 0.86);
}

.login-form {
  display: grid;
  align-content: center;
  gap: 14px;
}

.login-error {
  display: none;
  color: #8a3f32;
  background: #f7dfd8;
  border-radius: 8px;
  padding: 10px 12px;
}

.login-error.visible {
  display: block;
}

.loading-state,
.error-state {
  width: min(760px, 100%);
  min-height: 260px;
  margin: 8vh auto 0;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 248, 0.94);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 18px;
}

.loading-state h2,
.error-state h2 {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
}

.loading-state p,
.error-state p {
  margin: 0;
  color: var(--muted);
}

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

.error-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.spinner {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 4px solid #e7ded5;
  border-top-color: var(--taupe);
  animation: spin 0.9s linear infinite;
  flex: 0 0 auto;
}

.mode-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  border-radius: 999px;
  padding: 0 11px;
  background: var(--sage-2);
  color: #3f513b;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
}

.status-dot.ok {
  color: var(--green);
}

.status-dot.bad {
  color: #9a4438;
}

.status-separator {
  color: var(--muted);
}

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

@keyframes ryoLogoTraceA {
  0% {
    opacity: 0;
    transform: translate(-52px, 24px) scale(0.78) rotate(-10deg);
  }
  22% {
    opacity: 0.18;
    transform: translate(-28px, 12px) scale(0.88) rotate(-5.5deg);
  }
  62% {
    opacity: 0.14;
    transform: translate(-7px, 3px) scale(0.98) rotate(-0.9deg);
  }
  100% {
    opacity: 0.035;
    transform: translate(-4px, 1px) scale(1) rotate(-0.3deg);
  }
}

@keyframes ryoLogoTraceB {
  0% {
    opacity: 0;
    transform: translate(44px, -22px) scale(0.84) rotate(9deg);
  }
  24% {
    opacity: 0.15;
    transform: translate(22px, -10px) scale(0.91) rotate(4.5deg);
  }
  58% {
    opacity: 0.1;
    transform: translate(5px, -2px) scale(0.99) rotate(0.9deg);
  }
  100% {
    opacity: 0.03;
    transform: translate(3px, -1px) scale(1) rotate(0.3deg);
  }
}

@keyframes ryoLogoSettle {
  0% {
    opacity: 0;
    transform: translateY(24px) scale(0.88) rotate(-2.5deg);
  }
  30% {
    opacity: 0.48;
    transform: translateY(-5px) scale(1.04) rotate(0.7deg);
  }
  56% {
    opacity: 0.65;
    transform: translateY(2px) scale(0.99) rotate(-0.2deg);
  }
  78% {
    opacity: 0.69;
    transform: translateY(-1px) scale(1.004) rotate(0.1deg);
  }
  100% {
    opacity: 0.68;
    transform: translateY(0) scale(1) rotate(0deg);
  }
}

@keyframes ryoLogoFloat {
  0%   { transform: translateY(0)    scale(1)     rotate(0deg); }
  18%  { transform: translateY(-5px) scale(1.006) rotate(0.18deg); }
  36%  { transform: translateY(-8px) scale(1.009) rotate(-0.12deg); }
  54%  { transform: translateY(-4px) scale(1.005) rotate(0.22deg); }
  72%  { transform: translateY(-9px) scale(1.01)  rotate(-0.08deg); }
  88%  { transform: translateY(-3px) scale(1.004) rotate(0.15deg); }
  100% { transform: translateY(0)    scale(1)     rotate(0deg); }
}

.grid {
  display: grid;
  gap: 16px;
}

.notice-section {
  margin-bottom: 16px;
}

.notice {
  display: grid;
  gap: 4px;
  border-radius: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--sage-2);
  color: #3f513b;
}

.notice.warn {
  background: #fff2d8;
  color: #73521a;
  border-color: #ead3a5;
}

.muted {
  color: var(--muted);
  margin: 4px 0 0;
}

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

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

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

.surface,
.table-wrap {
  background: rgba(255, 252, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.surface {
  padding: 18px;
}

.surface h2,
.surface h3 {
  margin: 0 0 14px;
}

.stat {
  min-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

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

.stat strong {
  font-size: 30px;
}

.stat small {
  color: var(--muted);
}

.portal-summary-grid {
  grid-template-columns: repeat(2, minmax(120px, 190px));
  max-width: 430px;
  gap: 10px;
}

.portal-summary-grid .stat {
  min-height: 86px;
  padding: 12px;
}

.portal-summary-grid .stat strong {
  font-size: 24px;
}

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

.toolbar-group {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

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

.agenda-views,
.agenda-period,
.agenda-actions {
  flex-wrap: nowrap;
}

.agenda-period {
  justify-content: center;
}

.agenda-actions {
  justify-content: flex-end;
}

.agenda-toolbar .mode-button,
.agenda-toolbar .soft-button,
.agenda-toolbar .primary-button,
.agenda-toolbar .icon-button,
.agenda-toolbar input,
.agenda-toolbar select {
  min-height: 34px;
}

.agenda-toolbar .mode-button,
.agenda-toolbar .soft-button,
.agenda-toolbar .primary-button {
  padding: 0 11px;
}

.agenda-nav {
  width: 34px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.agenda-date {
  width: 150px;
  padding: 6px 9px;
}

.agenda-teacher-filter {
  width: 220px;
  padding: 6px 9px;
}

.primary-button {
  background: var(--taupe);
  color: white;
  padding: 0 16px;
}

.soft-button {
  background: var(--sage-2);
  color: #3f513b;
  padding: 0 14px;
}

.whatsapp-button {
  background: #25d366;
  color: #fff;
  border-color: #22c45e;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.whatsapp-button:hover {
  background: #1ebe5d;
  border-color: #1abe5b;
  color: #fff;
}

.danger-button {
  background: #f7dfd8;
  color: #8a3f32;
  padding: 0 14px;
}

.icon-button {
  width: 38px;
  background: var(--soft);
  color: var(--ink);
}

.field,
.field-row {
  display: grid;
  gap: 7px;
}

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

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

textarea {
  resize: vertical;
}

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

.enrollment-layout {
  display: grid;
  grid-template-columns: minmax(0, 760px);
  gap: 16px;
  align-items: start;
  justify-content: center;
  max-width: 820px;
  margin: 0 auto;
}

.enrollment-side,
.enrollment-layout > .surface {
  width: 100%;
}

.enrollment-side {
  max-width: 760px;
  margin: 0 auto;
}

.enrollment-intro,
.enrollment-prices {
  max-width: 580px;
  margin-left: auto;
  margin-right: auto;
}

.enrollment-form-card {
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

.stack-form {
  display: grid;
  gap: 14px;
  max-width: 760px;
  width: 100%;
}

.stack-form textarea {
  min-height: 92px;
}

.stack-form h2 {
  margin-top: 10px;
}

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

.checkbox-grid.compact-options {
  grid-template-columns: repeat(auto-fit, minmax(190px, max-content));
  column-gap: 26px;
  row-gap: 10px;
  justify-content: start;
}

.price-option-grid {
  grid-template-columns: repeat(2, minmax(0, 220px));
  gap: 10px 12px;
  justify-content: center;
}

.price-option-grid .item {
  min-height: 94px;
  padding: 12px 13px;
  display: grid;
  align-content: start;
  gap: 4px;
}

.price-option-grid .item strong {
  line-height: 1.2;
}

.price-option-grid .item p {
  font-size: 14px;
  line-height: 1.35;
}

.info-accordion-stack {
  display: grid;
  gap: 10px;
}

.info-accordion {
  padding: 0;
}

.info-accordion summary {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
}

.info-accordion summary::-webkit-details-marker {
  display: none;
}

.info-accordion summary::after {
  content: "v";
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--sage-2);
  color: #3f513b;
  font-size: 14px;
  line-height: 1;
  transition: transform 0.16s ease;
}

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

.info-accordion summary span {
  display: grid;
  gap: 3px;
}

.info-accordion summary strong {
  font-size: 18px;
}

.info-accordion summary small {
  color: var(--muted);
  line-height: 1.35;
}

.info-accordion .mini-list,
.info-accordion .actions {
  margin-left: 18px;
  margin-right: 18px;
}

.info-accordion .mini-list {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.info-accordion .actions {
  padding-bottom: 18px;
}

.checkbox-grid label,
.consent-line {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: var(--ink);
  line-height: 1.35;
}

.checkbox-grid input,
.consent-line input {
  width: auto;
  min-height: auto;
  margin-top: 3px;
}

.soft-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  padding: 0 14px;
  color: #3f513b;
  background: var(--sage-2);
  text-decoration: none;
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.ok {
  background: #e2ecd9;
  color: var(--green);
}

.pill.warn {
  background: #fff0cf;
  color: #8a6400;
}

.pill.bad {
  background: #f7dfd8;
  color: #8a3f32;
}

.pill.info {
  background: #e6edf1;
  color: var(--blue);
}

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

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--paper);
}

.student-card {
  cursor: pointer;
}

.student-card:hover {
  border-color: var(--taupe);
}

.clickable-head {
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.13s;
}

.clickable-head:hover {
  background: var(--sage-2);
}

.session-detail-label {
  margin: 16px 0 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

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

.item h3,
.item h4,
.item p {
  margin: 0;
}

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

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.profile-details {
  display: grid;
  gap: 12px;
}

.profile-details summary {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  list-style: none;
}

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

.profile-details summary::after {
  content: "⌄";
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--sage-2);
  color: #3f513b;
  font-size: 18px;
  line-height: 1;
  transition: transform 0.16s ease;
}

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

.profile-details summary span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.profile-details summary strong {
  font-size: 20px;
}

.profile-details summary small {
  color: var(--muted);
  line-height: 1.35;
}

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

.student-accordion-stack {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.section-details {
  overflow: hidden;
}

.surface.section-details,
.profile-section-surface {
  padding: 0;
}

.teacher-nav-details {
  position: sticky;
  top: 0;
  z-index: 20;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.section-details summary {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
}

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

.section-details summary::after {
  content: "v";
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--sage-2);
  color: #3f513b;
  font-size: 14px;
  line-height: 1;
  transition: transform 0.16s ease;
}

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

.section-details summary span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.section-details summary strong {
  font-size: 20px;
}

.section-details summary small {
  color: var(--muted);
  line-height: 1.35;
}

.section-details-body {
  border-top: 1px solid var(--line);
  padding: 16px 18px 18px;
}

.compact-info .item {
  padding: 12px;
}

.compact-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.teacher-portal {
  display: grid;
  gap: 16px;
}

.teacher-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
}

.teacher-nav a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  padding: 0 12px;
  background: var(--sage-2);
  color: #3f513b;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
}

.teacher-nav-details .teacher-nav {
  position: static;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  padding: 12px 18px 18px;
  border-top: 1px solid var(--line);
}

.teacher-portal > .surface,
.teacher-portal > .section-details,
.teacher-portal #teacher-summary {
  scroll-margin-top: 84px;
}

.calendar-day.is-muted {
  opacity: 0.48;
}

.teacher-calendar-grid .calendar-day {
  min-height: 102px;
}

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

.calendar-header-cell {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  text-align: center;
  padding: 4px 4px 8px;
}

.calendar-day {
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--paper);
  cursor: pointer;
  transition: border-color 0.13s, background 0.13s;
}

.calendar-day:hover {
  border-color: var(--taupe);
  background: var(--soft);
}

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

.calendar-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 4px;
}

.calendar-day-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: lowercase;
  font-weight: 400;
}

.calendar-day-num {
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  flex-shrink: 0;
}

.calendar-day-num.is-today-num {
  background: var(--sage);
  color: #fff;
}

.calendar-event {
  display: block;
  background: var(--sage-2);
  color: #3f513b;
  border-radius: 6px;
  padding: 5px 7px;
  font-size: 12px;
  margin-top: 5px;
  cursor: pointer;
  transition: background 0.12s;
}

.calendar-event:hover {
  background: var(--sage);
  color: #fff;
}

.monthly-bars {
  display: grid;
  gap: 10px;
}

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

.bar {
  height: 12px;
  border-radius: 999px;
  background: #e8ece9;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--sage), var(--taupe));
}

.portal-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 22px;
  align-items: stretch;
}

.student-shell .portal-hero {
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  max-width: 1120px;
  margin-left: auto;
  margin-right: auto;
}

.student-shell .portal-hero .surface {
  order: -1;
}

.portal-banner {
  min-height: 280px;
  border-radius: 8px;
  padding: 28px;
  color: white;
  background:
    linear-gradient(110deg, rgba(63, 51, 43, 0.78), rgba(156, 136, 117, 0.42)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='520' viewBox='0 0 900 520'%3E%3Crect width='900' height='520' fill='%23ddc9b6'/%3E%3Crect x='0' y='0' width='900' height='520' fill='%23f4eee7' opacity='.38'/%3E%3Cpath d='M0 390 C190 290 315 435 490 306 C642 194 730 274 900 184 L900 520 L0 520 Z' fill='%23cbb39d'/%3E%3Crect x='68' y='58' width='132' height='288' rx='8' fill='%23fffaf4' opacity='.68'/%3E%3Cpath d='M88 82 h92 M88 132 h92 M88 182 h92 M88 232 h92 M88 282 h92 M134 82 v242' stroke='%23a9998a' stroke-width='5' opacity='.52'/%3E%3Ccircle cx='720' cy='134' r='86' fill='%23fff6ea' opacity='.82'/%3E%3Cpath d='M724 256 c-42 4-82 48-86 112 M724 256 c56 8 92 46 98 118 M724 256 c-28-58-15-108 26-154 M724 256 c-52-38-94-84-118-142' fill='none' stroke='%235d754f' stroke-width='15' stroke-linecap='round' opacity='.78'/%3E%3Cpath d='M274 362 c64-118 169-128 225-46 30 44 73 66 135 64' fill='none' stroke='%233d463d' stroke-width='18' stroke-linecap='round' opacity='.72'/%3E%3Cpath d='M302 290 c58 30 120 24 176-18' fill='none' stroke='%23ffffff' stroke-width='12' stroke-linecap='round' opacity='.72'/%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.portal-banner h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 36px;
  font-weight: 500;
  margin: 0 0 8px;
}

.portal-banner p {
  max-width: 620px;
  margin: 0;
  color: rgba(255, 255, 255, 0.86);
}

.student-shell .content > .surface,
.student-shell .content > .grid,
.student-shell .content > .notice,
.student-shell .student-accordion-stack {
  max-width: 1120px;
  margin-left: auto;
  margin-right: auto;
}

.student-shell .content > .surface .grid.cols-3 {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.student-shell .profile-details-body {
  max-width: 760px;
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  width: min(720px, calc(100vw - 28px));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

dialog::backdrop {
  background: rgba(24, 35, 40, 0.42);
}

.dialog-content {
  padding: 18px;
}

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

.dialog-head h2 {
  margin: 0;
}

.empty {
  color: var(--muted);
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
}

/* ── Recibo / Ticket ───────────────────────────────── */
.receipt {
  font-family: var(--font-body, inherit);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.receipt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--accent, #5c6b5a);
  color: #fff;
  padding: 14px 18px;
}
.receipt-brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
}
.receipt-folio {
  font-size: 12px;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}
.receipt-body {
  padding: 16px 18px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.receipt-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 14px;
}
.receipt-row span:first-child {
  color: var(--muted);
  white-space: nowrap;
}
.receipt-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  border-top: 1px dashed var(--line);
  margin-top: 4px;
  padding-top: 12px;
  font-size: 18px;
  font-weight: 700;
}
.receipt-total span:first-child {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}
.receipt-footer {
  padding: 12px 18px;
  background: var(--surface, #f6f4f0);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

/* ============================================================
   Student Profile Card — Admin sidebar (.sp-*)
   ============================================================ */

.sp-card {
  display: flex;
  flex-direction: column;
}

.sp-hero {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.sp-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--sage-2);
  border: 2px solid var(--sage);
  color: var(--sage);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Georgia, serif;
  font-size: 17px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.sp-hero-body {
  flex: 1;
  min-width: 0;
}

.sp-name {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 500;
  margin: 0 0 3px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sp-meta {
  font-size: 11.5px;
  color: var(--muted);
  margin: 0 0 9px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sp-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.sp-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}

.sp-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 14px 6px;
  border-right: 1px solid var(--line);
  transition: background 0.14s;
  cursor: default;
}

.sp-stat:last-child {
  border-right: none;
}

.sp-stat:hover {
  background: var(--soft);
}

.sp-stat-val {
  font-size: 26px;
  font-weight: 700;
  font-family: Georgia, serif;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.sp-stat-val--sm {
  font-size: 16px;
}

.sp-stat-lbl {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  text-align: center;
}

.sp-stat--warn .sp-stat-val { color: var(--clay); }
.sp-stat--muted .sp-stat-val { color: var(--muted); }

.sp-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.sp-section-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 10px;
}

.sp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.sp-row:last-child { border-bottom: none; }

.sp-row--past { opacity: 0.6; }

.sp-date-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 7px;
  min-width: 38px;
  flex-shrink: 0;
  transition: background 0.14s;
}

.sp-date-chip--past {
  background: transparent;
  border-color: transparent;
}

.sp-chip-day {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.sp-chip-num {
  font-size: 19px;
  font-weight: 700;
  font-family: Georgia, serif;
  color: var(--ink);
  line-height: 1.1;
}

.sp-row-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

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

.sp-row-sub {
  font-size: 11px;
  color: var(--muted);
}

.sp-empty {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  padding: 4px 0;
}

.sp-collapse {
  border-bottom: 1px solid var(--line);
}

.sp-collapse > summary {
  padding: 9px 16px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  transition: background 0.14s, color 0.14s;
}

.sp-collapse > summary::-webkit-details-marker { display: none; }

.sp-collapse > summary::after {
  content: "›";
  margin-left: auto;
  font-size: 16px;
  transition: transform 0.18s;
  display: inline-block;
}

.sp-collapse[open] > summary::after { transform: rotate(90deg); }

.sp-collapse > summary:hover {
  color: var(--ink);
  background: var(--soft);
}

.sp-badge {
  background: var(--brand-smoke);
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  color: var(--ink);
}

.sp-collapse-body {
  padding: 4px 16px 12px;
}

.sp-note {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  margin: 0;
  line-height: 1.5;
}

.sp-note--health {
  color: var(--clay);
  font-weight: 500;
}

.sp-rgpd-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 11.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.sp-rgpd-label {
  font-weight: 600;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sp-text-btn {
  background: none;
  border: none;
  color: var(--sage);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  min-height: auto;
  border-radius: 0;
  font-family: inherit;
}

.sp-text-btn:hover { color: var(--ink); }

.sp-primary-actions {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.sp-primary-actions .primary-button,
.sp-primary-actions .soft-button {
  font-size: 13px;
  min-height: 36px;
  padding: 0 12px;
}

.sp-collapse--more > summary {
  font-size: 11.5px;
  color: var(--muted);
}

.sp-more-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sp-more-actions button {
  font-size: 12px;
  min-height: 32px;
  padding: 0 10px;
}

/* ============================================================
   Portal Student Hero Card (.ps-*)
   ============================================================ */

.ps-hero-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.ps-greeting {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.ps-greeting-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 3px;
}

.ps-greeting-name {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 26px;
  font-weight: 500;
  margin: 0;
  line-height: 1.15;
  color: var(--ink);
}

.ps-next-class {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
}

.ps-next-label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}

.ps-next-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ps-next-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  min-width: 46px;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.ps-next-chip-day {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sage);
}

.ps-next-chip-num {
  font-size: 22px;
  font-weight: 700;
  font-family: Georgia, serif;
  color: var(--ink);
  line-height: 1.1;
}

.ps-next-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ps-next-type {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ps-next-time {
  font-size: 12px;
  color: var(--muted);
}

.ps-no-next {
  font-size: 13px;
  color: var(--muted);
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  margin: 0;
}

.ps-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}

.ps-mini-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 6px;
  border-right: 1px solid var(--line);
  transition: background 0.14s;
}

.ps-mini-stat:last-child { border-right: none; }
.ps-mini-stat:hover { background: var(--soft); }

.ps-mini-stat strong {
  font-size: 20px;
  font-weight: 700;
  font-family: Georgia, serif;
  color: var(--ink);
  line-height: 1;
}

.ps-mini-stat span {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.ps-card-footer {
  padding: 12px 20px;
  display: flex;
  gap: 8px;
}

/* ============================================================ */

/* ============================================================
   Student Portal Views (.sh-*)
   ============================================================ */

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

.sh-eyebrow {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 3px;
}

.sh-name {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-weight: 500;
  margin: 0;
  line-height: 1.15;
  color: var(--ink);
}

.sh-next-card {
  margin-bottom: 16px;
  padding: 16px 20px;
}

.sh-next-empty {
  background: var(--soft);
}

.sh-card-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin: 0 0 12px;
}

.sh-next-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.sh-date-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--sage-2);
  border: 1px solid var(--sage);
  border-radius: 8px;
  padding: 6px 12px;
  min-width: 54px;
  flex-shrink: 0;
}

.sh-chip-day {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sage);
}

.sh-chip-num {
  font-size: 26px;
  font-weight: 700;
  font-family: Georgia, serif;
  color: var(--ink);
  line-height: 1.1;
}

.sh-next-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sh-next-type {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sh-next-meta {
  font-size: 12px;
  color: var(--muted);
}

.sh-stats {
  margin-bottom: 16px;
}

.student-cal-pending {
  background: var(--amber) !important;
  color: white !important;
}

/* ============================================================ */

@media (max-width: 980px) {
  .app-shell,
  .app-shell.student-shell,
  .app-shell.teacher-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(84vw, 320px);
    height: 100dvh;
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform 0.18s ease;
    box-shadow: 18px 0 42px rgba(54, 49, 42, 0.18);
  }

  .app-shell.nav-open .sidebar {
    transform: translateX(0);
  }

  .mobile-menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
  }

  .mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(44, 42, 38, 0.24);
    border: 0;
    padding: 0;
  }

  .app-shell.nav-open .mobile-menu-backdrop {
    display: block;
  }

  .app-shell.auth-locked .mobile-menu-backdrop {
    display: none;
  }

  .profile-mobile-nav {
    position: fixed;
    top: 78px;
    left: 12px;
    right: 12px;
    z-index: 45;
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 253, 248, 0.98);
    box-shadow: var(--shadow);
  }

  .app-shell.nav-open .profile-mobile-nav:not([hidden]) {
    display: grid;
  }

  .profile-mobile-nav a {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border-radius: 8px;
    background: var(--sage-2);
    color: #3f513b;
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
  }

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

  .grid.cols-3,
  .grid.cols-4,
  .portal-hero,
  .student-shell .portal-hero,
  .enrollment-layout,
  .public-hero,
  .login-panel {
    grid-template-columns: 1fr;
  }

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

  .public-hero {
    min-height: auto;
  }

  .public-hero-visual {
    min-height: 300px;
    order: -1;
  }

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

  .student-shell .portal-hero .surface {
    order: 0;
  }

  .student-shell .content,
  .teacher-shell .content,
  .student-shell .content > .surface,
  .student-shell .content > .grid,
  .teacher-shell .content > .surface,
  .teacher-shell .content > .grid,
  .student-shell .portal-hero,
  .teacher-shell .portal-hero,
  .stack-form,
  .student-shell .profile-details-body {
    max-width: none;
  }

  .enrollment-layout {
    max-width: 760px;
  }

  .enrollment-side,
  .enrollment-layout > .surface {
    max-width: none;
  }

  .agenda-toolbar {
    grid-template-columns: 1fr;
  }

  .agenda-period,
  .agenda-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
    min-height: auto;
  }

  .topbar-title-row {
    width: 100%;
    align-items: flex-start;
  }

  .topbar h1 {
    font-size: 26px;
  }

  .content {
    padding: 16px;
  }

  .grid.cols-2,
  .field-row,
  .checkbox-grid {
    grid-template-columns: 1fr;
  }

  .portal-summary-grid,
  .grid.cols-2.portal-summary-grid,
  .grid.cols-3:has(> .stat),
  .grid.cols-4:has(> .stat) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .portal-summary-grid {
    max-width: 100%;
    width: 100%;
    gap: 10px;
  }

  .grid:has(> .stat) {
    gap: 10px;
  }

  .grid:has(> .stat) > .stat {
    min-height: 92px;
    padding: 12px;
  }

  .grid:has(> .stat) > .stat strong {
    font-size: 22px;
    line-height: 1.08;
    overflow-wrap: anywhere;
  }

  .grid:has(> .stat) > .stat span,
  .grid:has(> .stat) > .stat small {
    font-size: 12px;
    line-height: 1.25;
  }

  .checkbox-grid.compact-options {
    grid-template-columns: 1fr;
  }

  .price-option-grid {
    grid-template-columns: 1fr;
  }

  .public-home {
    gap: 14px;
  }

  .public-hero-copy {
    padding: 24px;
  }

  .public-hero-copy p:not(.eyebrow) {
    font-size: 16px;
  }

  .public-hero-visual {
    min-height: 300px;
  }

  .public-sello {
    width: min(300px, 78%);
    aspect-ratio: 1 / 1;
    inset: 6% auto auto 11%;
  }

  .public-class-card {
    min-height: 150px;
    padding: 14px;
  }

  .ryo-welcome-mark {
    width: min(290px, 76%);
    inset: 14px 8px auto auto;
  }

  .login-copy {
    min-height: 300px;
  }

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

  .mode-button {
    flex: 0 0 auto;
  }

  .mode-status {
    white-space: normal;
  }

  .agenda-views,
  .agenda-period,
  .agenda-actions {
    flex-wrap: wrap;
  }

  .agenda-date,
  .agenda-teacher-filter {
    width: min(100%, 220px);
  }

  .portal-banner {
    min-height: 220px;
  }

  .portal-banner h2 {
    font-size: 30px;
  }

  .calendar-grid {
    grid-template-columns: repeat(7, minmax(52px, 1fr));
    overflow-x: auto;
    gap: 4px;
  }

  .calendar-day {
    min-height: 72px;
    padding: 6px;
  }

  .calendar-event {
    font-size: 10px;
    padding: 3px 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .calendar-header-cell {
    font-size: 10px;
    padding: 2px 2px 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ryo-welcome-mark img,
  .ryo-mark-echo {
    animation: none;
    opacity: 0.35;
    transform: none;
  }
}

/* ══════════════════════════════════════════════════════
   MOBILE UX — mejoras targetizadas
   ══════════════════════════════════════════════════════ */

@media (max-width: 680px) {

  /* ── Topbar: barra compacta de fila única ── */
  .topbar {
    flex-direction: row;
    align-items: center;
    padding: 0 14px;
    min-height: 52px;
    gap: 10px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  .topbar-title-row {
    flex: 1;
    min-width: 0;
    align-items: center;
    width: auto;
  }

  .topbar h1 {
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
  }

  #todayLabel {
    display: none;
  }

  .topbar-actions {
    flex: 0 0 auto;
    width: auto;
    justify-content: flex-end;
    padding: 2px 4px;
  }

  #modeStatus {
    display: none !important;
  }

  /* ── Dialog: bottom sheet deslizable ── */
  dialog {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    max-height: 92vh; /* fallback */
    max-height: 92dvh;
    margin-block-start: auto;
    margin-block-end: 0;
    margin-inline: 0;
    border-radius: 18px 18px 0 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .dialog-head::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--line);
    margin: 0 auto 14px;
  }

  .dialog-content {
    padding: 16px 16px 28px;
  }

  /* ── Content: padding reducido ── */
  .content {
    padding: 14px 14px 40px;
  }

  /* ── Surface: más compacta ── */
  .surface {
    padding: 14px;
  }

  .surface h2,
  .surface h3 {
    font-size: 17px;
    margin-bottom: 12px;
  }

  /* ── Items: menos padding ── */
  .item {
    padding: 12px;
  }

  /* ── Section details ── */
  .section-details summary {
    min-height: 52px;
    padding: 12px 14px;
  }

  .section-details summary strong {
    font-size: 17px;
  }

  .section-details-body {
    padding: 12px 14px 14px;
  }

  /* ── Portal banner: más compacta ── */
  .portal-banner {
    min-height: 190px;
    padding: 20px;
  }

  .portal-banner h2 {
    font-size: 26px;
  }

  /* ── Buttons: grid en .actions para mejor touch ── */
  .dialog-content .actions,
  .section-details-body .actions,
  .item .actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    margin-top: 12px;
  }

  .dialog-content .actions .primary-button,
  .dialog-content .actions .soft-button,
  .dialog-content .actions .danger-button,
  .section-details-body .actions .primary-button,
  .section-details-body .actions .soft-button,
  .section-details-body .actions .danger-button,
  .item .actions .primary-button,
  .item .actions .soft-button,
  .item .actions .danger-button {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 10px;
  }

  /* ── Inputs y selects: touch targets más grandes ── */
  input,
  select,
  textarea {
    min-height: 46px;
  }

  /* ── Compact-row: overflow controlado ── */
  .compact-row {
    align-items: center;
    gap: 8px;
  }

  .compact-row > div:first-child {
    min-width: 0;
    flex: 1;
  }

  .compact-row h4 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ── Item-head: nombre largo no desborda ── */
  .item-head > div:first-child {
    min-width: 0;
    flex: 1;
  }

  .item h3,
  .item h4 {
    overflow-wrap: break-word;
  }

  /* ── Tabla: más legible en scroll horizontal ── */
  .table-wrap {
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
  }

  /* ── Profile mobile nav: botones más grandes ── */
  .profile-mobile-nav a {
    min-height: 46px;
    font-size: 13px;
  }

  /* ── Stat grid: 2 columnas máximo ── */
  .grid.cols-3:has(> .stat),
  .grid.cols-4:has(> .stat) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* ── Receipt en dialog ── */
  .receipt-row {
    flex-wrap: wrap;
    gap: 4px;
  }

  /* ── Teacher portal nav ── */
  .teacher-nav {
    gap: 6px;
    padding: 8px;
  }

  .teacher-nav a {
    min-height: 40px;
    font-size: 13px;
    padding: 0 10px;
  }
}

/* ── Ultra-compact: teléfonos muy pequeños (≤430px) ── */
@media (max-width: 430px) {

  .content {
    padding: 10px 10px 32px;
  }

  .surface {
    padding: 12px;
  }

  .section-details-body {
    padding: 10px 12px 12px;
  }

  .item {
    padding: 10px 12px;
  }

  .section-details summary {
    min-height: 48px;
    padding: 10px 12px;
  }

  .section-details summary strong {
    font-size: 15px;
  }

  .section-details summary small {
    font-size: 12px;
  }

  .portal-banner {
    min-height: 150px;
    padding: 16px;
  }

  .portal-banner h2 {
    font-size: 22px;
  }

  .dialog-content {
    padding: 14px 14px 24px;
  }

  .dialog-head h2 {
    font-size: 17px;
  }

  .dialog-content .actions,
  .section-details-body .actions,
  .item .actions {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 6px;
  }

  .topbar h1 {
    font-size: 15px;
  }

  .topbar-actions {
    padding: 2px;
  }

  /* Stat: fuente más pequeña en pantallas muy chicas */
  .grid:has(> .stat) > .stat strong {
    font-size: 18px;
  }

  .grid:has(> .stat) > .stat {
    min-height: 80px;
    padding: 10px;
  }

  /* Portal summary grid: compensar el espacio reducido */
  .portal-summary-grid .stat {
    min-height: 76px;
    padding: 10px;
  }

  .portal-summary-grid .stat strong {
    font-size: 20px;
  }

  /* Item head: vertical si hay mucho contenido */
  .item-head {
    flex-wrap: wrap;
  }

  /* Pill: más compacta */
  .pill {
    font-size: 11px;
    padding: 0 7px;
    min-height: 22px;
  }

  /* Topbar-actions: solo mostrar "Salir" sin capsule */
  .topbar-actions {
    background: transparent;
    border: 0;
    padding: 0;
  }

  .mode-button {
    padding: 0 10px;
    font-size: 14px;
  }

  /* Tabla: min-width reducido para menos scroll */
  table {
    min-width: 520px;
  }
}

/* ── Mail enable row ── */
.mail-enable-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.mail-enable-row label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}

.mail-enable-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--sage);
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
}

.mail-enable-row .mail-enable-desc {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  max-width: 200px;
  line-height: 1.4;
}

/* ── Caja ledger ── */
.ledger-head,
.ledger-row {
  display: grid;
  grid-template-columns: 46px 88px minmax(0, 1fr) minmax(0, 1fr) 74px 52px 90px;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
}

.ledger-head {
  border-bottom: 2px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ledger-row {
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.1s;
  font-size: 13px;
}

.ledger-row:hover {
  background: var(--soft);
}

.ledger-row:last-child {
  border-bottom: none;
}

.ledger-row .l-date {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.ledger-row .l-folio,
.ledger-row .l-method {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ledger-row .l-concept,
.ledger-row .l-party {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ledger-row .l-party {
  color: var(--muted);
}

.ledger-row .l-amount {
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
  font-size: 13px;
}

@media (max-width: 900px) {
  .ledger-head,
  .ledger-row {
    grid-template-columns: 46px 80px minmax(0, 1fr) 64px 52px 84px;
  }
  .ledger-head span:nth-child(4),
  .ledger-row .l-party {
    display: none;
  }
}

/* ── Portal alumna: barra de navegación inferior en móvil ── */
@media (max-width: 680px) {
  .student-shell .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    height: auto;
    transform: none !important;
    overflow: visible;
    border-radius: 0;
    padding: 0;
    box-shadow: 0 -2px 16px rgba(54, 49, 42, 0.12);
    z-index: 40;
  }

  .student-shell .brand {
    display: none;
  }

  .student-shell .nav {
    display: flex;
    flex-direction: row;
    gap: 0;
    padding: 0;
  }

  .student-shell .nav button {
    flex: 1;
    border-radius: 0;
    padding: 6px 4px 10px;
    font-size: 11px;
    text-align: center;
    min-height: 54px;
    width: auto;
    border-top: 2px solid transparent;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  .student-shell .nav button span {
    display: block;
    margin: 0;
  }

  .student-shell .nav button.active {
    border-top-color: var(--sage);
    background: var(--sage-2);
  }

  .student-shell .workspace {
    padding-bottom: 70px;
  }

  .student-shell .mobile-menu-button {
    display: none;
  }
}
