:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --border: #e4e7ec;
  --border-strong: #d8dde3;

  --text: #172033;
  --muted: #667085;

  --primary: #16a86b;
  --primary-strong: #12905b;
  --mint: #eaf8f0;
  --event-bg: #ddf7e8;
  --today-bg: #eefaf3;

  --sun: #e96a6a;
  --sat: #159a70;

  --warn: #e8912f;
  --warn-bg: #fff2df;
  --danger: #e4574f;

  --shadow-card: 0 6px 22px rgba(20, 28, 46, 0.07);
  --shadow-pop: 0 16px 40px rgba(20, 28, 46, 0.16);
  --radius-card: 16px;
  --radius: 10px;

  --header-h: 68px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans Thai", "Sarabun", "Leelawadee UI", Tahoma, system-ui, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; }

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 14px;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease,
    color 0.15s ease, transform 0.06s ease;
}
button:hover { background: #eef1f3; }
button:active { transform: translateY(0.5px); }
button:disabled { opacity: 0.5; cursor: default; }

.btn-primary,
.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(22, 168, 107, 0.28);
}
.btn-primary:hover,
.primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  font-size: 14.5px;
}
.ghost { background: transparent; }
.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.danger:hover { background: #d64c44; border-color: #d64c44; }
.mini { padding: 5px 11px; font-size: 12.5px; }
.btn-soft { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; }
.btn-soft svg { opacity: 0.75; }

select, input, textarea {
  font: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  width: 100%;
}
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 168, 107, 0.18);
}
textarea { resize: vertical; }

/* ---------------- layout shell ---------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  height: var(--header-h);
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-icon { font-size: 26px; line-height: 1; }
.brand-text h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; }
.brand-text p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.header-actions { display: flex; align-items: center; gap: 10px; }
.pop-wrap { position: relative; }
.icon-btn {
  position: relative;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--text);
  border-radius: 11px;
}
.icon-btn.open,
.chip-btn.open { border-color: var(--primary); background: var(--mint); color: var(--primary); }
.dot-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
}
.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  font-size: 14px;
  max-width: 220px;
}
.chip-btn #acctLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-btn .caret { color: var(--muted); font-size: 11px; }

.popover {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 300px;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  box-shadow: var(--shadow-pop);
  padding: 7px;
  z-index: 40;
  max-height: 66vh;
  overflow: auto;
}
.pop-head { font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 9px 11px 6px; }
.pop-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 9px 11px;
  border-radius: 9px;
}
.pop-row:hover { background: #f2f5f6; }
.pop-row-main { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.pop-row-sub { font-size: 12px; color: var(--muted); margin-left: 14px; }
.pr-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: #b6bec9; }
.pop-row.r-overdue .pr-dot { background: var(--danger); }
.pop-row.r-today .pr-dot { background: var(--warn); }
.pr-tag { font-size: 10.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px; }
.pop-row.r-overdue .pr-tag { background: #fdecec; color: var(--danger); }
.pop-row.r-today .pr-tag { background: var(--warn-bg); color: #b5721a; }
.dot-badge { background: var(--warn); }
.dot-badge.is-overdue { background: var(--danger); }
.pop-empty, .pop-more { padding: 14px 11px; font-size: 12.5px; color: var(--muted); text-align: center; }
.pop-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 9px 11px;
  border-radius: 9px;
  font-size: 13.5px;
}
.pop-item:hover { background: #f2f5f6; }
.pop-item.active { color: var(--primary); font-weight: 600; background: var(--mint); }

.app-shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); }

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--header-h));
  padding: 18px 16px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.side-nav { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  padding: 12px 14px;
}
.nav-item:hover { background: #f2f5f6; color: var(--text); }
.nav-item .ni-icon { font-size: 17px; width: 20px; text-align: center; }
.nav-item.active { background: var(--mint); color: var(--primary); font-weight: 600; }
.sidebar-art { margin-top: auto; padding: 18px 10px 4px; opacity: 0.72; }
.sidebar-art svg { width: 100%; max-width: 190px; height: auto; display: block; margin: 0 auto; }

.main-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: calc(100vh - var(--header-h));
  padding: 20px 24px 24px;
}
.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 16px 18px 18px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 18px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#periodLabel {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  min-width: 168px;
  text-align: center;
}
.nav-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 19px;
  line-height: 1;
  border-radius: 10px;
  color: var(--text);
}
.btn-soft { padding: 9px 13px; }
.cust-filter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
}
.cust-filter select { width: auto; min-width: 160px; height: 38px; }

.seg { display: inline-flex; background: #ebeff1; border-radius: 10px; padding: 4px; gap: 3px; }
.seg-btn {
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 7px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}
.seg-btn:hover { background: rgba(255, 255, 255, 0.65); }
.seg-btn.is-active {
  background: var(--mint);
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(20, 28, 46, 0.08);
}
body[data-view="dashboard"] .seg,
body[data-view="customers"] .seg { display: none; }
body[data-view="customers"] .tb-left { display: none; }
body:not([data-view="customers"]) #printBtn { display: none; }

/* ---------------- calendar ---------------- */
#view { flex: 1; display: flex; flex-direction: column; margin-top: 14px; }
.calendar { flex: 1; display: flex; flex-direction: column; }
.cal { flex: 1; display: flex; flex-direction: column; }

