:root {
    --bg: #f6f7fb;
    --panel: #ffffff;
    --text: #182033;
    --muted: #657085;
    --line: #dfe4ee;
    --primary: #116149;
    --primary-dark: #0b4434;
    --danger: #b42318;
    --success: #0f7a43;
    --warning: #946200;
    --info: #175cd3;
    --purple: #6941c6;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
}

.topbar {
    align-items: center;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    min-height: 64px;
    padding: 0 32px;
}

.brand {
    color: var(--text);
    font-weight: 700;
}

.topbar nav {
    display: flex;
    gap: 18px;
}

.container {
    margin: 0 auto;
    max-width: 1200px;
    padding: 32px 20px 56px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
}

.narrow {
    margin: 0 auto;
    max-width: 680px;
}

.grid {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.narrowish {
    max-width: 520px;
}

h1, h2 {
    line-height: 1.2;
    margin: 0 0 18px;
}

h1 {
    font-size: 28px;
}

h2 {
    font-size: 18px;
    margin-top: 8px;
}

label {
    color: var(--muted);
    display: grid;
    font-size: 14px;
    gap: 6px;
}

input, select {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    min-height: 42px;
    padding: 9px 11px;
    width: 100%;
}

button, .button {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    justify-content: center;
    min-height: 40px;
    padding: 8px 14px;
}

.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.primary:hover {
    background: var(--primary-dark);
}

.danger {
    border-color: #f3b5af;
    color: var(--danger);
}

.alert {
    border-radius: 6px;
    margin-bottom: 18px;
    padding: 12px 14px;
}

.alert.success {
    background: #e8f7ef;
    color: var(--success);
}

.alert.error {
    background: #fff1f0;
    color: var(--danger);
}

.notice-inline {
    background: #eef4ff;
    border: 1px solid #c7d7fe;
    border-radius: 6px;
    color: var(--info);
    display: none;
    font-size: 14px;
    padding: 12px 14px;
}

.modal-backdrop {
    align-items: center;
    background: rgba(24, 32, 51, 0.55);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 20px;
    position: fixed;
    z-index: 20;
}

.modal {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(24, 32, 51, 0.28);
    max-width: 520px;
    padding: 26px;
    width: 100%;
}

.modal p {
    color: var(--muted);
    margin: 0 0 22px;
}

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

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

th, td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.date-row td {
    background: #f3f5f8;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    padding: 9px 10px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.dashboard-head {
    align-items: flex-start;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 18px;
}

.search-row {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(220px, 1fr) auto;
}

.result-panel {
    margin-top: 24px;
}

.compact-form {
    gap: 8px;
}

.top-gap {
    margin-top: 8px;
}

.pager {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 18px;
}

.muted {
    color: var(--muted);
}

.status-badge {
    border: 1px solid transparent;
    border-radius: 999px;
    display: inline-flex;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    padding: 7px 10px;
    white-space: nowrap;
}

.status-submitted {
    background: #eef4ff;
    border-color: #c7d7fe;
    color: var(--info);
}

.status-processing {
    background: #fff7e6;
    border-color: #fedf89;
    color: var(--warning);
}

.status-need-qrcode {
    background: #f4f3ff;
    border-color: #d9d6fe;
    color: var(--purple);
}

.status-completed {
    background: #e8f7ef;
    border-color: #a6e9c4;
    color: var(--success);
}

.status-cancelled {
    background: #fff1f0;
    border-color: #f3b5af;
    color: var(--danger);
}

.status-default {
    background: #f3f5f8;
    border-color: var(--line);
    color: var(--muted);
}

.qrcode {
    border: 1px solid var(--line);
    border-radius: 6px;
    max-height: 120px;
    max-width: 120px;
}

@media (max-width: 760px) {
    body {
        background: #fff;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
        padding: 14px 20px;
    }

    .topbar nav {
        flex-wrap: wrap;
        gap: 10px 14px;
    }

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

    .container {
        padding: 18px 12px 36px;
    }

    .panel {
        border-left: 0;
        border-radius: 0;
        border-right: 0;
        padding: 18px 12px;
    }

    h1 {
        font-size: 22px;
    }

    .dashboard-head {
        align-items: stretch;
        flex-direction: column;
    }

    .search-row {
        grid-template-columns: 1fr;
    }

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

    table.responsive-table {
        border-collapse: separate;
        border-spacing: 0 12px;
        min-width: 0;
    }

    .responsive-table thead {
        display: none;
    }

    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td {
        display: block;
        width: 100%;
    }

    .responsive-table tr {
        border: 1px solid var(--line);
        border-radius: 8px;
        padding: 8px 12px;
    }

    .responsive-table tr.date-row {
        background: transparent;
        border: 0;
        border-radius: 0;
        padding: 0;
    }

    .responsive-table tr.date-row td {
        border: 0;
        border-radius: 6px;
        display: block;
        margin-top: 4px;
        padding: 9px 12px;
    }

    .responsive-table tr.date-row td::before {
        content: none;
    }

    .responsive-table td {
        align-items: flex-start;
        border-bottom: 1px solid var(--line);
        display: grid;
        gap: 10px;
        grid-template-columns: 112px minmax(0, 1fr);
        padding: 10px 0;
    }

    .responsive-table td:last-child {
        border-bottom: 0;
    }

    .responsive-table td::before {
        color: var(--muted);
        content: attr(data-label);
        font-size: 13px;
        font-weight: 600;
    }

    .responsive-table td > form,
    .responsive-table td > .qrcode,
    .responsive-table td > .status-badge {
        justify-self: start;
    }

    .qrcode {
        max-height: 96px;
        max-width: 96px;
    }
}

@media (max-width: 420px) {
    .topbar nav {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }

    .responsive-table td {
        grid-template-columns: 1fr;
    }

    button, .button {
        width: 100%;
    }
}
