* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  line-height: 1.5;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  text-align: left;
}

.header-title {
  flex: 1;
  text-align: center;
}

.header-links {
  display: flex;
  gap: 0.75rem;
  font-size: 0.85rem;
  position: absolute;
  right: 1rem;
  top: 2rem;
}

.header-links a {
  color: #0071e3;
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border: 1px solid #0071e3;
  border-radius: 6px;
  transition: all 0.2s;
}

.header-links a:hover {
  background: #0071e3;
  color: white;
}

h1 {
  font-size: 2.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  cursor: pointer;
}

h1:hover {
  color: #0071e3;
}

.subtitle {
  color: #86868b;
  font-size: 1.1rem;
}

.info-note {
  color: #86868b;
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.info-note a {
  color: #0071e3;
  text-decoration: none;
}

.info-note a:hover {
  text-decoration: underline;
}

.stats {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #86868b;
}

/* Search and filters row */
.controls {
  display: flex;
  gap: 0.75rem;
  max-width: 900px;
  margin: 0 auto 2rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.search-box {
  flex: 1;
  min-width: 200px;
  max-width: 300px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 0.6rem 0.75rem 0.6rem 2.25rem;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input:focus {
  outline: none;
  border-color: #0071e3;
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.search-box::before {
  content: "⌕";
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  color: #86868b;
  font-size: 1rem;
}

/* Dropdown filters */
.filter-dropdown {
  position: relative;
}

.filter-trigger {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  background: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-trigger:hover {
  border-color: #0071e3;
}

.filter-trigger.has-selection {
  background: #0071e3;
  border-color: #0071e3;
  color: #fff;
}

.filter-trigger .arrow {
  font-size: 0.6rem;
  transition: transform 0.2s;
}

.filter-dropdown.open .filter-trigger .arrow {
  transform: rotate(180deg);
}

.filter-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 160px;
  background: #fff;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
  display: none;
  max-height: 240px;
  overflow-y: auto;
}

.filter-dropdown.open .filter-menu {
  display: block;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}

.filter-option:hover {
  background: #f5f5f7;
}

.filter-option.selected {
  background: #e8f4fd;
  color: #0071e3;
}

.filter-option .check {
  width: 16px;
  height: 16px;
  border: 1px solid #d2d2d7;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  flex-shrink: 0;
  color: transparent;
}

.filter-option.selected .check {
  background: #0071e3;
  border-color: #0071e3;
  color: #fff;
}

.sort-select {
  padding: 0.6rem 0.75rem;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  font-size: 0.85rem;
  background: #fff;
  cursor: pointer;
}

.sort-select:focus {
  outline: none;
  border-color: #0071e3;
}

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1rem;
  align-items: start;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: box-shadow 0.2s, transform 0.2s;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  min-height: 280px;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  transform: translateY(-2px);
}

.card:active {
  transform: translateY(0);
}

.card-header {
  margin-bottom: 0.5rem;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1d1d1f;
}

.card-title a {
  color: inherit;
  text-decoration: none;
}

.card-title a:hover {
  color: #0071e3;
  text-decoration: underline;
}

.card-source {
  font-size: 0.8rem;
  color: #86868b;
  margin-bottom: 0.5rem;
}

.card-deadline {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.deadline-date {
  color: #1d1d1f;
}

.deadline-relative {
  color: #86868b;
  font-weight: 400;
}

.deadline-urgent {
  color: #dc2626;
}

.deadline-soon {
  color: #d97706;
}

.status-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 0.5rem;
}

.status-open {
  background: #dcfce7;
  color: #166534;
}

.status-closed {
  background: #fee2e2;
  color: #991b1b;
}

.card.expired {
  opacity: 0.6;
}

.card.expired:hover {
  opacity: 0.8;
}

.card-description {
  font-size: 0.9rem;
  color: #424245;
  margin-bottom: 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
  cursor: pointer;
}

.card-description.expanded {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.tag {
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.tag-level,
.tag-citizenship,
.tag-type,
.tag-field,
.tag-funding {
  background: #f0f0f0;
  color: #555;
}

.card-visit {
  display: inline-block;
  color: #0071e3;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  margin-top: auto;
}

.card-visit:hover {
  text-decoration: underline;
}

.no-results {
  text-align: center;
  padding: 3rem;
  color: #86868b;
  font-size: 1.1rem;
}

.last-updated {
  text-align: center;
  margin-top: 2rem;
  font-size: 0.8rem;
  color: #86868b;
}

/* Pagination */
.pagination {
  margin-top: 2rem;
  text-align: center;
}

.pagination-inner {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.page-btn {
  padding: 0.5rem 0.75rem;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  background: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
  border-color: #0071e3;
  color: #0071e3;
}

.page-btn.active {
  background: #0071e3;
  border-color: #0071e3;
  color: #fff;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-ellipsis {
  padding: 0 0.25rem;
  color: #86868b;
}

.page-info {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: #86868b;
}

@media (max-width: 600px) {
  .header-links {
    position: static;
    justify-content: center;
    margin-top: 1rem;
  }
  .header-top {
    flex-direction: column;
  }
  h1 { font-size: 1.8rem; }
  .cards { grid-template-columns: 1fr; }
  .controls { flex-direction: column; align-items: stretch; }
  .search-box { max-width: none; }
  .filter-dropdown { width: 100%; }
  .filter-trigger { width: 100%; justify-content: space-between; }
  .filter-menu { width: 100%; }
}
