/* Functional admin styling. Badge print styles remain in their own document. */
:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  font-size: 14px;
  color: #20242b;
  background: #f5f6f8;
  line-height: 1.5;
  --border: #dfe3e8;
  --muted: #646d79;
  --surface: #fff;
  --primary: #303a49;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 19px; }
h2 { font-size: 22px; line-height: 1.4; }
h3 { font-size: 16px; }
p { line-height: 1.7; }
a { color: #344a69; }
button, input, select, textarea { font: inherit; }
button, input, select, textarea, a { outline-offset: 3px; }
:focus-visible { outline: 2px solid #50729d; }
button {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid #ccd2da;
  border-radius: 5px;
  color: #303843;
  background: var(--surface);
  cursor: pointer;
  line-height: 1.4;
}
button:hover:not(:disabled) { background: #f0f2f5; border-color: #aeb8c5; }
button:disabled { opacity: .5; cursor: default; }
button.primary { color: #fff; background: var(--primary); border-color: var(--primary); }
button.primary:hover:not(:disabled) { background: #465267; border-color: #465267; }
button.danger { color: #a32b2b; border-color: #e4bbbb; }
button.danger:hover:not(:disabled) { background: #fff2f2; border-color: #ce9191; }
button.text-button { color: var(--muted); border-color: transparent; background: transparent; }
button.text-button:hover:not(:disabled) { color: #20242b; text-decoration: underline; background: transparent; }
.wide { width: 100%; }
.muted, .hint, .small { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.hint { margin: 10px 0 16px; }

/* Login: a single form, without marketing content. */
.auth-layout { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-form { width: 100%; max-width: 400px; padding: 30px; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.auth-form h2 { margin-bottom: 10px; }
.auth-form .muted { margin-bottom: 24px; }
.auth-form .text-button { margin-top: 10px; }

/* Navigation and workspace. */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 216px; padding: 26px 16px; background: #fff; border-right: 1px solid var(--border); overflow-y: auto; }
.sidebar h1 { padding: 0 10px; margin-bottom: 28px; white-space: nowrap; }
.sidebar nav { display: grid; gap: 5px; }
.nav-item { text-align: left; padding: 11px 13px; border-color: transparent; background: transparent; color: #56606d; }
.nav-item[aria-current="page"] { color: #202b3b; background: #edf0f4; border-color: #edf0f4; font-weight: 700; }
.workspace { margin-left: 216px; min-width: 0; }
.topbar { min-height: 66px; padding: 14px 32px; display: flex; justify-content: flex-end; border-bottom: 1px solid var(--border); background: #fff; }
.session, .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.session { gap: 12px; }
#session-name { font-weight: 600; }
.content { max-width: 1440px; margin: 0 auto; padding: 30px 32px 48px; }
.page-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 20px; margin-bottom: 22px; }
.page-heading h2 { grid-column: 1; grid-row: 1; margin: 0; }
.page-heading > p { grid-column: 1 / -1; grid-row: 2; color: var(--muted); margin: 10px 0 0; }
.page-heading > .actions { grid-column: 2; grid-row: 1; }
.actions:empty { display: none; }
.panel { min-width: 0; padding: 22px; margin-bottom: 22px; background: #fff; border: 1px solid var(--border); border-radius: 7px; }
.panel h2, .panel h3 { margin-bottom: 16px; }
.grid-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.grid-two > .panel { margin-bottom: 0; }
.grid-two + .panel { margin-top: 22px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 22px; }
.stat { padding: 20px 22px; background: #fff; border: 1px solid var(--border); border-radius: 7px; }
.stat strong { display: block; margin-top: 10px; font-size: 28px; line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat small { font-size: 13px; font-weight: 400; color: var(--muted); }

/* Inputs, search and CSV upload. */
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; margin: 0 0 17px; font-size: 13px; font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; min-width: 0; min-height: 40px; padding: 9px 11px; border: 1px solid #cbd2db; border-radius: 5px; background: #fff; color: #20242b; font-size: 14px; font-weight: 400; }
.field input::placeholder { color: #818a95; }
.field input:disabled { background: #f2f3f5; color: #737b85; }
.field textarea { min-height: 90px; resize: vertical; }
.field input[type="file"] { padding: 9px; background: #fff; }
input::file-selector-button { padding: 5px 9px; margin-right: 10px; border: 1px solid #cbd2db; border-radius: 3px; background: #f3f4f6; cursor: pointer; }
.toolbar { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.toolbar > .field { min-width: 115px; }
.toolbar .field { margin-bottom: 0; }
.toolbar .search { flex: 1; min-width: 220px; }
.toolbar > button { min-height: 40px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; margin: 0 0 16px; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.upload-box { padding: 16px; margin: 18px 0; border: 1px dashed #c4cbd4; border-radius: 5px; background: #fafbfc; }
.upload-box .field { margin-bottom: 7px; }

/* Data tables and paging. */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 13px 12px; border-bottom: 1px solid #e5e8ed; text-align: left; vertical-align: middle; }
th { background: #f6f7f9; color: #576171; font-size: 12px; font-weight: 600; white-space: nowrap; }
td { max-width: 380px; overflow-wrap: anywhere; }
td:last-child { white-space: nowrap; }
tbody tr:hover { background: #fafbfc; }
td button { min-height: 32px; padding: 6px 10px; font-size: 12px; }
.secondary { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
.pill { display: inline-block; padding: 3px 8px; border: 1px solid #dbe1e8; border-radius: 4px; background: #f3f5f7; color: #465364; font-size: 12px; white-space: nowrap; }
.pill.inactive { color: #8e4141; border-color: #ecd9d9; background: #fbf3f3; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-top: 18px; color: var(--muted); font-size: 13px; }
.empty, .loading { padding: 36px 12px; margin: 0; text-align: center; color: var(--muted); }

/* Feedback and dialogs. */
.notice { padding: 12px 14px; margin: 16px 0; border: 1px solid #d7e1db; border-radius: 5px; background: #f4f8f5; color: #354d3c; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.7; }
.notice:empty { display: none; }
.notice.error { background: #fff5f4; border-color: #edceca; color: #962f26; }
.global-message { margin: 20px 32px 0; }
dialog { width: min(740px, calc(100% - 40px)); max-height: 88vh; padding: 0; border: 1px solid #cbd2db; border-radius: 8px; overflow: auto; color: #20242b; box-shadow: 0 16px 48px #18212b24; }
dialog::backdrop { background: #18212b66; }
.dialog-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 24px; border-bottom: 1px solid var(--border); background: #fff; }
.dialog-head h2 { margin: 0; font-size: 19px; overflow-wrap: anywhere; }
.dialog-head button { flex-shrink: 0; }
.dialog-body { padding: 24px; }
.dialog-body > .notice { margin-top: 0; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.definition { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px 16px; margin: 0 0 24px; font-size: 13px; }
.definition dt { color: var(--muted); }
.definition dd { margin: 0; overflow-wrap: anywhere; }
hr { height: 1px; border: 0; background: var(--border); margin: 24px 0; }
.avatar { width: 80px; height: 80px; margin-bottom: 16px; border: 1px solid var(--border); border-radius: 6px; object-fit: cover; }
.badge-roster { margin-top: 20px; border-top: 1px solid var(--border); }
.badge-roster > summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 17px 10px; margin: 0 -10px; border-radius: 5px; cursor: pointer; list-style: none; user-select: none; transition: background .15s ease; }
.badge-roster > summary::-webkit-details-marker { display: none; }
.badge-roster > summary:hover { background: #f5f6f8; }
.badge-roster-title { display: flex; align-items: center; gap: 10px; font-weight: 650; color: #303843; }
.badge-roster-caption { font-size: 12px; color: var(--muted); font-weight: 400; }
.badge-roster-meta { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
#badge-count { background: #edf0f4; border-radius: 20px; padding: 3px 9px; }
.badge-roster-chevron { flex-shrink: 0; transition: transform .18s ease; }
.badge-roster[open] .badge-roster-chevron { transform: rotate(180deg); }
.badge-roster #badge-results { padding-top: 4px; }
#badge-selection { margin-bottom: 0; font-size: 12px; }
@media (prefers-reduced-motion: reduce) { .badge-roster > summary, .badge-roster-chevron { transition: none; } }
#badge-frame { width: 100%; height: 1150px; border: 0; background: transparent; }

@media (max-width: 1100px) {
  .sidebar { width: 190px; padding: 24px 12px; }
  .workspace { margin-left: 190px; }
  .content { padding: 24px; }
  .topbar { padding-inline: 24px; }
  .global-message { margin-inline: 24px; }
  .grid-two { grid-template-columns: minmax(0, 1fr); }
  #badge-frame { height: 1800px; }
}
@media (max-width: 720px) {
  .sidebar { position: static; width: auto; padding: 16px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar h1 { margin: 0 0 14px; padding: 0; font-size: 18px; }
  .sidebar nav { display: flex; overflow-x: auto; gap: 4px; }
  .nav-item { flex: 0 0 auto; white-space: nowrap; padding: 9px 11px; }
  .workspace { margin-left: 0; }
  .topbar { min-height: 58px; padding: 10px 16px; }
  .session { gap: 8px; }
  .content { padding: 22px 16px 36px; }
  .global-message { margin: 16px 16px 0; }
  .page-heading { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .page-heading > .actions { grid-column: 1; grid-row: 3; }
  .page-heading > p { margin: 0; }
  .stats { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .stat { display: flex; align-items: center; justify-content: space-between; padding: 16px; }
  .stat strong { margin-top: 0; font-size: 24px; }
  .panel { padding: 16px; }
  .toolbar { gap: 10px; }
  .toolbar .search { flex-basis: 100%; min-width: 0; }
  .toolbar > .field { flex: 1; min-width: 100px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  table { min-width: 560px; }
  .dialog-head { padding: 15px 18px; }
  .dialog-body { padding: 18px; }
  .definition { grid-template-columns: 85px minmax(0, 1fr); gap: 10px; }
  .auth-layout { padding: 20px 16px; }
  .auth-form { padding: 24px; }
}
