:root {
  color-scheme: light;
  --green: #17372d;
  --green-2: #24483c;
  --paper: #f5f1e8;
  --warm-white: #fcfaf5;
  --ink: #1b201c;
  --muted: #626760;
  --chestnut: #784944;
  --danger: #8b342e;
  --line: #cbc5b8;
  --line-dark: #9d9a90;
  --display: "Songti SC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 0; font-family: var(--sans); background: var(--paper); }
body { margin: 0; min-width: 0; min-height: 100vh; color: var(--ink); background: var(--paper); }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-underline-offset: .2em; }
img, svg { max-width: 100%; }
code, small, td, .lede, .data-list span { overflow-wrap: anywhere; }
.skip-link { position: fixed; top: -5rem; left: 1rem; z-index: 100; padding: .8rem 1rem; background: var(--ink); color: white; }
.skip-link:focus { top: 1rem; }
:focus-visible { outline: 3px solid #b77262; outline-offset: 3px; }

.site-header { display: flex; min-height: 4.85rem; align-items: center; justify-content: space-between; gap: 1.25rem; padding: 0 clamp(1rem, 4vw, 3.5rem); border-bottom: 1px solid var(--line); background: var(--warm-white); }
.brand { display: inline-flex; min-width: 0; min-height: 44px; align-items: center; gap: .65rem; text-decoration: none; }
.brand-cn { font-family: var(--display); font-size: 1.55rem; font-weight: 600; letter-spacing: .06em; }
.brand-en { font-size: .62rem; font-weight: 700; letter-spacing: .2em; }
.brand-product { margin-left: .4rem; padding-left: 1rem; border-left: 1px solid var(--line-dark); color: var(--muted); font-size: .78rem; letter-spacing: .04em; }
.site-logout { flex: 0 0 auto; }
.site-logout .text-button { min-height: 44px; padding-inline: .7rem; }
.page-shell { width: min(100% - 2.5rem, 76rem); margin: 0 auto; padding: clamp(2.4rem, 6vw, 5.5rem) 0 5rem; }
.standalone-shell { width: min(100%, 48rem); margin: 0 auto; }
.auth-card, .content-card { width: min(100%, 40rem); margin: 0 auto; padding: clamp(1.5rem, 5vw, 3.2rem); border: 1px solid var(--line); background: var(--warm-white); }
.content-card { width: min(100%, 60rem); }
.auth-card::before { display: block; width: 4.5rem; margin-bottom: 2rem; border-top: 3px solid var(--green); content: ""; }
.eyebrow { margin: 0 0 .75rem; color: var(--chestnut); font-size: .7rem; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, h3 { overflow-wrap: anywhere; }
h1 { margin: 0; font-family: var(--display); font-size: clamp(2.25rem, 5vw, 4.2rem); font-weight: 500; line-height: 1.08; letter-spacing: -.025em; }
h2 { margin: 0 0 .45rem; font-family: var(--display); font-size: 1.35rem; font-weight: 600; line-height: 1.25; }
.lede { max-width: 44rem; margin: 1rem 0 2rem; color: var(--muted); font-size: 1.02rem; line-height: 1.75; }
.rich-text { line-height: 1.85; }

.button, button:not(.text-button) { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: .4rem; padding: .72rem 1.1rem; border: 1px solid var(--green); border-radius: 0; background: transparent; color: var(--green); cursor: pointer; font-weight: 700; line-height: 1.2; text-align: center; text-decoration: none; }
.button:hover, button:not(.text-button):hover { background: #ebe6da; }
.button:disabled, button:disabled { cursor: wait; opacity: .55; }
.button-primary, button.button-primary { background: var(--green); color: var(--warm-white); }
.button-primary:hover, button.button-primary:hover { background: var(--green-2); }
.button-danger { border-color: var(--danger); color: var(--danger); }
.button-compact { width: auto; min-height: 44px; padding: .65rem 1rem; }
.text-button { min-height: 44px; padding: .55rem .25rem; border: 0; background: none; color: var(--green); cursor: pointer; font-weight: 700; }
.danger { color: var(--danger); }
.back-link { display: inline-flex; min-height: 44px; align-items: center; margin-bottom: 1rem; color: var(--green); font-weight: 700; }

label { font-weight: 650; }
input:not([type="checkbox"]):not([type="radio"]), textarea, select, .text-input { width: 100%; min-height: 48px; padding: .75rem .85rem; border: 1px solid var(--line-dark); border-radius: 0; background: var(--warm-white); color: var(--ink); }
textarea { min-height: 9rem; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 1.2rem; height: 1.2rem; flex: 0 0 auto; accent-color: var(--green); }
.field-label { display: block; margin: 0 0 .5rem; }
.text-input { margin: 0 0 1rem; }
.status { min-height: 1.5rem; margin: 1rem 0 0; color: var(--muted); }
.security-note { display: grid; gap: .35rem; margin-top: 2rem; padding-top: 1.4rem; border-top: 1px solid var(--line); color: var(--muted); line-height: 1.55; }
.security-note strong { color: var(--ink); }
.steps { margin: 2rem 0 0; padding-left: 1.25rem; color: var(--muted); line-height: 1.9; }

.portal-layout { display: grid; grid-template-columns: 14.5rem minmax(0, 1fr); gap: clamp(2rem, 5vw, 5rem); align-items: start; }
.portal-sidebar { position: sticky; top: 1.25rem; display: grid; min-width: 0; min-height: calc(100vh - 8rem); padding: 1.4rem 1.15rem; background: var(--green); color: var(--warm-white); }
.portal-label { margin: 0 0 1.4rem; color: #becbc3; font-size: .68rem; font-weight: 750; letter-spacing: .17em; text-transform: uppercase; }
.portal-sidebar nav { display: grid; align-content: start; gap: .2rem; }
.portal-sidebar nav a { display: flex; min-height: 44px; align-items: center; padding: .7rem .8rem; border-left: 2px solid transparent; color: #eef1ec; text-decoration: none; }
.portal-sidebar nav a:hover, .portal-sidebar nav a:focus-visible { background: rgb(255 255 255 / 8%); }
.portal-sidebar nav a[aria-current="page"] { border-left-color: var(--warm-white); background: rgb(255 255 255 / 11%); color: white; font-weight: 750; }
.sidebar-user { align-self: end; display: grid; gap: .25rem; min-width: 0; padding: 1rem .8rem 0; border-top: 1px solid rgb(255 255 255 / 25%); }
.sidebar-user strong, .sidebar-user span { overflow-wrap: anywhere; }
.sidebar-user span { color: #becbc3; font-size: .8rem; }
.portal-main { min-width: 0; }
.page-heading { display: flex; gap: 1.25rem; align-items: flex-start; justify-content: space-between; margin-bottom: 2.4rem; padding-bottom: 1.4rem; border-bottom: 1px solid var(--line); }
.page-heading > div { min-width: 0; }
.page-heading > div:last-child:not(:first-child) { display: flex; flex-wrap: wrap; gap: .55rem; justify-content: flex-end; }
.page-heading .lede { margin-bottom: 0; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 2rem; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.metric-grid article { display: grid; gap: 1.2rem; min-width: 0; padding: 1.25rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--warm-white); }
.metric-grid span { color: var(--muted); font-size: .8rem; }
.metric-grid strong { font-family: var(--display); font-size: 2.5rem; font-weight: 500; line-height: 1; }

.panel { min-width: 0; margin-bottom: 1.25rem; padding: clamp(1rem, 3vw, 1.6rem); border: 1px solid var(--line); background: var(--warm-white); }
.panel-heading { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel-heading a { min-height: 44px; display: inline-flex; align-items: center; color: var(--green); font-weight: 700; }
.danger-zone { border-top: 3px solid var(--danger); }
.narrow-panel { max-width: 46rem; margin-inline: auto; }
.internal-panel { border-top: 3px solid var(--chestnut); }
.internal-panel h2 small { color: var(--chestnut); font-family: var(--sans); font-size: .7rem; font-weight: 700; }
.data-list { display: grid; min-width: 0; }
.data-list > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .45rem 1rem; min-width: 0; align-items: center; padding: .85rem 0; border-bottom: 1px solid var(--line); }
.data-list > div:last-child { border-bottom: 0; }
.data-list > div > * { min-width: 0; }
.data-list span { color: var(--muted); font-size: .84rem; }
.data-list form, .data-list a { justify-self: end; }
.record-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.record-card { display: block; min-width: 0; min-height: 11rem; padding: 1.2rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--warm-white); text-decoration: none; }
.record-card:hover { background: #eee9de; }
.record-card h2 { margin-top: 1.35rem; }
.record-card p, .record-card small { color: var(--muted); }
.status-pill { display: inline-flex; min-height: 1.75rem; align-items: center; padding: .25rem .5rem; border: 1px solid var(--green); color: var(--green); font-size: .68rem; font-weight: 750; }
.status-disabled, .status-archived, .status-removed { border-color: #806d63; color: #6d554a; }
.status-pending { border-color: #916a30; color: #74501e; }
.filter-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .65rem; align-items: end; margin-bottom: 1rem; }
.filter-bar label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.filter-bar .text-input { margin: 0; }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.inline-form, .form-stack { display: grid; gap: .8rem; margin-top: 1rem; }
.inline-form p, .form-stack p { margin: 0; }
.form-panel { max-width: 46rem; }
.form-panel form > p { display: grid; gap: .45rem; }
.helptext { color: var(--muted); font-size: .8rem; line-height: 1.5; }
.errorlist { margin: 0; padding-left: 1.25rem; color: var(--danger); }
.form-actions { display: flex; flex-wrap: wrap; gap: .65rem; align-items: center; }
.form-actions a { display: inline-flex; min-height: 44px; align-items: center; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 28rem; overflow: auto; border: 1px solid var(--line); }
.check-grid > div { min-width: 0; }
.check-grid label { display: flex; min-height: 48px; align-items: center; gap: .65rem; padding: .7rem; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.one-time-secret { display: grid; gap: .6rem; margin-bottom: 1.25rem; padding: 1.2rem; border: 2px solid var(--chestnut); background: var(--warm-white); }
.one-time-secret code { padding: .75rem; border: 1px solid var(--line); overflow-wrap: anywhere; font-size: .95rem; }
.flash-stack { display: grid; gap: .55rem; margin-bottom: 1.25rem; }
.flash { margin: 0; padding: .85rem 1rem; border-left: 4px solid var(--green); background: var(--warm-white); }
.flash-error { border-left-color: var(--danger); color: var(--danger); }
.empty-state { margin: 0; padding: 1.4rem; border: 1px dashed var(--line-dark); color: var(--muted); line-height: 1.6; text-align: center; }
.table-scroll { max-width: 100%; overflow-x: auto; border: 1px solid var(--line); background: var(--warm-white); }
table { width: 100%; min-width: 44rem; border-collapse: collapse; }
th, td { padding: .8rem 1rem; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }

.credential-list { display: grid; }
.credential-row { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.credential-row > div { min-width: 0; }
.credential-row p { margin: 0; color: var(--muted); font-size: .88rem; }
.student-avatar { display: grid; width: 2.7rem; height: 2.7rem; flex: 0 0 auto; place-items: center; border: 1px solid var(--line-dark); color: var(--green); font-family: var(--display); font-weight: 700; }
.student-avatar.large { width: 4.4rem; height: 4.4rem; font-size: 1.45rem; }
.student-hero, .child-summary { display: flex; min-width: 0; align-items: center; gap: 1.25rem; margin-bottom: 1.6rem; }
.student-hero > div:last-child { min-width: 0; }
.student-hero .lede { margin: .5rem 0 1rem; }
.tab-bar, .child-switcher { display: flex; max-width: 100%; gap: 0; margin: 0 0 1.25rem; overflow-x: auto; border-bottom: 1px solid var(--line-dark); }
.tab-bar a, .child-switcher a { display: inline-flex; min-height: 44px; align-items: center; padding: .65rem .85rem; border-bottom: 2px solid transparent; color: var(--muted); text-decoration: none; white-space: nowrap; }
.tab-bar a:hover, .child-switcher a:hover { color: var(--green); }
.child-switcher a[aria-current="page"] { border-bottom-color: var(--green); color: var(--green); font-weight: 750; }
.parent-shell { width: min(100%, 66rem); margin: 0 auto; }
.parent-topbar { display: flex; flex-wrap: wrap; gap: .25rem 1rem; justify-content: flex-end; margin-bottom: clamp(2rem, 6vw, 4rem); border-bottom: 1px solid var(--line); }
.parent-topbar a { display: inline-flex; min-height: 44px; align-items: center; border-bottom: 2px solid transparent; color: var(--green); font-weight: 700; text-decoration: none; }
.parent-topbar a[aria-current="page"] { border-bottom-color: var(--green); }
.parent-hero { max-width: 48rem; margin-bottom: 1.75rem; }
.parent-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.parent-card { min-width: 0; padding: clamp(1rem, 4vw, 1.5rem); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--warm-white); }
.family-item { display: flex; min-width: 0; min-height: 52px; align-items: center; justify-content: space-between; gap: .7rem; padding: .8rem 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.family-item strong { min-width: 0; overflow-wrap: anywhere; }
.family-item span { flex: 0 0 auto; color: var(--muted); font-size: .78rem; }
.parent-reading { max-width: 50rem; margin: 1rem auto 0; }

@media (max-width: 55rem) {
  .page-shell { width: min(100% - 2rem, 76rem); padding-top: 2rem; }
  .portal-layout { grid-template-columns: 1fr; gap: 2rem; }
  .portal-sidebar { position: static; min-height: auto; padding: .9rem; }
  .portal-label { margin: 0 0 .65rem .25rem; }
  .portal-sidebar nav { grid-template-columns: repeat(5, max-content); overflow-x: auto; }
  .portal-sidebar nav a { border-left: 0; border-bottom: 2px solid transparent; }
  .portal-sidebar nav a[aria-current="page"] { border-bottom-color: var(--warm-white); }
  .sidebar-user { display: none; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 38rem) {
  .site-header { min-height: 4.25rem; padding: 0 .85rem; }
  .brand { gap: .45rem; }
  .brand-cn { font-size: 1.35rem; }
  .brand-en { display: none; }
  .brand-product { margin-left: .15rem; padding-left: .65rem; font-size: .68rem; }
  .page-shell { width: min(100% - 1.25rem, 76rem); padding: 1.25rem 0 3rem; }
  .auth-card, .content-card, .panel, .parent-card { padding: 1rem; }
  h1 { font-size: clamp(2rem, 12vw, 3.2rem); }
  .page-heading { flex-direction: column; align-items: stretch; margin-bottom: 1.5rem; }
  .page-heading > div:last-child:not(:first-child) { justify-content: stretch; }
  .page-heading .button { width: 100%; }
  .two-column, .parent-card-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-grid article { padding: 1rem; }
  .metric-grid strong { font-size: 2rem; }
  .data-list > div { grid-template-columns: 1fr; align-items: stretch; }
  .data-list form, .data-list a { justify-self: stretch; }
  .data-list .text-button, .data-list a { width: 100%; justify-content: flex-start; }
  .check-grid { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: 1fr; }
  .filter-bar .button { width: 100%; }
  .credential-row { flex-direction: column; align-items: stretch; }
  .credential-row .button { width: 100%; }
  .student-hero { align-items: flex-start; }
  .student-avatar.large { width: 3.5rem; height: 3.5rem; }
  .parent-topbar { justify-content: flex-start; margin-bottom: 2rem; }
  .family-item { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
