:root {
  --navy: #1f4e79;
  --navy-dark: #163a5c;
  --navy-light: #eaf1f8;
  --accent: #0f766e;
  --warn: #b45309;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f3f5f9;
  --white: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(820px 460px at 0% 0%, rgba(56, 189, 248, .07), transparent 62%),
    radial-gradient(820px 520px at 100% 0%, rgba(167, 139, 250, .07), transparent 62%),
    radial-gradient(700px 480px at 60% 100%, rgba(45, 212, 191, .05), transparent 62%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Leelawadee UI", "Segoe UI", Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 { margin: 0; font-weight: 700; }

/* ---------- toast notification ---------- */
.toast-host {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(430px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--white);
  border: 1px solid #dbe4f0;
  border-left: 4px solid var(--navy);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(19, 47, 96, .18);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
  cursor: pointer;
  animation: toastIn .22s ease-out;
}

.toast.ok { border-left-color: #0f8a4d; }
.toast.error { border-left-color: #c8312b; }

.toast-ico {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: var(--navy);
  margin-top: 1px;
}
.toast.ok .toast-ico { background: #0f8a4d; }
.toast.error .toast-ico { background: #c8312b; }

.toast-body { flex: 1; min-width: 0; word-break: break-word; }

.toast-x {
  flex: 0 0 auto;
  border: 0;
  background: none;
  color: #9aabc2;
  font-size: 12px;
  line-height: 1;
  padding: 4px 2px;
  cursor: pointer;
}
.toast-x:hover { color: var(--text); }

.toast.out { animation: toastOut .2s ease-in forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px) scale(.98); }
  to { opacity: 1; transform: none; }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-10px) scale(.98); }
}

@media (max-width: 640px) {
  .toast-host { top: 10px; right: 10px; left: 10px; max-width: none; }
}

/* ---------- topbar ---------- */
.topbar {
  background: linear-gradient(135deg, var(--navy-dark), var(--navy));
  color: #fff;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 14px; }

.logo {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700;
  border: 1px solid rgba(255,255,255,.25);
}

.brand-text h1 { font-size: 19px; letter-spacing: .2px; }
.brand-text p { margin: 2px 0 0; font-size: 13px; opacity: .8; }

.privacy {
  font-size: 12.5px;
  text-align: right;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.18);
  padding: 8px 14px;
  border-radius: 10px;
  line-height: 1.35;
}
.privacy span { opacity: .75; font-size: 11.5px; }

/* ---------- layout ---------- */
main {
  max-width: 1240px;
  margin: 22px auto 40px;
  padding: 0 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

@media (max-width: 860px) {
  .two-col { grid-template-columns: 1fr; }
}

h2 {
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
  color: #111827;
}

.step {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.step.gray { background: #9ca3af; }

/* ---------- dropzone ---------- */
.dropzone {
  border: 2px dashed #c7d2e0;
  border-radius: 12px;
  background: #fbfcfe;
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: .15s ease;
  color: #64748b;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--navy);
  background: var(--navy-light);
  color: var(--navy);
}
.dz-icon { margin-bottom: 6px; }
.dz-main { font-size: 15px; color: #334155; }
.dz-sub { font-size: 13px; margin-top: 3px; }
.link { color: var(--navy); text-decoration: underline; cursor: pointer; }

.dropzone.compact {
  padding: 16px 14px;
  border-width: 1px;
}
.dropzone.compact .dz-main { font-size: 13.5px; }
.dropzone.compact .dz-sub { font-size: 12px; }

.file-info {
  margin-top: 12px;
  background: #f0f7ff;
  border: 1px solid #cfe2f6;
  color: #164e7a;
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.file-info b { font-weight: 700; }

/* ---------- form ---------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row.three { grid-template-columns: 1.15fr 1fr 1fr; }
.field-row + .field-row, .field-row + .field { margin-top: 12px; }
.wc-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.wc-btns + .hint { margin-top: 8px; }

/* แถวเลือกรอบ Welcome Call + ปุ่มลบ + จำนวนรอบ */
.wc-round-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.wc-round-row select {
  flex: 1 1 340px;
  min-width: 0;
  max-width: 100%;
}
.wc-round-row .hint {
  flex: 0 0 auto;
  white-space: nowrap;
  margin: 0;
}
.wc-upload-row { margin-bottom: 4px; }
.wc-source-note { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.wc-h3 { font-size: 13.5px; color: var(--navy); margin: 0 0 10px; }
.wc-rule-hint { font-size: 11.5px; line-height: 1.45; }
.wc-img-panel { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.wc-mail-img {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.wc-check { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; color: var(--navy); line-height: 1.4; cursor: pointer; }
.wc-check input { margin-top: 2px; }

@media (max-width: 720px) {
  .field-row.three { grid-template-columns: 1fr; }
}

/* ---------- reports page ---------- */
.report-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
@media (max-width: 1100px) {
  .report-grid { grid-template-columns: 1fr; }
}

.report-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 4px solid var(--navy);
}
.report-card.rep-upload { border-top-color: #0f9b8e; }
.report-card.rep-summary { border-top-color: #2e75b6; }
.report-card.rep-channel { border-top-color: #6366f1; }

.rc-head { display: flex; gap: 10px; align-items: flex-start; }
.rc-head h3 { font-size: 15px; margin: 0 0 4px; color: #1e3a5f; }
.rc-head .hint { margin: 0; }
.rc-badge {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--navy-light);
  color: var(--navy);
  font-weight: 800;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.rep-upload .rc-badge { background: #e6faf6; color: #0f8b6c; }
.rep-summary .rc-badge { background: #eaf3fc; color: #1d6fb8; }
.rep-channel .rc-badge { background: #f0f0ff; color: #4f46e5; }

.rc-body { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rc-body .dash { color: var(--muted); }
.rep-round-select {
  width: 100%;
  min-width: 0;
  padding: 7px 9px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy);
  border: 1px solid #cdece1;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.rep-round-select:disabled { color: var(--muted); background: #f4f7fa; cursor: not-allowed; }
.report-card .rc-body .tdate-input { width: 122px; }
.report-card .rc-body .tdate-btn { right: 2px; }
.rc-info { min-height: 18px; }
.rc-month { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.rc-or { flex: 0 0 auto; font-size: 11.5px; color: var(--muted); }
.rc-month select {
  flex: 1 1 0;
  min-width: 0;
  padding: 6px 8px;
  font: inherit;
  font-size: 12.5px;
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.rc-month select:focus { outline: 2px solid rgba(31, 78, 121, .25); outline-offset: 1px; }
.rc-month .dash { color: var(--muted); }
.rc-actions { margin-top: auto; display: flex; justify-content: flex-end; gap: 8px; }

.rep-preview { display: flex; flex-direction: column; gap: 14px; }
.rep-preview h3 { font-size: 15px; color: #1e3a5f; margin: 0; }
.rep-preview .rp-sub { font-size: 12.5px; color: var(--muted); margin: 0; }
.rep-preview .rp-block h4 {
  font-size: 13.5px;
  color: var(--navy);
  margin: 0 0 8px;
}
.rep-preview .table-wrap { max-height: 320px; }
.rep-preview table { font-size: 12.5px; }
.rep-preview .rp-small table { max-width: 680px; }
.rep-preview .rp-small th:first-child,
.rep-preview .rp-small td:first-child { width: 160px; text-align: left; }
.rep-preview .rp-small tbody tr:last-child { background: #f1f5f9; font-weight: 700; }
.rep-preview .rp-sub-row td { background: #f4f7fb; font-weight: 600; }
.rep-preview .rp-total-row td { background: #eef3f9; font-weight: 700; }
.rep-preview th.rp-grp { background: #dbe7f3; color: #1e3a5f; text-align: center; border-left: 2px solid #fff; }
.rep-preview th.rp-sub-h { background: #eaf1f8; color: #47617f; font-weight: 600; font-size: 11.5px; }

.round-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.round-picker { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.round-picker label { font-size: 12.5px; color: var(--muted); }
.round-picker select {
  flex: 1 1 320px;
  min-width: 0;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.round-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.round-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.round-main b { font-size: 13.5px; color: var(--navy); }
.round-meta { font-size: 12px; color: var(--muted); }
.round-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.btn-secondary.small { padding: 6px 12px; font-size: 12.5px; }

/* ---------- view filter banner ---------- */
.view-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 12px;
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  color: #0f766e;
  font-size: 13.5px;
}
.view-filter .vf-icon { font-size: 15px; }
.view-filter #viewFilterText { flex: 1; }
.view-filter #viewFilterText b { color: #047857; }

/* ---------- report summary (hero) ---------- */
.report-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
}
.rs-hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  padding: 24px 28px;
  background: linear-gradient(120deg, #163a5c 0%, #1f4e79 55%, #2e75b6 100%);
  color: #fff;
  box-shadow: 0 12px 28px rgba(22, 58, 92, .22);
  cursor: pointer;
}
.rs-hero::after {
  content: '';
  position: absolute;
  right: -60px;
  top: -70px;
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .07);
}
.rs-label { font-size: 13px; opacity: .85; letter-spacing: .2px; }
.rs-value { font-size: 42px; font-weight: 800; line-height: 1.1; margin: 8px 0 12px; letter-spacing: -.8px; }
.rs-unit { font-size: 16px; font-weight: 600; margin-left: 8px; opacity: .8; }
.rs-meta { display: flex; flex-wrap: wrap; gap: 8px; }
.rs-chip {
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12.5px;
  cursor: pointer;
  transition: .15s;
}
.rs-chip:hover { background: rgba(255, 255, 255, .26); }
.rs-chip b { font-weight: 700; }
.rs-foot { margin-top: 12px; font-size: 12px; color: rgba(255, 255, 255, .72); }

.rs-side { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.rs-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  border-left: 4px solid #f59e0b;
  display: flex;
  flex-direction: column;
  justify-content: center;
  cursor: pointer;
  transition: .15s;
}
.rs-card:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(30, 60, 90, .14); }
.rs-card-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.rs-card-value { font-size: 30px; font-weight: 800; color: #b45309; margin: 4px 0 6px; line-height: 1.1; }
.rs-card-more { font-size: 11.5px; color: var(--navy); }

@media (max-width: 1100px) {
  .report-summary { grid-template-columns: 1fr; }
}

/* ---------- preview table polish ---------- */
#previewTable th, #previewTable td { padding: 7px 9px; font-size: 12.5px; }
#previewTable th { white-space: nowrap; }
#previewTable td { white-space: normal; }
#previewTable td:nth-child(1) { width: 38px; }
#previewTable td:nth-child(2) { max-width: 105px; }
#previewTable td:nth-child(3) { max-width: 175px; }
#previewTable td:nth-child(5) { white-space: nowrap; }
#previewTable td:nth-child(6) { max-width: 115px; }
#previewTable td:nth-child(7) { max-width: 105px; }
#previewTable td:nth-child(8) { max-width: 150px; }
#previewTable td:nth-child(9) { white-space: nowrap; }
#previewTable td:nth-child(10),
#previewTable td:nth-child(11),
#previewTable td:nth-child(12) { white-space: nowrap; }
#previewTable td:nth-child(13) { max-width: 115px; }
#previewTable tbody tr:nth-child(even) { background: #fafcfe; }
#previewTable tbody tr:hover { background: var(--navy-light); }
#previewTable tbody td { border-bottom: 1px solid #eef3f9; }
#previewTable tfoot td {
  background: #f2f7fc;
  font-weight: 700;
  color: var(--navy);
  border-top: 2px solid #dbe6f2;
}
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--navy-light);
  color: var(--navy);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- coloured report stat cards ---------- */
.stat.c-blue { background: linear-gradient(180deg, #eef7ff 0%, #fff 62%); border-color: #cfe4f7; border-top: 3px solid #2e75b6; }
.stat.c-blue .stat-label { color: #1d6fb8; }
.stat.c-blue .stat-value { color: #155d9c; }

.stat.c-indigo { background: linear-gradient(180deg, #f2f3ff 0%, #fff 62%); border-color: #dcdcfb; border-top: 3px solid #6366f1; }
.stat.c-indigo .stat-label { color: #5457e0; }
.stat.c-indigo .stat-value { color: #4338ca; }

.stat.c-teal { background: linear-gradient(180deg, #eefaf8 0%, #fff 62%); border-color: #c7ece6; border-top: 3px solid #0f9b8e; }
.stat.c-teal .stat-label { color: #0f8b7f; }
.stat.c-teal .stat-value { color: #0f766e; }

.stat.c-green { background: linear-gradient(180deg, #ecfdf5 0%, #fff 62%); border-color: #bbf7d0; border-top: 3px solid #10b981; }
.stat.c-green .stat-label { color: #0d8f63; }
.stat.c-green .stat-value { color: #047857; }

.stat.c-amber { background: linear-gradient(180deg, #fffbeb 0%, #fff 62%); border-color: #fde68a; border-top: 3px solid #f59e0b; }
.stat.c-amber .stat-label { color: #b45309; }
.stat.c-amber .stat-value { color: #b45309; }

.stat.c-red { background: linear-gradient(180deg, #fef2f2 0%, #fff 62%); border-color: #fecaca; border-top: 3px solid #ef4444; }
.stat.c-red .stat-label { color: #b91c1c; }
.stat.c-red .stat-value { color: #b91c1c; }

.stat.c-blue .stat-label, .stat.c-indigo .stat-label, .stat.c-teal .stat-label,
.stat.c-green .stat-label, .stat.c-amber .stat-label, .stat.c-red .stat-label {
  font-weight: 600;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: #f8fbfe;
}

/* ---------- dashboard date filter ---------- */
.dash-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 12px 18px;
}
.dash-filter .mode-label { font-size: 12.5px; font-weight: 700; color: var(--navy); }
.dash-filter .dash { color: var(--muted); }

/* ---------- Welcome Call dashboard ---------- */
.wcd-round-select {
  flex: 1 1 340px;
  min-width: 0;
  max-width: 100%;
}
#view-wcdash .insights { margin-top: 16px; }

/* ---------- inline date search result ---------- */
.date-preview {
  margin-top: 16px;
  border: 1px solid #dbe9f8;
  border-radius: 12px;
  background: #fbfdff;
  padding: 14px 16px;
}
.date-preview .dp-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 10px;
  font-size: 13.5px;
  color: #1e3a5f;
}
.date-preview .dp-head b { color: var(--navy); }
.date-preview .dp-total { font-size: 13px; color: #334155; }
.date-preview .dp-total b { color: #047857; }
.date-preview .dp-table {
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.date-preview .dp-table table { font-size: 12px; }
.date-preview .dp-table th, .date-preview .dp-table td { padding: 6px 8px; white-space: normal; }
.date-preview .dp-table td:nth-child(1) { width: 34px; }
.date-preview .dp-table td:nth-child(2),
.date-preview .dp-table td:nth-child(3),
.date-preview .dp-table td:nth-child(8),
.date-preview .dp-table td:nth-child(9) { white-space: nowrap; }
.date-preview .dp-table td:nth-child(4) { max-width: 95px; }
.date-preview .dp-table td:nth-child(5) { max-width: 105px; }
.date-preview .dp-table td:nth-child(6) { max-width: 130px; }
.date-preview .dp-table td:nth-child(7) { max-width: 110px; }
.date-preview .dp-actions { display: flex; justify-content: flex-end; margin-top: 12px; }

/* ---------- mini bar chart ---------- */
.mini-chart-card { padding: 16px 20px; }
.mini-bars { display: flex; align-items: flex-end; gap: 6px; padding: 6px 2px 0; }
.mini-bar-wrap { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; }
.mini-bar {
  width: 100%;
  max-width: 40px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #4ea1d3 0%, #1f4e79 100%);
  transition: filter .15s ease;
}
.mini-bar:hover { filter: brightness(1.18); }
.mini-bar-label { font-size: 10px; color: var(--muted); white-space: nowrap; }

/* ---------- Thai date picker (พ.ศ.) ---------- */
.tdate { position: relative; display: inline-flex; align-items: center; }
.tdate .tdate-input {
  width: 156px;
  padding: 9px 34px 9px 12px;
  border: 1px solid #d7dde6;
  border-radius: 9px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  cursor: pointer;
  outline: none;
}
.tdate .tdate-input:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(31, 78, 121, .12); }
.tdate-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--navy);
  cursor: pointer;
  font-size: 15px;
  border-radius: 7px;
}
.tdate-btn:hover { background: var(--navy-light); }

.cal-pop {
  position: absolute;
  z-index: 60;
  width: 272px;
  background: #fff;
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(16, 40, 66, .18);
  padding: 10px;
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-weight: 700; font-size: 14px; color: var(--navy); }
.cal-nav {
  width: 28px; height: 28px;
  border: none; border-radius: 8px;
  background: var(--navy-light); color: var(--navy);
  cursor: pointer; font-size: 16px; line-height: 1;
}
.cal-nav:hover { background: #dceaf8; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; font-weight: 600; }
.cal-day {
  height: 32px;
  border: none; border-radius: 8px;
  background: transparent; color: var(--text);
  font-family: inherit; font-size: 13px;
  cursor: pointer;
}
.cal-day:hover:not(.disabled) { background: var(--navy-light); }
.cal-day.active { background: var(--navy); color: #fff; font-weight: 700; }
.cal-day.disabled { color: #c3ccd8; cursor: not-allowed; }
.cal-day.nodata { color: #b8c4d4; }
.cal-day.nodata.active { color: #fff; }

/* ---------- import card ---------- */
.import-card { max-width: 1040px; }

/* ---------- date export ---------- */
.date-export-card { padding: 16px 20px; }
.date-export-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}
.date-export-text h2 { margin-bottom: 4px; }
.date-export-text .hint { margin: 0; }
.date-export-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.date-export-controls input[type="date"] { width: 180px; }.date-export-info { margin-top: 10px; }
.date-export-info b { color: var(--navy); }

.date-export-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 14px;
}
.date-mode {
  background: #f7fafd;
  border: 1px solid #e3ebf4;
  border-radius: 12px;
  padding: 12px 14px;
}
.date-mode.mode-day { background: linear-gradient(180deg, #f2f9ff 0%, #fbfdff 100%); border-color: #d5e8f9; }
.date-mode.mode-range { background: linear-gradient(180deg, #f6f5ff 0%, #fdfdff 100%); border-color: #e0dcfb; }
.date-mode.mode-upload {
  grid-column: 1 / -1;
  background: linear-gradient(180deg, #f2fdf9 0%, #fbfefd 100%);
  border-color: #cdece1;
}
.date-mode.mode-upload .mode-label { color: #0f8b6c; }
.date-mode .mode-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 8px;
}
.date-mode.mode-day .mode-label { color: #1d6fb8; }
.date-mode.mode-range .mode-label { color: #4f46e5; }
.date-mode .date-export-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.date-export-controls .dash { color: var(--muted); }
.round-select {
  flex: 1 1 240px;
  width: auto;
  min-width: 240px;
  max-width: 380px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  border: 1px solid #cdece1;
  background: #fff;
  border-radius: 10px;
  cursor: pointer;
}
.round-select:disabled { color: var(--muted); background: #f4f7fa; cursor: not-allowed; }
@media (max-width: 640px) { .round-select { min-width: 0; width: 100%; } }
@media (max-width: 1100px) {
  .date-export-modes { grid-template-columns: 1fr; }
}

@media (max-width: 1100px) {
  .date-export-modes { grid-template-columns: 1fr; }
}
.upload-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.upload-col { display: flex; flex-direction: column; min-width: 0; }
.upload-col .dropzone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.upload-col .dropzone.compact { padding: 20px 14px; }

@media (max-width: 860px) {
  .upload-row { grid-template-columns: 1fr; }
}

.sep {
  height: 1px;
  background: #e8edf4;
  margin: 22px 0 18px;
}
.run-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}
.run-row .btn-primary { width: auto; min-width: 200px; margin-top: 0; }
.field label { font-size: 12.5px; color: #4b5563; font-weight: 600; }

input[type="text"], input[type="date"], textarea, .select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d7dde6;
  border-radius: 9px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: .15s;
}
input[type="text"]:focus, input[type="date"]:focus, textarea:focus, .select:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(31,78,121,.12);
}
textarea { resize: vertical; }

.hint { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; }

/* ---------- buttons ---------- */
.btn-primary, .btn-secondary, .btn-ghost {
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: .15s;
}

.btn-primary {
  background: var(--navy);
  color: #fff;
  padding: 12px 20px;
  font-size: 15px;
  width: 100%;
  margin-top: 16px;
  box-shadow: 0 2px 6px rgba(31,78,121,.25);
}
.btn-primary:hover:not(:disabled) { background: var(--navy-dark); }
.btn-primary:disabled { background: #c3ccd8; cursor: not-allowed; box-shadow: none; }

.btn-primary.small {
  width: auto;
  margin: 0;
  padding: 9px 16px;
  font-size: 14px;
}

.btn-secondary {
  background: var(--navy-light);
  color: var(--navy);
  padding: 9px 16px;
  font-size: 14px;
  border: 1px solid #cfe0f0;
}
.btn-secondary:hover { background: #dceaf8; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 9px 14px;
  font-size: 14px;
  border: 1px solid transparent;
}
.btn-ghost:hover { color: #b91c1c; border-color: #f3c6c6; background: #fff5f5; }

/* ---------- status ---------- */
.status {
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
  min-height: 20px;
  white-space: pre-line;
}
.status.error { color: #b91c1c; }
.status.ok { color: var(--accent); }

/* ---------- stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}
.stats.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.stat {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat-value { font-size: 22px; font-weight: 700; margin-top: 3px; letter-spacing: -.3px; }
.stat.accent { background: #ecfdf5; border-color: #bbf7d0; }
.stat.accent .stat-value { color: #047857; }
.stat.warn { background: #fffbeb; border-color: #fde68a; }
.stat.warn .stat-value { color: var(--warn); }

/* ---------- table ---------- */
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.card-head h2 { margin-bottom: 0; }
.card-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-actions .select { width: auto; padding: 8px 10px; font-size: 13px; }

.chips-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.chips-wrap .chip {
  background: #eef3f9;
  color: #1e3a5f;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 12.5px;
}

.table-wrap {
  overflow: auto;
  max-height: 520px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}
th, td { padding: 8px 11px; border-bottom: 1px solid var(--line); text-align: left; }
thead th {
  position: sticky;
  top: 0;
  background: #eef3f9;
  color: #1e3a5f;
  font-weight: 700;
  font-size: 12.5px;
  z-index: 1;
  border-bottom: 1px solid #d8e2ee;
}
tbody tr:nth-child(even) { background: #fafbfd; }
tbody tr:hover { background: #f1f6fc; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.empty { text-align: center; color: var(--muted); padding: 26px; }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  background: #fef3c7;
  color: var(--warn);
}

/* ---------- settings ---------- */
.settings summary {
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 9px;
  list-style: none;
  color: #111827;
}
.settings summary::-webkit-details-marker { display: none; }
.settings summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
.settings[open] summary::after { content: "▴"; }

.settings-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.span-2 { grid-column: span 2; }
@media (max-width: 760px) {
  .settings-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
}

.settings-actions {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.settings-actions .hint { margin: 0; }

/* ---------- footer ---------- */
footer {
  text-align: center;
  color: #9aa3af;
  font-size: 12px;
  padding: 0 0 26px;
}
footer .dot { margin: 0 8px; }

/* ---------- dashboard ---------- */
.dash-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.dash-head h2 { margin-bottom: 2px; }
.dash-head .hint { margin: 0; }

.stats.kpi { margin-bottom: 16px; }

.charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.chart-card.span2 { grid-column: span 2; }
@media (max-width: 900px) {
  .charts { grid-template-columns: 1fr; }
  .chart-card.span2 { grid-column: span 1; }
}

.chart-card { min-width: 0; }

.chart-card h3 {
  font-size: 14px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 10px;
}

.chart-box {
  position: relative;
  width: 100%;
  height: 280px;
  min-width: 0;
}
.chart-box canvas { display: block; max-width: 100%; }

.insights h3 { font-size: 14px; margin-bottom: 10px; color: #334155; }
.insights ul { margin: 0; padding-left: 22px; }
.insights li { margin-bottom: 6px; font-size: 13.5px; color: #374151; }
.insights li b { color: var(--navy); }

/* ---------- clickable stat cards ---------- */
.stat.clickable { cursor: pointer; position: relative; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
.stat.clickable:hover {
  transform: translateY(-2px);
  border-color: #b9cde3;
  box-shadow: 0 6px 18px rgba(31, 78, 121, .12);
}
.stat.clickable:focus-visible { outline: 3px solid rgba(31,78,121,.25); outline-offset: 2px; }
.stat-more {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--navy);
  opacity: .6;
  font-weight: 600;
}
.stat.clickable:hover .stat-more { opacity: 1; }

/* ---------- modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); }
.modal-panel {
  position: relative;
  background: #fff;
  border-radius: 14px;
  width: min(1150px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .35);
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}
.modal-head h3 { font-size: 16px; }
.modal-head .hint { margin: 2px 0 0; }
.modal-body { padding: 14px 20px 20px; overflow: auto; }
.modal-body .table-wrap { max-height: none; }
.modal-body table { font-size: 13px; }
.modal-body tfoot td { font-weight: 700; background: #f2f6fa; border-top: 2px solid #d8e2ee; }

/* ---------- app shell / sidebar ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background:
    radial-gradient(680px 420px at 8% -8%, rgba(56, 189, 248, .22), transparent 62%),
    radial-gradient(620px 460px at 112% 6%, rgba(167, 139, 250, .24), transparent 62%),
    radial-gradient(560px 420px at 50% 112%, rgba(45, 212, 191, .18), transparent 62%),
    linear-gradient(168deg, #0a1020 0%, #121a30 52%, #1a2142 100%);
  color: #fff;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 5;
  border-right: 1px solid rgba(255, 255, 255, .07);
  box-shadow: 12px 0 34px rgba(12, 20, 40, .16);
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.side-brand .logo {
  width: 42px; height: 42px;
  border-radius: 13px;
  background: linear-gradient(135deg, #22d3ee 0%, #6366f1 55%, #a855f7 100%);
  border: 1px solid rgba(255, 255, 255, .28);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700;
  color: #fff;
  box-shadow: 0 10px 24px rgba(99, 102, 241, .45);
}
.side-brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.side-brand-text strong { font-size: 15px; letter-spacing: .2px; }
.side-brand-text span { font-size: 11.5px; color: rgba(255, 255, 255, .62); }

.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-extra {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, .1);
}
.sidebar .side-foot { margin-top: 12px; }

.side-label {
  font-size: 10px;
  letter-spacing: .16em;
  font-weight: 700;
  color: rgba(255, 255, 255, .42);
  padding: 6px 12px 8px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px 8px 8px;
  background: transparent;
  border: none;
  border-radius: 12px;
  color: rgba(255, 255, 255, .78);
  font-family: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}

/* สีประจำเมนู */
.nav-item[data-view="import"]    { --tone: #38bdf8; --tone-soft: rgba(56, 189, 248, .16);  --tone-glow: rgba(56, 189, 248, .45); }
.nav-item[data-view="detail"]    { --tone: #a78bfa; --tone-soft: rgba(167, 139, 250, .16); --tone-glow: rgba(167, 139, 250, .45); }
.nav-item[data-view="reports"]   { --tone: #f472b6; --tone-soft: rgba(244, 114, 182, .16); --tone-glow: rgba(244, 114, 182, .45); }
.nav-item[data-view="history"]   { --tone: #fbbf24; --tone-soft: rgba(251, 191, 36, .16);  --tone-glow: rgba(251, 191, 36, .45); }
.nav-item[data-view="dashboard"] { --tone: #34d399; --tone-soft: rgba(52, 211, 153, .16);  --tone-glow: rgba(52, 211, 153, .45); }
.nav-item[data-view="settings"]  { --tone: #94a3b8; --tone-soft: rgba(148, 163, 184, .16); --tone-glow: rgba(148, 163, 184, .40); }
.nav-item[data-view="welcome"]   { --tone: #22d3ee; --tone-soft: rgba(34, 211, 238, .16);  --tone-glow: rgba(34, 211, 238, .45); }
.nav-item[data-view="wcdash"]    { --tone: #fb923c; --tone-soft: rgba(251, 146, 60, .16);  --tone-glow: rgba(251, 146, 60, .45); }
.nav-item[data-view="docs"]      { --tone: #60a5fa; --tone-soft: rgba(96, 165, 250, .16);  --tone-glow: rgba(96, 165, 250, .45); }
.nav-item[data-view="docs"] .nt  { font-size: 13.5px; letter-spacing: -.1px; }

.nav-item .ni {
  flex: none;
  width: 32px; height: 32px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  background: var(--tone-soft, rgba(255, 255, 255, .08));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1);
  transition: background .18s ease, box-shadow .18s ease, transform .18s ease;
}

.nav-item .nt { flex: 1; min-width: 0; }

.nav-item:hover {
  background: rgba(255, 255, 255, .07);
  color: #fff;
  transform: translateX(2px);
}
.nav-item:hover .ni {
  background: var(--tone, rgba(255, 255, 255, .16));
  box-shadow: 0 6px 16px var(--tone-glow, rgba(0, 0, 0, .3));
}

.nav-item.active {
  background: linear-gradient(90deg, var(--tone-soft, rgba(255, 255, 255, .17)), rgba(255, 255, 255, .03));
  color: #fff;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14), 0 8px 22px rgba(0, 0, 0, .22);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 62%;
  border-radius: 0 4px 4px 0;
  background: var(--tone, #fff);
  box-shadow: 0 0 14px var(--tone-glow, rgba(255, 255, 255, .5));
}
.nav-item.active .ni {
  background: var(--tone, #fff);
  box-shadow: 0 8px 18px var(--tone-glow, rgba(0, 0, 0, .35));
  transform: scale(1.04);
}

.nav-item .nb {
  margin-left: auto;
  background: linear-gradient(135deg, #f87171, #ef4444);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  box-shadow: 0 4px 12px rgba(239, 68, 68, .45);
}
.nav-item.active .nb { background: linear-gradient(135deg, #f87171, #ef4444); }

.side-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, .7);
  padding: 9px 10px;
  border-radius: 11px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
}
.dot-ok {
  width: 8px; height: 8px; border-radius: 50%;
  background: #34d399; flex: none;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, .22);
}

.main-area {
  padding: 22px 26px 34px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.main-area footer { margin-top: auto; }
.main-area .page-head { margin-bottom: 16px; }
.page-head h1 { font-size: 20px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.view { display: flex; flex-direction: column; gap: 18px; }

.empty-state { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty-state p { margin: 0; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .side-brand-text, .nav-item .nt, .side-foot span:last-child, .side-label { display: none; }
  .side-brand { justify-content: center; padding: 4px 0 16px; }
  .nav-item { justify-content: center; padding: 8px 0; }
  .nav-item .nb { display: none; }
  .sidebar { padding: 14px 10px; }
  .main-area { padding: 18px 18px 30px; }
}

@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    overflow-x: auto;
  }
  .side-brand { border: none; padding: 0 6px 0 0; }
  .side-brand-text { display: none; }
  .side-nav { flex-direction: row; gap: 6px; }
  .side-extra { margin-top: 0; padding-top: 0; border-top: none; padding-left: 6px; border-left: 1px solid rgba(255, 255, 255, .22); }
  .nav-item { width: auto; white-space: nowrap; padding: 6px 12px; }
  .nav-item .ni { width: 26px; height: 26px; border-radius: 8px; font-size: 13px; }
  .side-label { display: none; }
  .nav-item .nt { display: inline; font-size: 13px; }
  .side-foot { display: none; }
  .main-area { padding: 16px 14px 28px; }
}

/* ---------- modern polish (colors / depth) ---------- */
.card {
  border: 1px solid #e6eef9;
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 12px 28px rgba(30, 58, 138, .06);
  transition: box-shadow .22s ease, border-color .22s ease, transform .22s ease;
}
.card:hover {
  border-color: #d8e7f9;
  box-shadow: 0 2px 5px rgba(16, 24, 40, .05), 0 18px 38px rgba(30, 58, 138, .09);
}

.page-head {
  border-left: 4px solid transparent;
  border-image: linear-gradient(180deg, #22d3ee, #6366f1 55%, #a855f7) 1;
  padding-left: 14px;
}
.page-head h1 { font-size: 21px; letter-spacing: -.2px; color: #14264a; }
.page-head p { color: #64748b; }

.step {
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  box-shadow: 0 6px 14px rgba(99, 102, 241, .35);
}
.step.gray { background: linear-gradient(135deg, #94a3b8, #64748b); box-shadow: none; }

.btn-primary {
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 48%, #7c3aed 100%);
  box-shadow: 0 8px 20px rgba(37, 99, 235, .28);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); transform: translateY(-1px); }
.btn-primary:disabled { background: #cbd5e1; }
.btn-secondary {
  background: #fff;
  border: 1px solid #d7e6f8;
  color: #1f4e79;
}
.btn-secondary:hover { background: #f2f8ff; border-color: #93c5fd; color: #17427a; }

.stat {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
}
.stat::after {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 3px;
  background: linear-gradient(90deg, #22d3ee, #6366f1);
  opacity: .85;
}
.stat.accent { background: linear-gradient(160deg, #ecfdf5, #ffffff 70%); }
.stat.warn { background: linear-gradient(160deg, #fffbeb, #ffffff 70%); }
.stat[class*="c-"] { border-top-width: 0; }
.stat.c-blue::after { background: linear-gradient(90deg, #38bdf8, #2e75b6); }
.stat.c-indigo::after { background: linear-gradient(90deg, #818cf8, #6366f1); }
.stat.c-teal::after { background: linear-gradient(90deg, #2dd4bf, #0f9b8e); }
.stat.c-green::after { background: linear-gradient(90deg, #34d399, #10b981); }
.stat.c-amber::after { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.stat.c-red::after { background: linear-gradient(90deg, #f87171, #ef4444); }

thead th { background: linear-gradient(180deg, #f4f9ff, #e9f2fd); }
.table-wrap { border-radius: 12px; }

/* ---------- empty state ---------- */
.empty-state {
  text-align: center;
  padding: 34px 24px;
  background: linear-gradient(160deg, #ffffff, #f6fbff 70%);
  border: 1px solid #e6eefb;
}
.empty-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 760px;
  margin: 0 auto;
}
.empty-ico {
  width: 64px; height: 64px;
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  background: linear-gradient(135deg, rgba(34, 211, 238, .18), rgba(124, 58, 237, .18));
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, .18);
}
.empty-state h3 { margin: 0; font-size: 17px; color: #132a4d; }
.empty-state p { margin: 0; color: #64748b; font-size: 13.5px; line-height: 1.6; }
.empty-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 6px;
}
.empty-actions .btn-primary.small { margin: 0; }
.empty-saved {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed #dbe7f7;
  width: 100%;
}
.es-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #1f4e79;
  display: block;
  margin-bottom: 8px;
}
.es-chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.es-chip {
  border: 1px solid #d9e8fb;
  background: #f6fbff;
  color: #1f4e79;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: .15s;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.es-chip:hover { background: #eaf4ff; border-color: #93c5fd; transform: translateY(-1px); }

/* ---------- คลังเอกสาร (ระเบียบ / บันทึกข้อความ) ---------- */
.doc-pending {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}
.doc-pend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #dbe7f5;
  border-radius: 11px;
  background: #f4f9ff;
}
.doc-pend-item .dp-ico { font-size: 18px; flex: none; }
.doc-pend-item .dp-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.doc-pend-item input.dp-title {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid #cfe0f2;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12.5px;
  color: #12304f;
  background: #fff;
}
.doc-pend-item input.dp-title:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, .18);
}
.doc-pend-item .dp-file {
  font-size: 11px;
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-x {
  flex: none;
  border: 1px solid transparent;
  background: transparent;
  color: #b91c1c;
  font-size: 13px;
  cursor: pointer;
  border-radius: 8px;
  padding: 4px 7px;
}
.doc-x:hover { background: #fff1f1; border-color: #fecaca; }

.doc-save-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.doc-save-row .btn-primary { width: auto; margin: 0; padding: 10px 18px; font-size: 14px; }

.doc-search {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  min-width: 210px;
  color: #1e293b;
}
.doc-search:focus { outline: none; border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(147, 197, 253, .25); }

.doc-list { display: flex; flex-direction: column; gap: 10px; }

.doc-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid #e2ecf7;
  border-radius: 13px;
  background: #fff;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.doc-item:hover {
  border-color: #bcd8f2;
  box-shadow: 0 8px 22px rgba(15, 54, 96, .08);
}
.doc-item.editing { border-color: #93c5fd; background: #f8fbff; }
.doc-item .di-ico {
  flex: none;
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
  background: #eef4fb;
  box-shadow: inset 0 0 0 1px rgba(30, 64, 110, .06);
}
.doc-item.pdf .di-ico  { background: #fef2f2; }
.doc-item.doc .di-ico  { background: #eff6ff; }
.doc-item.xls .di-ico  { background: #ecfdf5; }
.doc-item.img .di-ico  { background: #fdf4ff; }
.doc-item.txt .di-ico  { background: #f8fafc; }

.doc-item .di-body { flex: 1; min-width: 0; }
.doc-item .di-title { font-size: 14px; font-weight: 700; color: #12304f; word-break: break-word; }
.doc-item .di-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 5px;
  font-size: 11.5px; color: #64748b;
}
.doc-item .di-note {
  margin-top: 7px;
  font-size: 12.5px;
  color: #475569;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.doc-item .di-file {
  margin-top: 6px;
  font-size: 11px;
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-item .di-acts { display: flex; gap: 6px; flex-wrap: wrap; flex: none; align-items: flex-start; }
.doc-item .di-acts .btn-secondary,
.doc-item .di-acts .btn-ghost { padding: 5px 10px; font-size: 12px; }

.doc-cat {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.doc-cat.c-reg   { background: #e0f2fe; color: #0369a1; }
.doc-cat.c-memo  { background: #ede9fe; color: #5b21b6; }
.doc-cat.c-ann   { background: #fef3c7; color: #b45309; }
.doc-cat.c-ord   { background: #ffe4e6; color: #9f1239; }
.doc-cat.c-guide { background: #dcfce7; color: #15803d; }
.doc-cat.c-other { background: #f1f5f9; color: #475569; }

.doc-edit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 10px;
}
.doc-edit-grid .field label { font-size: 12px; }
@media (max-width: 860px) {
  .doc-edit-grid { grid-template-columns: 1fr; }
  .doc-item { flex-wrap: wrap; }
  .doc-item .di-acts { width: 100%; }
}

/* ---------- ระเบียบ/บันทึกข้อความ: ตัวอักษรใหญ่ขึ้น + เพิ่มสีให้อ่านง่าย ---------- */
body[data-view="docs"] .page-head {
  background: linear-gradient(115deg, #e9f4ff 0%, #f6fbff 48%, #ecfaf6 100%);
  border: 1px solid #d6e8fb;
  border-left: 6px solid #2563eb;
  border-image: none;
  border-radius: 16px;
  padding: 16px 24px;
  box-shadow: 0 12px 30px rgba(37, 99, 235, .13);
}
body[data-view="docs"] .page-head h1 {
  font-size: 28px;
  color: #0b3d7a;
  letter-spacing: -.3px;
}
body[data-view="docs"] .page-head p {
  font-size: 15px;
  font-weight: 600;
  color: #2f5f92;
  margin-top: 7px;
}

#view-docs > .card { padding: 24px 26px; }
#view-docs > .card:nth-child(1) { border-top: 4px solid #38bdf8; }
#view-docs > .card:nth-child(2) { border-top: 4px solid #10b981; }

#view-docs .card-head h2 { font-size: 20px; color: #0b3d7a; gap: 11px; }
#view-docs .step { width: 30px; height: 30px; font-size: 15px; }
#view-docs .hint { font-size: 14px; color: #506a86; }

#view-docs #docStoreInfo {
  font-size: 13px;
  font-weight: 700;
  color: #12558f;
  background: #e6f3ff;
  border: 1px solid #c7e2fb;
  border-radius: 999px;
  padding: 6px 14px;
}

#view-docs .field label { font-size: 14px; font-weight: 700; color: #17466f; }
#view-docs input[type="text"],
#view-docs textarea,
#view-docs .select,
#view-docs .doc-search {
  font-size: 15.5px;
  padding: 11px 14px;
  border-color: #cfe0f3;
}
#view-docs textarea { line-height: 1.6; }
#view-docs .tdate-input { font-weight: 700; color: #10355c; }
#view-docs .tdate .tdate-btn { font-size: 15px; }

#view-docs .dropzone {
  background: linear-gradient(160deg, #f3f9ff 0%, #eefaf7 100%);
  border: 2px dashed #7fb6ec;
  color: #1f4e79;
  padding: 34px 20px;
}
#view-docs .dropzone:hover,
#view-docs .dropzone.dragover {
  border-color: #2563eb;
  background: linear-gradient(160deg, #e7f4ff 0%, #e5fbf4 100%);
  color: #0b3d7a;
}
#view-docs .dz-icon { font-size: 34px; }
#view-docs .dz-main { font-size: 18px; font-weight: 700; color: #0f3d73; }
#view-docs .dz-sub { font-size: 14px; color: #3f6e9e; margin-top: 6px; }
#view-docs .link { font-weight: 700; }

#view-docs .doc-pend-item {
  padding: 10px 12px;
  background: #f3f9ff;
  border-color: #cfe2f6;
}
#view-docs .doc-pend-item input.dp-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #0f3d73;
  padding: 7px 10px;
}
#view-docs .doc-pend-item .dp-file { font-size: 12.5px; }
#view-docs .doc-pend-item .dp-ico { font-size: 21px; }

#view-docs .doc-save-row .btn-primary { font-size: 16.5px; padding: 13px 28px; }
#view-docs .btn-ghost,
#view-docs .btn-secondary { font-size: 14px; }

#view-docs #docCountChip {
  font-size: 13px;
  padding: 4px 13px;
  background: #dbeafe;
  color: #0b5aa5;
}

#view-docs .doc-item { padding: 16px 18px; border-color: #dbe9f8; }
#view-docs .doc-item .di-ico { width: 50px; height: 50px; font-size: 23px; border-radius: 14px; }
#view-docs .doc-item .di-title { font-size: 17px; color: #0d3a6b; }
#view-docs .doc-item .di-meta { font-size: 13px; gap: 12px; color: #4a6b8d; }
#view-docs .doc-item .di-note { font-size: 14px; color: #33506e; }
#view-docs .doc-item .di-file { font-size: 12px; }
#view-docs .doc-item .di-acts .btn-secondary,
#view-docs .doc-item .di-acts .btn-ghost {
  font-size: 13.5px;
  padding: 7px 13px;
  border: 1px solid transparent;
}
#view-docs .doc-item .di-acts [data-doc-act="open"] {
  background: #e0f2fe; border-color: #bae6fd; color: #0369a1;
}
#view-docs .doc-item .di-acts [data-doc-act="open"]:hover {
  background: #cfeafd; border-color: #7dd3fc; color: #075985;
}
#view-docs .doc-item .di-acts [data-doc-act="save"] {
  background: #dcfce7; border-color: #bbf7d0; color: #15803d;
}
#view-docs .doc-item .di-acts [data-doc-act="save"]:hover {
  background: #caf8db; border-color: #86efac; color: #166534;
}
#view-docs .doc-item .di-acts [data-doc-act="edit"] {
  background: #fef3c7; border-color: #fde68a; color: #b45309;
}
#view-docs .doc-item .di-acts [data-doc-act="edit"]:hover {
  background: #fdecc4; border-color: #fcd34d; color: #92400e;
}
#view-docs .doc-item .di-acts [data-doc-act="del"] {
  background: #fee2e2; border-color: #fecaca; color: #b91c1c;
}
#view-docs .doc-item .di-acts [data-doc-act="del"]:hover {
  background: #fdd8d8; border-color: #fca5a5; color: #991b1b;
}
#view-docs .doc-cat { font-size: 13px; padding: 3px 13px; }

/* ---------- print ---------- */
@media print {
  @page { size: A4 landscape; margin: 10mm; }

  body { background: #fff; }
  .sidebar, .page-head, .topbar, #resultSection, .settings, footer, .card-actions, .modal,
  #dropZone, #dropZone2, .file-info, #status, #calPop { display: none !important; }

  main { max-width: none; margin: 0; padding: 0; gap: 10px; }

  .card {
    box-shadow: none;
    border: 1px solid #d1d5db;
    break-inside: avoid;
    page-break-inside: avoid;
    padding: 12px 14px;
  }

  .stats { grid-template-columns: repeat(6, 1fr); gap: 8px; }
  .stat { box-shadow: none; padding: 8px 10px; }
  .stat-value { font-size: 16px; }
  .stat-label { font-size: 10.5px; }

  .charts { grid-template-columns: 1fr 1fr; gap: 10px; }
  .chart-box { height: 210px; }
  .chart-card.span2 { grid-column: span 2; }
  .chart-box { page-break-inside: avoid; }
}

/* ---------- misc ---------- */
.hidden { display: none !important; }

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
