/* WatAccounting — modern clean light theme
   Tokens keep legacy names (--maroon, --gold) so existing JS inline styles keep working. */

:root {
  --ink: #1c2b3a;
  --muted: #64748b;
  --paper: #eef3f7;
  --paper-2: #e6eef4;
  --card: #ffffff;
  --gold: #1a7a7e;
  --gold-d: #145f62;
  --maroon: #0f6e73;
  --maroon-d: #0a4548;
  --line: #d5dee8;
  --line-soft: #e8eef4;
  --income: #0f8a56;
  --income-d: #0a5c39;
  --expense: #c0392b;
  --bank: #3b6ea5;
  --bank-d: #2a4f7a;
  --shadow-sm: 0 1px 2px rgba(28, 43, 58, 0.05);
  --shadow-md: 0 8px 24px rgba(28, 43, 58, 0.07);
  --radius: 12px;
  --radius-sm: 8px;
  --font-display: "Prompt", "Sarabun", sans-serif;
  --font-body: "Sarabun", "TH Sarabun New", sans-serif;
  --focus: 0 0 0 3px rgba(15, 110, 115, 0.22);
}

@keyframes wat-panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes wat-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  padding: 20px 18px 40px;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 480px at 8% -10%, rgba(26, 122, 126, 0.10), transparent 55%),
    radial-gradient(900px 420px at 100% 0%, rgba(59, 110, 165, 0.08), transparent 50%),
    linear-gradient(180deg, #f5f8fb 0%, var(--paper) 42%, var(--paper-2) 100%);
  background-attachment: fixed;
}

#wat-app,
#wat-app * {
  box-sizing: border-box;
}

#wat-app {
  --ink: #1c2b3a;
  --paper: #eef3f7;
  --card: #ffffff;
  --gold: #1a7a7e;
  --gold-d: #145f62;
  --maroon: #0f6e73;
  --line: #d5dee8;
  --income: #0f8a56;
  --expense: #c0392b;
  color: var(--ink);
  font-family: var(--font-body);
  max-width: 1200px;
  margin: 0 auto;
  animation: wat-fade-in 0.35s ease;
}

#wat-app h1,
#wat-app h2,
#wat-app h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
}

#wat-app table { border-collapse: collapse; width: 100%; }

#wat-app input,
#wat-app select,
#wat-app textarea,
#wat-app button {
  font-size: 14px;
  font-family: inherit;
}

#wat-app input,
#wat-app select,
#wat-app textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  background: var(--card);
  color: var(--ink);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

#wat-app input:hover,
#wat-app select:hover,
#wat-app textarea:hover {
  border-color: #b7c5d4;
}

#wat-app input:focus,
#wat-app select:focus,
#wat-app textarea:focus {
  outline: none;
  border-color: var(--maroon);
  box-shadow: var(--focus);
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

#wat-app button {
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
  padding: 8px 14px;
  color: var(--ink);
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.12s ease;
}

#wat-app button:hover {
  border-color: var(--gold-d);
  background: #f3fafb;
}

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

#wat-app button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

#wat-app .btn-primary {
  background: var(--maroon);
  border-color: var(--maroon);
  color: #fff;
  font-weight: 600;
}

#wat-app .btn-primary:hover {
  background: #0a4548;
  border-color: #0a4548;
  color: #fff;
}

#wat-app .btn-ghost {
  border-color: var(--line);
  background: var(--card);
  padding: 5px 10px;
}

#wat-app .btn-ghost:hover {
  background: var(--line-soft);
}

#wat-app .btn-danger {
  color: var(--expense);
  border-color: #f5cfc9;
}

#wat-app .btn-danger:hover {
  background: #fdecea;
}

.wat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 24px;
  padding: 20px 22px;
  border: 1px solid rgba(213, 222, 232, 0.9);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96) 0%, rgba(240, 248, 249, 0.92) 100%);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.wat-header::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--maroon), var(--bank));
}

.wat-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.wat-brand-mark {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--maroon), #0a4548);
  color: #fff;
  font-size: 24px;
  box-shadow: var(--shadow-sm);
}

.wat-brand h1 {
  font-size: clamp(1.35rem, 2.4vw, 1.75rem);
  line-height: 1.25;
  color: var(--ink);
}

.wat-brand h1 .ti {
  display: none;
}

#wat-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.35;
}

#wat-dev-credit,
.wat-dev-credit {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.45;
}

#wat-app.is-auth #wat-dev-credit {
  display: none;
}

.wat-auth .wat-dev-credit {
  margin: 2px 0 16px;
  font-size: 13px;
}

