:root {
  color-scheme: light;
  --ink: #0f2422;
  --forest: #0a2e2a;
  --accent: #0f766e;
  --accent-bright: #14b8a6;
  --grad-primary: linear-gradient(135deg, #07221f 0%, #0d423c 50%, #0f766e 100%);
  --grad-soft: linear-gradient(135deg, #e6f6f3 0%, #effaf8 100%);
  --paper: #f4f8f7;
  --surface: #ffffff;
  --line: #dbe7e4;
  --muted: #4b6561;
  --shadow-sm: 0 2px 10px rgba(7, 34, 31, 0.05);
  --shadow-md: 0 12px 32px rgba(7, 34, 31, 0.08);
  font-family: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(20, 184, 166, 0.1), transparent 40%),
    radial-gradient(circle at 88% 12%, rgba(15, 118, 110, 0.08), transparent 36%),
    linear-gradient(180deg, #eef5f3 0%, #f7faf9 100%);
  line-height: 1.65;
  font-size: 15px;
}

header {
  background: var(--grad-primary);
  color: white;
  box-shadow: 0 4px 20px rgba(7, 34, 31, 0.18);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.top, main {
  width: min(100% - 2rem, 960px);
  margin: auto;
}

.top {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

a { color: inherit; text-underline-offset: .3em; }

.wordmark {
  font: 700 clamp(1rem, 2.4vw, 1.28rem)/1.2 Georgia, serif;
  letter-spacing: .02em;
  text-decoration: none;
  color: #ffffff;
}

.nav-pill {
  text-decoration: none;
  font-size: .88rem;
  font-weight: 700;
  padding: .48rem 1.1rem;
  border-radius: 999px;
  color: #0a2e2a;
  background: linear-gradient(135deg, #ffffff 0%, #e6f6f3 100%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.14);
  transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
}

.nav-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  filter: brightness(1.03);
}

main {
  padding: clamp(1.35rem, 4vw, 2.4rem) 0 3rem;
}

.intro {
  border-inline-start: 4px solid var(--accent-bright);
  padding-inline-start: clamp(.9rem, 3vw, 1.4rem);
  margin-bottom: 1.5rem;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  font-size: clamp(1.5rem, 3.2vw, 2.15rem);
  line-height: 1.3;
  margin-bottom: .35rem;
  color: var(--forest);
  font-weight: 800;
}

h2 { margin-bottom: .75rem; font-size: 1.16rem; color: var(--forest); }
h3 { margin-bottom: .45rem; font-size: 1rem; color: var(--forest); }
p { margin-bottom: .7rem; }

.intro p, .muted { color: var(--muted); font-size: .92rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: clamp(1rem, 3vw, 1.5rem);
  border-radius: 16px;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-md);
}

label:not(.choice) {
  display: grid;
  gap: .35rem;
  margin-bottom: .9rem;
  font-weight: 600;
  font-size: .92rem;
}

input:not([type=radio]), select, textarea {
  min-width: 0;
  width: 100%;
  padding: .65rem .88rem;
  border: 1px solid #c3d5d0;
  border-radius: 10px;
  background: #fbfdfc;
  color: inherit;
  font: inherit;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

input:not([type=radio]):focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-bright);
  background: white;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.18);
}

textarea { resize: vertical; }

button {
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--grad-primary);
  color: white;
  padding: .62rem 1.3rem;
  min-height: 42px;
  font: inherit;
  font-size: .92rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(13, 66, 60, 0.22);
  transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(13, 66, 60, 0.28);
  filter: brightness(1.06);
}

button.secondary {
  background: white;
  color: var(--forest);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}

button.secondary:hover:not(:disabled) {
  background: #f2f8f6;
  filter: none;
}

button.btn-sm {
  min-height: 34px;
  padding: .35rem .85rem;
  font-size: .84rem;
  border-radius: 8px;
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

:focus-visible { outline: 3px solid var(--accent-bright); outline-offset: 2px; }

/* Login Card */
.login-card {
  max-width: 440px;
  margin: 1.5rem auto;
  padding: clamp(1.35rem, 4vw, 2rem);
  border-top: 4px solid var(--accent);
}

.login-head {
  display: flex;
  align-items: center;
  gap: .85rem;
  margin-bottom: 1.25rem;
}

.login-head h2 { margin-bottom: .15rem; }
.login-head p { margin-bottom: 0; font-size: .86rem; }

.login-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--grad-primary);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  box-shadow: 0 6px 16px rgba(13, 66, 60, 0.2);
}

