:root {
    --ink: #18322c;
    --muted: #64736f;
    --surface: #ffffff;
    --surface-soft: #f2f7f5;
    --line: #dce8e3;
    --green: #087f5b;
    --green-dark: #056347;
    --green-soft: #dff5ea;
    --lime: #b9db65;
    --danger: #b42318;
    --danger-soft: #fee4e2;
    --shadow: 0 18px 50px rgba(19, 62, 49, .10);
    --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--surface);
    font-family: "Anuphan", "Leelawadee UI", Tahoma, sans-serif;
    line-height: 1.65;
}
a { color: var(--green); }
button, input, select, textarea { font: inherit; }
.container { width: min(1120px, calc(100% - 32px)); margin-inline: auto; }
.narrow { max-width: 760px; }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; }
.skip-link:focus { left: 8px; padding: 8px 12px; background: white; border-radius: 8px; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255,255,255,.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}
.nav-wrap { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 1.05rem; font-weight: 800; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: white; background: var(--green); border-radius: 12px; font-size: 1.25rem; }
.main-nav { display: flex; align-items: center; gap: 22px; }
.main-nav a { color: var(--ink); text-decoration: none; font-weight: 650; }
.main-nav a:hover { color: var(--green); }
.nav-user { color: var(--muted); }
.nav-toggle { display: none; padding: 8px 13px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--ink); }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 10px 20px;
    border: 1px solid var(--green);
    border-radius: 12px;
    color: white !important;
    background: var(--green);
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
}
.button:hover { background: var(--green-dark); }
.button-secondary { color: var(--green) !important; background: transparent; }
.button-small { min-height: 38px; padding: 6px 14px; }
.button-block { width: 100%; }
.button-danger { border-color: var(--danger); color: var(--danger) !important; background: white; }
.button-danger:hover { color: white !important; background: var(--danger); }