.calendar-head,
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.calendar-head { margin-bottom: 8px; }
.calendar-grid { flex: 1; grid-auto-rows: minmax(116px, 1fr); }
.calendar-grid.week { grid-auto-rows: minmax(320px, 1fr); }

.dow {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 4px 0;
  letter-spacing: 0.02em;
}
.calendar-head > .dow:first-child { color: var(--sun); }
.calendar-head > .dow:nth-child(7) { color: var(--sat); }

.cell {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 9px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  min-height: 0;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.cell:hover {
  border-color: #bfe6d2;
  box-shadow: 0 4px 14px rgba(22, 168, 107, 0.12);
}
.cell.empty { background: transparent; border-color: transparent; cursor: default; box-shadow: none; }
.cell.today {
  border: 2px solid var(--primary);
  background: var(--today-bg);
  padding: 8px 8px 7px;
}
.cell-head { display: flex; align-items: baseline; gap: 6px; }
.daynum { font-weight: 700; font-size: 14px; color: var(--text); }
.cell-dow { display: none; font-size: 12px; font-weight: 600; color: var(--muted); }
.calendar-grid > .cell:nth-child(7n + 1) .daynum,
.calendar-grid > .cell:nth-child(7n + 1) .cell-dow { color: var(--sun); }
.calendar-grid > .cell:nth-child(7n) .daynum,
.calendar-grid > .cell:nth-child(7n) .cell-dow { color: var(--sat); }
.cell.today .daynum,
.cell.today .cell-dow { color: var(--primary); }

.chips { display: flex; flex-direction: column; gap: 6px; overflow: auto; }
.chip {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-left: 3px solid var(--primary);
  border-radius: 9px;
  padding: 8px 10px;
  background: var(--event-bg);
  transition: box-shadow 0.15s ease;
}
.chip:hover { box-shadow: 0 3px 12px rgba(20, 28, 46, 0.12); }
.chip.is-pending { background: var(--warn-bg); border-left-color: var(--warn); }
.chip-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 5px; }
.chip-status { font-size: 11.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.chip-status.s-done { color: var(--primary-strong); }
.chip-status.s-pending { color: #b5721a; }
.chip-move { font-size: 11.5px; color: #5b53e0; display: inline-flex; align-items: center; gap: 4px; }
.chip-more { color: var(--muted); font-style: italic; }

.legend {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.leg-item { display: inline-flex; align-items: center; gap: 8px; }
.leg-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.leg-dot.d-done { background: var(--primary); }
.leg-dot.d-pending { background: var(--warn); }
.leg-dot.d-move { background: #5b53e0; }

.filter-summary {
  flex: none;
  margin-top: 14px;
  padding: 11px 15px;
  background: var(--mint);
  border: 1px solid #c8ecd8;
  border-radius: 10px;
  font-size: 13.5px;
}

/* ---------------- dashboard ---------------- */
.dashboard { display: flex; flex-direction: column; }
.dash-toolbar { display: flex; align-items: center; gap: 12px; margin: 0 0 18px; flex-wrap: wrap; }
.dash-toolbar select { width: auto; }
.pill { background: var(--mint); color: var(--primary); padding: 4px 11px; border-radius: 999px; font-size: 12.5px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 17px 18px;
}
.card-label { color: var(--muted); font-size: 12.5px; margin-bottom: 7px; }
.card-value { font-size: 24px; font-weight: 700; }
.card.warn { background: var(--warn-bg); border-color: #f6d9b0; }
.card.warn .card-value { color: #b5721a; }
.card.ok { background: var(--event-bg); border-color: #b6e8cd; }
.card.ok .card-value { color: var(--primary-strong); }
.card.big .card-value { font-size: 30px; }

.dash-block {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 16px;
  overflow-x: auto;
}
.dash-block h3 { font-size: 14px; color: var(--muted); margin-bottom: 12px; font-weight: 600; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  white-space: nowrap;
}
.tbl th { color: var(--muted); font-weight: 600; }
.tbl td.wrap { white-space: normal; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover { background: var(--mint); }
.tbl td.warn { color: #b5721a; font-weight: 600; }
.tbl td.nowrap { white-space: nowrap; }
.empty-row { text-align: center; color: var(--muted); padding: 22px; }

/* ---------------- สรุปลูกค้า (customer report) ---------------- */
.cust-report { display: flex; flex-direction: column; gap: 16px; }
.cr-head { padding-bottom: 4px; }
.cr-head h2 { font-size: 20px; font-weight: 700; }
.cr-head p { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); }
.cr-cust {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  overflow-x: auto;
}
.cr-cust-head { margin-bottom: 12px; }
.cr-cust-head h3 { font-size: 16px; font-weight: 700; }
.cr-cust-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--muted);
}
.cr-cust-meta .m-ok { color: var(--primary-strong); font-weight: 600; }
.cr-cust-meta .m-warn { color: #b5721a; font-weight: 600; }
.st {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.st-done { background: var(--event-bg); color: var(--primary-strong); }
.st-pending { background: var(--warn-bg); color: #b5721a; }

/* ---------------- modal ---------------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 28, 46, 0.42);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  z-index: 60;
  overflow: auto;
}
.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.24);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 17px; font-weight: 700; }
.modal-head .x { border: none; background: transparent; font-size: 17px; padding: 4px 8px; }
.modal-body { padding: 20px; }
.modal-actions {
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding: 15px 20px;
  border-top: 1px solid var(--border);
}

.form { display: flex; flex-direction: column; gap: 14px; }
.fld { display: flex; flex-direction: column; gap: 6px; }
.fld > span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; background: #f5f7f8; border-radius: 9px; padding: 10px 12px; }

.item-list-head,
.irow { display: grid; grid-template-columns: 1fr 68px 66px 28px; gap: 7px; align-items: center; }
.item-list-head { font-size: 11.5px; color: var(--muted); padding: 0 2px 2px; }
.item-rows { display: flex; flex-direction: column; gap: 7px; }
.irow input, .irow select { width: 100%; padding: 8px 9px; }
.irow-del {
  width: 28px; height: 32px; padding: 0;
  display: grid; place-items: center;
  border: none; background: transparent; color: var(--muted);
  font-size: 13px; border-radius: 8px;
}
.irow-del:hover { background: #fbe9e8; color: var(--danger); }
.add-item-btn {
  margin-top: 9px; width: 100%;
  border: 1px dashed #b6e2cb; background: var(--mint);
  color: var(--primary-strong); font-weight: 600;
  border-radius: 9px; padding: 9px;
}
.add-item-btn:hover { background: var(--event-bg); }

.detail .kv { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.detail .kv .k { color: var(--muted); min-width: 120px; }
.detail .kv .v { font-weight: 500; white-space: pre-wrap; }
.detail-block { margin-top: 16px; }
.detail-block h3 { font-size: 13px; color: var(--muted); margin-bottom: 9px; font-weight: 600; }
.detail-items { display: flex; flex-direction: column; }
.ditem { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.ditem-qty { color: var(--muted); white-space: nowrap; }
.ditem-total { font-weight: 700; border-bottom: none; padding-top: 10px; }
.ditem-total .ditem-qty { color: var(--primary-strong); }
.timeline { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; }
.tl-item { display: flex; align-items: center; gap: 9px; }
.tl-item .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); display: inline-block; flex: none; }
.tl-move { color: var(--muted); padding-left: 3px; font-size: 12.5px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: #172033;
  color: #fff;
  padding: 12px 20px;
  border-radius: 11px;
  z-index: 80;
  font-size: 13.5px;
  box-shadow: var(--shadow-card);
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--primary); }

/* ---------------- responsive ---------------- */
.lbl-short { display: none; }

@media (max-width: 1100px) {
  .calendar-grid { grid-auto-rows: minmax(104px, 1fr); }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    align-items: center;
    min-height: 0;
    gap: 8px;
    padding: 10px 16px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .side-nav { flex-direction: row; }
  .sidebar-art { display: none; }
  .main-col { padding: 14px; min-height: 0; }
  .app-header { padding: 0 16px; }
  .brand-text p { display: none; }
  .brand-text h1 { font-size: 19px; }
  .chip-btn { max-width: 150px; }
}

@media (max-width: 640px) {
  body { font-size: 14px; }

  /* header: ปุ่มสั้นลง, ซ่อนป้ายลูกค้า */
  .app-header { height: 60px; gap: 10px; }
  .brand-icon { font-size: 22px; }
  .brand-text h1 { font-size: 17px; }
  .header-actions { gap: 7px; }
  .btn-primary { padding: 10px 12px; }
  .lbl-full { display: none; }
  .lbl-short { display: inline; }
  .icon-btn { width: 40px; height: 40px; }
  .header-actions .chip-btn { padding: 9px 10px; }
  .header-actions .chip-btn #acctLabel,
  .header-actions .chip-btn .caret { display: none; }

  /* toolbar: จัดเป็นบรรทัด อ่านง่าย */
  .main-col { padding: 12px; }
  .panel { padding: 14px 12px 14px; border-radius: 14px; }
  .toolbar { gap: 12px; padding-bottom: 12px; }
  .tb-left { width: 100%; justify-content: center; gap: 8px; }
  .tb-right { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
  .cust-filter { flex: 1; }
  .cust-filter select { flex: 1; min-width: 0; width: 100%; }
  #refreshBtn { grid-column: 1; }
  .seg { grid-column: 2; grid-row: 1 / span 2; }
  .seg-btn { padding: 8px 14px; }
  #periodLabel { min-width: 0; font-size: 18px; flex: 1; }
  .nav-btn { width: 40px; height: 40px; }

  /* ปฏิทิน: ซ่อนหัววันแยก, โชว์ชื่อวันในแต่ละช่องแทน */
  #view { margin-top: 10px; }
  .calendar-head { display: none; }
  .cell-dow { display: inline; }
  .cell-head { align-items: baseline; }

  /* มุมมองสัปดาห์ = คอลัมน์เดียว อ่านสบาย (เป็นค่าเริ่มต้นบนมือถือ) */
  .calendar-grid.week {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
    gap: 8px;
  }
  .calendar-grid.week .cell { min-height: 60px; padding: 11px 13px; border-radius: 12px; }
  .calendar-grid.week .cell .chips:empty { display: none; }
  .calendar-grid.week .cell .daynum { font-size: 15px; }
  .calendar-grid.week .cell-dow { font-size: 13px; }
  .calendar-grid.week .cell.today { padding: 10px 12px; }
  #periodLabel { font-size: 16px; line-height: 1.25; }

  /* มุมมองเดือน (ถ้าผู้ใช้สลับมาเอง) — ยังเป็น 7 คอลัมน์แบบกระชับ */
  .calendar-grid:not(.week) { gap: 3px; grid-auto-rows: minmax(72px, auto) !important; }
  .calendar-grid:not(.week) .cell { padding: 4px; border-radius: 7px; gap: 3px; }
  .calendar-grid:not(.week) .cell-dow { display: none; }
  .calendar-grid:not(.week) .daynum { font-size: 12px; }
  .calendar-grid:not(.week) .chip { padding: 4px 5px; border-radius: 6px; }
  .calendar-grid:not(.week) .chip-sub,
  .calendar-grid:not(.week) .chip-meta { display: none; }
  .calendar-grid:not(.week) .chip-title { font-size: 11px; }

  .legend { gap: 12px 16px; font-size: 12px; }
  .cards { grid-template-columns: 1fr 1fr; }
  .modal { max-width: 100%; }
  .overlay { padding: 16px 10px; }
}

/* ---------------- print (สรุปลูกค้า -> PDF/กระดาษ) ---------------- */
@media print {
  .app-header, .sidebar, .toolbar, #modalRoot, .toast { display: none !important; }
  body { background: #fff; }
  .app-shell { display: block; }
  .main-col { padding: 0; min-height: 0; }
  .panel { border: none; box-shadow: none; padding: 0; }
  #view { margin-top: 0; }
  .cr-cust {
    border: 1px solid #ccc;
    break-inside: avoid;
    page-break-inside: avoid;
    overflow: visible;
  }
  .cr-head h2 { font-size: 18pt; }
  .tbl tr.clickable { cursor: default; }
  .tbl tr.clickable:hover { background: none; }
  .tbl th, .tbl td { white-space: normal; }
}
