:root {
  --bg: #f7f7f8;
  --fg: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --border: #e5e7eb;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #ca8a04;
  --card: #ffffff;
  --radius: 8px;
}

* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0; background: var(--bg); color: var(--fg);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header.site {
  background: #111827; color: #f9fafb;
  padding: 0.75rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
}
header.site .brand {
  font-weight: 700; font-size: 1.1rem; color: #f9fafb;
  display: inline-flex; align-items: center; gap: 0.55rem;
}
header.site .brand-mark { display: block; }
header.site nav a { color: #d1d5db; margin-left: 1rem; }
header.site nav a:hover { color: #fff; }

main { max-width: 1100px; margin: 1.5rem auto; padding: 0 1.5rem; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
  margin-bottom: 1.25rem;
}

h1, h2, h3 { margin-top: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; border-bottom: 1px solid var(--border); padding-bottom: 0.4rem; }

.muted { color: var(--muted); font-size: 0.9rem; }

.btn {
  display: inline-block; padding: 0.45rem 0.9rem;
  border-radius: var(--radius); border: 1px solid var(--accent);
  background: var(--accent); color: #fff !important;
  cursor: pointer; font-size: 0.95rem; text-decoration: none !important;
}
.btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.secondary { background: #fff; color: var(--accent) !important; }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }

table { width: 100%; border-collapse: collapse; }
table th, table td {
  padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); text-align: left;
  vertical-align: top;
}
table th { background: #f3f4f6; font-weight: 600; }

.badge {
  display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px;
  font-size: 0.8rem; background: #e5e7eb; color: #1f2937;
}
.badge.success { background: #dcfce7; color: #166534; }
.badge.warning { background: #fef9c3; color: #854d0e; }
.badge.danger  { background: #fee2e2; color: #991b1b; }
.badge.info    { background: #dbeafe; color: #1e40af; }

form p { margin: 0.5rem 0; }
form label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
form input[type="text"], form input[type="email"], form input[type="password"],
form input[type="datetime-local"], form input[type="number"],
form textarea, form select {
  width: 100%; padding: 0.4rem 0.55rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font: inherit;
}
form .helptext { color: var(--muted); font-size: 0.85rem; }

ul.messages { list-style: none; padding: 0; }
ul.messages li {
  padding: 0.5rem 0.75rem; border-radius: var(--radius); margin-bottom: 0.5rem;
}
ul.messages li.success { background: #dcfce7; color: #166534; }
ul.messages li.error   { background: #fee2e2; color: #991b1b; }
ul.messages li.warning { background: #fef9c3; color: #854d0e; }
ul.messages li.info    { background: #dbeafe; color: #1e40af; }

.actions { margin-top: 1rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

.role-grid {
  display: grid; gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 0.5rem;
}
.role-card {
  display: flex; flex-direction: column; gap: 0.35rem;
  padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; color: var(--fg) !important; text-decoration: none !important;
  transition: border-color 120ms, transform 120ms;
}
.role-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.role-card-label { font-weight: 700; font-size: 1.05rem; color: var(--accent); }
button.role-card { font: inherit; cursor: pointer; text-align: left; width: 100%; }
.role-join-form { margin: 0; }

.stats {
  display: grid; gap: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}
.stat {
  background: #f3f4f6; border-radius: var(--radius); padding: 0.6rem 0.75rem;
  display: flex; flex-direction: column;
}
.stat-num { font-size: 1.6rem; font-weight: 700; color: var(--fg); }
.stat-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

dialog.confirm-modal {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; max-width: 480px; width: 90%;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
}
dialog.confirm-modal::backdrop { background: rgba(0,0,0,0.4); }
dialog.confirm-modal h2 { margin-top: 0; }
dialog.confirm-modal .actions { margin-top: 1rem; }

tr.overdue-row { background: #fef2f2; }
tr.overdue-row:hover { background: #fee2e2; }

.filter-bar {
  display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end;
  margin-bottom: 0.75rem;
}
.filter-bar label { font-size: 0.85rem; color: var(--muted); font-weight: 500; }

table thead th a { color: inherit; text-decoration: none; }
table thead th a:hover { color: var(--accent); text-decoration: underline; }

.role-edit-form {
  margin: 0; display: inline-flex; gap: 0.25rem; align-items: center;
}
.role-edit-form select { width: auto; padding: 0.25rem 0.4rem; font-size: 0.9rem; }

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.page-header-text h1 { margin-bottom: 0.15rem; }
.page-header-text p   { margin-top: 0; }
.admin-actions {
  display: inline-flex; gap: 0.4rem; flex-wrap: wrap;
  margin-top: 0.25rem;
}

.notif-dropdown { display: inline-block; position: relative; margin-left: 1rem; }
.notif-dropdown summary {
  cursor: pointer; list-style: none; padding: 0.15rem 0.4rem;
  color: #d1d5db; user-select: none;
}
.notif-dropdown summary::-webkit-details-marker { display: none; }
.notif-dropdown summary:hover { color: #fff; }
.notif-count {
  background: var(--danger); color: #fff;
  border-radius: 999px; padding: 0.05rem 0.4rem; font-size: 0.7rem;
  margin-left: 0.15rem; font-weight: 700;
}
.notif-menu {
  position: absolute; right: 0; top: 100%;
  background: #fff; color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  min-width: 320px; max-width: 400px; padding: 0.3rem;
  z-index: 100; margin-top: 0.4rem;
}
.notif-item {
  display: block; padding: 0.5rem 0.6rem;
  border-radius: var(--radius); color: var(--fg) !important;
  text-decoration: none !important;
}
.notif-item:hover { background: #f3f4f6; }
.notif-unread { background: #eff6ff; }
.notif-unread:hover { background: #dbeafe; }
.notif-subj { font-size: 0.9rem; font-weight: 600; }
.notif-meta { font-size: 0.75rem; color: var(--muted); }
.notif-empty { padding: 0.6rem; text-align: center; }
.notif-all {
  display: block; text-align: center; padding: 0.45rem;
  border-top: 1px solid var(--border); margin-top: 0.3rem;
  font-size: 0.85rem; color: var(--accent) !important;
}
