:root {
  --bg: #f3efe6;
  --bg-accent: #e7dfd0;
  --ink: #1c1914;
  --muted: #5c564c;
  --line: #cfc6b6;
  --brand: #0f5c4c;
  --brand-2: #c45c26;
  --card: #fffdf8;
  --ok: #1f7a4d;
  --err: #a33b2b;
  --warn: #9a6b12;
  --radius: 10px;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #d9ebe4 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #f3d9c7 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
}

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

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: #13231f;
  color: #f4f1ea;
  padding: 1.5rem 1rem;
}
.sidebar .brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  margin-bottom: 1.5rem;
  padding: 0 0.5rem;
}
.sidebar nav a {
  display: block;
  color: #d7d2c7;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.25rem;
  text-decoration: none;
}
.sidebar nav a:hover,
.sidebar nav a.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
  text-decoration: none;
}
.main { padding: 1.5rem 2rem 3rem; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
h1, h2, h3 { margin: 0 0 0.75rem; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1rem;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}
.stat .value { font-size: 1.8rem; font-weight: 700; color: var(--brand); }
.stat .label { color: var(--muted); font-size: 0.9rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid transparent;
  background: var(--brand);
  color: #fff;
  padding: 0.55rem 0.95rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.05); text-decoration: none; color: #fff; }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { color: var(--ink); background: var(--bg-accent); }
.btn-danger { background: var(--err); }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.9rem; }

.form-row { margin-bottom: 0.9rem; }
.form-row > label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.92rem;
}
.form-row input:not([type="checkbox"]):not([type="radio"]),
.form-row select,
.form-row textarea {
  width: 100%;
  max-width: 520px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
}
.form-row input[type="checkbox"],
.form-row input[type="radio"] {
  width: auto;
  max-width: none;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  accent-color: var(--brand);
}

/* Label + switch rows — text left, control right, vertically centered */
.check-list {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.25rem 0.5rem;
  background: #fff;
  max-width: 640px;
}
.check-row,
label.check-row,
.set-check,
label.set-check {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-weight: 400;
  font-size: 0.88rem;
  margin: 0;
  padding: 0.45rem 0.15rem;
  border-bottom: 1px dashed var(--line);
  line-height: 1.35;
  cursor: pointer;
}
.check-row:last-child,
.set-check:last-child { border-bottom: none; }
.check-row > span,
.set-check > span {
  flex: 1;
  min-width: 0;
  text-align: left;
}
.check-row > input[type="checkbox"],
.set-check > input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  flex-shrink: 0;
  align-self: center;
}

label.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  margin: 0;
  cursor: pointer;
  line-height: 1.3;
}
label.inline-check input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  flex-shrink: 0;
}

