:root {
  --bg: #0e1117;
  --bg-elev: #161b23;
  --bg-elev-2: #1d232d;
  --line: #2a3038;
  --line-soft: #222831;
  --text: #e7ecf3;
  --text-dim: #97a3b4;
  --text-faint: #6b7686;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --green: #3fb96b;
  --amber: #e0a63a;
  --red: #e5544b;
  --purple: #a879f0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --q1: #5b8cff;
  --q2: #3fb96b;
  --q3: #e0a63a;
  --q4: #a879f0;
}

* {
  box-sizing: border-box;
}

/* The `hidden` attribute must always win, even over components that set
   `display: flex/grid` (e.g. .modal, .chip). Without this, elements toggled
   via `.hidden` stay visible. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #12161d, var(--bg));
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar__logo {
  font-size: 22px;
  color: var(--accent);
  filter: drop-shadow(0 0 12px rgba(91, 140, 255, 0.5));
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.topbar__sub {
  margin: 0;
  font-size: 12px;
  color: var(--text-faint);
}

.yearnav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.yearnav__btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s;
}

.yearnav__btn:hover {
  background: var(--bg-elev-2);
  border-color: var(--accent);
}

.yearnav__label {
  min-width: 132px;
  text-align: center;
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.yearnav__year {
  font-size: 17px;
  font-weight: 650;
}

.yearnav__hint {
  font-size: 11px;
  color: var(--text-faint);
}

.yearnav__today {
  margin-left: 4px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  transition: background 0.15s, color 0.15s;
}

.yearnav__today:hover {
  background: var(--bg-elev);
  color: var(--text);
}

/* ---------- Banner ---------- */
.banner {
  margin: 16px 24px 0;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--red);
  background: rgba(229, 84, 75, 0.1);
  color: #ffd7d3;
  font-size: 13px;
}

/* ---------- Board ---------- */
.boards {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.programme__head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}

.programme__title {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.programme__meta {
  font-size: 12px;
  color: var(--text-faint);
}

.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  align-items: start;
}

@media (max-width: 1100px) {
  .board {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 620px) {
  .board {
    grid-template-columns: 1fr;
  }
}

.quarter {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.quarter--current {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 10px 30px rgba(91, 140, 255, 0.12);
}

.quarter__head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  gap: 10px;
}

.quarter__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.q1 .quarter__dot { background: var(--q1); }
.q2 .quarter__dot { background: var(--q2); }
.q3 .quarter__dot { background: var(--q3); }
.q4 .quarter__dot { background: var(--q4); }

.q1 { --qc: var(--q1); }
.q2 { --qc: var(--q2); }
.q3 { --qc: var(--q3); }
.q4 { --qc: var(--q4); }

.quarter__title {
  font-weight: 650;
  font-size: 15px;
}

.quarter__range {
  font-size: 11.5px;
  color: var(--text-faint);
}

.quarter__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.quarter__now {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 7px;
  border-radius: 999px;
}

.quarter__count {
  font-size: 11px;
  color: var(--text-faint);
}

.quarter__body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 80px;
}

/* Add-on card */
.card {
  background: var(--bg-elev-2);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--qc, var(--accent));
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  transition: border-color 0.15s, transform 0.05s;
}

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

.card__title {
  font-weight: 600;
  font-size: 14px;
  margin: 0 0 6px;
  word-break: break-word;
}

.card__partner {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 2px 9px;
  max-width: 100%;
}

.card__partner span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--line-soft);
  color: var(--text-dim);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tag--link {
  color: var(--accent);
  border-color: rgba(91, 140, 255, 0.35);
}

.tag--link:hover {
  background: var(--accent-soft);
}

.tag--sub {
  color: var(--purple);
  border-color: rgba(168, 121, 240, 0.35);
}

.card__foot {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line-soft);
}

.iconbtn {
  border: 1px solid var(--line-soft);
  background: transparent;
  color: var(--text-dim);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 12px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.iconbtn:hover {
  background: var(--bg-elev);
  color: var(--text);
}

.iconbtn--danger:hover {
  color: var(--red);
  border-color: rgba(229, 84, 75, 0.4);
}

/* Empty add slot */
.slot {
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--text-faint);
  font-size: 13px;
  background: transparent;
  text-align: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.slot:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.slot__num {
  opacity: 0.6;
  margin-right: 4px;
}

.skeleton {
  height: 66px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, #171c24, #1d232d, #171c24);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Status badges ---------- */
.badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid transparent;
}

.badge--A, .badge--R { color: var(--green); border-color: rgba(63, 185, 107, 0.4); }
.badge--O, .badge--MR, .badge--TD { color: var(--amber); border-color: rgba(224, 166, 58, 0.4); }
.badge--T, .badge--DL, .badge--WF { color: var(--red); border-color: rgba(229, 84, 75, 0.4); }
.badge--M, .badge--R2, .badge--SQ { color: var(--accent); border-color: rgba(91, 140, 255, 0.4); }
.badge--D { color: var(--text-faint); border-color: var(--line); }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, 0.7);
  backdrop-filter: blur(3px);
}

.modal__panel {
  position: relative;
  width: min(520px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  background: var(--bg-elev);
  z-index: 2;
}

.modal__head h2 {
  margin: 0;
  font-size: 16px;
}

.modal__x {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  padding: 0 4px;
}

.modal__x:hover { color: var(--text); }

/* ---------- Form ---------- */
.form {
  padding: 18px 20px 20px;
}

.form__context {
  margin: 0 0 16px;
  font-size: 12px;
  color: var(--text-faint);
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 550;
  margin-bottom: 6px;
  color: var(--text-dim);
}

.req { color: var(--red); }
.opt {
  color: var(--text-faint);
  font-weight: 400;
  font-size: 11px;
}

.field input[type="text"],
.field input[type="url"] {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field__note {
  margin: 6px 0 0;
  font-size: 12px;
  min-height: 1px;
  color: var(--text-dim);
}

.field__note.is-set {
  color: var(--green);
}

/* Combobox */
.combo {
  position: relative;
}

.combo__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 5;
}

.combo__opt {
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}

.combo__opt:last-child { border-bottom: none; }

.combo__opt:hover,
.combo__opt.is-active {
  background: var(--accent-soft);
}

.combo__opt small {
  color: var(--text-faint);
  font-size: 11px;
}

.combo__opt .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.combo__empty {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-faint);
}

/* Chip (selected submission) */
.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(168, 121, 240, 0.4);
  background: rgba(168, 121, 240, 0.1);
  font-size: 13px;
}

.chip__text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip__x {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
}

.chip__x:hover { color: var(--red); }

/* Form footer */
.form__error {
  margin: 4px 0 12px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: rgba(229, 84, 75, 0.12);
  border: 1px solid rgba(229, 84, 75, 0.4);
  color: #ffd7d3;
  font-size: 12.5px;
}

.form__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.form__spacer { flex: 1; }

.btn {
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1020;
}

.btn--primary:hover:not(:disabled) {
  background: #6f9bff;
}

.btn--ghost {
  background: transparent;
}

.btn--ghost:hover {
  background: var(--bg-elev-2);
}

.btn--danger {
  background: transparent;
  border-color: rgba(229, 84, 75, 0.4);
  color: var(--red);
}

.btn--danger:hover {
  background: rgba(229, 84, 75, 0.12);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 60;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast--error { border-color: var(--red); }
.toast--ok { border-color: var(--green); }
