:root {
  --blue: #00549f;
  --blue-light: #e5eef6;
  --text: #1d2430;
  --muted: #667085;
  --border: #d9dee5;
  --bg: #f5f7fa;
  --card: #fff;
  --green: #2e7d32;
  --green-bg: #e3f1e4;
  --amber: #a15c00;
  --amber-bg: #fff1d6;
  --red: #b42318;
  --red-bg: #fde8e6;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
a { color: var(--blue); }
h1 { font-size: 1.6rem; margin: 0.2em 0 0.6em; display: flex; align-items: center; gap: 0.5em; flex-wrap: wrap; }
h2 { font-size: 1.2rem; margin: 1.6em 0 0.6em; }
h3 { margin: 0 0 0.3em; font-size: 1.05rem; }
code { background: #eef1f5; padding: 0.1em 0.35em; border-radius: 4px; }

.dev-banner { background: #ffe08a; color: #5c4400; text-align: center; padding: 4px 8px; font-size: 0.85rem; }

.topbar {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: 0.6rem 1.2rem; background: var(--blue); color: #fff;
}
.topbar a { color: #fff; text-decoration: none; }
.brand { font-weight: 700; font-size: 1.15rem; }
.brand span { font-weight: 400; opacity: 0.8; }
.topbar nav { display: flex; gap: 0.25rem; flex-wrap: wrap; flex: 1; }
.topbar nav a { padding: 0.35rem 0.7rem; border-radius: 6px; opacity: 0.9; }
.topbar nav a:hover, .topbar nav a.active { background: rgba(255, 255, 255, 0.16); opacity: 1; }
.usermenu { display: flex; align-items: center; gap: 0.6rem; }
.usermenu form { margin: 0; }
.badge { background: #ffb300; color: #2b1d00; border-radius: 10px; padding: 0 7px; font-size: 0.8rem; font-weight: 700; }

.container { max-width: 1200px; margin: 0 auto; padding: 1.2rem; }
.narrow { max-width: 640px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; }
.stack > * + * { margin-top: 0.8rem; }
.muted { color: var(--muted); }
.pre { white-space: pre-wrap; }
.nowrap { white-space: nowrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.members { padding-left: 1.1rem; margin: 0.4rem 0 0.8rem; }

/* Buttons */
.btn {
  display: inline-block; padding: 0.45rem 0.9rem; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; color: var(--text); font: inherit; cursor: pointer; text-decoration: none; line-height: 1.3;
}
.btn:hover { background: #f0f3f7; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #004480; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger-outline { color: var(--red); border-color: #f0b4ae; }
.btn.danger-outline:hover { background: var(--red-bg); }
.btn.small { padding: 0.2rem 0.55rem; font-size: 0.85rem; }
button.link { background: none; border: none; color: inherit; cursor: pointer; font: inherit; text-decoration: underline; padding: 0; }
.buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-top: 0.8rem; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 0.25rem; }
.field label { font-weight: 600; font-size: 0.92rem; }
input[type=text], input[type=email], input[type=datetime-local], select, textarea {
  font: inherit; padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-light); border-color: var(--blue); }
.field ul { list-style: none; padding: 0; margin: 0; columns: 2; }
.field ul label { font-weight: normal; }
.has-error input, .has-error select { border-color: var(--red); }
.error, .errors { color: var(--red); }
.errors ul { margin: 0; padding-left: 1rem; }
.copyrow { display: flex; gap: 0.5rem; }
.copyrow input { font-family: ui-monospace, monospace; font-size: 0.85rem; }

/* Messages */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: 0.6rem 0.9rem; border-radius: 6px; margin-bottom: 0.4rem; background: var(--blue-light); }
.messages .msg-success { background: var(--green-bg); }
.messages .msg-error { background: var(--red-bg); }
.messages .msg-info { background: var(--amber-bg); }
.notice { background: var(--amber-bg); border-radius: var(--radius); padding: 0.7rem 1rem; margin: 1rem 0; }
.notice ul { margin: 0.3rem 0 0; padding-left: 1.2rem; }

/* Status & roles */
.status, .role { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 10px; vertical-align: middle; }
.status-approved { background: var(--green-bg); color: var(--green); }
.status-pending { background: var(--amber-bg); color: var(--amber); }
.status-rejected { background: var(--red-bg); color: var(--red); }
.role-teacher { background: #e8e0f8; color: #4b2a91; }
.role-student { background: #e6eef7; color: #24527a; }
.topbar .role { background: rgba(255, 255, 255, 0.2); color: #fff; }

/* Definition lists */
.props { display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1.2rem; margin: 0; }
.props dt { font-weight: 600; color: var(--muted); }
.props dd { margin: 0; }

/* Tables */
.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { background: #f0f3f7; font-size: 0.85rem; color: var(--muted); }
.table td.actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.table td.actions form { margin: 0; }
.table tr.inactive td { opacity: 0.55; }

/* Login */
.quick-login { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.quick-login form { margin: 0; }

/* Page headers with actions */
.calendar-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.calendar-head h1 { margin-right: auto; margin-bottom: 0.2em; }
.legend { display: flex; gap: 0.4rem; }
.hint { margin-top: 0.2rem; font-size: 0.9rem; }
.tabs { display: flex; gap: 0.25rem; }
.tabs a { padding: 0.3rem 0.7rem; border-radius: 6px; text-decoration: none; }
.tabs a.active { background: var(--blue-light); font-weight: 600; }

/* Approvals */
.approval { display: flex; gap: 1.5rem; margin-bottom: 0.8rem; flex-wrap: wrap; }
.approval.past { opacity: 0.7; }
.approval-info { flex: 1 1 300px; display: flex; flex-direction: column; gap: 0.2rem; }
.approval-form { flex: 0 1 320px; }
.approval-form .buttons { margin-top: 0.5rem; }
.overlap { color: var(--amber); font-size: 0.9rem; }

/* Calendar */
#calendar { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 0.8rem; }
.fc { --fc-today-bg-color: #f3f8fd; --fc-button-bg-color: var(--blue); --fc-button-border-color: var(--blue);
      --fc-button-active-bg-color: #003a70; --fc-button-active-border-color: #003a70;
      --fc-button-hover-bg-color: #004480; --fc-button-hover-border-color: #004480; }
.fc .fc-toolbar-title { font-size: 1.25rem; }
.fc-event.status-approved { background: var(--blue); border-color: var(--blue); }
.fc-event.status-pending {
  background: repeating-linear-gradient(135deg, #fff1d6, #fff1d6 6px, #ffe4b0 6px, #ffe4b0 12px);
  border: 1px dashed #c78100; color: #4d2e00;
}
.fc-event.status-pending .fc-event-main { color: #4d2e00; }
.fc-daygrid-event.status-pending .fc-daygrid-event-dot { border-color: #c78100; }
.ev { overflow: hidden; font-size: 0.8rem; line-height: 1.25; }
.ev-time { font-size: 0.72rem; opacity: 0.9; }
.ev-title { font-weight: 600; }
.ev-who { font-size: 0.72rem; opacity: 0.85; }
.fc-list-event .ev { display: flex; gap: 0.8rem; font-size: 0.9rem; }
.fc-list-event .ev-time { display: none; }

@media (max-width: 700px) {
  .container { padding: 0.8rem; }
  .topbar { gap: 0.6rem; padding: 0.6rem 0.8rem; }
  .table th:nth-child(3), .table td:nth-child(3) { display: none; }
  .field ul { columns: 1; }
  #calendar { padding: 0.4rem; }
}
