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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #eef4ff;
  --sheet: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #64748b;
  --soft-line: #cbd5e1;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Kanit", "Noto Sans Thai", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, #dbeafe 0, transparent 34%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
}

.page {
  width: 100%;
  min-height: 100vh;
  padding: 18px 12px 34px;
}

.leave-sheet {
  width: min(1220px, 100%);
  margin: 0 auto;
  background: var(--sheet);
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.1);
}

.sheet-header {
  display: grid;
  grid-template-columns: 1fr 120px;
  align-items: center;
  gap: 14px;
  border: 2px solid var(--line);
  border-bottom: none;
  padding: 10px 14px;
  text-align: center;
}

.sheet-title h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.sheet-title h2 {
  margin: 4px 0;
  font-size: 16px;
}

.sheet-title p {
  margin: 0;
  color: #334155;
  font-size: 13px;
}

.logo-box {
  display: grid;
  place-items: center;
  gap: 4px;
  color: #334155;
  font-size: 12px;
}

.logo-box img {
  width: 76px;
  height: 44px;
  object-fit: contain;
}

.top-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 14px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

.btn.primary {
  background: var(--primary);
  color: #ffffff;
}

.btn.secondary {
  background: #16a34a;
  color: #ffffff;
}

.btn.ghost {
  border: 1px solid #dbe3ef;
  background: #ffffff;
  color: #334155;
}

.employee-strip {
  display: grid;
  grid-template-columns: 1.7fr 0.75fr 1fr 1fr 0.9fr 0.8fr;
  border: 2px solid var(--line);
  border-bottom: none;
}

.employee-strip label {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 8px;
  border-right: 1px solid var(--soft-line);
  font-size: 12px;
  font-weight: 600;
  color: #334155;
}

.employee-strip label:last-child {
  border-right: none;
}

input,
select,
textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid #d9e2ef;
  border-radius: 4px;
  padding: 6px 8px;
  background: #ffffff;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.notice-box {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 13px;
  line-height: 1.6;
}

.table-wrap {
  overflow-x: auto;
  border: 2px solid var(--line);
}

.leave-table {
  width: 100%;
  min-width: 1100px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.leave-table th,
.leave-table td {
  border: 1px solid var(--line);
  padding: 5px;
  text-align: center;
  vertical-align: middle;
}

.leave-table th {
  background: #f1f5f9;
  font-weight: 700;
}

.leave-table tbody tr {
  min-height: 52px;
}

.leave-table input,
.leave-table select,
.leave-table textarea {
  min-height: 32px;
  padding: 5px;
  font-size: 12px;
}

.leave-table textarea {
  min-height: 42px;
}

.leave-table .date-col {
  width: 112px;
}

.leave-table .hours-col,
.leave-table .days-col {
  width: 70px;
}

.leave-table .reason-cell {
  width: 230px;
}

.approval-cell {
  color: #64748b;
  font-size: 11px;
  background: #f8fafc;
}

.remove-btn {
  border: none;
  border-radius: 8px;
  padding: 7px 9px;
  background: #fee2e2;
  color: #991b1b;
  font-family: inherit;
  cursor: pointer;
}

.form-status {
  min-height: 24px;
  margin: 12px 0 0;
  color: #475569;
  font-size: 14px;
}

.form-status.error {
  color: #dc2626;
}

.form-status.success {
  color: #16a34a;
}

.sheet-footer {
  margin-top: 14px;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-top: none;
  color: #475569;
  font-size: 12px;
  text-align: center;
}

@media (max-width: 860px) {
  .leave-sheet {
    padding: 12px;
  }

  .sheet-header {
    grid-template-columns: 1fr;
  }

  .employee-strip {
    grid-template-columns: 1fr 1fr;
  }

  .employee-strip label:nth-child(2n) {
    border-right: none;
  }
}

@media (max-width: 540px) {
  .page {
    padding: 10px 8px 24px;
  }

  .employee-strip {
    grid-template-columns: 1fr;
  }

  .employee-strip label {
    border-right: none;
  }

  .top-actions,
  .actions {
    display: grid;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .page {
    padding: 0;
  }

  .leave-sheet {
    width: 100%;
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .no-print {
    display: none !important;
  }

  .table-wrap {
    overflow: visible;
  }

  .leave-table {
    min-width: 0;
    font-size: 9px;
  }

  input,
  select,
  textarea {
    border: none;
    min-height: 22px;
    padding: 0;
    appearance: none;
  }
}

/* ==========================================================================
   🔙 PREMIUM BACK BUTTON (สำหรับหน้าย่อยฝั่งพนักงาน)
   ========================================================================== */

.back-nav {
  display: flex;
  align-items: center;
  margin-bottom: 16px; /* ระยะห่างจากหัวข้อด้านล่าง */
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 14px;
  background: #ffffff;
  color: var(--text);
  font-family: "Kanit", sans-serif;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(142, 153, 125, 0.03);
  cursor: pointer;
  transition: var(--pvt-ease); /* ใช้แอนิเมชันสมูทตัวเดียวกับหลัก */
}

/* เอฟเฟกต์ตอนใช้นิ้วแตะปุ่มย้อนกลับ (Elastic Tap) */
.btn-back:active {
  transform: scale(0.92);
  background: #fafaf8;
  border-color: #cbd5e1;
}

.back-icon {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary); /* ลูกศรสีเขียวพรีเมียมชี้ทาง */
  transition: var(--pvt-ease);
}

/* เพิ่มแอนิเมชันลูกศรขยับถอยหลังเบา ๆ ตอนกด */
.btn-back:active .back-icon {
  transform: translateX(-4px);
}