:root {
    --green-900: #14551f;
    --green-800: #176a29;
    --green-700: #18752c;
    --green-100: #e8f5eb;
    --green-050: #f5fbf6;
    --line: #dce8df;
    --text: #183327;
    --muted: #66786d;
    --bg: #f3f6f4;
    --white: #fff;
    --teal: #149db1;
    --danger: #dc2626;
    --warning: #f59e0b;
    font-family: Tahoma, "Noto Sans Thai", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--bg); line-height: 1.65; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.topbar {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: var(--white);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--green-800);
    color: white;
    font-weight: 700;
}
.brand small, .user-card span, .muted { display: block; color: var(--muted); font-size: 13px; }
.topbar nav { display: flex; gap: 8px; align-items: center; }
.topbar nav a, .pill, .button {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 14px;
    background: var(--white);
    color: var(--green-800);
    font-weight: 700;
}
.topbar nav a:hover, .button:hover { border-color: #b8d7c0; background: var(--green-050); }

.public-wrap { width: min(1100px, calc(100% - 32px)); margin: 16px auto 48px; background: var(--white); box-shadow: 0 18px 36px rgba(20, 60, 31, .12); }
.hero {
    min-height: 215px;
    display: grid;
    place-items: center;
    color: white;
    text-align: center;
    background: radial-gradient(circle at 96% 22%, rgba(255,255,255,.22) 0 95px, transparent 96px), linear-gradient(115deg, #14551f, #1d7d31 62%, #61b766);
}
.hero h1 { margin: 0; font-size: clamp(34px, 5vw, 52px); line-height: 1; text-shadow: 0 2px 4px rgba(0,0,0,.18); letter-spacing: 0; }
.hero .rule { width: 175px; height: 1px; background: rgba(255,255,255,.26); margin: 22px auto 10px; }
.hero p { margin: 0; font-size: 24px; font-weight: 700; }
.public-content { padding: 26px 29px 38px; }
.category-tabs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 20px; }
.pill { border-radius: 999px; background: var(--green-100); border-color: #cce6d2; min-width: 92px; text-align: center; }
.pill.active { background: var(--green-800); color: white; box-shadow: 0 4px 10px rgba(20, 80, 31, .24); }
.pill.icon { min-width: 48px; width: 48px; padding-inline: 0; }
.section-banner {
    border: 1px solid var(--line);
    border-left: 5px solid #2d9545;
    border-radius: 8px;
    padding: 13px 18px;
    text-align: center;
    font-weight: 700;
    color: var(--green-800);
    background: #fbfdfb;
    margin-bottom: 16px;
}
.filterbar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.search { width: min(390px, 100%); border: 1px solid var(--line); border-radius: 8px; padding: 10px 13px; background: white; }

.data-table { width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: white; }
.data-table th { background: #edf4ef; padding: 14px 16px; font-weight: 700; color: #2a4034; }
.data-table td { padding: 17px 16px; border-top: 1px solid #e7eee9; vertical-align: middle; }
.data-table tbody tr.group-row td { background: #e7f5e9; color: var(--green-800); font-weight: 700; border-left: 5px solid #2d9545; }
.code-cell { width: 110px; text-align: center; color: var(--green-800); font-weight: 700; white-space: nowrap; }
.action-cell { width: 230px; white-space: nowrap; }
.status-cell { width: 140px; text-align: center; }
.file-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.file-button, .copy-button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 36px;
    border-radius: 999px;
    cursor: pointer;
}
.file-button { background: var(--teal); color: white; padding: 7px 13px; font-weight: 700; box-shadow: inset 0 -2px 0 rgba(0,0,0,.15); }
.copy-button { color: var(--green-800); background: #f3faf5; border: 1px solid #c9decd; padding: 6px 12px; font-size: 13px; font-weight: 700; }
.status-check {
    width: 31px;
    height: 31px;
    margin: 0 auto 3px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: white;
    background: var(--badge-color, #16a34a);
    box-shadow: 0 0 0 5px #e8f6ed;
    font-weight: 900;
}
.status-date { color: var(--green-800); font-size: 12px; }
.badge { border: 1px solid color-mix(in srgb, var(--badge-color, #16a34a), white 70%); color: var(--badge-color, #16a34a); background: color-mix(in srgb, var(--badge-color, #16a34a), white 90%); border-radius: 999px; padding: 4px 10px; font-weight: 700; white-space: nowrap; }
.badge.muted { color: var(--muted); border-color: var(--line); background: #f8faf9; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; background: #fbfdfb; }

.hero-progress { position: absolute; right: 28px; bottom: 18px; text-align: right; font-size: 13px; color: rgba(255,255,255,.8); }
.hero { position: relative; }
.progress-bar-wrap { height: 6px; width: 170px; background: rgba(255,255,255,.25); border-radius: 99px; margin-top: 5px; }
.progress-bar-fill { height: 100%; background: white; border-radius: 99px; transition: width .5s; }
.public-footer { text-align: center; padding: 20px 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.flash { width: min(1100px, calc(100% - 32px)); margin: 16px auto 0; padding: 12px 16px; border: 1px solid #bfe5c7; border-radius: 8px; color: var(--green-800); background: #eef9f0; font-weight: 700; }
.login-panel { width: min(430px, calc(100% - 32px)); margin: 54px auto; background: white; border: 1px solid var(--line); border-radius: 10px; padding: 28px; box-shadow: 0 18px 34px rgba(20,60,31,.1); }
.login-panel h1 { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-weight: 700; color: #294234; }
.field input, .field select, .field textarea {
    width: 100%;
    border: 1px solid #ceddd3;
    border-radius: 8px;
    padding: 10px 12px;
    background: white;
}
.field textarea { min-height: 94px; resize: vertical; }
.field.full { grid-column: 1 / -1; }
.button { border-color: transparent; background: var(--green-800); color: white; font-weight: 700; padding-inline: 16px; }
.button.secondary { background: var(--teal); }
.button.danger { background: var(--danger); }
.button.ghost { background: white; border-color: var(--line); color: var(--green-800); }
.button.small { min-height: 30px; padding: 4px 10px; font-size: 13px; }

.admin-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.sidebar { background: #102f1b; color: white; padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.sidebar a { padding: 10px 12px; border-radius: 8px; color: #e5f6e8; }
.sidebar a.active, .sidebar a:hover { background: rgba(255,255,255,.13); }
.user-card { border: 1px solid rgba(255,255,255,.14); border-radius: 8px; padding: 14px; margin-bottom: 8px; }
.user-card span { color: #bfe5c7; }
.admin-main { padding: 24px; min-width: 0; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-title h1 { margin: 0; line-height: 1.2; }
.panel { background: white; border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.panel h2 { margin: 0 0 14px; font-size: 20px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { background: white; border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.stat strong { display: block; font-size: 32px; color: var(--green-800); line-height: 1.1; }
.admin-table { width: 100%; border-collapse: collapse; background: white; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.admin-table th, .admin-table td { border-bottom: 1px solid #e7eee9; padding: 10px 12px; text-align: left; vertical-align: top; }
.admin-table th { background: #edf4ef; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.file-list { display: grid; gap: 6px; margin: 8px 0; }
.file-list a { color: var(--teal); font-weight: 700; }

@media (max-width: 820px) {
    .topbar { height: auto; align-items: flex-start; flex-direction: column; gap: 12px; padding: 14px 16px; }
    .topbar nav { flex-wrap: wrap; }
    .public-wrap { width: 100%; margin-top: 0; }
    .public-content { padding: 18px 12px 28px; }
    .hero { min-height: 180px; }
    .hero p { font-size: 18px; }
    .filterbar, .page-title { flex-direction: column; align-items: stretch; }
    .data-table { display: block; overflow-x: auto; white-space: normal; }
    .admin-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .form-grid, .stats { grid-template-columns: 1fr; }
    .admin-main { padding: 16px; }
}
