/* Look follows sellcenter's KOL Info page: gradient header bar, white
   rounded cards on a light-gray page, accent-bordered section headers,
   pills and colored stat badges. */

:root {
  --brand: #0e7c86;
  --brand-dark: #0a5a62;
  --page-bg: #eef1f6;
  --card-bg: #ffffff;
  --border: #e4e8f0;
  --text: #202433;
  --text-muted: #767d8c;
  --radius: 14px;
  /* badge set from the KOL page — validated colorblind-safe as a set */
  --blue: #2a78d6;
  --orange: #eb6834;
  --aqua: #1baf7a;
  --yellow: #eda100;
  --inside: #1baf7a;
  --outside: #f4a582;
  --tick-in: #0d6b49;
  --tick-out: #c4471a;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans Thai", "Leelawadee UI", Arial, sans-serif;
  color: var(--text);
  background: var(--page-bg);
  font-size: 14px;
  line-height: 1.55;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.r { text-align: right; }
.c { text-align: center; }
.pad { padding: 14px 18px; }
.pad-x { padding: 0 18px 12px; margin: 0; }
.zk-page { min-height: 100vh; display: flex; flex-direction: column; }

/* ---- Header bar ---- */
.header-bar {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}
.header-bar .title-group {
  display: flex; align-items: center; gap: 10px;
  font-size: 22px; font-weight: 700; letter-spacing: .2px; color: #fff;
}
.header-bar .title-group:hover { text-decoration: none; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.tabs a {
  color: rgba(255, 255, 255, .88);
  padding: 7px 14px; border-radius: 20px; font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .15s ease;
}
.tabs a:hover { background: rgba(255, 255, 255, .14); text-decoration: none; }
.tabs a.active { background: #fff; color: var(--brand-dark); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.header-right { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.header-right form { margin: 0; }
.refresh-btn {
  border: none; background: rgba(255, 255, 255, .16); color: #fff;
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
}
.refresh-btn:hover { background: rgba(255, 255, 255, .3); }
.banner { padding: 10px 24px; font-weight: 600; }
.banner.warn { background: #fff4d6; color: #7a5200; border-bottom: 1px solid #f3dc9b; }

/* ---- Page ---- */
.page { padding: 20px 24px 8px; flex: 1; width: 100%; max-width: 1680px; margin: 0 auto; }
.page-title { font-size: 18px; margin: 4px 2px 14px; }
.page-title small { font-size: 13px; font-weight: 400; margin-left: 8px; }
.page-foot { text-align: center; color: var(--text-muted); font-size: 12.5px; padding: 6px 16px 22px; }

/* ---- Card ---- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(20, 30, 60, 0.06);
  overflow: hidden;
  margin-bottom: 18px;
}
.card-head {
  background: #f8f9fc;
  border-left: 3px solid var(--brand);
  border-bottom: 1px solid var(--border);
  padding: 11px 18px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 14px;
}
.card-head h2 {
  color: var(--brand-dark); font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  display: flex; align-items: center; gap: 8px;
}
.card-head h2 a { color: inherit; }
.card-head .count { background: #e3eef0; color: var(--brand-dark); border-radius: 10px; padding: 1px 8px; font-size: 12px; text-transform: none; letter-spacing: 0; }
.hint { font-size: 12.5px; }
.hint-block { margin: 4px 0 18px; font-size: 13px; }

/* ---- Toolbar ---- */
.toolbar { padding: 12px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; overflow: visible; }
.toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.date-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-nav form { margin: 0; }
.date-title { font-size: 18px; font-weight: 700; margin-left: 6px; display: flex; align-items: center; gap: 8px; }
input[type=date], select, input[type=search] {
  font: inherit; color: var(--text);
  border: 1px solid #cfd6e2; border-radius: 10px; padding: 7px 10px; background: #fff;
  min-height: 38px;
}
input[type=date]:focus, select:focus, input[type=search]:focus { outline: 2px solid rgba(14, 124, 134, .35); border-color: var(--brand); }
.search { position: relative; display: inline-flex; align-items: center; }
.search i { position: absolute; left: 11px; color: var(--text-muted); pointer-events: none; }
.search input { padding-left: 32px; width: 220px; }
.search.big input { width: 320px; font-size: 15px; }
.field { display: inline-flex; align-items: center; gap: 6px; }
.field span { color: var(--text-muted); font-size: 13px; }
.range-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 0; }
.range-inputs { display: flex; align-items: center; gap: 8px; }
.range-dash { color: var(--text-muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 12px; border-radius: 20px; background: #eef1f8; color: var(--text);
  font-size: 13px; font-weight: 600; border: 1px solid transparent;
}
.chip:hover { text-decoration: none; border-color: #c9d3e3; }
.chip.active { background: var(--brand); color: #fff; }
.person-switch { margin: 0; }
.person-switch select { max-width: 240px; font-weight: 600; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 7px 14px; border-radius: 10px;
  background: #fff; border: 1px solid #cfd6e2; color: var(--text);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; background: #f4f7fb; }
.btn.icon { width: 38px; padding: 0; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { border-color: transparent; background: #eef1f8; }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn.disabled { opacity: .35; cursor: default; }

/* ---- Pills & badges ---- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: #eef1f8; color: var(--text);
  border-radius: 20px; padding: 3px 11px; font-size: 12.5px; margin: 2px 4px 2px 0;
  white-space: nowrap;
}
.pill b { color: var(--brand-dark); }
.pill.warn { background: #fff4d6; color: #7a5200; }
.pill.live { background: #e0f5ec; color: #0d6b49; font-size: 12px; }
.pill.live .fa-circle { font-size: 7px; color: var(--aqua); }
.pill.person:hover { text-decoration: none; background: #e3e9f4; }
.badges { padding: 0 18px 16px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.badge-stat {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 20px; padding: 4px 11px; font-weight: 700; font-size: 12.5px; color: #fff;
}
.badge-stat.blue { background: var(--blue); }
.badge-stat.orange { background: var(--orange); }
.badge-stat.aqua { background: var(--aqua); }
.badge-stat.yellow { background: var(--yellow); }
.unnamed { color: var(--text-muted); font-style: italic; }

/* ---- Stat tiles ---- */
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; box-shadow: 0 1px 3px rgba(20, 30, 60, 0.06);
  border-top: 3px solid #c9d3e3; display: flex; flex-direction: column;
}
.stat b { font-size: 26px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat small { color: var(--text-muted); font-size: 12px; }
.stat-label { color: var(--text-muted); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat.in { border-top-color: var(--aqua); }
.stat.out { border-top-color: var(--orange); }
.stat.inside { border-top-color: var(--blue); }
.stat.outside { border-top-color: var(--outside); }
.stat.warn { border-top-color: var(--yellow); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th {
  background: #eef2f9; color: #495057; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 2px solid var(--border); padding: 9px 12px; white-space: nowrap; vertical-align: bottom;
  position: relative;
}
table.data th small { display: block; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text-muted); font-size: 11px; }
table.data th[data-sort] { cursor: pointer; user-select: none; }
table.data th[data-sort]:hover { background: #e4eaf5; }
table.data th.sorted-asc::after, table.data th.sorted-desc::after {
  font-family: "Font Awesome 6 Free"; font-weight: 900; margin-left: 5px; color: var(--brand);
}
table.data th.sorted-asc::after { content: "\f0de"; }
table.data th.sorted-desc::after { content: "\f0dd"; }
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tr.row-main, table.data tr.row-link { cursor: pointer; }
table.data tr.row-main:hover td, table.data tr.row-link:hover td { background: #f5f8ff; }
table.data tr.row-main:focus-visible, table.data tr.row-link:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
table.data tr.open td { background: #f2f9f9; border-bottom-color: transparent; }
table.data tr.row-detail td { background: #f8fbfb; padding: 4px 12px 12px 40px; white-space: normal; }
table.data tr.flagged td { background: #fffaf0; }
.num-in { color: #0d6b49; font-weight: 700; }
.num-out { color: #b4441a; font-weight: 700; }
.expander { color: var(--text-muted); font-size: 11px; width: 14px; transition: transform .15s ease; }
tr.open .expander { transform: rotate(90deg); color: var(--brand); }
.visit-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.vchip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 8px; font-size: 12.5px; border: 1px solid; }
.vchip.inside { background: #e8f7f0; border-color: #b6e5cf; color: #0b5e40; }
.vchip.outside { background: #fdf0e9; border-color: #f6cdb6; color: #9a3a14; }
.vchip.inside.now { border-style: dashed; }
.vchip.warn { background: #fff4d6; border-color: #f3dc9b; color: #7a5200; }

/* ---- Timeline ---- */
.tl-col { width: 34%; min-width: 300px; }
th.tl-col { vertical-align: bottom; padding-bottom: 4px; }
.timeline {
  position: relative; height: 18px; background: #f1f3f8; border-radius: 5px;
  background-image: repeating-linear-gradient(90deg, transparent 0, transparent calc(100% / var(--hours, 10) - 1px), #e2e6ef calc(100% / var(--hours, 10) - 1px), #e2e6ef calc(100% / var(--hours, 10)));
}
.timeline.big { height: 30px; border-radius: 7px; }
.tl-bar { position: absolute; top: 3px; bottom: 3px; border-radius: 3px; }
.timeline.big .tl-bar { top: 5px; bottom: 5px; }
.tl-bar.inside { background: var(--inside); }
.tl-bar.inside.now { background: repeating-linear-gradient(45deg, var(--inside) 0 6px, #7fd6b3 6px 12px); }
.tl-bar.outside { background: var(--outside); top: 6px; bottom: 6px; }
.timeline.big .tl-bar.outside { top: 10px; bottom: 10px; }
.tl-tick { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; border-radius: 1px; }
.tl-tick.in { background: var(--tick-in); }
.tl-tick.out { background: var(--tick-out); }
.tl-flag { position: absolute; top: -9px; margin-left: -6px; color: var(--yellow); font-size: 11px; text-shadow: 0 0 2px #fff; }
.timeline.big .tl-flag { top: -12px; font-size: 13px; }
.tl-axis { position: relative; height: 15px; font-size: 10.5px; color: var(--text-muted); font-weight: 600; letter-spacing: 0; text-transform: none; }
.tl-axis.big { font-size: 11.5px; height: 18px; }
.tl-axis span { position: absolute; transform: translateX(-50%); }
.tl-axis span.first { transform: none; }
.tl-axis span.last { transform: translateX(-100%); }
.tl-block { padding-top: 16px; }

/* ---- Legend ---- */
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 10px 18px 12px; font-size: 12.5px; color: var(--text); border-top: 1px solid var(--border); background: #fbfcfe; }
section > .legend:first-child, .page > .legend { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 18px; height: 10px; border-radius: 3px; }
.sw.inside { background: var(--inside); }
.sw.outside { background: var(--outside); height: 6px; }
.sw.tick-in { background: var(--tick-in); width: 3px; height: 14px; }
.sw.tick-out { background: var(--tick-out); width: 3px; height: 14px; }
.warn-ico { color: var(--yellow); }
.in-ico { color: var(--aqua); }
.out-ico { color: var(--orange); }

/* ---- Day strip (summary) ---- */
.strip-col { min-width: 160px; }
.strip { display: flex; gap: 2px; }
.strip .cell { width: 9px; height: 18px; border-radius: 2px; background: #eceff5; flex: 0 0 auto; }
.strip .cell.wkend { opacity: .55; }
.strip .cell.l1 { background: #c6ece0; }
.strip .cell.l2 { background: #84d4b6; }
.strip .cell.l3 { background: #3fbb8d; }
.strip .cell.l4 { background: #128a5f; }

/* ---- Day cards (person) ---- */
.day-card .card-head h2 { text-transform: none; letter-spacing: 0; font-size: 15px; }
.day-pills { display: flex; flex-wrap: wrap; gap: 2px; }
table.visits td, table.visits th { padding-left: 16px; padding-right: 16px; }

/* ---- Profile ---- */
.profile-row { display: flex; align-items: center; gap: 16px; padding: 16px 18px 12px; }
.profile-name { font-size: 21px; font-weight: 700; }
.avatar {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%;
  background: #e3eef0; color: var(--brand-dark); font-weight: 700; font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
}
.avatar.big { width: 60px; height: 60px; font-size: 26px; border: 2px solid var(--border); }
.avatar.unnamed { background: #eef1f6; color: var(--text-muted); }

/* ---- People grid ---- */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-bottom: 14px; }
.person-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(20, 30, 60, 0.06); color: var(--text);
  transition: transform .12s ease, box-shadow .12s ease;
}
.person-card:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(20, 30, 60, 0.1); border-color: #c9d8dc; }
.person-card.removed { opacity: .6; }
.person-meta { display: flex; flex-direction: column; min-width: 0; }
.person-meta b { font-size: 15px; }

/* ---- Clock page ---- */
.device-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 16px 18px; }
.device { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.device-top { display: flex; gap: 12px; align-items: center; }
.device-ico { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 17px; }
.device.in .device-ico { background: var(--aqua); }
.device.out .device-ico { background: var(--orange); }
.device-clock { font-size: 15px; }
.device-clock.ok { color: #0d6b49; }
.device-clock.bad { color: #a8460f; }
.callout { display: flex; gap: 12px; margin: 0 18px 16px; padding: 12px 14px; background: #fff8e6; border: 1px solid #f3dc9b; border-radius: 10px; color: #5c4300; }
.callout > i { font-size: 18px; margin-top: 2px; color: var(--yellow); }

/* ---- Empty state ---- */
.empty { text-align: center; padding: 42px 20px; }
.empty > i { font-size: 38px; color: #b7c0cf; margin-bottom: 10px; }
.empty h2 { font-size: 18px; margin-bottom: 6px; }
.empty .btn { margin-top: 10px; }
.warn-text { color: #a8460f; }

/* ---- Responsive ---- */
@media (max-width: 1280px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .header-bar { padding: 12px 16px; }
  .header-bar .title-group { font-size: 19px; }
  .tabs { order: 3; flex-basis: 100%; }
  .tabs a { padding: 6px 11px; font-size: 13px; }
  .page { padding: 14px 12px 6px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat b { font-size: 22px; }
  .toolbar-right { margin-left: 0; width: 100%; }
  .search, .search input, .search.big input { width: 100%; }
  .toolbar-right .btn { flex: 1; }
  .date-title { font-size: 16px; margin-left: 0; flex-basis: 100%; }
  .device-grid { grid-template-columns: 1fr; }
  .tl-col { min-width: 240px; }
}

/* ---- Employee names & mapping ---- */
.tab-badge { background: var(--yellow); color: #3d2a00; border-radius: 10px; padding: 0 7px; font-size: 11.5px; font-weight: 700; margin-left: 2px; }
.pname { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; vertical-align: middle; }
.pname-main { font-weight: 600; }
.pname-sub { flex-basis: 100%; color: var(--text-muted); font-size: 12px; line-height: 1.3; }
.map-flag { font-size: 11px; padding: 0 7px; border-radius: 8px; background: #fff4d6; color: #7a5200; white-space: nowrap; }
.map-flag.none { background: #eef1f6; color: var(--text-muted); }
.map-flag:hover { text-decoration: none; filter: brightness(.97); }
.profile-full { font-size: 15px; font-weight: 500; color: var(--text-muted); margin-left: 6px; }
.callout.soft { margin: 0 0 14px; background: #f1f7fb; border-color: #cfe1ee; color: #24425a; }
.callout.soft > i { color: var(--blue); }
.dept-form { margin: 0; }
.dept-form select { max-width: 210px; }
.hint-block.left { text-align: left; margin: -4px 4px 14px; }
.map-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.map-row {
  margin: 0; padding: 12px 16px; display: grid; grid-template-columns: minmax(230px, 1fr) minmax(280px, 2fr) auto;
  gap: 10px 18px; align-items: start; border-left: 4px solid #d5dbe6; overflow: visible;
}
.map-row.status-confirmed { border-left-color: var(--aqua); }
.map-row.status-suggested { border-left-color: var(--yellow); }
.map-row.status-none { border-left-color: #b9c2d0; }
.map-row.idle { opacity: .7; }
.map-row.just-saved { box-shadow: 0 0 0 3px rgba(27, 175, 122, .35); }
.map-who { display: flex; gap: 12px; align-items: center; }
.map-state { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.map-current { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ok-ico { color: var(--aqua); }
.suggestion { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px dashed #e9cf87; background: #fffbef; border-radius: 10px; margin: 0; }
.suggestion-text { flex: 1; min-width: 0; }
.note { margin-top: 2px; }
.form-error { color: #a8460f; font-weight: 600; }
.map-edit { justify-self: end; text-align: right; }
.map-edit summary { list-style: none; }
.map-edit summary::-webkit-details-marker { display: none; }
.map-edit[open] { grid-column: 1 / -1; justify-self: stretch; text-align: left; background: #f8fafc; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.map-edit[open] summary { margin-bottom: 10px; }
.map-form { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.map-form select { width: 100%; }
.field.col { flex-direction: column; align-items: stretch; gap: 3px; }
.field.col span { font-size: 12.5px; }
.field input[type=text], .field input[type=time] { font: inherit; border: 1px solid #cfd6e2; border-radius: 10px; padding: 7px 10px; min-height: 38px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions { display: flex; gap: 8px; }
.clear-form { margin: 10px 0 6px; }
@media (max-width: 900px) {
  .map-row { grid-template-columns: 1fr; }
  .map-edit { justify-self: start; }
  .row2 { grid-template-columns: 1fr; }
}

/* ---- Outside ranking ---- */
.rank { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 28px; border-radius: 50%; font-weight: 700; background: #eef1f6; color: var(--text-muted); }
.rank-1 { background: #eb6834; color: #fff; }
.rank-2 { background: #f08a5d; color: #fff; }
.rank-3 { background: #f4a582; color: #4a1d07; }
.bar-cell { min-width: 150px; }
.rank-bar { display: inline-block; vertical-align: middle; width: 90px; height: 10px; background: #f1f3f8; border-radius: 5px; overflow: hidden; margin-right: 8px; }
.rank-bar .fill { display: block; height: 100%; border-radius: 5px; }
.rank-bar .fill.out { background: var(--orange); }
.rank-bar .fill.time { background: var(--outside); }
.bar-num { font-variant-numeric: tabular-nums; }
table.data th.sorted-by { color: var(--brand-dark); background: #e3eef0; }
.trips-cell { white-space: normal !important; min-width: 280px; }
.tchip { display: inline-flex; gap: 4px; align-items: baseline; padding: 2px 8px; margin: 2px 4px 2px 0; border-radius: 8px; font-size: 12.5px; background: #fdf0e9; border: 1px solid #f6cdb6; color: #7a2e10; white-space: nowrap; }
.tchip.long { background: #fbe0d2; border-color: #eb6834; color: #7a2e10; font-weight: 600; }
.tchip.unknown { background: #f1f3f8; border: 1px dashed #b9c2d0; color: var(--text-muted); }
.export-range { position: relative; }
.export-range summary { list-style: none; }
.export-range summary::-webkit-details-marker { display: none; }
.export-range-form {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 240px;
  display: flex; flex-direction: column; gap: 8px; padding: 12px; margin: 0;
  background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 24px rgba(20, 30, 60, .14);
}

/* ---- Lunch break ---- */
.tl-lunch { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(90deg, rgba(42, 120, 214, .10) 0 4px, rgba(42, 120, 214, .04) 4px 8px); border-left: 1px dashed rgba(42, 120, 214, .35); border-right: 1px dashed rgba(42, 120, 214, .35); }
.tl-bar.outside.lunch { background: #8fb8e8; }
.sw.lunch { background: #8fb8e8; height: 6px; }
.sw.lunch-band { background: rgba(42, 120, 214, .14); border: 1px dashed rgba(42, 120, 214, .4); }
.vchip.lunch { background: #ebf3fc; border-color: #bcd5f2; color: #1f4f86; }
.tchip.lunch { background: #ebf3fc; border-color: #bcd5f2; color: #1f4f86; }
.lunch-cell { white-space: nowrap; }
.over { color: #b4441a; font-weight: 700; }
.pill.lunch { background: #ebf3fc; color: #1f4f86; }
.stat.lunch-stat { border-top-color: #8fb8e8; }

/* ---- ID + card column ---- */
.code-cell { line-height: 1.25; }
.code-cell b { display: block; font-weight: 600; }
.code-cell small { display: block; color: var(--text-muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }

/* ---- Fit wide tables on laptop screens (≥1280px) without hiding columns ---- */
table.data th, table.data td { padding-left: 9px; padding-right: 9px; }
table.data td.name-cell { white-space: normal; min-width: 150px; max-width: 230px; }
table.data td.two small { display: block; color: var(--text-muted); font-size: 11.5px; line-height: 1.3; white-space: nowrap; }
table.data td.lunch-cell .over { display: block; font-size: 12px; }
.tl-col { width: auto; min-width: 200px; }
.trips-cell { min-width: 210px; }
.bar-cell { min-width: 0; white-space: nowrap; }
.rank-bar { width: 56px; }
.strip { display: grid; grid-template-columns: repeat(var(--days, 7), minmax(4px, 9px)); gap: 2px; }
.strip .cell { width: auto; }
.strip-col { min-width: 0; }
.table-wrap { position: relative; }
.scroll-hint { display: none; position: sticky; left: 0; padding: 4px 12px; font-size: 12px; color: #7a5200; background: #fff8e6; border-bottom: 1px solid #f3dc9b; }
.table-wrap.scrollable .scroll-hint { display: block; }
@media (max-width: 1600px) { .tl-axis:not(.big) span.odd { display: none; } }

/* ---- Tree table (ตารางสรุป) ---- */
table.tree { font-size: 14px; }
table.tree th.name-col { width: 46%; }
table.tree th.num-col { width: 90px; }
table.tree th.time-col { width: 150px; }
table.tree th a.th-sort { color: inherit; text-decoration: none; }
table.tree th a.th-sort:hover { color: var(--brand); }
table.tree td { white-space: normal; }
table.tree tr.total-row td { background: #f3f8f8; border-bottom: 2px solid var(--border); }
table.tree tr.has-kids { cursor: pointer; }
table.tree tr.has-kids:hover td { background: #f5f8ff; }
table.tree tr.has-kids:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
table.tree .tw { display: inline-block; width: 16px; color: var(--text-muted); transition: transform .12s ease; }
table.tree tr[aria-expanded="true"] > td > .tw { transform: rotate(90deg); color: var(--brand); }
table.tree tr.lvl1 td { border-top: 1px solid #dfe5ee; }
table.tree tr.lvl1 small { margin-left: 4px; }
table.tree tr.lvl2 td:first-child { padding-left: 34px; }
table.tree tr.lvl3 td:first-child { padding-left: 62px; }
table.tree tr.lvl2:not(.exit-row) td { background: #fafcfe; }
table.tree tr.exit-row td { font-size: 13px; padding-top: 5px; padding-bottom: 5px; color: #3b4252; }
table.tree tr.exit-row.kind-home td, table.tree tr.exit-row.kind-now td { color: var(--text-muted); }
table.tree tr.exit-row.kind-unknown td:first-child { color: var(--text-muted); font-style: italic; }
table.tree .lunch-ico { color: #4a7fc1; }
table.tree .detail-link { margin-left: 8px; font-size: 12px; white-space: nowrap; }
table.tree .over { margin-right: 6px; }
table.data th { text-align: left; }
table.data th.r { text-align: right; }
table.data th.c { text-align: center; }
table.tree td.tick { color: var(--text-muted); font-size: 12px; }
table.tree tr.leg-in td:first-child { color: #0d6b49; }
table.tree tr.leg-in.kind-nopair td:first-child { color: #7a5200; }
table.tree tr.leg-in.kind-arrive td { color: var(--text-muted); }

/* ---- Login ---- */
.who { font-weight: 600; white-space: nowrap; }
.logout-link { color: #fff; width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, .16); }
.logout-link:hover { background: rgba(255, 255, 255, .3); text-decoration: none; }
.login-body { min-height: 100vh; background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%); display: flex; }
.login-wrap { margin: auto; padding: 24px 16px; width: 100%; max-width: 440px; }
.login-card { background: #fff; border-radius: 18px; box-shadow: 0 18px 50px rgba(0, 0, 0, .22); padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.login-head { display: flex; gap: 14px; align-items: center; }
.login-logo { width: 56px; height: 56px; }
.login-head h1 { font-size: 22px; }
.login-head p { margin: 2px 0 0; color: var(--text-muted); font-size: 13px; }
.login-btn { min-height: 48px; font-size: 16px; border-radius: 12px; }
.login-note { margin: 0; text-align: center; color: var(--text-muted); font-size: 12.5px; }
.login-msg { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: #eef5fb; color: #24425a; font-size: 14px; line-height: 1.5; }
.login-msg.warn { background: #fff4d6; color: #5c4300; }
.login-msg > i { margin-top: 3px; }
