/* ── Reset & base ─────────────────────────────────────────────────────────── */

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

:root {
  --navy:       #1a1f3c;
  --navy-light: #252c54;
  --gold:       #8B7320;
  --gold-light: #a8892a;
  --white:      #ffffff;
  --gray-50:    #f9fafb;
  --gray-100:   #f3f4f6;
  --gray-200:   #e5e7eb;
  --gray-400:   #9ca3af;
  --gray-600:   #4b5563;
  --gray-700:   #374151;
  --green:      #166534;
  --green-bg:   #dcfce7;
  --red:        #991b1b;
  --red-bg:     #fee2e2;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--gray-700);
  background: var(--gray-50);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ───────────────────────────────────────────────────────────────── */

.site-header {
  background: var(--navy);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.site-header__logo {
  height: 38px;
  width: auto;
}

.site-header__wordmark {
  display: flex;
  flex-direction: column;
}

.site-header__name {
  color: var(--white);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  line-height: 1.2;
}

.site-header__tagline {
  color: var(--gold);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Main content ─────────────────────────────────────────────────────────── */

.page-body {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2.5rem 1rem 3rem;
}

.card {
  background: var(--white);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  width: 100%;
  max-width: 520px;
  padding: 2rem;
}

/* ── Page states ──────────────────────────────────────────────────────────── */

.state {
  display: none;
}

.state.visible {
  display: block;
}

/* ── Error / invalid link state ───────────────────────────────────────────── */

.state-error .error-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.state-error h1 {
  font-size: 1.15rem;
  color: var(--navy);
  margin-bottom: 0.5rem;
}

.state-error p {
  font-size: 0.9rem;
  color: var(--gray-600);
}

/* ── Form state ───────────────────────────────────────────────────────────── */

.form-heading {
  margin-bottom: 1.5rem;
}

.form-heading h1 {
  font-size: 1.2rem;
  color: var(--navy);
  margin-bottom: 0.25rem;
}

.form-heading p {
  font-size: 0.875rem;
  color: var(--gray-600);
}

.context-block {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-left: 3px solid var(--gold);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.context-block__row {
  display: flex;
  gap: 0.5rem;
}

.context-block__label {
  color: var(--gray-400);
  min-width: 5rem;
  flex-shrink: 0;
}

.context-block__value {
  color: var(--gray-700);
  font-weight: 500;
}

.divider {
  border: none;
  border-top: 1px solid var(--gray-200);
  margin: 1.25rem 0;
}

/* ── Form fields ──────────────────────────────────────────────────────────── */

.field-group {
  margin-bottom: 1.1rem;
}

.field-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.35rem;
}

.field-group input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: 5px;
  font-size: 0.925rem;
  color: var(--gray-700);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}

.field-group input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(26, 31, 60, 0.1);
}

.field-group input::placeholder {
  color: var(--gray-400);
}

.field-hint {
  display: block;
  font-size: 0.78rem;
  color: var(--gray-400);
  margin-top: 0.3rem;
}

/* ── Submit button ────────────────────────────────────────────────────────── */

.btn-submit {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--gold);
  color: var(--white);
  border: none;
  border-radius: 5px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: background 0.15s;
  letter-spacing: 0.02em;
}

.btn-submit:hover:not(:disabled) {
  background: var(--gold-light);
}

.btn-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* ── Inline messages ──────────────────────────────────────────────────────── */

.message {
  border-radius: 5px;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  margin-top: 1rem;
  display: none;
}

.message.visible {
  display: block;
}

.message--error {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid #fca5a5;
}

/* ── Success state ────────────────────────────────────────────────────────── */

.state-success .success-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.state-success h2 {
  font-size: 1.15rem;
  color: var(--navy);
  margin-bottom: 0.5rem;
}

.state-success p {
  font-size: 0.9rem;
  color: var(--gray-600);
}

/* ── Footer ───────────────────────────────────────────────────────────────── */

.site-footer {
  background: var(--navy);
  color: rgba(255,255,255,0.4);
  text-align: center;
  font-size: 0.75rem;
  padding: 0.9rem 1rem;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 560px) {
  .card {
    padding: 1.5rem;
  }

  .page-body {
    padding: 1.5rem 0.75rem 2rem;
  }
}

/* ── Weekly Review — wide card for the correction matrix ─────────────────── */

