:root {
  /* Light theme */
  --bg: #f5f7fb; /* light slate */
  --panel: #ffffff;
  --text: #0f172a; /* slate-900 */
  --muted: #475569; /* slate-600 */
  --accent: #16a34a; /* green-600 */
  --accent-2: #2563eb; /* blue-600 */
  --danger: #dc2626; /* red-600 */
  --border: #e2e8f0; /* slate-200 */
  --hover: #eef2ff; /* indigo-50 */
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica Neue, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
}

#app {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  height: 100vh;
  width: 100%;
  max-width: none;
  margin: 0;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(6px);
  z-index: 10;
}

.app-header h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.file-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

label { color: var(--muted); font-size: 14px; }

select, button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

button { cursor: pointer; }
button:hover { border-color: var(--accent-2); }

.table-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
}

.pagination { display: flex; gap: 8px; align-items: center; }
.page-size { display: flex; gap: 8px; align-items: center; }
.filter-controls { display: flex; gap: 8px; align-items: center; }
.options { display: flex; gap: 16px; align-items: center; }

.table-container {
  padding: 16px 0;
  overflow: hidden;
}

.table-wrapper {
  width: 100%;
  height: calc(100vh - 200px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--panel);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(255, 255, 255, 0.95);
}

th, td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

tbody tr:nth-child(odd) td { background: #fafafa; }
tbody tr:hover td { background: var(--hover); }

.cell {
  max-width: none;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
  line-height: 1.3;
}

.nowrap .cell { white-space: nowrap; text-overflow: ellipsis; }

.cell.expanded {
  display: block;
  max-width: none;
  overflow: visible;
}

.cell-toggle {
  color: var(--accent-2);
  cursor: pointer;
  font-size: 12px;
  user-select: none;
}

.loading, .error {
  padding: 12px 16px;
  margin-bottom: 12px;
  border-radius: 8px;
}

.loading { background: #eff6ff; border: 1px solid #93c5fd; }
.error { background: #fee2e2; border: 1px solid var(--danger); }
.hidden { display: none; }

.app-footer {
  padding: 12px 20px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

code { background: #f3f4f6; padding: 2px 6px; border-radius: 6px; }

/* Summary bar */
.summary {
  display: flex;
  gap: 16px;
  align-items: baseline;
  color: var(--muted);
}
.summary strong { color: var(--text); }

/* Correctness badge */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
}
.badge.success { background: #ecfdf5; color: #065f46; border-color: #34d399; }
.badge.error { background: #fef2f2; color: #991b1b; border-color: #fca5a5; }

/* Modal */
.modal.hidden { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
}
.modal-content {
  position: relative;
  margin: 5vh auto;
  width: min(900px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 16px; max-height: 70vh; overflow: auto; }
.modal-body table { width: 100%; border-collapse: collapse; }
.modal-body th, .modal-body td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.modal-body th { width: 220px; color: var(--muted); font-weight: 500; }
.modal-header button { background: transparent; border: none; font-size: 18px; cursor: pointer; }

/* Login Page */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--bg) 0%, #e0e7ff 100%);
}

.login-container {
  width: min(420px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.12);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header h1 {
  margin: 0 0 8px 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.login-header p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.login-form {
  display: grid;
  gap: 20px;
}

.login-form .field { 
  display: grid; 
  gap: 8px; 
}

.login-form label {
  font-weight: 500;
  color: var(--text);
  font-size: 14px;
}

.login-form input {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.login-form button {
  width: 100%;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--accent-2);
  background: var(--accent-2);
  color: white;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.login-form button:hover:not(:disabled) {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.login-form button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-loading {
  opacity: 0.7;
}

.file-controls .secondary {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}


