:root {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --ink: #20242a;
    --muted: #66717c;
    --line: #dce2e8;
    --blue: #1f6feb;
    --green: #1b7f4c;
    --red: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--line);
    background: #fff;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-size: 20px;
    font-weight: 800;
}

.brand-icon {
    display: inline-grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid #cfe1d6;
    border-radius: 8px;
    background: #eefbf4;
    color: var(--green);
}

.brand-icon svg {
    width: 24px;
    height: 24px;
}

.brand-icon path,
.brand-icon circle {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

nav {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

nav form {
    margin: 0;
}

nav button {
    border: 0;
    background: transparent;
    color: var(--blue);
    cursor: pointer;
    font: inherit;
}

main {
    width: min(1120px, calc(100% - 32px));
    margin: 28px auto 64px;
}

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

h1 {
    margin-bottom: 6px;
    font-size: 34px;
}

h2 {
    font-size: 20px;
}

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

.eyebrow {
    color: var(--green);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.lede {
    color: #3f4a55;
    font-size: 18px;
    line-height: 1.55;
}

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

.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
    gap: 28px;
    align-items: center;
    min-height: 62vh;
}

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

.auth-panel {
    display: grid;
    gap: 14px;
}

.columns {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
    gap: 16px;
    margin-bottom: 18px;
}

.runtime-panel {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(280px, 1fr);
    gap: 16px;
    align-items: start;
}

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

.grid-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(160px, 1fr)) auto;
    gap: 12px;
    align-items: end;
}

.compact-form {
    gap: 8px;
}

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

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
}

input, select, textarea {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #c9d2dc;
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}

textarea {
    resize: vertical;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid #bdc7d1;
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    font-weight: 750;
    white-space: nowrap;
}

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

.button.danger {
    border-color: #e3b5b0;
    color: var(--red);
}

.button.wide {
    width: 100%;
}

.flash {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid #b9dac9;
    border-radius: 8px;
    background: #eefbf4;
    color: #145a36;
}

.flash.error {
    border-color: #e9b9b4;
    background: #fff3f2;
    color: var(--red);
}

.turn-notice {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid #c9d6e4;
    border-radius: 8px;
    background: #f3f7fb;
    color: #2d445c;
    font-weight: 700;
}

.turn-notice.active {
    border-color: #b9dac9;
    background: #eefbf4;
    color: #145a36;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.history-table {
    max-height: 420px;
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

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

th {
    background: #eef2f5;
    color: #4d5964;
    font-size: 13px;
    text-transform: uppercase;
}

tr:last-child td {
    border-bottom: 0;
}

.status {
    display: inline-flex;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eef2f5;
    font-weight: 800;
}

.status-0 {
    background: #fff3f2;
    color: var(--red);
}

.status-1 {
    background: #eefbf4;
    color: #145a36;
}

.status-2 {
    background: #fff8e6;
    color: #8a5a00;
}

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

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

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

.button-row form {
    margin: 0;
}

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

.settings-form {
    margin-bottom: 14px;
}

.embedded {
    border-radius: 6px;
}

.participant-pick {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 8px;
}

.admin-pick-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 10px;
    align-items: end;
    margin-top: 12px;
}

.add-items-form {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 14px;
}

.pending-list {
    display: grid;
    gap: 10px;
}

.pending-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
}

.order-list {
    margin: 12px 0 0;
    padding-left: 24px;
}

.order-list li {
    padding: 6px 0;
}

.order-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.order-row form {
    margin: 0;
}

.method-panel {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
}

.method-panel[hidden] {
    display: none;
}

.method-panel h2 {
    margin-bottom: 0;
}

.item-list-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.item-list-toolbar p {
    margin: 0;
}

.item-list, .item-grid {
    display: grid;
    gap: 10px;
}

.item-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.item {
    padding: 12px;
    border: 1px solid var(--line);
    border-left: 5px solid var(--green);
    border-radius: 8px;
    background: #fff;
}

.item img {
    width: 100%;
    height: 160px;
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    object-fit: cover;
}

.item.pending {
    border-left-color: #9a6700;
}

.item.claimed {
    border-left-color: #84909b;
    background: #f7f8f9;
}

.hide-claimed-items .item.claimed {
    display: none;
}

pre {
    overflow-x: auto;
    padding: 12px;
    border-radius: 6px;
    background: #20242a;
    color: #f6f7f9;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (max-width: 760px) {
    .topbar, .page-head, .auth-shell {
        align-items: stretch;
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .inline-form {
        align-items: stretch;
        flex-direction: column;
    }

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

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

    .runtime-panel, .admin-pick-form, .add-items-form {
        grid-template-columns: 1fr;
    }

    .item-list-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .pending-row {
        align-items: stretch;
        flex-direction: column;
    }
}

@media print {
    .topbar, .print-hide, .button-row {
        display: none !important;
    }

    body {
        background: #fff;
    }

    main {
        width: 100%;
        margin: 0;
    }

    .panel, .table-wrap {
        border: 0;
        padding: 0;
    }
}
