:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --ink: #1d2824;
  --muted: #66736d;
  --brand: #1f4b3f;
  --brand-soft: #e5f0ec;
  --accent: #c8945c;
  --danger: #a33a32;
  --ok: #2f7d55;
  --border: #d9dedb;
  --topbar-height: 76px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; border: 0; border-radius: 12px; padding: .8rem 1rem; background: var(--brand); color: white; font-weight: 700; }
button.secondary { background: var(--brand-soft); color: var(--brand); }
button.ghost { background: transparent; border: 1px solid rgba(255,255,255,.5); }
button:disabled { opacity: .55; cursor: not-allowed; }
.topbar { position: sticky; top: 0; z-index: 10; min-height: var(--topbar-height); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem 1rem; padding: .9rem 1rem; background: var(--brand); color: white; box-shadow: 0 3px 18px rgba(0,0,0,.12); }
.topbar-brand { flex: 0 0 auto; }
.topbar-brand strong, .topbar-brand span { display: block; }
.topbar-brand span { opacity: .8; font-size: .82rem; }
main { width: min(1120px, 100%); margin: 0 auto; padding: 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 1rem; box-shadow: 0 8px 28px rgba(31,75,63,.06); }
.login-card { max-width: 430px; margin: 6vh auto; }
form { display: grid; gap: 1rem; }
label { display: grid; gap: .45rem; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: .8rem; background: white; color: var(--ink); }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: .6rem; }
.inline-form label { flex: 1 1 130px; gap: .3rem; font-weight: 600; font-size: .85rem; }
.inline-form input, .inline-form select { padding: .55rem .6rem; }
.inline-form button { flex: 0 0 auto; height: 2.6rem; align-self: end; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2rem; }
.tabs { flex: 1 1 auto; display: flex; justify-content: center; gap: .4rem; overflow-x: auto; scrollbar-width: thin; }
.tabs button { white-space: nowrap; background: rgba(255,255,255,.12); color: white; border: 1px solid rgba(255,255,255,.3); }
.tabs button.active { background: white; color: var(--brand); border-color: white; font-weight: 700; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.metric { padding: 1rem; background: white; border: 1px solid var(--border); border-radius: 16px; }
.metric strong { display: block; font-size: 1.7rem; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .8rem; }
.assignment { display: grid; gap: .7rem; }
.assignment h3 { margin: 0; }
.badges { display: flex; flex-wrap: wrap; gap: .4rem; }
.badge { display: inline-flex; padding: .3rem .55rem; border-radius: 999px; background: #eef1ef; color: #4b564f; font-size: .8rem; font-weight: 700; }
.badge.ok { background: #e0f2e8; color: #1f6b46; }
.badge.warn { background: #f7ead8; color: #87511d; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1rem 0 .7rem; }
.list { display: grid; gap: .7rem; }
.team-member { display: grid; gap: .7rem; }
.progress { height: 10px; background: #e5e8e6; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); }
dialog { width: min(760px, calc(100% - 1.2rem)); max-height: calc(100vh - 1.2rem); overflow: auto; border: 0; border-radius: 20px; padding: 1rem; }
dialog::backdrop { background: rgba(13, 25, 21, .55); }
.dialog-close { float: right; width: 40px; height: 40px; padding: 0; border-radius: 50%; }
.diff { display: grid; gap: .35rem; }
.diff-item { padding: .55rem .7rem; border-radius: 8px; font-family: ui-monospace, monospace; font-size: .86rem; }
.diff-item.added { background: #e3f5e9; color: #235f3f; }
.diff-item.removed { background: #fae7e5; color: #83302b; text-decoration: line-through; }
.regulation-content { white-space: pre-wrap; line-height: 1.6; background: #f7f8f7; padding: 1rem; border-radius: 12px; }
.quiz-question { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1rem; }
.option { display: flex; align-items: flex-start; gap: .5rem; padding: .35rem 0; font-weight: 400; }
.option input { width: auto; margin-top: .25rem; }
.toast {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  background: var(--ink);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 16px;
  box-shadow: 0 12px 42px rgba(0,0,0,0.4);
  font-weight: 600;
  text-align: center;
  max-width: min(480px, calc(100vw - 2rem));
  font-size: 0.95rem;
  pointer-events: none;
  animation: slideDownToast 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 2px solid var(--accent);
}
@keyframes slideDownToast {
  from { transform: translate(-50%, -20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
table { width: 100%; border-collapse: collapse; background: white; border-radius: 14px; overflow: hidden; }
th, td { text-align: left; padding: .7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
@media (max-width: 720px) {
  .metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid { grid-template-columns: 1fr; }
  main { padding: .75rem; }
  .card { border-radius: 15px; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  td { border-bottom: 0; padding: .4rem .7rem; }
  tr { border-bottom: 1px solid var(--border); padding: .6rem 0; }
}
.editor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; align-items: start; }
.editor-grid form, .editor-grid section { display: grid; gap: .85rem; }
.editor-grid h3 { margin: 0; }
.form-stack { display: grid; gap: .65rem; margin-top: .75rem; }
.check-row { display: flex; align-items: flex-start; gap: .55rem; font-weight: 500; }
.check-row input { width: auto; margin-top: .2rem; }
.draft-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .75rem; border: 1px solid var(--border); border-radius: 12px; }
.draft-row[draggable="true"] { cursor: grab; }
.draft-row.dragging { opacity: .4; }
.drag-handle { display: inline-block; margin-right: .4rem; color: var(--muted); cursor: grab; }
.roster-row { display: flex; align-items: center; flex-wrap: nowrap; gap: .75rem; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; white-space: nowrap; }
.roster-row strong { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.roster-row-edit { overflow-x: visible; white-space: normal; flex-wrap: wrap; }
.roster-row-edit input, .roster-row-edit select { flex: 1 1 130px; width: auto; padding: .45rem .5rem; }
.compact { max-height: 220px; overflow: auto; padding: .25rem; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; align-items: end; }
.notice { padding: .75rem; border-radius: 12px; background: #f7ead8; color: #87511d; }
fieldset { min-width: 0; border: 1px solid var(--border); border-radius: 12px; padding: .75rem; }
legend { padding: 0 .35rem; font-weight: 700; }
.table-wrap { overflow-x: auto; }
.loading-card { min-height: 80px; }
@media (max-width: 820px) {
  .editor-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .two-cols { grid-template-columns: 1fr; }
  .draft-row { align-items: stretch; flex-direction: column; }
  .topbar { position: static; }
  .tabs { justify-content: flex-start; order: 3; flex-basis: 100%; }
}