.login-btn {
  width: 100%;
  margin-top: .4rem;
}

/* Assessment Wizard */
.track {
  position: sticky;
  top: .5rem;
  z-index: 2;
  padding: .9rem 1.25rem;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
}

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

.badge {
  display: inline-flex;
  align-items: center;
  padding: .18rem .65rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  color: var(--forest);
  background: var(--grad-soft);
  border: 1px solid #bce0da;
}

.count-pill {
  font-size: .85rem;
  font-weight: 700;
  color: var(--accent);
}

.spread, .actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .65rem;
}

.spread { justify-content: space-between; }
.toolbar { margin-bottom: .9rem; }

progress {
  width: 100%;
  height: .5rem;
  border-radius: 999px;
  overflow: hidden;
  accent-color: var(--accent);
  display: block;
  margin-top: .6rem;
}

progress::-webkit-progress-bar { background: #e3ece9; border-radius: 999px; }
progress::-webkit-progress-value { background: var(--grad-primary); border-radius: 999px; transition: width .25s ease; }

fieldset { min-width: 0; border: 0; margin: 0; padding: 0; }

legend {
  font-weight: 700;
  font-size: 1.06rem;
  color: var(--forest);
  padding: 0;
  margin-bottom: .9rem;
  display: flex;
  align-items: baseline;
  gap: .55rem;
}

.number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.7rem;
  height: 1.7rem;
  padding: 0 .4rem;
  border-radius: 8px;
  background: var(--grad-primary);
  color: white;
  font-size: .85rem;
  font-weight: 700;
  flex: none;
}

.choice {
  display: flex;
  align-items: center;
  gap: .7rem;
  border: 1px solid var(--line);
  padding: .68rem .95rem;
  margin-bottom: .5rem;
  border-radius: 10px;
  cursor: pointer;
  background: #fcfefd;
  transition: border-color .18s ease, background .18s ease;
}

.choice:hover {
  border-color: #93cbc3;
  background: #f2faf8;
}

.choice:has(:checked) {
  border-color: var(--accent);
  background: var(--grad-soft);
  font-weight: 600;
}

input[type=radio] {
  accent-color: var(--accent);
  flex: none;
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
}

.wizard-actions { margin-top: .25rem; }
.nav-buttons { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }

.done-card {
  text-align: center;
  padding: 2rem 1.5rem;
}

.message {
  color: #9b2c1c;
  background: #fdf2f0;
  border: 1px solid #f5cfc8;
  padding: .65rem 1rem;
  border-radius: 10px;
  font-size: .9rem;
}

.message:empty { display: none; }
#retry { margin-bottom: 1rem; }

/* Admin Tables */
.table-card { padding: 0; overflow: hidden; }
.empty-note { padding: 1.25rem; margin: 0; }

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: start;
  font-size: .9rem;
}

.data-table thead th {
  background: #f1f7f5;
  color: var(--forest);
  font-weight: 700;
  font-size: .83rem;
  padding: .72rem .9rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.data-table tbody td {
  padding: .62rem .9rem;
  border-bottom: 1px solid #eaf1ef;
  vertical-align: middle;
}

.data-table tbody tr:hover { background: #f8fbfa; }
.data-table tbody tr:last-child td { border-bottom: 0; }

.data-table tfoot td {
  background: #f1f7f5;
  font-weight: 700;
  color: var(--forest);
  padding: .7rem .9rem;
  border-top: 2px solid var(--line);
}

.col-num { width: 52px; text-align: center; }
.col-count, .col-date, .col-action { white-space: nowrap; }
.col-score { width: 120px; text-align: center; }

.q-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.65rem;
  height: 1.65rem;
  padding: 0 .35rem;
  border-radius: 7px;
  background: var(--grad-soft);
  color: var(--forest);
  border: 1px solid #bce0da;
  font-size: .8rem;
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: .18rem .6rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.is-submitted {
  background: #e3f5ef;
  color: #0b5d47;
  border: 1px solid #b3e2d3;
}

.status-pill.is-draft {
  background: #fef6e6;
  color: #92560a;
  border: 1px solid #f5dca8;
}

/* Admin Detail */
.meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: .95rem 1.25rem;
}

.meta-bar p { margin-bottom: .15rem; }

.total-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: .45rem 1.1rem;
  border-radius: 12px;
  background: var(--grad-primary);
  color: white;
  min-width: 125px;
  box-shadow: 0 4px 12px rgba(13, 66, 60, 0.2);
}

