/* Xavier Catholic Education Trust brand palette: navy #142146, red #c4232a,
   gold #ebd166, sand #cfccbc, plum #953d76, white #ffffff. */
:root {
  --dark: #142146;
  --blue: #2d3a5f;
  --bg: #f7f5f0;
  --surface: #ffffff;
  --border: #cfccbc;
  --text: #142146;
  --muted: #6e6a5c;
  --accent: #953d76;
  --ok: #3f7d5c;
  --warn: #8a6a12;
  --danger: #c4232a;
  --shadow: 0 2px 10px rgba(20, 33, 70, .10);
  --hover-tint: rgba(149, 61, 118, 0.06);
  --collision-tint: rgba(138, 106, 18, 0.10);
}

@media (prefers-color-scheme: dark) {
  :root {
    --dark: #0b1024;
    --blue: #1b2547;
    --bg: #10162c;
    --surface: #182140;
    --border: #3a3f5c;
    --text: #f1efe9;
    --muted: #a9a394;
    --accent: #c76aa3;
    --ok: #5fae82;
    --warn: #e8c65a;
    --danger: #e5646b;
    --shadow: 0 2px 10px rgba(0, 0, 0, .5);
    --hover-tint: rgba(199, 106, 163, 0.10);
    --collision-tint: rgba(232, 198, 90, 0.14);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

h1, h2, h3 { font-weight: 700; }

.page-header {
  background: linear-gradient(135deg, var(--dark), var(--blue));
  color: #fff;
  padding: 20px 32px;
  box-shadow: var(--shadow);
}

.header-content {
  max-width: 1600px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  height: 36px;
  width: 36px;
  flex: 0 0 auto;
}

.brand-title {
  margin: 0;
  font-size: 20px;
}

.version-badge {
  min-height: unset;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.version-badge:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: none;
}

.release-entry + .release-entry {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.release-entry h3 {
  margin: 0 0 2px;
  font-size: 15px;
}

.release-entry .release-date {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
}

.release-entry ul {
  margin: 0;
  padding-left: 18px;
}

.release-entry li {
  margin-bottom: 6px;
  font-size: 13px;
}

.header-badge {
  min-height: 20px;
  font-size: 13px;
  color: #fff;
}

.header-badge.error { color: #fecaca; }
.header-badge.success { color: #bbf7d0; }

.page-content {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px 32px 40px;
}

.toolbar,
.control-panel,
.table-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.toolbar {
  margin-bottom: 20px;
  background: var(--surface);
  padding: 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

button {
  min-height: 36px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}

button:hover:not(:disabled) { transform: translateY(-1px); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.danger { background: var(--surface); color: var(--danger); border: 1px solid var(--danger); }

.status { color: var(--muted); font-size: 13px; }
.status.error { color: var(--danger); }
.status.success { color: var(--ok); }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.summary-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.summary-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--accent);
}

.summary-number { margin: 0; font-size: 28px; font-weight: 700; }
.summary-label { margin-top: 6px; color: var(--muted); font-size: 13px; }

.control-panel {
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.control-group.full { grid-column: 1 / -1; }

label { color: var(--muted); font-size: 12px; font-weight: 600; }

input, select, textarea {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 9px;
  font: 14px inherit;
  background: var(--surface);
  color: var(--text);
}

textarea { min-height: unset; }

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}

.table-heading {
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.table-title { margin: 0; font-size: 16px; }
.result-count { font-size: 13px; color: var(--muted); }

.table-wrapper { overflow: auto; max-height: 60vh; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
}

td {
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  font-size: 13px;
  vertical-align: top;
}

tbody tr:hover { background: var(--hover-tint); }

tr.row-collision td { background: var(--collision-tint); }

.editable { width: 150px; }
.editable.mono { font-family: monospace; }

.inline-value { display: flex; align-items: center; gap: 4px; }

.reset-btn {
  min-height: 26px;
  min-width: 26px;
  padding: 0;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1;
}

.warn-badge { color: var(--warn); font-weight: 700; }

.length-badge {
  background: var(--warn);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  white-space: nowrap;
}

.empty {
  padding: 40px;
  text-align: center;
  color: var(--muted);
  white-space: normal;
}

/* =====================================================
   Groups checkbox dropdown (per-row and bulk edit bar)
   ===================================================== */
.group-picker { position: relative; display: inline-block; }

.group-picker-toggle {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.group-picker-menu {
  display: none;
  position: fixed;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  padding: 6px;
  max-height: 240px;
  overflow: auto;
  min-width: 200px;
}

.group-picker.open .group-picker-menu { display: block; }

.group-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.group-option:hover { background: var(--bg); }

.script-output {
  margin: 0;
  padding: 16px 18px;
  font-family: monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 50vh;
  overflow: auto;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 20px;
}

.modal.open { display: flex; }

.modal-panel {
  width: min(760px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  padding: 22px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

#schoolValidationErrors {
  margin: 0;
  padding-left: 18px;
  list-style: disc;
}

@media (max-width: 900px) {
  .page-content { padding-left: 16px; padding-right: 16px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
}