.wat-balances {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.wat-balance {
  min-width: 132px;
  padding: 10px 16px;
  text-align: right;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
}

.wat-balance--emphasis {
  background: linear-gradient(145deg, rgba(15, 110, 115, 0.08), rgba(59, 110, 165, 0.06));
  border-color: rgba(15, 110, 115, 0.22);
}

.wat-balance-label {
  font-size: 12px;
  color: var(--muted);
}

.wat-balance-value {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ink);
  margin-top: 2px;
  letter-spacing: -0.02em;
}

.wat-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding: 9px 14px;
  font-size: 12px;
  color: var(--gold-d);
  background: rgba(232, 242, 243, 0.85);
  border: 1px solid rgba(15, 110, 115, 0.12);
  border-radius: 10px;
}

#wat-file-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

#wat-tabs.wat-tabs {
  display: flex;
  gap: 2px;
  margin: 18px 0 14px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0;
}

#wat-app .wat-tab {
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 8px 8px 0 0;
  background: transparent;
  padding: 11px 14px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: -1px;
  transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

#wat-app .wat-tab .ti {
  margin-right: 6px;
  vertical-align: -2px;
  opacity: 0.85;
}

#wat-app .wat-tab:hover {
  color: var(--ink);
  background: rgba(15, 110, 115, 0.05);
  border-color: transparent;
}

#wat-app .wat-tab.is-active {
  color: var(--maroon);
  font-weight: 600;
  border-bottom-color: var(--maroon);
  background: transparent;
}

#wat-content {
  animation: wat-panel-in 0.28s ease;
}

#wat-content > h2,
#wat-app h2 {
  font-size: 1.15rem;
}

#wat-app th {
  font-weight: 600;
}

#wat-app tr:hover td {
  background: rgba(241, 245, 249, 0.55);
}

#wat-app code {
  font-size: 11px;
  background: var(--line-soft);
  padding: 2px 6px;
  border-radius: 4px;
}

.wat-auth {
  max-width: 420px;
  margin: 36px auto 20px;
  text-align: center;
  animation: wat-panel-in 0.32s ease;
}

.wat-auth-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(145deg, var(--maroon), #0a4548);
  color: #fff;
  font-size: 32px;
  box-shadow: var(--shadow-md);
}

.wat-auth h2 {
  font-size: 1.35rem;
  margin-bottom: 4px;
}

.wat-auth-lead {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 20px;
}

.wat-auth-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  text-align: left;
  box-shadow: var(--shadow-md);
}

.wat-auth-foot {
  font-size: 11px;
  color: var(--muted);
  margin-top: 14px;
  line-height: 1.5;
}

.wat-loading .ti-loader-2 {
  display: inline-block;
  animation: wat-spin 0.9s linear infinite;
  color: var(--maroon);
}

#wat-app input[type="date"],
#wat-app input.wat-date-input {
  min-width: 9.6rem;
  font-size: 16px;
}
.wat-date-thai {
  font-size: 12px;
  color: #64748b;
  margin-top: 3px;
  line-height: 1.3;
}

@media (max-width: 860px) {
  body { padding: 12px 10px 28px; }
  #wat-app .dash-2col { grid-template-columns: 1fr !important; }
  .wat-header { padding: 16px; }
  .wat-balances { width: 100%; }
  .wat-balance { flex: 1 1 140px; text-align: left; }
  #wat-app .wat-tab { padding: 10px 11px; font-size: 13px; }
  #wat-app input,
  #wat-app select,
  #wat-app textarea {
    font-size: 16px;
  }
}

/* Table + section readability */
#wat-app thead th {
  background: #f5f8fb;
  border-bottom: 1px solid var(--line);
}

#wat-app tbody td {
  border-bottom: 1px solid var(--line-soft);
}

/* Cash/bank ledger side panels: show ~10 data rows, scroll the rest; totals stay below */
#wat-app .ledger-side-scroll {
  max-height: 28rem; /* ≈10 dual-line list rows */
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Monthly bank status: show 6 rows, scroll the rest (up to 12 months) */
#wat-app .bank-month-status-scroll {
  max-height: 14.25rem; /* header + 6 data rows */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#wat-app .bank-month-status-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eef2f7;
  box-shadow: 0 1px 0 var(--line);
}

/* Account status cards: show 10 accounts (2 rows of 5), scroll the rest */
#wat-app .bank-acc-status-scroll {
  max-height: 11.25rem;
  overflow-y: auto;
  padding-right: 4px;
  -webkit-overflow-scrolling: touch;
}

#wat-app .ledger-side-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eef2f7;
  box-shadow: 0 1px 0 var(--line);
}

#wat-app .ledger-side-totals {
  border-top: 2px solid var(--line);
  background: var(--card);
}

#wat-app .ledger-side-totals td {
  border-bottom: none;
}

#wat-app label {
  font-weight: 500;
}

