* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, "Noto Sans Thai", sans-serif;
    color: #16231f;
    background: #f5f7f4;
}

a {
    color: inherit;
}

.page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.panel,
.qr-panel,
.admin-section,
.metric-grid article {
    border: 1px solid #d9e2dd;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 12px 34px rgba(25, 43, 36, 0.08);
}

.panel {
    width: min(100%, 520px);
    padding: 30px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    color: #ffffff;
    background: #06c755;
    font-size: 13px;
    font-weight: 700;
}

.badge.error {
    background: #c62828;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 8px;
    font-size: 30px;
    line-height: 1.25;
}

h2 {
    margin-bottom: 10px;
    font-size: 22px;
}

p {
    color: #5b6c65;
    line-height: 1.65;
}

.button,
button,
.link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border: 0;
    border-radius: 6px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.button.line {
    width: 100%;
    color: #ffffff;
    background: #06c755;
}

.button.secondary,
button,
.link-button {
    color: #ffffff;
    background: #253832;
}

.form {
    display: grid;
    gap: 16px;
}

label {
    display: grid;
    gap: 8px;
    font-weight: 700;
}

input,
select {
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid #cbd7d1;
    border-radius: 6px;
    background: #ffffff;
    font: inherit;
}

.alert,
.success {
    padding: 12px 14px;
    border-radius: 6px;
}

.alert {
    color: #8a1f1f;
    background: #ffe9e9;
}

.success {
    color: #145b2f;
    background: #e7f8ed;
}

.result {
    display: grid;
    gap: 8px;
    margin-top: 18px;
    padding: 14px;
    border: 1px solid #c9ded2;
    border-radius: 8px;
    background: #f4fbf6;
    overflow-wrap: anywhere;
}

.result span {
    color: #65766f;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.result strong {
    font-size: 15px;
}

.claim-page {
    width: min(100%, 960px);
    margin: 0 auto;
    padding: 24px;
}

.claim-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.qr-panel {
    display: grid;
    grid-template-columns: minmax(260px, 380px) 1fr;
    gap: 28px;
    padding: 28px;
}

.qr-box {
    display: grid;
    place-items: center;
    min-height: 320px;
    border: 1px solid #dbe5df;
    border-radius: 8px;
    background: #f9fbfa;
}

.qr-box img {
    width: min(100%, 320px);
    height: auto;
}

.qr-missing {
    display: grid;
    gap: 10px;
    padding: 22px;
    text-align: center;
    overflow-wrap: anywhere;
}

.claim-detail dl {
    display: grid;
    gap: 14px;
    margin: 24px 0 0;
}

.claim-detail dt {
    color: #65766f;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.claim-detail dd {
    margin: 4px 0 0;
    overflow-wrap: anywhere;
    font-weight: 700;
}

.empty-state {
    grid-column: 1 / -1;
    padding: 36px;
    text-align: center;
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 9px;
    border-radius: 999px;
    color: #ffffff;
    background: #607d8b;
    font-size: 12px;
    font-weight: 700;
}

.status.available {
    background: #2e7d32;
}

.status.staging,
.status.given {
    background: #1565c0;
}

.status.used {
    background: #6a1b9a;
}

.status.expired,
.status.void,
.status.cancelled {
    background: #9e3b25;
}

.admin-page {
    width: min(100%, 1200px);
    margin: 0 auto;
    padding: 22px;
}

.admin-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.admin-nav a {
    padding: 10px 14px;
    border-radius: 6px;
    color: #253832;
    background: #e8efeb;
    text-decoration: none;
    font-weight: 700;
}

.admin-nav a.active {
    color: #ffffff;
    background: #253832;
}

.admin-header {
    margin-bottom: 18px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.metric-grid article {
    padding: 18px;
}

.metric-grid span {
    display: block;
    color: #65766f;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.metric-grid strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
}

.admin-section {
    padding: 18px;
    margin-bottom: 18px;
}

.admin-card {
    margin: 0;
}

.filter-bar {
    display: grid;
    grid-template-columns: 180px 1fr auto;
    gap: 10px;
    margin-bottom: 18px;
}

.toolbar-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 780px;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid #e1e8e4;
    text-align: left;
    vertical-align: top;
}

th {
    color: #65766f;
    font-size: 12px;
    text-transform: uppercase;
}

.inline-form {
    display: flex;
    gap: 8px;
}

.inline-form select {
    min-width: 120px;
}

@media (max-width: 760px) {
    .claim-header,
    .qr-panel {
        display: grid;
    }

    .qr-panel {
        grid-template-columns: 1fr;
        padding: 18px;
    }

    .filter-bar {
        grid-template-columns: 1fr;
    }
}
