/* ------------------------------------------------------------------ base */
:root {
  /* Blues and neutrals share the IDEA League logo's hue (227°). */
  --brand-navy: #011458;     /* IDEA League logo background, top bar */
  --primary-dark: #092071;   /* hover, text on light blue */
  --primary: #213fab;        /* buttons, links */
  --primary-mid: #c6cff1;    /* light blue borders */
  --primary-light: #ebeffc;  /* light blue backgrounds */
  --accent: #d97706;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-hover: #fafafd;
  --muted-bg: #edeff5;
  --text: #182039;
  --text-muted: #606780;
  --border: #dfe2ec;
  --success-bg: #ecfdf5; --success-fg: #047857; --success-bd: #a7f3d0;
  --error-bg: #fef2f2;   --error-fg: #b91c1c;   --error-bd: #fecaca;
  --warning-bg: #fffbeb; --warning-fg: #b45309; --warning-bd: #fde68a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(1, 20, 88, .08), 0 1px 2px rgba(1, 20, 88, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 .75rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 .5rem; }
a { color: var(--primary); }
img { max-width: 100%; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  background: var(--brand-navy);
  color: #fff;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  min-height: 56px;
}
.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  padding: .4rem 0;
}
.brand img { height: 44px; width: auto; }
.brand span { display: flex; flex-direction: column; line-height: 1.15; }
.brand small { font-weight: 400; font-size: .72rem; opacity: .85; }

.nav {
  display: flex;
  align-items: center;
  gap: .15rem;
  margin-left: auto;
  flex-wrap: wrap;
}
.nav a {
  color: rgba(255, 255, 255, .88);
  text-decoration: none;
  padding: .45rem .65rem;
  border-radius: 6px;
  font-size: .92rem;
}
.nav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.nav a.active { background: rgba(255, 255, 255, .18); color: #fff; font-weight: 600; }
.nav-user {
  display: flex;
  align-items: center;
  gap: .15rem;
  margin-left: .75rem;
  padding-left: .75rem;
  border-left: 1px solid rgba(255, 255, 255, .25);
}
.nav-email {
  font-size: .8rem;
  opacity: .8;
  max-width: 16ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-toggle { display: none; }
.nav-toggle-label { display: none; cursor: pointer; margin-left: auto; padding: .5rem; }
.nav-toggle-label span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  margin: 5px 0;
  border-radius: 2px;
}

@media (max-width: 860px) {
  .nav-toggle-label { display: block; }
  .nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    padding-bottom: .75rem;
  }
  .nav-toggle:checked ~ .nav { display: flex; }
  .nav-user {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, .25);
    margin-top: .5rem;
    padding-top: .5rem;
    flex-direction: column;
    align-items: stretch;
  }
  .nav-email { max-width: none; }
}

/* ------------------------------------------------------------- container */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  flex: 1;
}
.container-narrow { max-width: 480px; margin: 0 auto; }

.footer {
  text-align: center;
  padding: 1rem;
  font-size: .8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ----------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card h2:first-child, .card h3:first-child { margin-top: 0; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.page-head h1 { margin: 0; }

/* ---------------------------------------------------------------- alerts */
.alert {
  padding: .7rem 1rem;
  border-radius: var(--radius);
  border: 1px solid;
  margin-bottom: .75rem;
  font-size: .92rem;
}
.alert-success { background: var(--success-bg); color: var(--success-fg); border-color: var(--success-bd); }
.alert-error   { background: var(--error-bg);   color: var(--error-fg);   border-color: var(--error-bd); }
.alert-warning { background: var(--warning-bg); color: var(--warning-fg); border-color: var(--warning-bd); }
.alert-info    { background: var(--primary-light); color: var(--primary-dark); border-color: var(--primary-mid); }

/* ----------------------------------------------------------------- forms */
label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: .25rem; }
.field { margin-bottom: .9rem; }
.hint { font-size: .8rem; color: var(--text-muted); font-weight: 400; }

input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="number"], input[type="search"], select, textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}
textarea { min-height: 110px; resize: vertical; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .9rem;
}
.checkbox-line {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  font-weight: 400;
  font-size: .92rem;
}
.checkbox-line input { width: auto; }

