:root {
  --bg: #f6f0e6;
  --surface: #fff8f0;
  --surface-muted: #f2e2c5;
  --text: #3c3222;
  --muted: #7d6a52;
  --border: #dbc7a2;
  --accent: #8a6b40;
  --accent-alt: #c59b4f;
  --accent-soft: rgba(197, 155, 79, 0.16);
  --accent-deep: #5e432a;
  --highlight: #dfc08a;
  --danger: #9f2724;
  --shadow: rgba(75, 58, 30, 0.14);
}

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

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  background: linear-gradient(180deg, #fff7ed 0%, #f7ece0 40%, var(--bg) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.65;
  padding: 2rem 1rem;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: 
    repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(111, 100, 79, 0.01) 2px, rgba(111, 100, 79, 0.01) 4px);
  pointer-events: none;
  z-index: -1;
}

.page-shell {
  max-width: 1180px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* ========== HEADER SECTION ========== */

.brand-header {
  position: relative;
  padding: 2.4rem;
  border-radius: 32px;
  background: linear-gradient(135deg, var(--surface) 0%, rgba(255, 245, 228, 0.95) 100%);
  border: 2px solid rgba(138, 107, 64, 0.16);
  box-shadow: 
    0 32px 80px rgba(75, 58, 30, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
  overflow: hidden;
}

.brand-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(circle at top right, rgba(197, 155, 79, 0.14), transparent 30%),
    radial-gradient(circle at bottom left, rgba(138, 107, 64, 0.08), transparent 25%),
    repeating-linear-gradient(90deg, transparent, transparent 12px, rgba(138, 107, 64, 0.02) 12px, rgba(138, 107, 64, 0.02) 24px);
  pointer-events: none;
}

.brand-header::after {
  content: '';
  position: absolute;
  top: 1rem;
  left: 1rem;
  width: 6px;
  height: 100px;
  background: linear-gradient(180deg, var(--accent-alt), var(--accent));
  border-radius: 999px;
  opacity: 0.7;
}

.header-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2rem;
  align-items: center;
  position: relative;
  z-index: 2;
}

.lang-switcher {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  z-index: 10;
}

.lang-btn {
  border: 1px solid rgba(111, 100, 79, 0.22);
  background: rgba(255, 250, 240, 0.96);
  color: var(--text);
  padding: 0.65rem 1.2rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(77, 56, 25, 0.08);
}

.lang-btn:hover,
.lang-btn:focus-visible {
  transform: translateY(-2px);
  background: rgba(111, 100, 79, 0.08);
  border-color: rgba(111, 100, 79, 0.32);
  box-shadow: 0 8px 20px rgba(77, 56, 25, 0.12);
}

