:root {
  color-scheme: light;
  --bg: #eef2f5;
  --panel: #ffffff;
  --line: #d9e0e7;
  --text: #1d2733;
  --muted: #627184;
  --blue: #1f6feb;
  --green: #117a48;
  --red: #b42318;
  --amber: #996900;
}

* { box-sizing: border-box; }

html {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  overflow-x: hidden;
}

aside {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  background: #17202a;
  color: #fff;
  width: 248px;
  height: 100vh;
  overflow-y: auto;
  min-width: 0;
  padding: 22px 16px;
}

.brand {
  font-weight: 800;
  font-size: 22px;
  line-height: 1.1;
  margin-bottom: 24px;
}

.brand span {
  display: block;
  margin-top: 5px;
  color: #9fb1c2;
  font-size: 12px;
  letter-spacing: 0;
}

nav {
  display: grid;
  gap: 6px;
}

nav a {
  color: #d8e2ec;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 7px;
}

nav a.active,
nav a:hover {
  background: #243545;
  color: #fff;
}

main {
  grid-column: 2;
  padding: 24px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1 {
  margin: 0 0 4px;
  font-size: 26px;
}

h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.stat {
  font-size: 30px;
  font-weight: 800;
  margin-top: 8px;
}

.dashboard-charts {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.chart-panel {
  overflow: hidden;
}

.chart-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.chart-panel-header h2 {
  margin-bottom: 0;
}

.chart-panel-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.chart-metric-select {
  display: grid;
  gap: 5px;
  min-width: 150px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.chart-metric-select select {
  min-height: 38px;
}

.dynamic-chart {
  position: relative;
}

.dynamic-chart-canvas-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px 0 4px;
}

.dynamic-chart-canvas {
  display: block;
  min-width: 100%;
  height: 340px;
}

.dynamic-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.legend-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 7px 9px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.legend-button:hover {
  border-color: #94a3b8;
}

.legend-button.is-muted {
  background: #f5f7fa;
  color: var(--muted);
  opacity: .62;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.legend-button.is-muted .legend-swatch {
  opacity: .35;
}

.info-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.info-list div {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.info-list strong {
  color: var(--text);
  font-size: 13px;
}

.info-list span {
  min-width: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.dynamic-chart-tooltip {
  position: absolute;
  z-index: 20;
  display: none;
  gap: 2px;
  min-width: 140px;
  pointer-events: none;
  border-radius: 7px;
  background: #1d2733;
  color: #fff;
  padding: 8px 10px;
  box-shadow: 0 10px 26px rgba(23, 32, 42, .22);
  font-size: 12px;
  line-height: 1.35;
}

.dynamic-chart-tooltip strong {
  font-size: 12px;
}

.dynamic-chart-tooltip span {
  color: #d8e2ec;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  max-width: 100%;
  margin-bottom: 14px;
}

.actions label {
  min-width: min(220px, 100%);
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  padding: 9px 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
}

button.danger,
.button.danger { background: var(--red); }

button.ghost,
.button.ghost {
  background: #eef2f5;
  color: var(--text);
  border: 1px solid var(--line);
}

button.compact,
.button.compact {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  font: inherit;
  background: #fff;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

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

th {
  background: #f7f9fb;
  color: #435265;
}

tr:last-child td { border-bottom: 0; }

.table-scroll-shell {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin-bottom: 14px;
}

.table-scroll-controls {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin: 0 0 8px;
}

.scroll-button {
  width: 34px;
  min-height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  background: #eef2f5;
  color: var(--text);
}

.scroll-button:hover {
  border-color: #94a3b8;
  background: #fff;
}

.table-scroll-area {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  scrollbar-gutter: stable;
}

.table-scroll-area table {
  min-width: 900px;
  border: 0;
  border-radius: 0;
}

.table-scroll-area table.lecturers-table,
.lecturers-table {
  min-width: 1120px;
}

.table-scroll-area table.wide-table,
.table-scroll-area table.publications-table,
.table-scroll-area table.lecturer-publications-table,
.wide-table,
.publications-table,
.lecturer-publications-table {
  min-width: 2650px;
}

.table-scroll-area table.openalex-recommendations-table,
.openalex-recommendations-table {
  min-width: 1600px;
}

.table-scroll-area table.scopus-recommendations-table,
.scopus-recommendations-table {
  min-width: 1550px;
}

.table-scroll-area table.source-publisher-table,
.source-publisher-table {
  min-width: 1450px;
}

.table-scroll-area table.sinta-journals-table,
.sinta-journals-table {
  min-width: 1900px;
}

.action-cell {
  width: 150px;
  min-width: 150px;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
}

.lecturer-actions { flex-direction: column; align-items: stretch; }
.researcher-corrections { min-width: 0; }
.identity-section { padding: 18px 0; border-bottom: 1px solid var(--line); }
.identity-section h2 { font-size: 20px; line-height: 1.4; overflow-wrap: anywhere; }
.identity-section h3 { font-size: 16px; }
.identity-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 16px; }
.identity-facts > div { min-width: 0; }
.identity-facts dt { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.identity-facts dd { margin: 0; overflow-wrap: anywhere; }
.identity-form { display: grid; gap: 16px; max-width: 640px; margin-bottom: 16px; }
.identity-form label, .identity-review-form label { display: grid; gap: 6px; min-width: 0; }
.identity-form input, .identity-form select, .identity-form textarea { width: 100%; min-width: 0; }
.identity-form .identity-confirm { display: flex; align-items: flex-start; gap: 10px; line-height: 1.5; }
.identity-confirm input { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 3px; }
.identity-impact { border-left: 3px solid var(--amber); padding: 12px; line-height: 1.6; }
.identity-review-form { display: grid; gap: 12px; width: 270px; padding: 12px 0; }
.researcher-corrections button, .researcher-corrections .button { white-space: normal; max-width: 100%; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.pagination div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.page-link {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}

.page-link.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.page-link.disabled {
  color: #9aa8b7;
  background: #f3f6f9;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: #e9eef4;
  color: #334155;
}

.badge.valid,
.badge.success { background: #e8f5ee; color: var(--green); }
.badge.s1,
.badge.s2 { background: #e8f5ee; color: var(--green); }
.badge.s3,
.badge.s4 { background: #fff6df; color: var(--amber); }
.badge.s5,
.badge.s6 { background: #e9eef4; color: #334155; }
.badge.high { background: #e8f5ee; color: var(--green); }
.badge.medium { background: #fff6df; color: var(--amber); }
.badge.low { background: #e9eef4; color: #334155; }
.badge.running,
.badge.queued,
.badge.validating { background: #e8f1ff; color: var(--blue); }
.badge.failed,
.badge.invalid,
.badge.validation_failed,
.badge.canceled { background: #fdecea; color: var(--red); }
.badge.rate_limited,
.badge.access_blocked,
.badge.quota_exceeded,
.badge.finished_with_errors { background: #fff6df; color: var(--amber); }

.badge.sdg {
  max-width: 220px;
  white-space: normal;
  line-height: 1.25;
  border-radius: 7px;
}

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 160px;
}

.flash {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  background: #e8f5ee;
  color: var(--green);
  font-weight: 700;
}

.flash.error {
  background: #fdecea;
  color: var(--red);
}

.login {
  display: grid;
  place-items: center;
  grid-template-columns: 1fr;
  padding: 20px;
}

.login main {
  grid-column: auto;
  width: min(420px, 100%);
}

.muted { color: var(--muted); }

@media (max-width: 900px) {
  body {
    grid-template-columns: minmax(0, 1fr);
  }

  aside {
    position: static;
    width: auto;
    height: auto;
    min-height: auto;
    overflow-y: visible;
  }

  main {
    grid-column: auto;
  }

  .grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}
