:root {
  --brand: #4f46e5;
  --ink: #0f172a;
  --body: #334155;
  --muted: #64748b;
  --line: #e5e7eb;
  --appbg: #f8fafc;
  --success: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --card: #ffffff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--appbg);
  color: var(--body);
  line-height: 1.5;
}

h1, h2 { color: var(--ink); margin: 0 0 8px; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--danger); }
.ok { color: var(--success); }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 0.9rem;
}
.brand-name { font-weight: 700; color: var(--ink); }
.brand-sub { font-size: 0.8rem; color: var(--muted); }
.userbox { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; flex-wrap: wrap; justify-content: flex-end; }
.role-pill {
  background: #eef2ff;
  color: var(--brand);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: capitalize;
}

/* Layout */
main { max-width: 960px; margin: 0 auto; padding: 16px; }
.foot { text-align: center; padding: 24px 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.login-card { max-width: 420px; margin: 48px auto; }

/* Batch bar + tabs */
.batchbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.batch-title { font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.batchpick { font-size: 0.85rem; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; }
.tab {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.95rem;
  cursor: pointer;
  white-space: nowrap;
}
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Stats */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.stat-num { font-size: 1.6rem; font-weight: 700; color: var(--ink); }
.stat.warn .stat-num { color: var(--warn); }
.stat-label { font-size: 0.85rem; color: var(--muted); }

/* Forms */
label { display: block; margin-bottom: 12px; font-size: 0.9rem; font-weight: 600; color: var(--ink); }
input, select {
  width: 100%;
  padding: 10px 12px;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.form-grid button { grid-column: 1 / -1; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 1rem;
  cursor: pointer;
  background: #e5e7eb;
  color: var(--ink);
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--line); padding: 6px 12px; font-size: 0.9rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: wait; }
.btn-small { padding: 4px 10px; font-size: 0.85rem; }

.filepick {
  display: inline-block;
  border: 1px dashed var(--brand);
  border-radius: 8px;
  padding: 14px 18px;
  cursor: pointer;
  color: var(--brand);
  font-weight: 600;
}
.filepick input { display: none; }

/* Tables */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tbl th, .tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; }
.tbl tr:hover td { background: #f8fafc; }

/* Status flags */
.flag { font-weight: 700; }
.flag-red { color: var(--danger); }
.flag-green { color: var(--success); }
.flag-amber { color: var(--warn); }
.pill {
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.8rem;
  font-weight: 600;
}
.pill-present { background: #dcfce7; color: #166534; }
.pill-absent { background: #fee2e2; color: #991b1b; }
.pill-late { background: #fef3c7; color: #92400e; }

/* Lists */
.date-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 10px 4px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--ink);
}
.date-row:hover { background: #f8fafc; }
.risk-row { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.risk-row:last-child { border-bottom: none; }
.email-cell { cursor: pointer; }
.email-cell:hover { text-decoration: underline; }
.unknown-list { margin: 8px 0; padding-left: 20px; }