.lang-btn.active {
  background: linear-gradient(135deg, #6f644f 0%, #8b7355 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 24px rgba(111, 100, 79, 0.24);
}

.brand-logo {
  display: flex;
  gap: 1.4rem;
  align-items: center;
  z-index: 3;
}

.brand-logo-image {
  width: 96px;
  height: 96px;
  border-radius: 28px;
  background: linear-gradient(135deg, #2d2416, rgba(139, 96, 42, 0.08));
 
 border: 2px solid rgba(111, 100, 79, 0.24); 
  box-shadow: 
    0 24px 48px rgba(139, 96, 42, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  object-fit:contain;
  display: block;
}

.brand-logo-copy {
  display: grid;
  gap: 0.24rem;
}

.brand-motif {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.brand-motif span {
  flex: 1;
  min-width: 16px;
  height: 5px;
  border-radius: 999px;
  background: rgba(111, 100, 79, 0.6);
  box-shadow: 0 2px 4px rgba(111, 100, 79, 0.15);
  transition: all 0.3s ease;
}

.brand-motif span:nth-child(2) {
  background: rgba(111, 100, 79, 0.4);
}

.brand-motif span:nth-child(3) {
  background: rgba(111, 100, 79, 0.5);
}

.brand-logo-copy span {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  color: #6f644f;
  font-weight: 700;
}

.brand-logo-copy strong {
  font-size: clamp(1.4rem, 1.6vw, 1.95rem);
  letter-spacing: 0.02em;
  color: #332b1f;
  font-weight: 800;
}

.brand-tag {
  color: #7f6b39;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  margin-top: 0.5rem;
  font-size: 0.81rem;
  z-index: 1;
  font-weight: 600;
}

.brand-header h1 {
  margin-top: 0.6rem;
  font-size: clamp(2rem, 3.2vw, 3.2rem);
  line-height: 1.1;
  z-index: 1;
  letter-spacing: -0.02em;
  color: #332b1f;
}

.brand-subtitle,
.brand-note {
  margin-top: 0.6rem;
  color: #5d4c2e;
  line-height: 1.8;
  z-index: 1;
  font-size: 0.95rem;
}

.brand-note {
  font-style: italic;
  color: #7f6b39;
}

.header-intro {
  display: grid;
  gap: 0.55rem;
  align-items: start;
}

/* Notice banner shown under header intro */
.form-notice {
  margin-top: 0.2rem;
  padding: 0.9rem 1rem;
  background: linear-gradient(90deg, rgba(197,155,79,0.06), rgba(138,107,64,0.04));
  border: 1px solid rgba(138,107,64,0.14);
  color: var(--accent-deep);
  border-radius: 12px;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(75,58,30,0.06);
  font-size: 0.95rem;
}

@media (max-width: 700px) {
  .form-notice {
    font-size: 0.92rem;
    padding: 0.85rem 1rem;
  }
}

/* ========== FORM SECTION ========== */

.form-wrapper {
  margin-top: 2rem;
}

.form-card {
  background: var(--surface);
  border-radius: 32px;
  overflow: hidden;
  border: 2px solid rgba(111, 100, 79, 0.16);
  box-shadow: 
    0 32px 80px rgba(139, 96, 42, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  padding: 2.4rem;
  position: relative;
}

.form-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    repeating-linear-gradient(90deg, transparent, transparent 12px, rgba(111, 100, 79, 0.01) 12px, rgba(111, 100, 79, 0.01) 24px);
  pointer-events: none;
}

.form-card .stamp {
  position: absolute;
  top: 1.5rem;
  right: 2rem;
  font-size: 3.5rem;
  color: rgba(28, 90, 36, 0.06);
  line-height: 1;
  z-index: 0;
  transform: rotate(-15deg);
}

.counting-form {
  display: grid;
  gap: 1.8rem;
  position: relative;
  z-index: 1;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.4rem;
}

label {
  display: grid;
  gap: 0.6rem;
  font-weight: 650;
  color: #1c3d2f;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

input,
select,
textarea {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 0.95rem 1.2rem;
  font: 500 0.95rem 'Inter', system-ui, sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--surface-muted) 0%, rgba(255, 250, 240, 0.94) 100%);
  transition: all 0.3s ease;
  box-shadow: 0 10px 24px rgba(75, 58, 30, 0.08);
}

input::placeholder,
textarea::placeholder {
  color: #9a8560;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 
    0 12px 32px rgba(138, 107, 64, 0.14),
    inset 0 0 0 1px rgba(138, 107, 64, 0.08);
  transform: translateY(-2px);
  background: linear-gradient(135deg, #fffdf5 0%, #fff8ec 100%);
}

textarea {
  resize: vertical;
  min-height: 140px;
}

/* Validation Error State */
input.input-error,
select.input-error,
textarea.input-error {
  border-color: #d9534f;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 230, 230, 0.8) 100%);
  box-shadow: 0 10px 24px rgba(217, 83, 79, 0.12);
}

input.input-error:focus,
select.input-error:focus,
textarea.input-error:focus {
  border-color: #d9534f;
  box-shadow: 
    0 12px 32px rgba(217, 83, 79, 0.16),
    inset 0 0 0 1px rgba(217, 83, 79, 0.1);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-weight: 550;
  color: #2d2416;
  background: linear-gradient(135deg, var(--surface-muted) 0%, rgba(255, 250, 240, 0.8) 100%);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  transition: all 0.2s ease;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(139, 96, 42, 0.08);
}

.checkbox-grid label:hover {
  border-color: #8b7355;
  background: linear-gradient(135deg, rgba(111, 100, 79, 0.1), rgba(255, 250, 240, 0.95));
  box-shadow: 0 8px 20px rgba(139, 96, 42, 0.12);
}

.checkbox-grid input {
  width: auto;
  accent-color: #6f644f;
  cursor: pointer;
}

.full-width {
  display: grid;
  gap: 0.4rem;
}

.form-section {
  border: 1px solid rgba(138, 107, 64, 0.18);
  border-radius: 24px;
  padding: 1.8rem;
  background: linear-gradient(135deg, rgba(250, 243, 231, 0.95) 0%, rgba(255, 250, 240, 0.94) 100%);
  position: relative;
  transition: all 0.3s ease;
  box-shadow: 0 18px 40px rgba(75, 58, 30, 0.06);
}

.form-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 1.6rem;
  width: calc(100% - 3.2rem);
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-alt));
  border-radius: 999px;
}

.form-section::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    repeating-linear-gradient(90deg, transparent, transparent 18px, rgba(138, 107, 64, 0.005) 18px, rgba(138, 107, 64, 0.005) 36px);
  pointer-events: none;
  border-radius: 24px;
}