.card-wide {
  max-width: 1080px;
}

.context-summary {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 1.25rem;
  font-size: 0.92rem;
}

.context-summary__row strong {
  color: var(--navy);
}

.context-summary__expiry {
  color: var(--gray-600);
  font-size: 0.82rem;
  margin-top: 0.4rem;
}

/* ── Matrix table ─────────────────────────────────────────────────────────── */

.matrix-wrap {
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
}

.matrix {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
  font-size: 0.86rem;
}

.matrix th, .matrix td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--gray-200);
  border-right: 1px solid var(--gray-100);
  text-align: center;
}

.matrix thead th {
  background: var(--gray-50);
  color: var(--navy);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 2;
}

.matrix .person-col {
  text-align: left;
  font-weight: 600;
  color: var(--gray-700);
  background: var(--white);
  position: sticky;
  left: 0;
  z-index: 1;
  white-space: nowrap;
  max-width: 220px;
}

.matrix .person-col__kind {
  display: block;
  font-size: 0.72rem;
  color: var(--gray-400);
  font-weight: 400;
  text-transform: capitalize;
}

.matrix .cell-empty {
  color: var(--gray-200);
}

.matrix .cell {
  position: relative;
}

.matrix .cell select {
  width: 100%;
  font-size: 0.82rem;
  padding: 0.2rem 0.3rem;
  border: 1px solid var(--gray-200);
  border-radius: 3px;
  background: var(--white);
  color: var(--gray-700);
}

.matrix .cell.cell-changed {
  background: #fef3c7;
}

.matrix .cell.cell-original::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1px solid var(--gray-100);
  border-radius: 3px;
  pointer-events: none;
}

.matrix .cell .pd-toggle {
  font-size: 0.7rem;
  margin-top: 0.2rem;
  color: var(--gray-600);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  cursor: pointer;
}

/* ── Per-diem modal ───────────────────────────────────────────────────────── */

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-backdrop.visible {
  display: flex;
}

.modal-card {
  background: var(--white);
  border-radius: 8px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
}

.modal-card h2 {
  color: var(--navy);
  font-size: 1.05rem;
  margin-bottom: 0.4rem;
}

.modal-card p {
  font-size: 0.875rem;
  color: var(--gray-600);
  margin-bottom: 1rem;
}

.travel-list {
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.travel-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.75rem;
  background: var(--gray-50);
  border-radius: 4px;
  font-size: 0.875rem;
}

.travel-row.missing {
  background: var(--red-bg);
  border-left: 3px solid var(--red);
}

.travel-row.added {
  background: #fef3c7;
  border-left: 3px solid var(--gold);
}

.travel-row__person {
  font-weight: 600;
  color: var(--gray-700);
}

.travel-row__date {
  color: var(--gray-600);
  font-size: 0.8rem;
}

.travel-row label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  cursor: pointer;
}

#notes-field {
  display: none;
  margin: 1rem 0;
}

#notes-field.visible {
  display: block;
}

#notes-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--red);
  margin-bottom: 0.4rem;
}

#notes-field textarea {
  width: 100%;
  min-height: 80px;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: 5px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--gray-700);
  resize: vertical;
}

.btn-row {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

.btn-row .btn-primary {
  flex: 1;
}

/* ── Approve confirmation page ───────────────────────────────────────────── */

.approve-summary {
  background: var(--gray-50);
  border-left: 3px solid var(--green);
  border-radius: 0 4px 4px 0;
  padding: 1rem 1.25rem;
  margin: 1rem 0 1.5rem;
}

.approve-summary p {
  margin: 0.2rem 0;
  font-size: 0.92rem;
}

.approve-summary strong {
  color: var(--navy);
}

.btn-approve {
  background: var(--green);
  color: var(--white);
  border: 0;
  border-radius: 5px;
  padding: 0.7rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  width: 100%;
}

.btn-approve:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-approve:hover:not(:disabled) {
  background: #135228;
}

/* btn-primary alias for matching gold button style across all pages */
.btn-primary {
  background: var(--gold);
  color: var(--white);
  border: none;
  border-radius: 5px;
  padding: 0.65rem 1.25rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.02em;
}

.btn-primary:hover:not(:disabled) {
  background: var(--gold-light);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
  border-radius: 5px;
  padding: 0.65rem 1.25rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-ghost:hover {
  background: var(--gray-50);
}
