:root {
  --navy: #1B1F6B;
  --navy-deep: #12154a;
  --red: #E63329;
  --paper: #F7F3E8;
  --paper-line: #d8cfb8;
  --ink: #2b2b2b;
  --gold: #C99A2E;
  --green: #2E7D4F;
  --radius: 4px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Work Sans', sans-serif;
  -webkit-font-smoothing: antialiased;
}

.tricolor-bar {
  height: 6px;
  width: 100%;
  background: linear-gradient(90deg, var(--red) 0 33%, #ffffff 33% 66%, var(--navy) 66% 100%);
}

/* ---------- Masthead ---------- */

.masthead {
  background: var(--navy);
  padding: 22px 16px 26px;
  border-bottom: 3px solid var(--red);
}

.masthead-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.15);
}

.masthead-text h1 {
  font-family: 'Zilla Slab', serif;
  font-weight: 700;
  font-size: 1.5rem;
  color: #fff;
  margin: 0;
  line-height: 1.15;
}

.masthead-text h1 span {
  display: block;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--gold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
}

.tagline {
  margin: 6px 0 0;
  font-size: 0.8rem;
  font-style: italic;
  color: #cfd2ea;
}

/* ---------- Ledger page ---------- */

.ledger-wrap {
  max-width: 640px;
  margin: 28px auto 40px;
  padding: 0 16px;
}

.ledger-page {
  position: relative;
  background:
    repeating-linear-gradient(
      to bottom,
      var(--paper) 0px,
      var(--paper) 37px,
      var(--paper-line) 38px
    );
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  padding: 28px 24px 24px;
  box-shadow: 0 8px 24px rgba(27, 31, 107, 0.12);
}

.ledger-page::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 54px;
  width: 2px;
  background: rgba(230, 51, 41, 0.28);
  pointer-events: none;
}

.ledger-topline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: 'Zilla Slab', serif;
  font-size: 0.82rem;
  color: var(--navy);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1.5px dashed var(--paper-line);
}

.entry-no em {
  font-style: normal;
  font-weight: 700;
  color: var(--red);
}

/* ---------- Form ---------- */

.field-row {
  margin-bottom: 18px;
}

.field-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field-row.two-col > div {
  margin-bottom: 0;
}

label {
  display: block;
  font-family: 'Zilla Slab', serif;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--navy-deep);
  margin-bottom: 6px;
}

label small {
  font-family: 'Work Sans', sans-serif;
  font-weight: 400;
  font-size: 0.72rem;
  color: #6b6f8f;
}

input, select, textarea {
  width: 100%;
  border: none;
  border-bottom: 2px solid var(--navy);
  background: transparent;
  font-family: 'Work Sans', sans-serif;
  font-size: 1rem;
  color: var(--ink);
  padding: 6px 4px;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

textarea { resize: vertical; }

input:focus, select:focus, textarea:focus {
  border-color: var(--red);
  background: rgba(230, 51, 41, 0.04);
}

input::placeholder, textarea::placeholder {
  color: #a9a49a;
  font-style: italic;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%231B1F6B' stroke-width='2' fill='none' fill-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  padding-right: 22px;
}

.ledger-divider {
  text-align: center;
  margin: 22px 0 20px;
  position: relative;
}

.ledger-divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  border-top: 1.5px dashed var(--paper-line);
}

.ledger-divider span {
  position: relative;
  background: var(--paper);
  padding: 0 12px;
  font-family: 'Zilla Slab', serif;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--red);
}

.birthday-row label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.khaas-badge {
  background: var(--gold);
  color: #fff;
  font-family: 'Work Sans', sans-serif;
  font-weight: 600;
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- Stamp button ---------- */

.stamp-btn {
  display: block;
  width: 100%;
  margin-top: 26px;
  padding: 15px;
  background: var(--red);
  color: #fff;
  border: 2px solid var(--navy-deep);
  border-radius: var(--radius);
  font-family: 'Zilla Slab', serif;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  transform: rotate(-1deg);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  box-shadow: 3px 3px 0 var(--navy-deep);
}

.stamp-btn:hover { background: #d12a21; }

.stamp-btn:active,
.stamp-btn.stamping {
  transform: rotate(0deg) scale(0.96);
  box-shadow: 0 0 0 var(--navy-deep);
}

.stamp-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.form-note {
  text-align: center;
  font-size: 0.72rem;
  color: #8a8676;
  margin-top: 14px;
}

/* ---------- Success / Error screens ---------- */

.success-screen, .error-screen {
  display: none;
  text-align: center;
  padding: 30px 10px 10px;
}

.success-screen.visible, .error-screen.visible {
  display: block;
}

.stamp-mark {
  display: inline-block;
  border: 4px solid var(--green);
  color: var(--green);
  font-family: 'Zilla Slab', serif;
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: 0.12em;
  padding: 10px 22px;
  border-radius: 8px;
  transform: rotate(-6deg);
  margin-bottom: 16px;
}

.stamp-mark.error {
  border-color: var(--red);
  color: var(--red);
}

.success-screen h2, .error-screen h2 {
  font-family: 'Zilla Slab', serif;
  margin: 0 0 6px;
  color: var(--navy-deep);
}

.link-btn {
  margin-top: 18px;
  background: none;
  border: none;
  color: var(--navy);
  text-decoration: underline;
  font-family: 'Work Sans', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
}

/* ---------- Footer ---------- */

.page-footer {
  text-align: center;
  font-size: 0.72rem;
  color: #8a8676;
  padding-bottom: 18px;
}

/* ---------- Responsive ---------- */

@media (max-width: 420px) {
  .field-row.two-col {
    grid-template-columns: 1fr;
  }
  .masthead-text h1 { font-size: 1.25rem; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .stamp-btn { transition: none; }
}

/* ---------- Focus visibility ---------- */

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