.form-section h2 {
  font-size: 1.14rem;
  margin-bottom: 1.2rem;
  color: var(--text);
  font-weight: 750;
  letter-spacing: 0.01em;
  position: relative;
  z-index: 1;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  margin-top: 1rem;
}

button {
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #6f644f 0%, #8b7355 100%);
  color: #fff;
  font-weight: 750;
  padding: 1.1rem 2rem;
  cursor: pointer;
  box-shadow: 
    0 20px 48px rgba(111, 100, 79, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: all 0.2s ease;
  font-size: 0.98rem;
  letter-spacing: 0.03em;
  position: relative;
  overflow: hidden;
}

button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.15), transparent 50%);
  pointer-events: none;
}

button:hover {
  transform: translateY(-3px);
  box-shadow: 
    0 28px 56px rgba(111, 100, 79, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

button:active {
  transform: translateY(-1px);
}

button.secondary {
  background: linear-gradient(135deg, #fff9f0 0%, #f6e7cf 100%);
  color: #6f644f;
  border: 2px solid rgba(111, 100, 79, 0.28);
  box-shadow: 0 12px 32px rgba(139, 96, 42, 0.12);
  font-weight: 700;
}

button.secondary:hover,
button.secondary:focus-visible {
  background: linear-gradient(135deg, rgba(111, 100, 79, 0.15), rgba(255, 248, 235, 1));
  border-color: #8b7355;
  box-shadow: 0 16px 40px rgba(139, 96, 42, 0.16);
}

/* Required field marker using :has for modern browsers */
label:has(input[required]), label:has(select[required]) {
  position: relative;
}
label:has(input[required])::after, label:has(select[required])::after {
  content: '*';
  color: var(--danger);
  position: absolute;
  right: -8px;
  top: 0.1rem;
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1;
}

/* Disabled button / loading state */
button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

button[data-loading="true"] {
  pointer-events: none;
}

button[data-loading="true"]::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: rgba(255,255,255,0.95);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* small helper text for fields */
.field-helper {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.45rem;
}
.field-helper.ok {
  color: #2a7a3a;
}

.toast-container {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  gap: 0.75rem;
  z-index: 1100;
  max-width: min(360px, calc(100vw - 2rem));
}

.toast {
  padding: 0.95rem 1.2rem;
  border-radius: 18px;
  background: rgba(51, 43, 31, 0.92);
  color: #fff;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateY(16px);
  transition: all 0.25s ease;
  will-change: opacity, transform;
}

.toast--success {
  background: linear-gradient(135deg, #2a7a3a, #4a8c4d);
}

.toast--error {
  background: linear-gradient(135deg, #9f2724, #bf4a39);
}

.toast--info {
  background: linear-gradient(135deg, #4a6b8a, #5f84b0);
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
}

.print-btn {
  background: linear-gradient(135deg, #6f644f 0%, #8b7355 100%);
  color: #fff;
}

.form-message {
  margin-top: 1rem;
  padding: 1.1rem 1.3rem;
  border-radius: 18px;
  font-weight: 650;
  display: none;
  line-height: 1.6;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.form-message.success {
  display: block;
  background: linear-gradient(135deg, rgba(111, 100, 79, 0.08), rgba(111, 100, 79, 0.04));
  color: #2d2416;
  border: 1px solid rgba(111, 100, 79, 0.18);
  box-shadow: 0 8px 20px rgba(111, 100, 79, 0.08);
}

.form-message.error {
  display: block;
  background: linear-gradient(135deg, rgba(217, 83, 79, 0.12), rgba(217, 83, 79, 0.08));
  color: #8b2b1f;
  border: 2px solid rgba(217, 83, 79, 0.24);
  box-shadow: 0 8px 20px rgba(217, 83, 79, 0.12);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ========== RESPONSIVE DESIGN ========== */

@media (max-width: 900px) {
  .brand-header {
    padding: 1.8rem;
    border-width: 6px;
  }

  .form-card {
    padding: 1.8rem;
    border-width: 4px;
  }

  .header-grid {
    gap: 1.5rem;
  }

  .form-row,
  .checkbox-grid {
    gap: 1rem;
  }
}

@media (max-width: 700px) {
  body {
    padding: 1.2rem 0.8rem;
  }

  .page-shell {
    width: calc(100% - 1.6rem);
  }

  .brand-header {
    padding: 1.5rem;
    border-width: 4px;
    border-radius: 24px;
  }

  .brand-header::after {
    font-size: 2.5rem;
    top: -8px;
    right: 1rem;
  }

  .header-grid {
    grid-template-columns: 1fr;
    gap: 1.2rem;
  }

  .lang-switcher {
    justify-content: center;
    margin-bottom: 0.5rem;
  }

  .brand-logo {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .brand-logo-image {
    width: 80px;
    height: 80px;
  }

  .brand-header h1 {
    font-size: clamp(1.5rem, 2.5vw, 2rem);
  }

  .form-row,
  .checkbox-grid {
    grid-template-columns: 1fr;
  }

  .checkbox-grid {
    gap: 0.8rem;
  }

  .form-card {
    padding: 1.2rem;
    border-width: 3px;
  }

  .form-section {
    padding: 1.2rem;
  }

  .actions {
    gap: 0.8rem;
  }

  button {
    padding: 0.9rem 1.6rem;
    font-size: 0.9rem;
  }
}

/* ========== PRINT STYLES ========== */

@media print {
  body {
    background: #fff;
    color: #000;
    padding: 0;
  }

  .page-shell,
  .form-wrapper,
  .brand-header,
  .form-card {
    box-shadow: none;
    background: transparent;
  }

  .page-shell {
    max-width: 100%;
    margin: 0;
  }

  .brand-header {
    border-radius: 0;
    padding: 1.5rem 1rem 1rem;
    border: none;
  }

  .brand-header::before,
  .brand-header::after,
  .form-card::before,
  .form-section::after,
  .palm-banner {
    display: none !important;
  }

  .actions,
  .print-btn,
  .secondary,
  .lang-switcher {
    display: none !important;
  }

  input,
  select,
  textarea {
    border-color: #999;
    background: transparent;
    box-shadow: none;
  }

  textarea {
    min-height: 80px;
  }

  .form-card {
    padding: 0;
    border: none;
  }
}

/* ========== SUCCESS DIALOG ========== */

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(51, 43, 31, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(2px);
}

.dialog-overlay.show {
  opacity: 1;
  visibility: visible;
}

.dialog-modal {
  background: linear-gradient(135deg, #fff9f0 0%, #f6e7cf 100%);
  border-radius: 32px;
  padding: 2.4rem;
  box-shadow: 0 48px 96px rgba(51, 43, 31, 0.32);
  max-width: 480px;
  width: 90%;
  transform: scale(0.9) translateY(20px);
  transition: all 0.3s ease;
  border: 2px solid rgba(111, 100, 79, 0.18);
  position: relative;
}

.dialog-overlay.show .dialog-modal {
  transform: scale(1) translateY(0);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.6rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid rgba(111, 100, 79, 0.12);
}

.dialog-header h2 {
  font-size: 1.6rem;
  color: #332b1f;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
}

.dialog-close {
  background: none;
  border: none;
  font-size: 2rem;
  color: rgba(111, 100, 79, 0.5);
  cursor: pointer;
  padding: 0;
  width: 2.4rem;
  height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
  line-height: 1;
}

.dialog-close:hover {
  background: rgba(111, 100, 79, 0.1);
  color: #332b1f;
}

.dialog-body {
  margin-bottom: 1.8rem;
}

.dialog-body p {
  color: #6f644f;
  font-size: 1rem;
  line-height: 1.8;
  margin: 0;
}

.dialog-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

.dialog-action-btn {
  background: linear-gradient(135deg, #6f644f 0%, #8b7355 100%);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.95rem 2rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(111, 100, 79, 0.16);
  transition: all 0.2s ease;
  letter-spacing: 0.02em;
}

.dialog-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(111, 100, 79, 0.24);
}

.dialog-action-btn:active {
  transform: translateY(0);
}

@media (max-width: 700px) {
  .dialog-modal {
    padding: 1.8rem;
    border-radius: 24px;
    max-width: 90%;
  }

  .dialog-header h2 {
    font-size: 1.4rem;
  }

  .dialog-action-btn {
    padding: 0.85rem 1.6rem;
    font-size: 0.9rem;
  }
}