.hero { overflow: hidden; padding: 88px 0 72px; background: radial-gradient(circle at 85% 10%, #d8f2df 0, transparent 36%), linear-gradient(135deg, #f7fbf9, #eef7f2); }
.hero-grid { display: grid; grid-template-columns: 1.12fr .88fr; align-items: center; gap: 70px; }
.eyebrow { display: block; margin-bottom: 12px; color: var(--green); font-size: .78rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3 { margin-top: 0; line-height: 1.25; }
h1 { margin-bottom: 22px; font-size: clamp(2.25rem, 5vw, 4.5rem); letter-spacing: -.045em; }
h1 span { color: var(--green); }
h2 { font-size: clamp(1.8rem, 3.5vw, 2.75rem); }
.hero-copy { max-width: 650px; color: var(--muted); font-size: 1.12rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.status-line { display: flex; align-items: center; gap: 9px; margin-top: 26px; color: var(--muted); font-size: .92rem; }
.status-dot { width: 10px; height: 10px; border-radius: 999px; background: #98a2b3; box-shadow: 0 0 0 4px #eaecf0; }
.status-ok { background: #12b76a; box-shadow: 0 0 0 4px #d1fadf; }
.status-error { background: #f04438; box-shadow: 0 0 0 4px #fee4e2; }
.hero-card { padding: 24px; border: 1px solid rgba(255,255,255,.8); border-radius: 28px; background: rgba(255,255,255,.76); box-shadow: var(--shadow); transform: rotate(1.5deg); }
.metric-card { padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.metric-card span, .metric-card small { display: block; color: var(--muted); }
.metric-card strong { display: block; margin: 4px 0; font-size: 1.35rem; }
.metric-primary { min-height: 190px; padding: 32px; color: white; background: var(--green); border: 0; }
.metric-primary span, .metric-primary small { color: rgba(255,255,255,.78); }
.metric-primary strong { margin: 18px 0 8px; font-size: 2.8rem; }
.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }

.section { padding: 72px 0; }
.section-soft { background: var(--surface-soft); }
.section-heading { max-width: 660px; margin-bottom: 34px; }
.feature-grid, .dashboard-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.feature-card, .panel, .dashboard-card { padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: 0 8px 30px rgba(19,62,49,.04); }
.feature-icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 28px; border-radius: 12px; color: var(--green); background: var(--green-soft); font-weight: 850; }
.feature-card p, .panel p { margin-bottom: 0; color: var(--muted); }

.page-header { padding: 48px 0 22px; background: var(--surface-soft); border-bottom: 1px solid var(--line); }
.page-header h1 { margin-bottom: 8px; font-size: clamp(2rem, 4vw, 3.1rem); }
.page-header p { margin: 0; color: var(--muted); }
.form-card { padding: 30px; border: 1px solid var(--line); border-radius: 22px; background: white; box-shadow: var(--shadow); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-group { display: flex; flex-direction: column; gap: 7px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-weight: 700; }
.input {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid #b8c9c2;
    border-radius: 10px;
    color: var(--ink);
    background: white;
}
.input:focus { border-color: var(--green); outline: 3px solid rgba(8,127,91,.15); }
.validation { color: var(--danger); font-size: .86rem; }
.alert { margin-bottom: 18px; padding: 13px 15px; border-radius: 10px; }
.alert-error { color: var(--danger); background: var(--danger-soft); }
.alert-success { color: var(--green-dark); background: var(--green-soft); }
.alert-warning { color: #854d0e; background: #fef3c7; }
.date-input { background: #fff no-repeat right 12px center; padding-right: 42px; cursor: pointer; }
.date-hint { color: var(--muted); font-size: .82rem; }

/* SweetAlert2 follows the application typography and button system. */
.swal2-popup { font-family: "Anuphan", "Leelawadee UI", Tahoma, sans-serif !important; border-radius: 20px !important; }
.swal2-title { color: var(--ink) !important; font-size: 1.55rem !important; }
.swal2-html-container { color: var(--muted) !important; }
.swal-confirm, .swal-cancel {
    min-height: 44px;
    padding: 9px 20px;
    border-radius: 11px;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
}
.swal-confirm { border: 1px solid var(--green); color: white; background: var(--green); }
.swal-confirm:hover { background: var(--green-dark); }
.swal-cancel { border: 1px solid var(--line); color: var(--ink); background: white; }

/* Flatpickr Thai datepicker. */
.flatpickr-calendar { font-family: "Anuphan", "Leelawadee UI", Tahoma, sans-serif; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.flatpickr-months { padding-top: 8px; }
.flatpickr-current-month { font-size: 1rem; }
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year { font-family: inherit; font-weight: 700; }
.flatpickr-weekday { color: var(--muted) !important; font-weight: 700 !important; }
.flatpickr-day { border-radius: 10px; }
.flatpickr-day:hover { border-color: var(--green-soft); background: var(--green-soft); }
.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange { border-color: var(--green); background: var(--green); }
.form-actions { display: flex; align-items: center; gap: 14px; margin-top: 24px; }
.helper { color: var(--muted); font-size: .9rem; }
.center { text-align: center; }
.error-code { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 20px; color: var(--danger); background: var(--danger-soft); border-radius: 50%; font-size: 2rem; font-weight: 900; }

.dashboard-card .value { margin: 8px 0 0; color: var(--green); font-size: 2rem; font-weight: 850; }
.dashboard-card .label { color: var(--muted); }
.card-link { display: inline-block; margin-top: 10px; color: var(--green); font-size: .86rem; font-weight: 700; text-decoration: none; }
.record-page-header { padding-bottom: 0; }
.page-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.record-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 34px 0 0; padding: 0; list-style: none; }
.record-steps li { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 3px solid var(--line); color: var(--muted); font-weight: 700; }
.record-steps li span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: var(--muted); background: white; border: 1px solid var(--line); }
.record-steps li.active { color: var(--green); border-color: var(--green); }
.record-steps li.active span { color: white; background: var(--green); border-color: var(--green); }
.record-container { display: grid; gap: 22px; }
.record-panel { padding: 0; overflow: hidden; }
.record-panel > :not(.panel-heading) { margin-right: 26px; margin-left: 26px; }
.record-panel > :last-child { margin-bottom: 26px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 24px; padding: 22px 26px; border-bottom: 1px solid var(--line); background: #fbfdfc; }
.panel-heading h2 { margin: 2px 0 0; font-size: 1.3rem; }
.panel-kicker { color: var(--green); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.required-note, .item-counter { color: var(--muted); font-size: .86rem; }
.item-counter { padding: 6px 11px; border-radius: 999px; color: var(--green-dark); background: var(--green-soft); font-weight: 700; }
.textarea { min-height: 76px; resize: vertical; }
.item-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.item-form-actions, .record-save-actions { display: flex; align-items: center; gap: 14px; margin-top: 22px; }
.record-save-actions { justify-content: flex-end; padding-top: 22px; border-top: 1px solid var(--line); }
.empty-state { padding: 34px 20px; border: 1px dashed #b8c9c2; border-radius: 14px; text-align: center; background: var(--surface-soft); }
.empty-state strong, .empty-state p { display: block; }
.empty-state p { margin: 5px 0 0; color: var(--muted); }
.empty-icon { display: grid; place-items: center; width: 50px; height: 50px; margin: 0 auto 12px; border-radius: 50%; color: var(--green); background: var(--green-soft); font-size: 1.5rem; }
.record-table-wrap { overflow-x: auto; }
.record-table { width: 100%; border-collapse: collapse; }
.record-table th, .record-table td { padding: 13px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.record-table th { color: var(--muted); background: #fbfdfc; font-size: .82rem; white-space: nowrap; }
.record-table td small { display: block; margin-top: 3px; color: var(--muted); }
.record-table .number-cell { text-align: right; white-space: nowrap; }
.action-cell { width: 54px; text-align: right !important; }
.remove-link { color: var(--danger); font-weight: 700; text-decoration: none; }
.summary-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--line); overflow: hidden; }
.summary-strip > div { padding: 16px; background: white; }
.summary-strip span, .summary-strip strong { display: block; }
.summary-strip span { color: var(--muted); font-size: .82rem; }
.summary-strip strong { margin-top: 3px; font-size: 1.08rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.admin-filter-bar { display: grid; grid-template-columns: minmax(180px, .55fr) minmax(260px, 1.3fr) auto auto; align-items: end; gap: 14px; margin-bottom: 22px; }
.admin-filter-bar .button { margin-bottom: 0; }
.status-badge { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 10px; border-radius: 999px; font-size: .8rem; font-weight: 800; white-space: nowrap; }
.status-pending { color: #854d0e; background: #fef3c7; }
.status-active { color: var(--green-dark); background: var(--green-soft); }
.status-suspended { color: #9a3412; background: #ffedd5; }
.status-rejected { color: var(--danger); background: var(--danger-soft); }
.status-draft { color: #475467; background: #f2f4f7; }
.status-submitted { color: #175cd3; background: #eff8ff; }
.status-approved { color: var(--green-dark); background: var(--green-soft); }
.status-cancelled { color: #667085; background: #eaecf0; }
.status-start { color: #475467; background: #f2f4f7; }
.member-actions { display: flex; flex-wrap: wrap; gap: 7px; min-width: 150px; }
.member-admin-table td:first-child { min-width: 230px; }
.report-filter-bar { display: grid; grid-template-columns: minmax(150px, .55fr) minmax(180px, .7fr) minmax(260px, 1.25fr) auto; align-items: end; gap: 14px; margin-bottom: 22px; }
.report-metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
.report-metric { min-width: 0; padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.report-metric span, .report-metric small { display: block; color: var(--muted); }
.report-metric span { font-size: .82rem; }
.report-metric strong { display: block; margin: 6px 0 2px; color: var(--green); font-size: clamp(1.2rem, 2.2vw, 1.75rem); overflow-wrap: anywhere; }
.report-metric small { font-size: .72rem; }
.report-table-wrap { margin-top: 4px; }
.admin-summary-table td:first-child { min-width: 220px; }
.admin-summary-table td:nth-child(2) { min-width: 230px; }
.report-note { margin: 14px 0 0; color: var(--muted); font-size: .8rem; }
.daily-summary-filter { display: grid; grid-template-columns: minmax(180px,.6fr) minmax(280px,1.25fr) minmax(190px,.7fr) auto; align-items: end; gap: 14px; margin-bottom: 24px; }
.daily-metric-grid { grid-template-columns: repeat(5,minmax(0,1fr)); margin-bottom: 0; }
.carbon-calculation-note { padding: 18px 20px; border: 1px solid #b2ddff; border-radius: 14px; color: #175cd3; background: #eff8ff; }
.carbon-calculation-note strong, .carbon-calculation-note span, .carbon-calculation-note small { display: block; }
.carbon-calculation-note span { margin-top: 6px; font-weight: 700; }
.carbon-calculation-note small { margin-top: 5px; color: #475467; }
.daily-location-table td:first-child, .daily-location-table td:nth-child(2) { min-width: 210px; }
.daily-location-table td:nth-child(3) { min-width: 230px; }
.daily-breakdown-table td:first-child, .daily-breakdown-table td:nth-child(2) { min-width: 180px; }
.record-status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.member-record-filter { display: grid; grid-template-columns: minmax(180px, .55fr) minmax(280px, 1.35fr) auto auto; align-items: end; gap: 14px; margin-bottom: 22px; }
.member-record-table td:first-child { min-width: 190px; }
.member-record-table td:nth-child(2) { min-width: 150px; }
.member-account-table td:first-child { min-width: 150px; }
.member-account-table td:nth-child(2) { min-width: 210px; }
.user-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.user-filter-bar { grid-template-columns: minmax(150px, .5fr) minmax(170px, .55fr) minmax(260px, 1.2fr) auto auto; }
.user-admin-table td:first-child { min-width: 170px; }
.user-admin-table td:nth-child(2) { min-width: 210px; }
.user-admin-table td:nth-child(4) { min-width: 190px; }
.account-context-card { padding: 22px 26px; }
.account-context-card h2 { margin: 4px 0 0; font-size: 1.35rem; }
.account-context-card p { margin-top: 3px; }
.account-actions { justify-content: space-between; }
.password-security-note { margin: 0 26px 20px; padding: 13px 15px; border: 1px solid #b2ddff; border-radius: 12px; color: #175cd3; background: #eff8ff; font-size: .88rem; }
.review-header-actions { display: flex; align-items: center; gap: 12px; }
.review-metadata-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.review-metadata-grid > div { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.review-metadata-grid span, .review-metadata-grid strong { display: block; }
.review-metadata-grid span { color: var(--muted); font-size: .8rem; }
.review-metadata-grid strong { margin-top: 4px; overflow-wrap: anywhere; }
.review-metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.document-note { margin-top: 4px; padding: 15px; border-left: 3px solid var(--green); background: var(--surface-soft); }
.document-note span { color: var(--muted); font-size: .8rem; font-weight: 700; }
.document-note p { margin: 5px 0 0; white-space: pre-wrap; }
.review-comment-field { margin-bottom: 0; }
.review-item-table td:first-child { width: 42px; }
.review-item-table td:nth-child(2), .review-item-table td:nth-child(5) { min-width: 170px; }
.approval-history-table td:last-child { min-width: 220px; }
.review-queue-table td:first-child, .review-queue-table td:nth-child(2) { min-width: 180px; }
.site-footer { padding: 28px 0; border-top: 1px solid var(--line); color: var(--muted); background: #fbfdfc; }
.footer-wrap { display: flex; justify-content: space-between; gap: 20px; }

@media (max-width: 820px) {
    .nav-toggle { display: inline-flex; }
    .main-nav { display: none; position: absolute; inset: 72px 16px auto; padding: 18px; align-items: stretch; flex-direction: column; gap: 12px; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: var(--shadow); }
    .main-nav.is-open { display: flex; }
    .hero { padding-top: 56px; }
    .hero-grid { grid-template-columns: 1fr; gap: 42px; }
    .hero-card { transform: none; }
    .feature-grid, .dashboard-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .item-form-grid { grid-template-columns: 1fr; }
    .admin-filter-bar { grid-template-columns: 1fr 1fr; }
    .admin-search-field { grid-column: 2; }
    .report-filter-bar { grid-template-columns: 1fr 1fr; }
    .report-member-filter { grid-column: 1 / -1; }
    .report-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .daily-summary-filter { grid-template-columns: 1fr 1fr; }
    .daily-member-filter { grid-column: 1 / -1; }
    .record-status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .member-record-filter { grid-template-columns: 1fr 1fr; }
    .member-record-search { grid-column: 2; }
    .user-filter-bar { grid-template-columns: 1fr 1fr; }
    .user-account-search { grid-column: 1 / -1; }
    .review-metadata-grid, .review-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-group.full { grid-column: auto; }
    .page-header-row { flex-direction: column; }
    .record-steps li { padding: 12px 8px; font-size: .8rem; }
    .record-steps li span { flex: 0 0 auto; }
    .summary-strip { grid-template-columns: 1fr; }
    .record-table, .record-table tbody, .record-table tr, .record-table td { display: block; width: 100%; }
    .record-table thead { display: none; }
    .record-table tr { margin-bottom: 14px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
    .record-table td { display: grid; grid-template-columns: minmax(100px, 38%) 1fr; gap: 12px; border-bottom: 1px solid var(--line); text-align: left !important; white-space: normal !important; }
    .record-table td:last-child { border-bottom: 0; }
    .record-table td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 700; }
    .action-cell { width: auto; }
    .record-save-actions { align-items: stretch; flex-direction: column-reverse; }
    .record-save-actions .button { width: 100%; }
    .footer-wrap { flex-direction: column; }
}

@media (max-width: 480px) {
    .container { width: min(100% - 22px, 1120px); }
    .hero-actions .button { width: 100%; }
    .mini-grid { grid-template-columns: 1fr; }
    .form-card { padding: 20px; }
    .record-panel > :not(.panel-heading) { margin-right: 16px; margin-left: 16px; }
    .panel-heading { padding: 18px 16px; }
    .record-steps { grid-template-columns: 1fr; }
    .record-steps li { border-bottom-width: 1px; border-left: 3px solid var(--line); }
    .record-steps li.active { border-left-color: var(--green); border-bottom-color: var(--line); }
    .item-form-actions { align-items: stretch; flex-direction: column; }
    .admin-filter-bar { grid-template-columns: 1fr; }
    .admin-search-field { grid-column: auto; }
    .admin-filter-bar .button { width: 100%; }
    .member-actions { min-width: 0; }
    .report-filter-bar { grid-template-columns: 1fr; }
    .report-member-filter { grid-column: auto; }
    .report-filter-bar .button { width: 100%; }
    .report-metric-grid { grid-template-columns: 1fr; }
    .daily-summary-filter { grid-template-columns: 1fr; }
    .daily-member-filter { grid-column: auto; }
    .daily-summary-filter .button { width: 100%; }
    .record-status-grid { grid-template-columns: 1fr 1fr; }
    .member-record-filter { grid-template-columns: 1fr; }
    .member-record-search { grid-column: auto; }
    .member-record-filter .button { width: 100%; }
    .user-summary-grid, .user-filter-bar { grid-template-columns: 1fr; }
    .user-account-search { grid-column: auto; }
    .user-filter-bar .button { width: 100%; }
    .password-security-note { margin-right: 16px; margin-left: 16px; }
    .review-header-actions { align-items: flex-start; flex-direction: column; }
    .review-metadata-grid, .review-metric-grid { grid-template-columns: 1fr; }
}
