:root {
  --bg: #FFFFFF;
  --panel: #F7F9FA;
  --panel-2: #EEF2F3;
  --border: #DCE2E5;
  --text: #17212A;
  --text-dim: #5B6B73;
  --accent: #17A18E;
  --accent-dim: rgba(23, 161, 142, 0.10);
  --danger: #C1443B;
  --danger-dim: rgba(193, 68, 59, 0.08);

  --status-student: #B8710F;
  --status-mentor: #6A55E0;
  --status-ready: #17A18E;
  --status-submitted: #2F8F49;

  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --font-sans: 'Inter', -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
}

body { font-size: 15px; line-height: 1.5; }

.hidden { display: none !important; }

a { color: var(--accent); }

button {
  font-family: var(--font-sans);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  transition: border-color .15s ease, background .15s ease;
}
button:hover { border-color: var(--accent); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button.primary {
  background: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
  font-weight: 600;
}
button.danger {
  background: var(--danger-dim);
  border-color: var(--danger);
  color: var(--danger);
}
button:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  font-family: var(--font-sans);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 11px;
  font-size: 14px;
  width: 100%;
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--panel-2);
  color: var(--text-dim);
  cursor: not-allowed;
}

label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 14px 0 6px;
}

/* ---------------- Login ---------------- */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 480px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(23, 33, 42, 0.06);
  border-radius: 12px;
  padding: 48px;
}
.login-logo {
  display: block;
  width: 200px;
  height: auto;
  margin: 0 0 12px;
}
.login-card .tag {
  color: var(--text-dim);
  font-size: 15px;
  margin-bottom: 28px;
}
.login-card label { font-size: 12px; margin: 18px 0 7px; }
.login-card input { padding: 13px 14px; font-size: 15px; }
.login-card button.primary { width: 100%; margin-top: 24px; padding: 13px 14px; font-size: 15px; }
#login-error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------------- App shell ---------------- */
#app { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(6px);
}
.topbar .brand {
  display: flex;
  align-items: center;
}
.topbar .brand-logo {
  height: 22px;
  width: auto;
  display: block;
}
.topbar .search { flex: 1; max-width: 420px; }
.topbar .spacer { flex: 1; }
.topbar .who {
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
}
.role-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid var(--accent);
  color: var(--accent);
}

.content { padding: 24px; max-width: 1400px; margin: 0 auto; }

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.content-header h2 {
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 500;
  margin: 0;
}

/* ---------------- Table ---------------- */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
}
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
thead th:hover { color: var(--text); }
thead th .arrow { opacity: .5; margin-left: 4px; }
tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--panel-2); }
tbody td { padding: 13px 16px; vertical-align: middle; font-size: 14px; }
td.name-cell { font-weight: 600; }
td.name-cell .desc {
  display: block;
  font-weight: 400;
  color: var(--text-dim);
  font-size: 12.5px;
  margin-top: 2px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
td.date-cell { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-dim); }
td.deadline-cell { color: var(--text); font-weight: 600; }

.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-dim);
}
.empty-state .big { font-family: var(--font-mono); font-size: 16px; color: var(--text); margin-bottom: 6px; }

/* ---------------- Stage tracker (signature element) ---------------- */
.stage-tracker { display: flex; align-items: center; gap: 3px; }
.stage-tracker .seg {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  min-width: 16px;
}
.stage-tracker .seg.filled { background: var(--stage-color, var(--accent)); }
.stage-label {
  font-family: var(--font-mono);
  font-size: 11px;
  margin-top: 6px;
  color: var(--stage-color, var(--text-dim));
  white-space: nowrap;
}

/* ---------------- Modal ---------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(4, 7, 8, .7);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
  z-index: 20;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 640px;
  padding: 28px;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.modal-head h3 {
  font-family: var(--font-mono);
  font-size: 16px;
  margin: 0;
}
.modal-close {
  background: none; border: none; color: var(--text-dim); font-size: 20px; padding: 2px 8px;
}
.field-row { display: flex; gap: 14px; }
.field-row > div { flex: 1; }
.modal-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border);
}
.modal-actions .right { display: flex; gap: 10px; }

/* Documents inside modal */
.doc-section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.doc-list { list-style: none; padding: 0; margin: 10px 0 0; }
.doc-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 13.5px;
}
.doc-list li .doc-actions { display: flex; gap: 6px; }
.doc-list li .doc-actions button { padding: 4px 10px; font-size: 12px; }
.doc-empty { color: var(--text-dim); font-size: 13px; margin-top: 10px; }
.upload-row { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.upload-row input[type=file] { flex: 1; }

/* Users modal */
.user-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.user-row:last-child { border-bottom: none; }
.user-row .email { font-size: 14px; }
.user-row .meta { display: flex; align-items: center; gap: 10px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 12px 18px; border-radius: 8px; font-size: 13.5px;
  z-index: 40; max-width: 90vw;
}
.toast.error { border-color: var(--danger); color: var(--danger); }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .topbar .search { order: 3; max-width: none; width: 100%; }
  .content { padding: 16px; }
  .field-row { flex-direction: column; }

  .table-wrap { background: none; border: none; overflow: visible; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { display: none; }

  tbody tr {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 14px;
  }
  tbody tr:last-child { margin-bottom: 0; }

  tbody td {
    padding: 5px 0;
    border-bottom: none;
  }

  /* Labels for each stacked field, since column headers are hidden */
  tbody td[data-label]::before {
    content: attr(data-label) ": ";
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-dim);
    font-weight: 400;
  }
  tbody td.name-cell::before,
  tbody td[data-label="Status"]::before {
    content: none; /* name and status are self-evident without a label */
  }

  /* Deadline gets extra visual weight on mobile since there's no column header to anchor it */
  tbody td.deadline-cell {
    background: var(--accent-dim);
    border-radius: 6px;
    padding: 6px 10px;
    margin: 4px 0;
    display: inline-block;
  }

  /* Last-update date is redundant on mobile without headers to explain it */
  tbody td.last-update-cell { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