.form-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
th, td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.mono { font-family: var(--mono); font-size: 0.88rem; }
.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--bg-accent);
}
.badge-ok { background: #d9efe3; color: var(--ok); }
.badge-err { background: #f5ddd8; color: var(--err); }
.badge-warn { background: #f3e5c5; color: var(--warn); }

.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  border: 1px solid var(--line);
}
.flash.success { background: #e5f5ec; border-color: #b7ddc7; }
.flash.error { background: #f8e8e5; border-color: #e5bfb7; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: 0 20px 50px rgba(28,25,20,0.08);
}

.public-header {
  padding: 1.5rem 1.25rem 0.5rem;
  max-width: 1100px;
  margin: 0 auto;
}
.public-header h1 { font-size: clamp(1.5rem, 3vw, 2.2rem); }
.public-body { max-width: 1100px; margin: 0 auto; padding: 1rem 1.25rem 3rem; }

details.qrow { margin-top: 0.35rem; }
details.qrow summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.qlist { margin: 0.5rem 0 0; padding: 0; list-style: none; }
.qlist li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.9rem;
}
.solved { color: var(--ok); font-weight: 600; }
.unsolved { color: var(--muted); }

.codebox {
  background: #13231f;
  color: #e8efe9;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.82rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }

/* Smoother admin motion + sync UI */
.card {
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}
.flash {
  animation: flash-in 0.35s ease;
}
@keyframes flash-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
.badge {
  transition: background 0.2s ease, color 0.2s ease;
}
.badge-queue { background: #e4eaf5; color: #35507a; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid var(--line);
  background: #fff;
}
.chip strong { font-size: 0.95rem; }
.chip-run { border-color: #c9b27a; background: #fff8e8; }
.chip-wait { border-color: #b7c4db; background: #eef3fb; }

.sync-hero-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}
.sync-controls select { min-width: 260px; }
.live-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.live-head h2 { margin: 0; }
.live-college {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  letter-spacing: -0.02em;
}
.queue-chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
.runs-table td.run-msg {
  max-width: 360px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 0.88rem;
}
.runs-table .dim { color: var(--muted); font-size: 0.82rem; }
.runs-table tr.run-row {
  transition: background 0.25s ease;
}
.runs-table tr.is-active {
  background: #eef7f3;
}
.runs-table tr.status-queued td { opacity: 0.85; }
.sidebar nav a {
  transition: background 0.2s ease, color 0.2s ease;
}
.btn {
  transition: filter 0.2s ease, transform 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.main h1 {
  animation: title-in 0.4s ease;
}
@keyframes title-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.sync-progress { margin-top: 0.5rem; }
.sync-progress-track {
  height: 18px;
  background: var(--bg-accent);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.sync-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brand), #1a8f74);
  transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
.sync-progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 0.55rem;
  font-size: 1.05rem;
}
.sync-progress-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

@media (max-width: 860px) {
  .sync-hero-top { align-items: stretch; }
  .sync-controls { width: 100%; }
  .sync-controls select { min-width: 0; width: 100%; }
}

/* Live OIF dashboard */
.live-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
  background: #0b1220;
  color: #e8eef8;
  font-family: var(--font);
}
.live-side {
  background: #0f172a;
  border-right: 1px solid #1e293b;
  padding: 1rem 0.75rem;
}
.live-side-title {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: #94a3b8;
  padding: 0 0.6rem 0.75rem;
  font-weight: 700;
}
.live-nav {
  display: block;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  color: #cbd5e1;
  text-decoration: none;
  margin-bottom: 0.25rem;
}
.live-nav strong { display: block; font-size: 0.95rem; }
.live-nav span { display: block; font-size: 0.75rem; color: #64748b; }
.live-nav:hover { background: #1e293b; text-decoration: none; color: #fff; }
.live-nav.active { background: #1d4ed8; color: #fff; }
.live-nav.active span { color: #bfdbfe; }
.live-side-sep { height: 1px; background: #1e293b; margin: 0.6rem 0.4rem; }
.live-muted { color: #94a3b8; font-size: 0.85rem; padding: 0.5rem; }
.live-main { padding: 0 0 2rem; }
.live-header {
  background: linear-gradient(90deg, #1d4ed8, #2563eb 55%, #3b82f6);
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
}
.live-header h1 { margin: 0; font-size: clamp(1.3rem, 2.5vw, 1.9rem); color: #fff; }
.live-oif { font-size: 0.8rem; opacity: 0.85; }
.live-sub { margin: 0.25rem 0 0; opacity: 0.9; font-size: 0.9rem; }
.live-sync { font-size: 0.85rem; opacity: 0.95; }
.batch-row { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 1rem 1.25rem 0.25rem; }
.batch-chip {
  background: #1e293b;
  color: #cbd5e1;
  border: 1px solid #334155;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  text-decoration: none;
}
.batch-chip.active, .batch-chip:hover { background: #2563eb; color: #fff; border-color: #2563eb; text-decoration: none; }
.stat-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(110px, 1fr));
  gap: 0.6rem;
  padding: 0.75rem 1.25rem 1rem;
}
.stat-card {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
}
.stat-label { font-size: 0.68rem; color: #94a3b8; letter-spacing: 0.04em; font-weight: 700; }
.stat-value { font-size: 1.35rem; font-weight: 700; margin-top: 0.2rem; }
.stat-value.ok { color: #34d399; }
.stat-value.info { color: #60a5fa; }
.stat-value.bad { color: #f87171; }
.stat-sub { font-size: 0.75rem; color: #94a3b8; }
.live-card {
  margin: 0 1.25rem 1rem;
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 1rem;
}
.live-card h2 { margin: 0 0 0.75rem; font-size: 1.05rem; }
.live-card-head { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin-bottom: 0.75rem; }
.live-card-head h2 { margin: 0; }
.live-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.live-table th, .live-table td {
  border-bottom: 1px solid #1f2937;
  padding: 0.55rem 0.45rem;
  text-align: left;
  vertical-align: top;
}
.live-table th { color: #94a3b8; font-size: 0.75rem; }
.live-table select {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 0.3rem;
}
.batch-tag {
  display: inline-block;
  background: #1e3a8a;
  color: #bfdbfe;
  border-radius: 6px;
  padding: 0.15rem 0.4rem;
  font-size: 0.75rem;
}
.prog-dots { display: flex; gap: 0.25rem; margin-top: 0.35rem; }
.dot {
  width: 12px; height: 12px; border-radius: 3px;
  background: #334155; display: inline-block;
}
.dot.on { background: #22c55e; }
.live-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1rem 1.25rem;
}
.live-actions input {
  background: #0f172a;
  border: 1px solid #334155;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
}
.live-shell .btn { background: #2563eb; }
.live-shell .badge { background: #1e293b; color: #e2e8f0; }
.live-shell .badge-ok { background: #14532d; color: #86efac; }
.live-shell .badge-warn { background: #713f12; color: #fde68a; }
.live-shell .badge-err { background: #7f1d1d; color: #fecaca; }

@media (max-width: 1100px) {
  .stat-row { grid-template-columns: repeat(3, 1fr); }
  .live-grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .live-shell { grid-template-columns: 1fr; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { padding-bottom: 0.5rem; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 0.25rem; }
  .grid-3 { grid-template-columns: 1fr; }
  .main { padding: 1rem; }
}
