/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #f5f6f8;
  --surface:    #ffffff;
  --border:     #dde1e7;
  --primary:    #2c5f8a;
  --primary-dk: #1e4468;
  --accent:     #4a90d9;
  --success:    #2e7d32;
  --success-bg: #e8f5e9;
  --error:      #c62828;
  --error-bg:   #ffebee;
  --warn:       #e65100;
  --warn-bg:    #fff3e0;
  --text:       #1a1d23;
  --text-muted: #6b7280;
  --sidebar-w:  220px;
  --radius:     8px;
  --shadow:     0 1px 4px rgba(0,0,0,.10);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

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

/* ── Auth pages (login / upload) ─────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 440px;
  padding: 2.5rem 2rem;
}

.auth-logo {
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-logo .site-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: .02em;
}

.auth-logo .site-sub {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

.auth-card h1 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--text);
}

/* Upload page wider card */
.upload-card { max-width: 600px; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }

label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  margin-bottom: .35rem;
  color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  padding: .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74,144,217,.15);
}

textarea { resize: vertical; min-height: 90px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border: none;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dk); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #ccd0d8; }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #1b5e20; }
.btn-danger    { background: var(--error); color: #fff; }
.btn-danger:hover { background: #8e0000; }
.btn-sm        { padding: .3rem .7rem; font-size: .82rem; }
.btn-full      { width: 100%; justify-content: center; }
.btn:disabled  { opacity: .5; cursor: default; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: 6px;
  font-size: .9rem;
  margin-bottom: 1rem;
  border-left: 4px solid transparent;
}
.alert-error   { background: var(--error-bg);   border-color: var(--error);   color: var(--error); }
.alert-success { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.alert-warn    { background: var(--warn-bg);    border-color: var(--warn);    color: var(--warn); }

/* ── Upload history table (participant view) ─────────────────────────────── */
.upload-history { margin-top: 2rem; }
.upload-history h2 { font-size: 1rem; font-weight: 600; margin-bottom: .75rem; color: var(--text-muted); }

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.history-table th {
  text-align: left;
  padding: .45rem .6rem;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
}
.history-table td {
  padding: .45rem .6rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.history-table tr:last-child td { border-bottom: none; }

/* ── Instructions box ────────────────────────────────────────────────────── */
.instructions-box {
  background: #f0f4f8;
  border: 1px solid #c8d6e3;
  border-radius: 6px;
  padding: .9rem 1rem;
  font-size: .9rem;
  color: #334;
  margin-bottom: 1.5rem;
  line-height: 1.65;
}

/* ── File drop zone ──────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  margin-bottom: 1rem;
  color: var(--text-muted);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: #f0f6ff;
  color: var(--primary);
}
.drop-zone input[type="file"] { display: none; }
.drop-zone .drop-icon { font-size: 2rem; display: block; margin-bottom: .4rem; }
.drop-zone .drop-label { font-size: .9rem; }
.drop-zone .selected-name {
  margin-top: .5rem;
  font-size: .85rem;
  color: var(--primary);
  font-weight: 500;
}

/* ── Admin layout ────────────────────────────────────────────────────────── */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-header {
  padding: 1.4rem 1.2rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.15);
}
.sidebar-header .site-name { font-weight: 700; font-size: 1rem; }
.sidebar-header .site-sub  { font-size: .75rem; opacity: .7; margin-top: .15rem; }

.sidebar-nav { flex: 1; padding: .8rem 0; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem 1.2rem;
  color: rgba(255,255,255,.8);
  font-size: .9rem;
  transition: background .12s, color .12s;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255,255,255,.15);
  color: #fff;
  text-decoration: none;
}
.sidebar-nav .nav-icon { font-size: 1rem; width: 1.2rem; text-align: center; }

.sidebar-footer {
  padding: 1rem 1.2rem;
  border-top: 1px solid rgba(255,255,255,.15);
}
.sidebar-footer a { color: rgba(255,255,255,.7); font-size: .82rem; }
.sidebar-footer a:hover { color: #fff; }

.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.admin-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .85rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.admin-topbar h1 { font-size: 1.1rem; font-weight: 600; }

.admin-content {
  padding: 1.75rem;
  flex: 1;
}

/* ── Admin sections (tabs) ───────────────────────────────────────────────── */
.admin-section { display: none; }
.admin-section.active { display: block; }

/* ── Stat cards ──────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
}
.stat-card .stat-label {
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
  margin-top: .2rem;
}
.stat-card .stat-sub {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

/* ── Admin tables ────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.card-header {
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.card-header h2 { font-size: .95rem; font-weight: 600; }
.card-body { padding: 1.25rem; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.data-table th {
  text-align: left;
  padding: .5rem .75rem;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.data-table td {
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafbfc; }
.data-table .actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ── Badge / status ──────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-green  { background: #e8f5e9; color: #2e7d32; }
.badge-red    { background: #ffebee; color: #c62828; }
.badge-gray   { background: #f0f0f0; color: #666; }
.badge-blue   { background: #e3f2fd; color: #1565c0; }

/* ── Progress bar ────────────────────────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--bg);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
  margin-top: .4rem;
}
.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width .4s;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  width: 100%;
  max-width: 500px;
  padding: 2rem;
  position: relative;
}
.modal h2 { font-size: 1.05rem; font-weight: 600; margin-bottom: 1.2rem; }
.modal-close {
  position: absolute;
  top: .9rem; right: 1rem;
  background: none; border: none;
  font-size: 1.2rem; cursor: pointer;
  color: var(--text-muted);
}
.modal-close:hover { color: var(--text); }

/* ── Search input ────────────────────────────────────────────────────────── */
.search-input {
  padding: .4rem .75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .88rem;
  width: 220px;
}
.search-input:focus { outline: none; border-color: var(--accent); }

/* ── Misc ────────────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: .85rem; }
.mt-1  { margin-top: .5rem; }
.mt-2  { margin-top: 1rem; }
.mt-3  { margin-top: 1.5rem; }
.mb-1  { margin-bottom: .5rem; }
.mb-2  { margin-bottom: 1rem; }
.flex  { display: flex; }
.items-center { align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* window status pill */
.window-status {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .82rem;
  font-weight: 600;
}
.window-status .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.window-open  .dot { background: #2e7d32; }
.window-closed .dot { background: #c62828; }
.window-open  { color: #2e7d32; }
.window-closed { color: #c62828; }

/* editable cell */
.editable {
  cursor: pointer;
  border-bottom: 1px dashed var(--border);
}
.editable:hover { border-color: var(--accent); color: var(--primary); }
