:root {
  --red: #b8342a;
  --red-dark: #8f2620;
  --ink: #1a1b1e;
  --ink-soft: #44474d;
  --muted: #71767e;
  --line: #e4ded6;
  --paper: #f6f3ee;
  --card: #fffdfa;
  --green: #2f7a4f;
  --amber: #a8681a;
  --blue: #2a5d8f;
  --shadow: 0 1px 2px rgba(26, 27, 30, .05), 0 8px 24px rgba(26, 27, 30, .06);
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", "Songti SC", "Noto Serif SC", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--red); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  background: var(--paper);
}
.login-art {
  background: linear-gradient(160deg, #b8342a 0%, #7d1f19 60%, #45100d 100%);
  color: #fff;
  padding: 56px 52px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-art .brandline { font-family: var(--serif); font-size: 40px; letter-spacing: .04em; }
.login-art .brandsub { font-size: 12px; letter-spacing: .32em; opacity: .8; margin-top: 6px; }
.login-art .quote { font-family: var(--serif); font-size: 22px; line-height: 1.55; max-width: 460px; opacity: .95; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-box { width: 100%; max-width: 360px; }
.login-box .logo-mark { width: 54px; height: 54px; margin-bottom: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; letter-spacing: .04em; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=month], input[type=email], select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(184, 52, 42, .1); }
textarea { min-height: 84px; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { border-color: #cfc7bc; background: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn.danger { color: var(--red); border-color: #e6c9c5; }
.btn.block { width: 100%; justify-content: center; padding: 11px; }
.err { color: var(--red); font-size: 12px; min-height: 18px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100dvh; }
.side {
  background: #121316;
  color: #cfd2d7;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100dvh;
}
.side .brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 18px; }
.side .brand img { width: 34px; height: 34px; }
.side .brand b { color: #fff; font-family: var(--serif); font-size: 15px; font-weight: 600; line-height: 1.2; display: block; }
.side .brand span { color: #8a8f98; font-size: 10px; letter-spacing: .18em; }
.side a.nav {
  display: flex; align-items: center; gap: 10px;
  color: #b9bdc5; padding: 9px 10px; border-radius: 9px;
  font-size: 13.5px;
}
.side a.nav:hover { background: #1d1f24; color: #fff; }
.side a.nav.on { background: var(--red); color: #fff; }
.side a.nav svg { width: 16px; height: 16px; opacity: .85; }
.side .foot { margin-top: auto; font-size: 11px; color: #6f747c; padding: 8px 6px 0; line-height: 1.6; }
.side .foot a { color: #8f949c; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 243, 238, .86);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.top .crumb { font-size: 12px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.top .spacer { flex: 1; }
.lang-switch { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--card); }
.lang-switch button { border: 0; background: transparent; padding: 5px 11px; font-size: 12px; cursor: pointer; color: var(--muted); }
.lang-switch button.on { background: var(--ink); color: #fff; }
.who { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-soft); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600; }
.content { padding: 26px; max-width: 1240px; width: 100%; }

.page-head { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- cards ---------- */
.grid { display: grid; gap: 14px; }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card.tight { padding: 14px; }
.card h2 { margin-bottom: 12px; }
.stat .k { font-size: 11.5px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.stat .v { font-family: var(--serif); font-size: 30px; line-height: 1.15; margin-top: 6px; }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.warn .v { color: var(--amber); }
.stat.bad .v { color: var(--red); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:hover { background: #fbf8f3; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 28px; text-align: center; color: var(--muted); font-size: 13px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; background: #efeae3; color: var(--ink-soft); }
.pill.red { background: #f7e2df; color: var(--red-dark); }
.pill.green { background: #e2efe6; color: var(--green); }
.pill.amber { background: #f6ebd8; color: var(--amber); }
.pill.blue { background: #e3ecf5; color: var(--blue); }
.pill.gray { background: #eceef1; color: var(--muted); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=text] { max-width: 260px; }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; background: #ece7df; border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; font-size: 12.5px; cursor: pointer; color: var(--ink-soft); }
.seg button.on { background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.08); color: var(--ink); font-weight: 600; }

/* ---------- student ---------- */
.profile { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.avatar-lg { width: 56px; height: 56px; border-radius: 14px; background: var(--red); color: #fff; display: grid; place-items: center; font-family: var(--serif); font-size: 22px; }
dl.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 10px; margin: 12px 0 0; font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 18px; border-left: 2px solid var(--line); margin-left: 5px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--card); border: 2px solid var(--red); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline .when { font-size: 11.5px; color: var(--muted); }
.timeline .what { font-size: 13px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(18, 19, 22, .45);
  display: grid; place-items: center; padding: 20px; z-index: 100;
  animation: fade .15s ease-out;
}
.modal {
  background: var(--card); border-radius: 16px; width: 100%; max-width: 560px;
  max-height: calc(100dvh - 40px); overflow: auto; box-shadow: 0 24px 80px rgba(0,0,0,.28);
  animation: pop .18s ease-out;
}
.modal.wide { max-width: 760px; }
.modal header { display: flex; align-items: center; gap: 10px; padding: 18px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 2; }
.modal header h2 { flex: 1; }
.modal .body { padding: 18px 20px; }
.modal footer { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--card); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
@keyframes fade { from { opacity: 0 } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99) } }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 200; max-width: 80vw;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--red-dark); }

/* ---------- misc ---------- */
.alertbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-radius: 11px; background: #f7e8d6; color: #7a4a12; font-size: 13px; margin-bottom: 14px;
}
.alertbar.red { background: #f8e3e0; color: var(--red-dark); }
.alertbar .spacer { flex: 1; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: #efeae3; color: var(--ink-soft); }
.switch { display: flex; align-items: center; gap: 8px; }
.switch input { width: 16px; height: 16px; accent-color: var(--red); }
.list { display: flex; flex-direction: column; gap: 10px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .t { font-size: 13.5px; }
.list-row .s { font-size: 12px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px dashed #d5cdc2; border-radius: 999px; padding: 3px 10px; font-size: 12px; }
.stars { color: var(--amber); letter-spacing: 1px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { border: 0; background: transparent; padding: 9px 13px; font-size: 13px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--red); font-weight: 600; }
.sched-grid { display: grid; grid-template-columns: 84px repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.sched-cell { background: var(--card); min-height: 58px; padding: 4px; font-size: 11px; }
.sched-cell.head { background: #f1ece5; text-align: center; padding: 7px 2px; font-size: 11px; color: var(--muted); font-weight: 600; }
.sched-time { background: #f7f3ed; text-align: center; padding-top: 16px; color: var(--muted); font-size: 10.5px; }
.sess {
  border-radius: 7px; padding: 4px 6px; margin-bottom: 3px; cursor: pointer; overflow: hidden;
  background: #f3e6e4; color: var(--red-dark); border-left: 3px solid var(--red);
}
.sess.done { background: #e4efe7; color: #235f3d; border-left-color: #2f7a4f; }
.sess.cancelled { background: #eef0f2; color: #8a8f96; border-left-color: #b9bdc4; text-decoration: line-through; }
.sess.teacher { background: #e6ecf4; color: #234a72; border-left-color: var(--blue); }

@media (max-width: 980px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; height: auto; flex-direction: row; overflow-x: auto; padding: 8px; z-index: 50; border-top: 1px solid #2a2c31; }
  .side .brand, .side .foot { display: none; }
  .side a.nav { flex-direction: column; gap: 2px; font-size: 10px; padding: 6px 10px; min-width: 62px; text-align: center; }
  .side a.nav svg { width: 18px; height: 18px; }
  .content { padding: 16px 14px 90px; }
  .grid.c4, .grid.c3, .grid.c2 { grid-template-columns: 1fr 1fr; }
  .profile { grid-template-columns: 1fr; }
  .top { padding: 10px 14px; }
  .sched-grid { font-size: 10px; }
  table { font-size: 12.5px; }
  th, td { padding: 8px 6px; }
}
@media (max-width: 560px) {
  .grid.c4, .grid.c3, .grid.c2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 21px; }
  .side a.nav { min-width: 0; flex: 1 1 0; padding: 6px 1px; font-size: 8px; letter-spacing: 0; }
  .side a.nav span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  table .col-opt { display: none; }
  .grid.money-grid, .grid.grid-2col, .grid.grid-3col { grid-template-columns: 1fr !important; }
  table { font-size: 13px; }
  th, td { padding: 9px 8px; }
}

.alerts { }
.alertbar { display:flex; align-items:center; gap:10px; margin:12px 26px 0; padding:9px 14px; border-radius:10px; background:#fbe9e4; color:#8f2b20; border:1px solid #f0c9bf; font-size:13px; }
.alertbar a { margin-left:auto; color:#8f2b20; font-weight:600; text-decoration:none; }
@media (max-width:560px){ .alertbar{ margin:10px 12px 0; font-size:12px; } }