#wat-btn-logout,
#wat-btn-password,
#wat-btn-platform {
  font-size: 12px;
  padding: 5px 10px;
}

#wat-current-user {
  font-weight: 600;
  color: var(--ink);
}

.wat-presence {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}
.wat-presence::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}
.wat-presence.is-online { color: #0f6e73; }
.wat-presence.is-online::before { background: #16a34a; }
.wat-presence.is-offline { color: #64748b; font-weight: 500; }

#wat-app .wat-tab.is-active .ti {
  opacity: 1;
}
/* Auth: keep header brand-first, hide balances/status noise */
#wat-app.is-auth .wat-balances,
#wat-app.is-auth .wat-status {
  display: none;
}
#wat-app.is-auth .wat-header {
  justify-content: center;
  text-align: center;
}
#wat-app.is-platform .wat-tabs {
  display: none;
}
.wat-platform {
  max-width: 720px;
}

/* Alert / confirm modal (statement import failures, etc.) */
.wat-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(28, 43, 58, 0.42);
  animation: wat-fade-in 0.18s ease;
}

.wat-modal {
  width: min(520px, 100%);
  background: var(--card, #fff);
  border: 1px solid var(--line, #d5dee8);
  border-radius: 14px;
  box-shadow: var(--shadow-md, 0 8px 24px rgba(28, 43, 58, 0.12));
  padding: 22px 22px 18px;
  animation: wat-panel-in 0.22s ease;
}

.wat-modal-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  background: #fef3e8;
  color: #b45309;
  font-size: 22px;
}

.wat-modal-title {
  font-family: var(--font-display, "Prompt", "Sarabun", sans-serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink, #1c2b3a);
  margin: 0 0 8px;
  line-height: 1.35;
}

.wat-modal-message {
  font-size: 14px;
  color: var(--ink, #1c2b3a);
  line-height: 1.55;
  margin: 0 0 8px;
}

.wat-modal-hint {
  font-size: 12.5px;
  color: var(--muted, #64748b);
  line-height: 1.5;
  margin: 0 0 16px;
}

.wat-modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.wat-modal-actions .btn-primary,
.wat-modal-overlay .btn-primary {
  background: var(--maroon, #0f6e73);
  border: 1px solid var(--maroon, #0f6e73);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 14px;
}

.wat-modal-actions .btn-primary:hover,
.wat-modal-overlay .btn-primary:hover {
  background: #0a4548;
  border-color: #0a4548;
  color: #fff;
}

/* ผู้ใช้บัญชีเพิ่ม/แก้ได้ แต่ลบไม่ได้ — ซ่อนปุ่มลบรายการที่บันทึกแล้ว
   ยังเห็นปุ่มลบบรรทัดในฟอร์มร่าง และปุ่มลบเวลาเข้า-ออก (พิมพ์ผิดแล้วแก้เองได้) */
body.is-staff [data-del],
body.is-staff [data-adv-del],
body.is-staff [data-del-voucher],
body.is-staff [data-pv-del-voucher],
body.is-staff [data-del-staff],
body.is-staff [data-amu-del],
body.is-staff [data-amu-del-move],
body.is-staff [data-land-del],
body.is-staff [data-land-deed-del],
body.is-staff #acc-manage-del,
body.is-staff [data-del-category],
body.is-staff [data-del-preset],
body.is-staff [data-rule-del],
body.is-staff [data-weekend-rule-del],
body.is-staff [data-del-holiday] {
  display: none !important;
}

/* คนที่ดิน/วัตถุมงคลไม่เห็นยอดเงินสดและยอดรวมบนหัวเว็บ */
body.is-limited-menu #wat-cash-badge,
body.is-limited-menu #wat-total-badge {
  display: none !important;
}

/* พิมพ์จากหน้าเดิม — ห้ามใช้ iframe ขนาด 0 เพราะ Chrome/Edge จะเปิดหน้าต่างพิมพ์ไม่ออกหรือได้หน้าว่าง */
#wat-print-host {
  display: none;
}

@media print {
  html, body {
    background: #fff !important;
    background-image: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  body.wat-printing #wat-app,
  body.wat-printing .wat-modal-overlay,
  body.wat-printing iframe[data-printframe] {
    display: none !important;
  }
  body.wat-printing #wat-print-host {
    display: block !important;
    color: #000;
  }
  body.wat-printing #wat-print-host * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body.wat-printing .wat-print-sheet {
    max-width: none !important;
  }
  .no-print,
  .wat-closed-period-status {
    display: none !important;
  }
  /* กันช่องลงชื่อ/ผู้รับรองหลุดไปหน้าเปล่า */
  body.wat-printing .wat-print-sign {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    page-break-before: avoid !important;
    break-before: avoid !important;
  }
}