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

:root {
  --bg:       #F1F5F9;
  --surface:  #FFFFFF;
  --border:   #E2E8F0;
  --border2:  #CBD5E1;
  --text:     #0F172A;
  --muted:    #475569;
  --subtle:   #94A3B8;
  --blue:     #2563EB;
  --teal:     #0D9488;
  --amber:    #D97706;
  --indigo:   #4F46E5;
  --rose:     #E11D48;
  --fine:     #16A34A;
  --fine-bg:  #DCFCE7;
  --ok:       #2563EB;
  --ok-bg:    #DBEAFE;
  --concern:  #D97706;
  --concern-bg:#FEF3C7;
  --flag:     #DC2626;
  --flag-bg:  #FEE2E2;
  --radius:   10px;
  --shadow:   0 1px 4px rgba(15,23,42,.07), 0 2px 12px rgba(15,23,42,.04);
  --font:     'DM Sans', system-ui, sans-serif;
  --mono:     'DM Mono', monospace;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── PAGES ────────────────────────────────────────────────────────────────── */
.page { display: none; min-height: 100vh; }
.page.active { display: block; }

/* ── CONFIG PAGE ──────────────────────────────────────────────────────────── */
.config-wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 48px 24px 64px;
}

.brand-tag {
  font-size: 10px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--subtle);
  margin-bottom: 10px;
  font-weight: 500;
}

.page-title {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: 10px;
}

.page-sub {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 32px;
  max-width: 480px;
  line-height: 1.6;
}

/* ── CARDS ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--subtle);
  margin-bottom: 16px;
}

/* ── FORM FIELDS ──────────────────────────────────────────────────────────── */
.field-row {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
}
.field-row:last-child { margin-bottom: 0; }

.field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

input[type="text"],
input[type="number"] {
  background: var(--bg);
  border: 1.5px solid var(--border2);
  border-radius: 7px;
  padding: 9px 12px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
input:focus { border-color: var(--blue); }

/* ── QMARKS GRID ──────────────────────────────────────────────────────────── */
.qmarks-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.qmark-cell {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
}
.qmark-cell .q-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--subtle);
  margin-bottom: 4px;
  letter-spacing: .5px;
}
.qmark-cell input {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  width: 100%;
}
.qmark-cell input:focus { outline: none; }

/* ── BUTTONS ──────────────────────────────────────────────────────────────── */
.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  padding: 10px 20px;
  cursor: pointer;
  border: none;
  transition: all .15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
  flex: 1;
  padding: 12px;
  font-size: 14px;
}
.btn-primary:hover { background: #1d4ed8; }

.btn-teal   { background: var(--teal); color: #fff; }
.btn-teal:hover { background: #0f766e; }

.btn-outline {
  background: var(--surface);
  border: 1.5px solid var(--border2);
  color: var(--text);
  flex: 1;
  padding: 12px;
  font-size: 14px;
}
.btn-outline:hover { border-color: var(--blue); color: var(--blue); }

.btn-ghost {
  background: transparent;
  border: 1.5px solid var(--border2);
  color: var(--muted);
}
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }

.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ── ENTRY PAGE ───────────────────────────────────────────────────────────── */
.entry-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.entry-header h2 { font-size: 18px; font-weight: 700; }
.entry-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

.table-scroll { overflow-x: auto; }

.marks-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}
.marks-table th {
  background: var(--bg);
  padding: 9px 8px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  min-width: 58px;
  font-size: 11px;
}
.marks-table td {
  padding: 2px;
  border-bottom: 1px solid var(--border);
}
.marks-table td.sno {
  padding: 3px 12px;
  color: var(--subtle);
  text-align: center;
  background: var(--bg);
  position: sticky;
  left: 0;
  font-size: 11px;
  font-family: var(--mono);
}
.marks-table th.sno-h {
  position: sticky;
  left: 0;
  z-index: 2;
}

.marks-table input {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 4px;
  text-align: center;
  font-size: 13px;
  font-family: var(--mono);
  color: var(--text);
  outline: none;
  transition: border-color .1s, background .1s;
}
.marks-table input:focus { border-color: var(--blue); background: #EFF6FF; }
.marks-table input.filled { background: #EFF6FF; border-color: #93C5FD; }

/* ── CHART HEADER ─────────────────────────────────────────────────────────── */
.chart-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 8px rgba(15,23,42,.06);
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
}
.hdr-code { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 6px; }
.hdr-dept { font-size: 11px; color: var(--subtle); margin-top: 1px; }

.header-stats {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.stat-pill {
  text-align: center;
  min-width: 52px;
}
.stat-val {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--blue);
  line-height: 1.15;
}
.stat-lbl {
  display: block;
  font-size: 10px;
  color: var(--subtle);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.stat-pill.fine .stat-val  { color: var(--fine); }
.stat-pill.flag .stat-val  { color: var(--flag); }

.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── EXPORT STATUS ────────────────────────────────────────────────────────── */
.export-status {
  background: #FEF9C3;
  border-bottom: 1px solid #FDE68A;
  padding: 8px 28px;
  font-size: 12px;
  color: #78350F;
  font-weight: 500;
}
.export-status.hidden { display: none; }

/* ── TAB BAR ──────────────────────────────────────────────────────────────── */
.tab-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  gap: 0;
  overflow-x: auto;
}

.tab {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 12px 16px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.tab:hover { color: var(--blue); }
.tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  font-weight: 700;
}

/* ── TAB CONTENT ──────────────────────────────────────────────────────────── */
.tab-content {
  display: none;
  padding: 24px 28px;
}
.tab-content.active { display: block; }

/* ── STATUS CARDS ─────────────────────────────────────────────────────────── */
.status-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.sc {
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  border: 1px solid transparent;
}
.sc-count { font-size: 32px; font-weight: 700; line-height: 1; }
.sc-label { font-size: 12px; font-weight: 600; margin-top: 4px; }

/* ── CHART CARDS ──────────────────────────────────────────────────────────── */
.chart-card { margin-bottom: 20px; }
.chart-wrap { height: 320px; position: relative; }
.radar-wrap { height: 300px !important; }
.radar-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ── CONCERN TABLE ────────────────────────────────────────────────────────── */
.concern-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}
.concern-table th {
  background: var(--bg);
  padding: 10px 14px;
  color: var(--muted);
  font-weight: 700;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.concern-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.concern-table tr:nth-child(even) td { background: var(--bg); }

.badge {
  display: inline-block;
  border-radius: 5px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 700;
}

/* ── FOOTER ───────────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 14px 24px;
  color: var(--subtle);
  font-size: 11px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 8px;
}

/* ── RESPONSIVE ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .page-title { font-size: 28px; }
  .qmarks-grid { grid-template-columns: repeat(4, 1fr); }
  .field-row { flex-direction: column; }
  .status-cards { grid-template-columns: repeat(2, 1fr); }
  .radar-grid { grid-template-columns: 1fr; }
  .chart-header { flex-direction: column; align-items: flex-start; }
  .tab-content { padding: 16px; }
}
