:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #1d4ed8;
  --brand-dark: #1e40af;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #dc2626;
  --radius: 12px;
}

* { box-sizing: border-box; }

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

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}

.wide { max-width: 1100px; }

header.app {
  text-align: center;
  padding: 8px 0 20px;
}
header.app h1 { margin: 0 0 4px; font-size: 1.5rem; }
header.app p { margin: 0; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

label { display: block; font-weight: 600; margin-bottom: 6px; }

select, input[type="text"], input[type="password"] {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { background: #9ca3af; cursor: not-allowed; }
.btn.secondary { background: #eef2ff; color: var(--brand-dark); }
.btn.secondary:hover { background: #e0e7ff; }
.btn.small { width: auto; padding: 8px 12px; font-size: 0.85rem; }

.hint { color: var(--muted); font-size: 0.9rem; margin-top: 6px; }
.error { color: var(--danger); font-weight: 600; margin-top: 10px; }

.instructions {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.instructions h3 { margin: 0 0 8px; }
.instructions ul { margin: 0; padding-left: 20px; }
.instructions li { margin-bottom: 4px; }
.instructions .flag {
  display: inline-block;
  margin-top: 10px;
  font-weight: 700;
  color: var(--warn);
  background: var(--warn-bg);
  padding: 6px 10px;
  border-radius: 8px;
}

.radios { display: grid; gap: 10px; }
.radio {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
}
.radio input { margin-top: 3px; }
.radio.selected { border-color: var(--brand); background: #eff6ff; }
.radio strong { display: block; }
.radio span { color: var(--muted); font-size: 0.9rem; }

.field { margin-bottom: 18px; }

.filelist { margin-top: 16px; display: grid; gap: 10px; }
.fileitem {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
.fileitem .top { display: flex; justify-content: space-between; gap: 10px; }
.fileitem .name { font-weight: 600; word-break: break-all; }
.fileitem .meta { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.bar { height: 8px; background: var(--line); border-radius: 6px; overflow: hidden; margin-top: 8px; }
.bar > div { height: 100%; width: 0; background: var(--brand); transition: width 0.2s; }
.status { font-size: 0.85rem; margin-top: 6px; }
.status.done { color: var(--ok); font-weight: 600; }
.status.failed { color: var(--danger); font-weight: 600; }

.hidden { display: none !important; }

/* ---- admin ---- */
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.grid-cell { text-align: center; }
.pill {
  display: inline-block;
  min-width: 34px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}
.pill.none { background: #f3f4f6; color: #9ca3af; }
.pill.some { background: var(--warn-bg); color: var(--warn); }
.pill.alldone { background: var(--ok-bg); color: var(--ok); }
.missing { color: var(--danger); font-weight: 700; }

.classrow { cursor: pointer; }
.classrow:hover { background: #f9fafb; }
.detail td { background: #f9fafb; }
.filetable th, .filetable td { padding: 8px 10px; font-size: 0.9rem; }
.badge { font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; }
.badge.pending { background: var(--warn-bg); color: var(--warn); }
.badge.collected { background: var(--ok-bg); color: var(--ok); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.check { width: 18px; height: 18px; }

/* preview lightbox */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.75); }
.modal-body {
  position: relative;
  z-index: 1;
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-head span { font-weight: 600; word-break: break-all; }
.modal-content {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  min-width: 200px;
  min-height: 120px;
}
.modal-content img, .modal-content video { max-width: 86vw; max-height: 72vh; border-radius: 8px; background: #000; }
.modal-body .btn { align-self: flex-start; }