.total-badge span { font-size: .75rem; opacity: .9; }
.total-badge strong { font-size: 1.25rem; line-height: 1.3; }

.overall-card { padding: 1rem 1.25rem; }

.overall-grid {
  display: grid;
  grid-template-columns: minmax(170px, 230px) 1fr;
  gap: .85rem;
  align-items: end;
}

.overall-grid label { margin-bottom: 0; }

.scores-head {
  padding: .95rem 1.25rem .75rem;
  border-bottom: 1px solid var(--line);
}

.scores-head h3 { margin-bottom: 0; }

.score-title-text {
  font-weight: 700;
  font-size: .9rem;
  color: var(--forest);
}

.score-answer {
  font-size: .83rem;
  color: var(--muted);
  margin-top: .18rem;
  overflow-wrap: anywhere;
}

.score-input {
  text-align: center;
  font-weight: 700;
  padding: .42rem .5rem !important;
  border-radius: 8px !important;
  max-width: 96px;
  margin: auto;
}

.save-bar {
  padding: .9rem 1.25rem;
  background: #fafcfb;
  border-top: 1px solid var(--line);
}

.save-msg {
  font-size: .88rem;
  font-weight: 700;
  color: var(--accent);
}

.print-header { display: none; }

@media (max-width: 640px) {
  .top { min-height: 58px; padding-block: .5rem; }
  .overall-grid { grid-template-columns: 1fr; }
  .data-table thead th, .data-table tbody td { padding: .55rem .65rem; font-size: .84rem; }
  .col-score { width: 92px; }
  .score-input { max-width: 78px; }
  .nav-buttons { width: 100%; }
  .nav-buttons button { flex: 1; }
}

@media print {
  @page {
    size: A4;
    margin: 12mm 14mm;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body {
    background: white !important;
    font-size: 12.5px;
    line-height: 1.45;
  }

  header, .intro, .toolbar, #message, .save-bar, #pagination, #list {
    display: none !important;
  }

  main {
    width: 100%;
    padding: 0;
    margin: 0;
  }

  .print-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: .75rem;
    margin-bottom: .85rem;
    border-bottom: 2px solid var(--forest);
  }

  .print-kicker {
    font-size: .82rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: .15rem;
  }

  .print-brand {
    font-size: 1.35rem;
    margin: 0;
    color: var(--forest);
  }

  .print-meta {
    text-align: end;
    font-size: .8rem;
  }

  .print-org {
    font: 700 1rem/1.2 Georgia, serif;
    color: var(--forest);
    margin-bottom: .2rem;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid #cbd9d5;
    border-radius: 10px;
    margin-bottom: .75rem;
    break-inside: avoid;
  }

  .meta-bar {
    padding: .65rem .9rem;
  }

  .overall-card {
    padding: .7rem .9rem;
  }

  .overall-grid {
    grid-template-columns: 180px 1fr;
    gap: .65rem;
  }

  input:not([type=radio]), select {
    border: 1px solid #d5e1dd;
    background: #fafcfb;
    padding: .35rem .55rem;
    font-size: .86rem;
    border-radius: 6px;
  }

  select {
    appearance: none;
    -webkit-appearance: none;
    font-weight: 700;
    color: var(--forest);
  }

  .scores-card {
    break-inside: auto;
  }

  .scores-head {
    padding: .6rem .9rem;
  }

  .scores-head .muted {
    display: none;
  }

  .table-wrap {
    overflow: visible;
  }

  .data-table thead th {
    padding: .45rem .65rem;
    font-size: .8rem;
  }

  .data-table tbody td {
    padding: .38rem .65rem;
    font-size: .82rem;
  }

  .data-table tbody tr {
    break-inside: avoid;
  }

  .data-table tfoot td {
    padding: .48rem .65rem;
  }

  .score-input {
    border: 1px solid #b8cbc5 !important;
    padding: .25rem .35rem !important;
    max-width: 72px;
  }
}

[hidden] { display: none !important; }
