/* ---- Reset -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ---- Variables ---------------------------------------------------- */
:root {
  --bg:          #0f0f0f;
  --surface:     #161616;
  --surface2:    #1c1c1c;
  --border:      #2a2a2a;
  --border-focus:#555;
  --accent:      #e8e8e8;
  --accent-dim:  #888;
  --green:       #4ec994;
  --red:         #e06c75;
  --yellow:      #e5c07b;
  --blue:        #61afef;
  --purple:      #c678dd;
  --text:        #d4d4d4;
  --text-muted:  #666;
  --text-dim:    #3a3a3a;
  --font:        'JetBrains Mono', 'Courier New', monospace;
  --radius:      4px;
}

/* ---- Base --------------------------------------------------------- */
html { font-size: 14px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Header ------------------------------------------------------- */
header {
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 2rem;
}
.header-inner {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}
.site-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: .02em;
}
.site-sub {
  font-size: .8rem;
  color: var(--text-muted);
}

/* ---- Main --------------------------------------------------------- */
main {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ---- Panel -------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ---- Two col layout ----------------------------------------------- */
.two-col {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 600px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ---- Fields ------------------------------------------------------- */
.field-group {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.field-label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--accent-dim);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.field-note {
  font-size: .7rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
}
.field-hint {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: .15rem;
}

/* ---- Inputs ------------------------------------------------------- */
.input-row {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
}
.text-input {
  flex: 1;
  min-width: 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: .82rem;
  padding: .6rem .85rem;
  outline: none;
  transition: border-color .15s;
}
.text-input:focus { border-color: var(--border-focus); }
.text-input::placeholder { color: var(--text-dim); }
.text-input option { background: var(--surface); }

/* ---- Buttons ------------------------------------------------------ */
.primary-btn {
  background: var(--accent);
  color: #0f0f0f;
  font-family: var(--font);
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .04em;
  border: none;
  border-radius: var(--radius);
  padding: .6rem 1.25rem;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .15s;
}
.primary-btn:hover { opacity: .85; }
.primary-btn:disabled { opacity: .35; cursor: not-allowed; }

.secondary-btn {
  background: transparent;
  color: var(--accent);
  font-family: var(--font);
  font-size: .75rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .9rem;
  cursor: pointer;
  transition: border-color .15s;
}
.secondary-btn:hover { border-color: var(--accent-dim); }

.ghost-btn {
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .9rem;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.ghost-btn:hover { color: var(--text); border-color: var(--border-focus); }

.expand-btn {
  background: transparent;
  color: var(--blue);
  font-family: var(--font);
  font-size: .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .2rem .5rem;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s;
}
.expand-btn:hover { border-color: var(--blue); }

/* ---- Status ------------------------------------------------------- */
.status-panel { gap: .75rem; }
.status-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .8rem;
  color: var(--text-muted);
}
.spinner {
  width: 10px; height: 10px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  flex-shrink: 0;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-track {
  height: 2px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--green);
  width: 0%;
  transition: width .35s ease;
}

/* ---- Error -------------------------------------------------------- */
.error-box {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  font-size: .8rem;
  color: var(--red);
}
.error-label {
  font-weight: 600;
  letter-spacing: .06em;
  white-space: nowrap;
  font-size: .7rem;
  padding-top: .05rem;
}

/* ---- Results header ----------------------------------------------- */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: .75rem;
}
.results-meta {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  flex-wrap: wrap;
}
.count-num {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--green);
}
.count-label { font-size: .75rem; color: var(--text-muted); }
.source-tag {
  font-size: .7rem;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: .1rem .5rem;
}
.results-actions { display: flex; gap: .5rem; }

/* ---- Filters ------------------------------------------------------ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .75rem;
}
.filter-input,
.filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: .75rem;
  padding: .45rem .75rem;
  outline: none;
  transition: border-color .15s;
  min-width: 150px;
}
.filter-input:focus,
.filter-select:focus { border-color: var(--border-focus); }
.filter-input::placeholder { color: var(--text-dim); }
.filter-select option { background: var(--surface); }

/* ---- Table -------------------------------------------------------- */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .76rem;
}
thead {
  background: var(--surface2);
  position: sticky;
  top: 0;
  z-index: 2;
}
th {
  text-align: left;
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
th.col-num { cursor: default; width: 40px; text-align: center; }
th:hover:not(.col-num) { color: var(--accent); }
.sort-icon { opacity: .25; font-size: .6rem; }
th.sorted-asc .sort-icon,
th.sorted-desc .sort-icon { opacity: 1; color: var(--green); }

tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

td {
  padding: .65rem .9rem;
  vertical-align: middle;
  color: var(--text);
}
td.col-num {
  text-align: center;
  color: var(--text-muted);
  font-size: .7rem;
  width: 40px;
}
td.name-cell { max-width: 220px; font-weight: 500; }

/* ---- Badges ------------------------------------------------------- */
.level-badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 3px;
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .04em;
  white-space: nowrap;
}
.level-bachelor   { color: var(--green);  background: rgba(78,201,148,.1);  border: 1px solid rgba(78,201,148,.2);  }
.level-master     { color: var(--blue);   background: rgba(97,175,239,.1);  border: 1px solid rgba(97,175,239,.2);  }
.level-phd        { color: var(--yellow); background: rgba(229,192,123,.1); border: 1px solid rgba(229,192,123,.2); }
.level-foundation { color: var(--purple); background: rgba(198,120,221,.1); border: 1px solid rgba(198,120,221,.2); }
.level-other      { color: var(--text-muted); background: transparent; border: 1px solid var(--border); }

.chip {
  display: inline-block;
  padding: .12rem .45rem;
  border-radius: 3px;
  font-size: .68rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}
.chip-green { color: var(--green); border-color: rgba(78,201,148,.25); background: rgba(78,201,148,.07); }
.chip-red   { color: var(--red);   border-color: rgba(224,108,117,.25); background: rgba(224,108,117,.07); }

.url-link { color: var(--blue); font-size: .72rem; }
.url-link:hover { text-decoration: underline; }
.nil { color: var(--text-dim); }

/* ---- Modal -------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.4;
}
.modal-close {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: .75rem;
  padding: .2rem .5rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: color .15s;
}
.modal-close:hover { color: var(--text); }
.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.modal-description {
  font-size: .8rem;
  color: var(--text);
  line-height: 1.7;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
}
.modal-description p  { margin-bottom: .6rem; }
.modal-description ul,
.modal-description ol  { padding-left: 1.25rem; margin-bottom: .6rem; }
.modal-description li  { margin-bottom: .2rem; }
.modal-description strong { color: var(--accent); font-weight: 600; }
.modal-section-title {
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--green);
  padding: .6rem 0 .2rem 0;
  margin-top: .25rem;
}
.modal-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: .5rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  align-items: start;
}
.modal-row:last-child { border-bottom: none; }
.modal-key {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-top: .05rem;
}
.modal-val {
  font-size: .8rem;
  color: var(--text);
  word-break: break-word;
}

/* ---- No results --------------------------------------------------- */
.no-results {
  text-align: center;
  padding: 2.5rem;
  font-size: .8rem;
  color: var(--text-muted);
}

/* ---- Footer ------------------------------------------------------- */
footer {
  border-top: 1px solid var(--border);
  padding: 1rem 2rem;
  text-align: center;
  font-size: .68rem;
  color: var(--text-dim);
}

/* ---- Utility ------------------------------------------------------ */
.hidden { display: none !important; }
