@font-face {
    font-family: Sarabun;
    src: local("Sarabun"), url("../vendor/sarabun/thai.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
    unicode-range: U+0E00-0E7F;
}

@font-face {
    font-family: Sarabun;
    src: local("Sarabun Bold"), url("../vendor/sarabun/thai-bold.woff2") format("woff2");
    font-weight: 700;
    font-display: swap;
    unicode-range: U+0E00-0E7F;
}

:root {
    --navy: #022247;
    --blue: #064a8b;
    --muted: #a4b3d3;
    --gold: #c3a138;
    --border: #dce3ec;
    --text: #1f2937;
    --secondary: #52637b;
    --background: #f4f7fb;
    --bar-height: 64px;
    --sidebar-width: 226px;
}
.report-cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:16px; margin:16px 0; }
.report-cards a { display:flex; flex-direction:column; color:var(--navy); }
.report-cards strong { font-size:32px; }
.report-charts { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.report-charts .phase1-card { min-width:0; }
.report-chart { width:100%; min-height:330px; }
.report-detail { min-width:260px; max-width:520px; overflow-wrap:anywhere; }
@media(max-width:767px) { .report-charts { grid-template-columns:1fr; } }

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--text); font: 18px/1.55 Sarabun, Tahoma, system-ui, sans-serif; }
[hidden] { display: none !important; }
body.menu-collapsed { --sidebar-width: 72px; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.skip-link { position: fixed; z-index: 8; top: 8px; left: 12px; transform: translateY(-160%); background: white; padding: 8px 14px; }
.skip-link:focus { transform: none; }
.topbar {
    position: fixed; inset: 0 0 auto; z-index: 5; height: var(--bar-height);
    display: flex; align-items: center; gap: 12px; padding: 0 22px;
    color: white; background: var(--navy); border-bottom: 1px solid #35516e;
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; font-weight: 700; }
.brand:hover { color: white; text-decoration: underline; }
.brand-mark { background: var(--gold); color: var(--navy); border-radius: 6px; padding: 3px 7px; font-size: 14px; }
.menu-toggle { background: transparent; color: inherit; border: 1px solid #52708d; border-radius: 6px; width: 40px; height: 40px; cursor: pointer; }
.visitor { margin-left: auto; color: #e7eef8; font-size: 14px; white-space: nowrap; }
.sidebar { position: fixed; z-index: 4; inset: var(--bar-height) auto 0 0; width: var(--sidebar-width); padding: 18px 12px; background: var(--navy); overflow-y: auto; }
.sidebar .nav-link { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 12px; border-radius: 6px; text-decoration: none; color: #fff; white-space: nowrap; }
.sidebar .nav-link:hover, .sidebar .nav-link.active { background: var(--blue); }
.sidebar .nav-link.active { box-shadow: inset 3px 0 var(--gold); }
.nav-icon { display: grid; width: 21px; place-items: center; }
.nav-icon > * { grid-area: 1 / 1; }
body.icons-ready .icon-fallback { display: none; }
.menu-collapsed .nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.workspace { margin-left: var(--sidebar-width); padding-top: var(--bar-height); min-height: 100vh; display: flex; flex-direction: column; }
.content { width: min(100%, 1280px); margin: 0 auto; flex: 1; padding: 26px clamp(16px, 4vw, 54px); }
.breadcrumb-text { margin-bottom: 18px; color: var(--secondary); font-size: 14px; }
.breadcrumb-text span { margin: 0 8px; color: var(--blue); }
.hero { background: linear-gradient(120deg, var(--navy), #0a3968); border-radius: 8px; border-left: 4px solid var(--gold); padding: clamp(20px, 4vw, 48px); color: white; margin-bottom: 20px; }
.hero p { color: #e2eaf7; margin: 12px 0 0; }
.hero h1, .error-panel h1 { font-size: clamp(24px, 4vw, 42px); line-height: 1.3; margin: 0; font-weight: 700; }
.panel { border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: 22px; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.panel p, .details p { margin: 5px 0 0; color: var(--secondary); }
.panel h2, .details h2 { font-size: 21px; margin: 0; font-weight: 700; }
.action { display: inline-flex; align-items: center; background: var(--blue); border: 1px solid var(--blue); color: #fff; min-height: 42px; padding: 6px 15px; border-radius: 6px; cursor: pointer; text-decoration: none; }
.action:hover { color: #fff; background: var(--navy); }
.details { border: 1px solid var(--border); border-radius: 8px; padding: 24px; width: min(540px, calc(100% - 32px)); max-height: calc(100% - 32px); }
.details::backdrop { background: #02224799; }
.details .action { margin-top: 16px; }
.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 14px; padding: 14px clamp(16px, 4vw, 54px); border-top: 1px solid var(--border); color: var(--secondary); font-size: 14px; background: #fff; }
.overlay { position: fixed; z-index: 3; inset: var(--bar-height) 0 0; background: #02224799; }
.exit-button { border: 1px solid #52708d; background: transparent; color: #fff; border-radius: 6px; padding: 6px 9px; }
.phase1-heading { margin: 4px 0 18px; }
.phase1-heading h1 { margin: 0; color: var(--navy); font-size: clamp(25px, 4vw, 36px); font-weight: 700; overflow-wrap: anywhere; }
.phase1-heading p, .phase1-hint { color: var(--secondary); margin: 6px 0 12px; }
.phase1-toolbar, .phase1-actions, .phase1-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.phase1-toolbar { justify-content: space-between; }
.phase1-tabs { margin-bottom: 12px; }
.phase1-card { min-width: 0; background: white; border: 1px solid var(--border); border-radius: 8px; padding: clamp(12px, 2.5vw, 24px); margin-bottom: 16px; }
.phase1-card h2, .modal-title { font-size: 21px; font-weight: 700; margin: 0 0 8px; }
.phase1-card.access-card { max-width: 480px; }
.phase1-filters, .phase1-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 155px), 1fr)); gap: 12px; align-items: start; }
.phase1-fields { grid-template-columns: repeat(auto-fit, minmax(min(100%, 215px), 1fr)); }
.phase1-filters { padding-bottom: 16px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.phase1-filters .phase1-actions { align-self: end; grid-column: 1 / -1; }
.phase1-fields label, .phase1-filters label { min-width: 0; margin: 0; }
.phase1-fields input, .phase1-fields select, .phase1-filters select { margin-top: 4px; }
.phase1-table { overflow-x: auto; width: 100%; }
.phase1-table table { min-width: 480px; margin-bottom: 6px !important; }
.phase1-table th { white-space: nowrap; font-weight: 700; }
.employee-complete-table td { white-space: nowrap; }
.phase1-table th, .phase1-table td { color: var(--text); }
.phase1-table .dataTables_paginate .pagination { flex-wrap: wrap; }
.secondary-action { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 6px 12px; border-radius: 6px; border: 1px solid #b6c3d5; background: white; color: var(--blue); cursor: pointer; }
.secondary-action:hover, .secondary-action.current { background: #e8eff8; color: var(--navy); }
.compact-action { min-height: 34px; padding: 3px 8px; white-space: nowrap; }
.danger-action, .required { color: #9b1728; }
.phase1-notice { padding: 10px 14px; background: #e8f5ec; border-radius: 6px; color: #175633; }
.form-error { background: #fbecef; color: #8c1629; padding: 9px; border-radius: 6px; }
.detail-list { margin: 12px 0 0; }
.detail-list dt { color: var(--secondary); font-size: 14px; }
.detail-list dd { font-weight: 600; overflow-wrap: anywhere; }
.phase1-mapping { border-top: 1px solid var(--border); padding: 10px 0; }
.phase1-mapping summary { color: var(--blue); cursor: pointer; }
.phase1-mapping p { color: var(--secondary); margin: 8px 0; }
.import-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 100px), 1fr)); gap: 8px; margin: 14px 0; }
.import-totals div { background: var(--background); border: 1px solid var(--border); border-radius: 6px; padding: 10px; }
.import-totals strong { display: block; font-size: 23px; color: var(--navy); }
.hash { font-family: monospace; }
.person-work-counts { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr)); gap:12px; }
.person-work-counts strong { font-size:32px; color:var(--navy); }
.task-photo-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(min(100%,170px),1fr)); gap:12px; margin-bottom:16px; }
.task-photo-grid img { width:100%; height:150px; object-fit:contain; background:var(--background); border:1px solid var(--border); border-radius:6px; }
.task-photo-grid span { display:block; font-size:14px; }
.notice-bell { color: white; display: inline-flex; gap: 5px; align-items: center; margin-left: auto; padding: 5px; }
.notice-bell:hover { color: white; }
.notice-bell + .visitor { margin-left: 8px; }
.notice-bell span { font-size: 12px; min-width: 18px; text-align: center; background: #064a8b; border-radius: 4px; }
.tracking-calendar { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); border-left: 1px solid var(--border); border-top: 1px solid var(--border); }
.calendar-day { min-width: 0; min-height: 130px; padding: 8px; background: white; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.calendar-day h2 { font-size: 14px; font-weight: 700; }
.calendar-today { background: #eef5ff; }
.calendar-event { display: block; background: #e8eff8; padding: 7px; border-left: 3px solid var(--blue); margin: 6px 0; border-radius: 4px; overflow-wrap: anywhere; }
.calendar-event span { display: block; font-size: 12px; }
.calendar-event strong { font-size: 14px; font-weight: 500; }
.event-followup { background: #fff7dd; border-color: var(--gold); }
.event-due { background: #fceef0; border-color: #9b1728; }
.calendar-day.calendar-today h2 { color: var(--blue); }
.calendar-day .phase1-hint { margin: 0; }
.calendar-day pre { white-space: pre-wrap; }
.tracking-calendar.calendar-view-day { grid-template-columns: 1fr; }
@media(max-width:767px) { .tracking-calendar { grid-template-columns: 1fr; } .calendar-day { min-height: 70px; } .notice-bell { font-size: 13px; } }
.meeting-prose { white-space: pre-wrap; overflow-wrap: anywhere; }
.meeting-event { max-width: 480px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.meeting-calendar { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,220px),1fr)); gap: 14px; }
.meeting-calendar-date { grid-column: 1 / -1; }
.roles-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 255px), 1fr)); gap: 14px; }
.login-page .workspace { margin-left: 0; padding-top: 0; }
.login-page .content { max-width: 520px; padding-top: clamp(32px, 10vh, 100px); }
.login-page .access-card { max-width: none; }
.portal-page .workspace { margin-left: 0; }
.system-card.card { min-height: 240px; border: 1px solid var(--border); border-radius: 8px; color: var(--navy); }
.system-card:hover { border-color: var(--blue); background: #edf3fb; color: var(--navy); text-decoration: none; }
.system-card .system-icon { font-size: 32px; color: var(--blue); margin-bottom: 24px; }
.system-card .card-title { font-size: 24px; font-weight: 700; line-height: 1.5; }
.system-card .card-text { padding-top: 16px; color: var(--blue); }
.role-options { display: grid; gap: 8px; margin-bottom: 16px; padding: 0; }
.role-options label { display: flex; align-items: baseline; gap: 8px; margin: 0; }
.role-options input { flex-shrink: 0; }
.select2-container--default .select2-selection--single { min-height: 38px; border: 1px solid #b6c3d5; }
.select2-container--default .select2-selection--single .select2-selection__rendered,
.select2-container--default .select2-selection--single .select2-selection__arrow { line-height: 36px; height: 36px; }
@media (max-width: 767px) {
    .topbar { padding: 0 12px; gap: 8px; }
    .topbar .brand { gap: 7px; font-size: 14px; }
    .topbar .exit-button { font-size: 13px; }
    .sidebar { display: none; width: min(280px, 86vw); }
    .menu-open .sidebar { display: block; }
    .menu-open { overflow: hidden; }
    .workspace { margin-left: 0; }
    .phase1-table .dataTables_paginate { overflow-x: auto; }
    .modal-dialog { margin: 8px; }
}
