:root {
  --bg: #f2f6fb;
  --panel: #ffffff;
  --text: #10263f;
  --muted: #58708b;
  --line: #dbe5ef;
  --primary: #0c6de8;
  --primary-2: #00a57e;
  --warn: #e98a12;
  --danger: #c23f2a;
  --radius: 18px;
  --shadow: 0 20px 40px rgba(12, 30, 61, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Tajawal", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f7fafc 0%, var(--bg) 100%);
}

.ambient {
  display: none;
}

.ambient-a {
  width: 280px;
  height: 280px;
  top: -60px;
  right: -80px;
  background: #78c8ff;
}

.ambient-b {
  width: 300px;
  height: 300px;
  left: -90px;
  bottom: -80px;
  background: #7af0c0;
}

.page-header,
.page-content {
  width: min(1220px, 94%);
  margin-inline: auto;
}

.page-header {
  margin-top: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  background: #ffffff;
  border: 1px solid rgba(15, 43, 70, 0.08);
  border-radius: calc(var(--radius) + 4px);
  padding: 14px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(15, 43, 70, 0.12);
  background: #fff;
  box-shadow: 0 8px 18px rgba(8, 50, 110, 0.14);
}

.brand-logo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.brand-kicker {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.brand h1 {
  margin: 2px 0 0;
  font-size: clamp(1.15rem, 2vw, 1.55rem);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.back-link {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.page-content {
  margin-top: 16px;
  margin-bottom: 28px;
}

.auth-card,
.panel {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid rgba(16, 38, 63, 0.08);
  box-shadow: var(--shadow);
  padding: 18px;
}

.auth-card {
  width: min(520px, 100%);
  margin-inline: auto;
}

.auth-card h2 {
  margin: 0;
  font-size: 1.18rem;
}

.auth-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 600;
}

.auth-form {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  color: #1f3f5e;
}

.auth-form input {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  font-family: inherit;
  font-size: 0.95rem;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(12, 109, 232, 0.16);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 10px;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.panel-tools {
  margin-bottom: 12px;
}

.search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search-input {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.95rem;
}

.filter-input {
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.95rem;
  background: #fff;
  color: var(--text);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(12, 109, 232, 0.16);
}

.filter-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(12, 109, 232, 0.16);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.card {
  background: linear-gradient(150deg, #ffffff, #f8fbff);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-clickable {
  cursor: pointer;
}

.card-clickable:hover {
  border-color: #b8d2f6;
  box-shadow: 0 12px 24px rgba(12, 109, 232, 0.08);
}

.card-clickable:focus-visible {
  outline: 3px solid rgba(12, 109, 232, 0.35);
  outline-offset: 2px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.id-badge {
  font-weight: 800;
  color: #0c3b63;
  background: #e7f1fe;
  border: 1px solid #cfe2ff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.85rem;
}

.status {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-completed {
  background: #e7f9f3;
  color: #0f7f5f;
}

.status-draft {
  background: #fff4e6;
  color: #9b5d00;
}

.registration-status-badge {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-completed-accepted {
  background: #dcfce7;
  color: #166534;
}

.status-accepted-incomplete {
  background: #dbeafe;
  color: #1e40af;
}

.status-incomplete {
  background: #fef9c3;
  color: #854d0e;
}

.status-rejected {
  background: #fee2e2;
  color: #991b1b;
}

.card-status-completed_accepted {
  border-right: 4px solid #22c55e;
}

.card-status-accepted_incomplete {
  border-right: 4px solid #3b82f6;
}

.card-status-incomplete {
  border-right: 4px solid #eab308;
}

.card-status-rejected {
  border-right: 4px solid #ef4444;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.card-actions .view-profile-link {
  flex: 1;
  margin-top: 0;
}

.card-actions .btn-sm {
  padding: 8px 12px;
  font-size: 0.85rem;
}

.notes-preview {
  margin: 0;
  font-size: 0.88rem;
  color: #58708b;
  background: #f8fafc;
  padding: 8px 10px;
  border-radius: 8px;
  white-space: pre-wrap;
}

.card-editor {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.card-editor summary {
  cursor: pointer;
  font-weight: 700;
  color: #174a78;
}

.editor-grid {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.editor-grid label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  color: #1f3f5e;
}

.editor-grid input,
.editor-grid select,
.editor-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.92rem;
}

.editor-grid textarea {
  resize: vertical;
}

.editor-notes-wrap {
  grid-column: 1 / -1;
}

.card-actions-editor .view-profile-link {
  flex: 1 1 160px;
}

.card h3 {
  margin: 0;
  font-size: 1.08rem;
}

.card .sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.meta {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.meta li {
  font-size: 0.92rem;
  color: #24415e;
}

.meta strong {
  color: #123154;
}

.view-profile-link {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #0c4d8d;
  background: #eaf3ff;
  border: 1px solid #cfe2ff;
  border-radius: 11px;
  padding: 9px 12px;
  font-weight: 700;
  width: 100%;
}

.view-profile-link:hover {
  background: #dcecff;
}

.state {
  margin: 14px 0 0;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
}

.state.error {
  color: var(--danger);
}

.pager {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(120deg, var(--primary), #4b9bff);
}

.btn-ghost {
  color: #174a78;
  background: #eaf3ff;
}

.btn-danger {
  color: #fff;
  background: linear-gradient(120deg, #d44537, #b92f26);
}

.btn-warning {
  color: #fff;
  background: linear-gradient(120deg, #d28810, #b96a00);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.9rem;
}

.page-info {
  min-width: 120px;
  text-align: center;
  font-weight: 700;
  color: #345675;
}

.hidden {
  display: none !important;
}

.field-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 4px;
}

.field-stat-pill {
  border: 1px solid #d5e5f6;
  background: #f8fbff;
  color: #1a466f;
  border-radius: 999px;
  padding: 8px 12px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

.field-stat-pill span {
  display: inline-flex;
  min-width: 24px;
  justify-content: center;
  margin-inline-start: 6px;
  border-radius: 999px;
  background: #e4efff;
  padding: 2px 8px;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(16, 38, 63, 0.36);
  padding: 16px;
  z-index: 50;
}

.modal-card {
  width: min(480px, 100%);
  background: #fff;
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.modal-card h3 {
  margin: 0 0 10px;
}

.modal-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

@media (max-width: 1100px) {
  .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-form .btn,
  .search-input,
  .filter-input {
    width: 100%;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .pager {
    flex-wrap: wrap;
  }

  .header-actions {
    justify-content: space-between;
  }
}
