:root {
  color-scheme: light;
  --blue: #1a73e8;
  --blue-soft: #e8f0fe;
  --green: #188038;
  --green-soft: #e6f4ea;
  --amber: #b06000;
  --amber-soft: #fef7e0;
  --purple: #8430ce;
  --purple-soft: #f3e8fd;
  --red: #c5221f;
  --red-soft: #fce8e6;
  --ink: #202124;
  --muted: #5f6368;
  --line: #dadce0;
  --surface: #fff;
  --canvas: #f8f9fa;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: Arial, "Noto Sans Thai", "Tahoma", sans-serif; font-size: 14px; }
button, input { font: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.topbar { position: sticky; z-index: 10; top: 0; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(10px); }
.topbar-inner { display: flex; min-height: 68px; max-width: 1240px; margin: auto; padding: 10px 24px; align-items: center; gap: 14px; }
.brand-mark, .avatar { display: grid; position: relative; flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; place-items: center; color: #fff; background: var(--blue); font-size: 17px; font-weight: 700; }
.brand-mark { border-radius: 10px; }
.heading { min-width: 0; }
.heading h1 { overflow: hidden; margin: 0; font-size: 20px; font-weight: 500; line-height: 25px; text-overflow: ellipsis; white-space: nowrap; }
.heading p { overflow: hidden; margin: 1px 0 0; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { display: flex; margin-left: auto; align-items: center; gap: 8px; }
.icon-button { display: grid; width: 40px; height: 40px; border-radius: 50%; place-items: center; color: var(--muted); text-decoration: none; font-size: 25px; }
.icon-button:hover { background: #f1f3f4; }
.compact-input { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.compact-input span { font-size: 12px; }
.compact-input input { height: 38px; border: 1px solid var(--line); border-radius: 5px; padding: 0 10px; color: var(--ink); background: #fff; outline: none; }
.compact-input input:focus { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.date-picker { display: flex; position: relative; align-items: center; gap: 8px; color: var(--muted); }
.date-picker-field-label { font-size: 12px; }
.date-picker-trigger { display: flex; height: 40px; min-width: 174px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; align-items: center; gap: 9px; color: var(--ink); background: #fff; cursor: pointer; }
.date-picker-trigger:hover { border-color: #bdc1c6; background: #f8f9fa; }
.date-picker-trigger:focus-visible, .date-picker-trigger[aria-expanded="true"] { border-color: var(--blue); outline: 0; box-shadow: 0 0 0 1px var(--blue); }
.date-picker-trigger svg { width: 17px; height: 17px; fill: none; stroke: var(--blue); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.date-picker-value { flex: 1; text-align: left; white-space: nowrap; }
.date-picker-caret { width: 0; height: 0; border-top: 5px solid var(--muted); border-right: 4px solid transparent; border-left: 4px solid transparent; transition: transform .15s; }
.date-picker-trigger[aria-expanded="true"] .date-picker-caret { transform: rotate(180deg); }
.date-picker-popover { position: absolute; z-index: 30; top: calc(100% + 8px); right: 0; width: 304px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 8px 24px rgba(60,64,67,.22), 0 1px 3px rgba(60,64,67,.18); color: var(--ink); }
.date-picker-header { display: flex; min-height: 36px; padding: 0 3px 8px 7px; align-items: center; }
.date-picker-header strong { font-size: 14px; font-weight: 500; }
.date-picker-nav { display: flex; margin-left: auto; gap: 2px; }
.date-picker-nav button { display: grid; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; place-items: center; color: var(--muted); background: transparent; cursor: pointer; font-size: 24px; line-height: 1; }
.date-picker-nav button:hover:not(:disabled) { color: var(--ink); background: #f1f3f4; }
.date-picker-nav button:disabled { opacity: .3; cursor: default; }
.date-picker-weekdays, .date-picker-days { display: grid; grid-template-columns: repeat(7, 1fr); }
.date-picker-weekdays span { padding: 7px 0 5px; color: var(--muted); text-align: center; font-size: 10px; font-weight: 700; }
.date-picker-days { row-gap: 2px; }
.date-picker-day { display: grid; width: 34px; height: 34px; margin: auto; padding: 0; border: 0; border-radius: 50%; place-items: center; color: var(--ink); background: transparent; cursor: pointer; font-size: 12px; }
.date-picker-day:hover:not(:disabled) { background: var(--blue-soft); }
.date-picker-day.today:not(.selected) { color: var(--blue); font-weight: 700; }
.date-picker-day.selected { color: #fff; background: var(--blue); font-weight: 700; }
.date-picker-day:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.date-picker-day:disabled { color: #bdc1c6; cursor: default; }
.date-picker-footer { margin: 9px -14px -14px; padding: 8px 14px; border-top: 1px solid #eee; text-align: right; }
.date-picker-footer button { height: 32px; padding: 0 10px; border: 0; border-radius: 5px; color: var(--blue); background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; }
.date-picker-footer button:hover { background: var(--blue-soft); }

.container { width: min(1192px, calc(100% - 32px)); min-height: calc(100vh - 130px); margin: 28px auto 48px; }
footer { padding: 8px 20px 28px; color: #80868b; text-align: center; font-size: 11px; }
.toolbar-card, .list-card, .calendar-card, .detail-card { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.toolbar-card { display: flex; padding: 18px 20px; align-items: center; gap: 20px; }
.toolbar-card h2, .profile-line h2, .day-heading h2, .section-title h2 { margin: 0; font-size: 20px; font-weight: 500; }
.toolbar-card p, .profile-line p, .day-heading p, .section-title p { margin: 4px 0 0; color: var(--muted); }
.search { display: flex; width: min(360px, 100%); margin-left: auto; border-radius: 6px; background: #f1f3f4; align-items: center; }
.search span { padding-left: 13px; color: var(--muted); font-size: 22px; transform: rotate(-20deg); }
.search input { width: 100%; height: 42px; border: 0; padding: 0 14px 0 8px; background: transparent; outline: none; }
.search:focus-within { background: #fff; box-shadow: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15); }
.list-card { overflow: hidden; margin-top: 16px; }
.admin-row { display: grid; min-height: 82px; padding: 14px 18px; align-items: center; border-bottom: 1px solid #eee; grid-template-columns: 48px minmax(180px, 1fr) 190px 230px 20px; gap: 14px; text-decoration: none; transition: background .12s; }
.admin-row:last-child { border-bottom: 0; }
.admin-row:hover { background: #f8fafd; }
.presence { position: absolute; right: -1px; bottom: 0; width: 12px; height: 12px; border: 2px solid #fff; border-radius: 50%; background: #9aa0a6; }
.presence.online { background: #34a853; }
.presence.away { background: #f9ab00; }
.admin-main { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
.admin-main strong { overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.admin-main span, .admin-metric span, .admin-metric small { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.admin-metric { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.admin-metric b { font-size: 14px; font-weight: 500; }
.chevron { color: #9aa0a6; font-size: 25px; }

.profile-line { display: flex; margin-bottom: 18px; padding: 2px 2px 4px; align-items: center; gap: 14px; }
.avatar.large { width: 52px; height: 52px; font-size: 21px; }
.stats-grid { display: grid; margin-bottom: 26px; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.stat-card { display: flex; min-width: 0; min-height: 112px; padding: 16px; border: 1px solid var(--line); border-radius: 9px; background: #fff; flex-direction: column; }
.stat-card > span { color: var(--muted); font-size: 12px; }
.stat-card strong { overflow: hidden; margin: 13px 0 5px; font-size: 22px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.stat-card small { overflow: hidden; margin-top: auto; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.stat-card.blue { border-top: 3px solid var(--blue); }
.stat-card.green { border-top: 3px solid var(--green); }
.stat-card.amber { border-top: 3px solid #f9ab00; }
.stat-card.purple { border-top: 3px solid var(--purple); }
.section-title { display: flex; margin: 0 2px 12px; align-items: flex-end; }
.legend { display: flex; margin-left: auto; gap: 16px; color: var(--muted); font-size: 12px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; }
.worked-dot { background: var(--green); }
.absent-dot { background: #bdc1c6; }
.calendar-card { overflow: hidden; }
.weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.weekdays { border-bottom: 1px solid var(--line); background: #f8f9fa; }
.weekdays span { padding: 11px 8px; color: var(--muted); text-align: center; font-size: 11px; font-weight: 700; }
.calendar-day { display: flex; position: relative; min-width: 0; min-height: 126px; padding: 10px; border-right: 1px solid #eee; border-bottom: 1px solid #eee; flex-direction: column; text-decoration: none; gap: 5px; }
.calendar-day:nth-child(7n) { border-right: 0; }
.calendar-day:hover:not(.blank):not(.future) { z-index: 1; background: #f8fafd; box-shadow: inset 0 0 0 1px var(--blue); }
.calendar-day.blank, .calendar-day.future { background: #fafafa; color: #bdc1c6; }
.calendar-day.absent { background: #fff; }
.calendar-day .day-number { display: grid; width: 25px; height: 25px; border-radius: 50%; place-items: center; font-size: 12px; }
.calendar-day.today .day-number { color: #fff; background: var(--blue); }
.calendar-day b { margin-top: 3px; color: var(--muted); font-size: 12px; font-weight: 500; }
.calendar-day.worked b { color: var(--green); }
.calendar-day small { color: var(--muted); font-size: 10px; line-height: 15px; }
.calendar-day em { width: fit-content; margin-top: auto; border-radius: 10px; padding: 3px 7px; color: var(--amber); background: var(--amber-soft); font-size: 9px; font-style: normal; }

.day-heading { margin-bottom: 18px; }
.eyebrow { display: block; margin-bottom: 6px; color: var(--blue); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.day-stats { grid-template-columns: repeat(5, 1fr); }
.split-grid { display: grid; margin-bottom: 16px; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-card { overflow: hidden; }
.card-heading { display: flex; min-height: 62px; padding: 14px 18px; border-bottom: 1px solid #eee; align-items: center; }
.card-heading h3 { margin: 0; font-size: 15px; font-weight: 500; }
.card-heading p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.card-heading > span { margin-left: auto; border-radius: 12px; padding: 4px 9px; color: var(--muted); background: #f1f3f4; font-size: 10px; }
.period-row { display: grid; min-height: 52px; padding: 10px 18px; border-bottom: 1px solid #f1f3f4; grid-template-columns: 90px 1fr auto; align-items: center; gap: 12px; }
.period-row:last-child { border-bottom: 0; }
.period-row span, .period-row small { color: var(--muted); font-size: 11px; }
.period-row b { font-size: 13px; font-weight: 500; }
.muted-pad { margin: 0; padding: 22px 18px; color: var(--muted); }
.activity-card { margin-top: 0; }
.timeline { padding: 8px 0; }
.timeline-item { display: grid; position: relative; min-height: 70px; padding: 10px 18px; grid-template-columns: 76px 28px 1fr; gap: 11px; }
.timeline-item:not(:last-child)::after { position: absolute; top: 47px; bottom: -13px; left: 108px; width: 1px; background: #e2e5e9; content: ""; }
.timeline-time { padding-top: 7px; color: var(--muted); text-align: right; font-size: 11px; font-variant-numeric: tabular-nums; }
.timeline-icon { display: grid; z-index: 1; width: 28px; height: 28px; border-radius: 50%; place-items: center; color: var(--blue); background: var(--blue-soft); font-size: 11px; font-weight: 700; }
.timeline-icon.login, .timeline-icon.logout { color: var(--green); background: var(--green-soft); font-size: 16px; }
.timeline-icon.afk { color: var(--amber); background: var(--amber-soft); }
.timeline-icon.ticket { color: var(--purple); background: var(--purple-soft); }
.timeline-body { min-width: 0; padding: 4px 0 8px; }
.timeline-body strong { font-size: 13px; font-weight: 500; }
.timeline-body p { max-width: 850px; margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 17px; overflow-wrap: anywhere; }
.timeline-body a { display: inline-block; margin-top: 5px; color: var(--blue); font-size: 11px; text-decoration: none; }

.page-loading { display: flex; min-height: 100vh; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }
.spinner { width: 20px; height: 20px; border: 2px solid #d6d9de; border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { display: flex; min-height: 380px; padding: 30px; align-items: center; justify-content: center; text-align: center; flex-direction: column; }
.empty-state.compact { min-height: 220px; }
.empty-state h2 { margin: 12px 0 3px; font-size: 18px; font-weight: 500; }
.empty-state p { margin: 5px 0 18px; color: var(--muted); }
.empty-icon { display: grid; width: 42px; height: 42px; border-radius: 50%; place-items: center; color: var(--red); background: var(--red-soft); font-size: 20px; }
.primary { height: 38px; border: 0; border-radius: 4px; padding: 0 18px; color: #fff; background: var(--blue); cursor: pointer; }

@media (max-width: 1000px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .day-stats { grid-template-columns: repeat(3, 1fr); }
  .admin-row { grid-template-columns: 48px minmax(150px,1fr) 170px 20px; }
  .admin-metric:nth-of-type(2) { display: none; }
  .calendar-day { min-height: 110px; }
}

@media (max-width: 700px) {
  .topbar-inner { padding: 9px 14px; }
  .heading p, .compact-input span, .date-picker-field-label { display: none; }
  .compact-input input { width: 132px; }
  .date-picker-trigger { min-width: 152px; }
  .container { width: min(100% - 20px, 1192px); margin-top: 16px; }
  .toolbar-card { align-items: stretch; flex-direction: column; }
  .search { width: 100%; margin: 0; }
  .admin-row { min-height: 78px; padding: 12px; grid-template-columns: 42px 1fr 18px; gap: 10px; }
  .admin-row .avatar { width: 38px; height: 38px; }
  .admin-metric { display: none; }
  .stats-grid, .day-stats { grid-template-columns: repeat(2, 1fr); }
  .stat-card { min-height: 102px; }
  .stat-card strong { font-size: 19px; }
  .legend { display: none; }
  .calendar-card { overflow-x: auto; }
  .weekdays, .calendar-grid { min-width: 680px; }
  .calendar-day { min-height: 108px; }
  .split-grid { grid-template-columns: 1fr; }
  .period-row { grid-template-columns: 70px 1fr; }
  .period-row small { display: none; }
  .timeline-item { padding-inline: 10px; grid-template-columns: 62px 26px 1fr; gap: 8px; }
  .timeline-item:not(:last-child)::after { left: 105px; }
}

@media (max-width: 420px) {
  .heading h1 { max-width: 125px; font-size: 17px; }
  .compact-input input { width: 126px; }
  .date-picker-trigger { min-width: 0; width: 142px; padding-inline: 9px; }
  .date-picker-popover { position: fixed; top: 66px; right: 10px; width: min(304px, calc(100vw - 20px)); }
  .stats-grid, .day-stats { gap: 7px; }
  .stat-card { min-height: 94px; padding: 12px; }
}