.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--primary-dark); }
.btn-secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-secondary:hover { background: var(--primary-light); }
.btn-danger { background: var(--error-fg); }
.btn-danger:hover { background: #7f1d1d; }
.btn-sm { padding: .3rem .7rem; font-size: .85rem; }

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

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: .92rem;
}
table.data th, table.data td {
  text-align: left;
  padding: .55rem .7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data th {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}
table.data tr:hover td { background: var(--surface-hover); }

/* ----------------------------------------------------------------- badges */
.badge {
  display: inline-block;
  padding: .1rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-uni  { background: var(--primary-light); color: var(--primary-dark); }
.badge-warn { background: var(--warning-bg); color: var(--warning-fg); }
.badge-danger { background: var(--error-bg); color: var(--error-fg); }
.badge-ok   { background: var(--success-bg); color: var(--success-fg); }
.badge-muted{ background: var(--muted-bg); color: var(--text-muted); }

/* ------------------------------------------------------------ thesis cards */
.thesis-grid { display: grid; gap: 1rem; }
.thesis-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
}
.thesis-card h3 { margin: .25rem 0 .35rem; }
.thesis-card h3 a { text-decoration: none; color: var(--text); }
.thesis-card h3 a:hover { color: var(--primary); }
.thesis-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem .5rem;
  align-items: center;
  font-size: .85rem;
  color: var(--text-muted);
}
.thesis-badges { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }

/* skill dots */
.dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.dots i {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--border);
}
.dots i.on { background: var(--primary); }

/* detail page description */
.prose :is(h1, h2, h3) { margin-top: 1rem; }
.prose img { border-radius: 8px; }
.figure-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.figure-grid figure { margin: 0; }
.figure-grid img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.figure-grid figcaption { font-size: .82rem; color: var(--text-muted); margin-top: .3rem; }

/* file rows in edit form */
.file-row {
  display: flex;
  gap: .75rem;
  align-items: center;
  padding: .5rem 0;
  border-bottom: 1px dashed var(--border);
  flex-wrap: wrap;
}
.file-row .grow { flex: 1; min-width: 200px; }

/* login */
.login-card { margin-top: 8vh; }
.login-logo { text-align: center; margin-bottom: 1rem; }
.login-logo img { height: 64px; }

details.filterbox summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
}
fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0 0 1rem;
}
legend { font-size: .85rem; font-weight: 600; color: var(--text-muted); padding: 0 .35rem; }

/* selection page */
.priority-select { max-width: 130px; }

/* ---------------------------------------------------------------- print */
@media print {
  .topbar, .footer, .no-print { display: none !important; }
  body { background: #fff; }
  .container { max-width: none; padding: 0; }
  .thesis-card, .card { box-shadow: none; break-inside: avoid; }
}

/* sortable table headers */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable::after { content: " ↕"; color: var(--text-muted); font-weight: normal; }
th.sortable[data-dir="asc"]::after { content: " ▲"; color: inherit; }
th.sortable[data-dir="desc"]::after { content: " ▼"; color: inherit; }

/* full-width search with a magnifier icon */
.search-box { position: relative; margin-bottom: 1rem; }
.search-box input {
  padding: .75rem .9rem .75rem 2.6rem;
  font-size: 1rem;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat .85rem center;
}

/* bulk actions, shown once rows are ticked */
.bulk-bar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: .75rem; margin-bottom: 1rem; padding: .6rem .9rem;
  background: var(--primary-light); border: 1px solid var(--primary-mid); border-radius: 8px;
}
.bulk-bar[hidden] { display: none; }
