:root {
    color-scheme: light;
    --ink: #122b2b;
    --muted: #4e6262;
    --line: #d5e1de;
    --canvas: #f2f6f4;
    --paper: #fff;
    --accent: #0e5b4c;
    --accent-hover: #084336;
    --soft: #e5f4ed;
    --radius: 16px;
    font-family: Kanit, "Noto Sans Thai", "Thonburi", system-ui, sans-serif;
    font-size: 16px;
    color: var(--ink);
    background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; line-height: 1.55; }
button, input, select, textarea { font: inherit; }
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.65rem, 4vw, 2.3rem); line-height: 1.28; overflow-wrap: anywhere; }
h2 { font-size: 1.18rem; margin: 0 0 12px; }
h3 { font-size: 1rem; }
p { margin: 6px 0 12px; }
small, .muted, .heading p { color: var(--muted); }
:focus-visible { outline: 3px solid #087b70; outline-offset: 3px; }

.container { width: min(100% - 32px, 1184px); margin-inline: auto; }
.masthead { background: #102e2b; color: #fff; }
.nav, .identity { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.nav { min-height: 72px; }
.brand { color: #fff; text-decoration: none; font-size: 1.2rem; font-weight: 700; letter-spacing: .015em; }
.identity span { max-width: 15rem; overflow-wrap: anywhere; }
.masthead :focus-visible { outline-color: #b5f3d9; }
.masthead .ghost { color: #fff; border-color: #689084; }
.content { padding: clamp(24px, 5vw, 56px) 0 80px; }
.heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.sync { display: grid; justify-items: end; gap: 8px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); padding: clamp(16px, 3vw, 26px); }
.login { max-width: 480px; margin: clamp(24px, 12vh, 112px) auto 0; padding: 32px; }
.login .button { width: 100%; margin-top: 12px; }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 48px; padding: 8px 16px; border: 1px solid transparent; border-radius: 8px; color: var(--ink); background: var(--paper); font-weight: 650; line-height: 1.3; text-decoration: none; white-space: nowrap; cursor: pointer; }
.primary, .line { color: #fff; background: var(--accent); }
.primary:hover, .line:hover { background: var(--accent-hover); }
.secondary, .ghost { color: var(--accent); border-color: #a8c2ba; }
.button:disabled { background: #e4eae7; color: #50605a; cursor: default; }
.notice { margin: 0 0 16px; background: #e9f2f0; border-left: 3px solid #508977; border-radius: 6px; padding: 12px 14px; overflow-wrap: anywhere; }
.notice.error { background: #fff1ee; color: #741f1b; border-color: #b9382c; }
.notice.warning { background: #fff4de; color: #5b370a; border-color: #a86408; }
.notice.success { background: var(--soft); color: #154938; }

.status-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.status-filters a { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); text-decoration: none; background: var(--paper); }
.status-filters a.selected { border-color: var(--accent); background: var(--soft); color: #103f32; }
.table-card { padding: 0; overflow: hidden; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #eaf1ed; font-size: .9rem; }
tr:last-child td { border-bottom: 0; }
.request-link { display: inline-flex; min-height: 48px; align-items: center; font-weight: 700; }
.amount { font-variant-numeric: tabular-nums; text-align: right; }
.nowrap { white-space: nowrap; }
.badge { display: inline-flex; align-items: center; min-height: 32px; padding: 2px 10px; background: #edf1f2; color: #314547; border-radius: 6px; font-size: .88rem; font-weight: 700; white-space: nowrap; }
.badge.submitted { background: #e6eef9; color: #163b67; }
.badge.returned { background: #fff0d7; color: #6b410a; }
.badge.accepted { background: var(--soft); color: #174f3d; }
.empty { min-height: 152px; }

.back { display: inline-flex; align-items: center; min-height: 48px; font-weight: 650; }
.request-code { font-weight: 700; color: var(--accent) !important; }
.request-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 0 0 20px; }
dt { color: var(--muted); font-size: .88rem; }
dd { margin: 4px 0 0; font-weight: 650; overflow-wrap: anywhere; }
.request-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
.app-menu { display: flex; flex-wrap: wrap; gap: 4px 20px; border-bottom: 1px solid var(--line); margin: -12px 0 24px; }
.app-menu a { display: flex; min-height: 48px; align-items: center; font-weight: 650; }
.section-gap { margin-block: 0 20px; }
.card + .section-gap, .table-card + .section-gap { margin-top: 20px; }
.filter-form { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; }
.filter-form > label { flex: 1 1 174px; }
.filter-form > .button { align-self: end; }
.document-stack { display: grid; gap: 20px; }
.files { padding: 0; margin: 0 0 16px; list-style: none; }
.files li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.files a { display: flex; min-height: 44px; align-items: center; }
.upload, .spend-entry { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 12px; row-gap: 8px; align-items: end; }
.upload .button, .spend-entry > .button { justify-self: start; }
label { display: grid; min-width: 0; gap: 6px; font-weight: 650; }
select, input:not([type="hidden"]), textarea { min-width: 0; width: 100%; min-height: 52px; color: var(--ink); background: #fff; border: 1px solid #a4b6b1; border-radius: 7px; padding: 8px 10px; font-weight: 400; }
input[type="file"] { padding: 8px 6px; }
textarea { resize: vertical; }
.spend { margin: 8px 0 16px; padding: 12px 0 16px; border-top: 1px solid var(--line); }
.spend-title { display: flex; justify-content: space-between; gap: 12px; }
.spend-title h3 { overflow-wrap: anywhere; }
.spend-title strong { white-space: nowrap; }
.spend-edit summary { display: list-item; min-height: 48px; padding-top: 12px; color: var(--accent); cursor: pointer; }
.review-form { display: grid; gap: 10px; margin-top: 18px; }
.checklist { padding-inline-start: 22px; }
.checklist li { margin-bottom: 8px; }

@media (max-width: 780px) {
    .request-layout { grid-template-columns: 1fr; }
    .request-facts { grid-template-columns: 1fr 1fr; }
    thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    table, tbody, tr, td { display: block; width: 100%; }
    tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
    td { display: flex; flex-wrap: wrap; justify-content: space-between; padding: 5px 0; gap: 6px 16px; border: 0; text-align: left; }
    td:first-child { display: block; }
    td:not(:first-child)::before { content: attr(data-label); color: var(--muted); font-size: .88rem; }
    tr:last-child { border: 0; }
}

@media (max-width: 480px) {
    .container { width: calc(100% - 24px); }
    .heading { align-items: flex-start; flex-direction: column; gap: 12px; }
    .sync { justify-items: start; }
    .nav { gap: 8px; }
    .identity { gap: 4px; }
    .identity span { max-width: 90px; font-size: .85rem; }
    .masthead .button { padding-inline: 8px; }
    .brand { font-size: 1.03rem; }
    .upload, .spend-entry { grid-template-columns: 1fr; }
    .upload > .button, .spend-entry > .button { justify-self: stretch; }
}
