:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #1d2733;
    --muted: #5d6b7a;
    --line: #dde3ea;
    --accent: #0f5c7a;
    --accent-strong: #0b4760;
    --accent-soft: #e3f0f5;
    --problem: #b42318;
    --problem-soft: #fdecea;
    --screen: #10202b;
    --screen-text: #d7f3ff;
    --radius: 8px;
    color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

a { color: var(--accent); }
a:hover { color: var(--accent-strong); }

h1 { font-size: 1.5rem; margin: 0 0 0.5rem; }
h1:focus { outline: none; }
h2 { font-size: 1.15rem; margin: 0 0 0.5rem; }
h3 { font-size: 1rem; margin: 0 0 0.4rem; }

.shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.5rem;
    padding: 0.6rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; color: var(--text); font-weight: 600; }
.brand-mark {
    display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 7px;
    background: var(--accent); color: #fff; font-size: 0.8rem; font-weight: 700;
}

.channels { display: flex; flex-wrap: wrap; gap: 0.5rem; flex: 1; }
.channel { display: flex; align-items: center; gap: 0.25rem; padding: 0.15rem 0.4rem; border-radius: var(--radius); }
.channel.current { background: var(--accent-soft); }
.channel-name { font-weight: 600; margin-inline-end: 0.25rem; color: var(--muted); }
.tab { padding: 0.25rem 0.55rem; border-radius: 6px; text-decoration: none; color: var(--text); }
.tab.active { background: var(--accent); color: #fff; }

.account { display: flex; align-items: center; gap: 0.75rem; margin-inline-start: auto; }
.partner-name { font-weight: 600; }
.signout-form { margin: 0; }

.content { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 1.25rem; }

.footer {
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem;
    padding: 0.75rem 1.25rem; color: var(--muted); font-size: 0.8rem; border-top: 1px solid var(--line);
}

.hint { color: var(--muted); margin: 0 0 1rem; }
.small { font-size: 0.85rem; }
.mono { font-family: Consolas, "Cascadia Mono", Menlo, monospace; font-size: 0.85rem; }

.notice {
    padding: 0.6rem 0.85rem; margin: 0 0 1rem; border-radius: var(--radius);
    background: var(--accent-soft); border: 1px solid #c6dfe9;
}
.notice.problem { background: var(--problem-soft); border-color: #f4c7c2; color: var(--problem); }

button {
    font: inherit; border-radius: 6px; padding: 0.45rem 0.95rem; cursor: pointer; border: 1px solid transparent;
}
button:disabled { opacity: 0.55; cursor: default; }
button.primary { background: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--accent-strong); }
button.secondary { background: var(--surface); border-color: var(--line); color: var(--text); }
button.secondary:hover:not(:disabled) { border-color: var(--accent); }
button.small { padding: 0.2rem 0.6rem; font-size: 0.85rem; }
.link-button { background: none; border: none; color: var(--accent); padding: 0.2rem 0.3rem; text-decoration: underline; }

input[type=text], input[type=password], input[type=date], select {
    font: inherit; padding: 0.4rem 0.55rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
    color: var(--text); min-width: 0; width: 100%;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Sign in */
.signin { display: grid; place-items: center; padding: 3rem 1rem; }
.signin-card {
    width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
    border-radius: 12px; padding: 1.5rem;
}
.signin-form { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.signin-form label { font-weight: 600; margin-top: 0.4rem; }
.signin-form button { margin-top: 0.9rem; }

.page-message { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1.25rem 1.5rem; }
.start-list li { margin: 0.35rem 0; }

/* Search */
.search {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.75rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin-bottom: 1rem;
}
.field { display: flex; flex-direction: column; gap: 0.25rem; }
.field label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.field.checkbox { flex-direction: row; align-items: center; gap: 0.4rem; padding-top: 1.3rem; }
.field.checkbox input { width: auto; }
.actions { display: flex; align-items: flex-end; }

.result-count { color: var(--muted); margin: 0 0 0.5rem; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.grid { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.grid th, .grid td { text-align: start; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid th { color: var(--muted); font-weight: 600; background: #fafbfc; }
.grid tr.row { cursor: pointer; }
.grid tr.row:hover td { background: #f7fafc; }
.grid tr.problem td { color: var(--problem); }
.grid .number { text-align: end; font-variant-numeric: tabular-nums; }
.badge {
    display: inline-block; margin-inline-start: 0.35rem; padding: 0 0.4rem; border-radius: 999px;
    background: var(--accent-soft); color: var(--accent); font-size: 0.75rem; font-weight: 600; vertical-align: middle;
}
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: 0.75rem 0; }

/* Detail */
.back { margin: 0 0 0.75rem; }
.detail h1 { display: flex; align-items: center; gap: 0.25rem; }
.summary, .fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.5rem 1rem; margin: 0; }
.summary { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin-bottom: 1.25rem; }
.pair dt { font-size: 0.8rem; color: var(--muted); }
.pair dd { margin: 0; word-break: break-word; }
.pair.problem dd { color: var(--problem); font-weight: 600; }
.section { margin-bottom: 1.25rem; }
.item { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0.75rem 1rem; margin-bottom: 0.5rem; }
.item.problem { border-color: #f4c7c2; background: #fffafa; }
.item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-bottom: 0.4rem; }
.item-head .time { color: var(--muted); font-size: 0.85rem; }
.item-head button { margin-inline-start: auto; }

.overlay { position: fixed; inset: 0; background: rgba(16, 32, 43, 0.45); z-index: 10; }
.dialog {
    position: fixed; z-index: 11; inset: 5vh 50% auto auto; transform: translateX(50%);
    width: min(900px, 94vw); max-height: 90vh; overflow: auto; background: var(--surface);
    border-radius: 12px; padding: 1rem 1.25rem; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.25rem; }
.code-block { margin: 0.75rem 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 0.3rem 0.6rem; background: #fafbfc; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.code-block pre { margin: 0; padding: 0.6rem; overflow-x: auto; font-size: 0.82rem; white-space: pre-wrap; word-break: break-all; }
.status-line { margin: 0.5rem 0; }

/* Test */
.test-layout { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; gap: 1.25rem; margin-bottom: 1.5rem; }
@media (max-width: 860px) { .test-layout { grid-template-columns: 1fr; } }

.dispenser { background: #2b3a46; border-radius: 16px; padding: 1rem; color: #fff; }
.dispenser-head { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.85rem; color: #b9cad6; margin-bottom: 0.6rem; }
.screen { background: var(--screen); color: var(--screen-text); border-radius: 10px; padding: 1rem; text-align: center; min-height: 220px; }
.screen-text { font-size: 1.05rem; font-weight: 600; margin: 0 0 0.75rem; }
.qr { width: 100%; max-width: 260px; background: #fff; padding: 0.5rem; border-radius: 8px; image-rendering: pixelated; }
.countdown { margin: 0.5rem 0 0; font-size: 0.9rem; }
.qr-text { color: #8fb6c9; margin: 0.25rem 0 0; }
.screen-figures { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem 1rem; margin: 0.9rem 0 0; text-align: start; }
.screen-figures dt { font-size: 0.75rem; color: #8fb6c9; }
.screen-figures dd { margin: 0; font-variant-numeric: tabular-nums; font-size: 1rem; }
.dispenser-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.9rem; align-items: flex-end; }
.dispenser-actions .sale { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.4rem; }
.dispenser-actions .sale label { width: 100%; font-size: 0.8rem; color: #b9cad6; }
.dispenser-actions .sale input { width: 8rem; }
.dispenser .messages { margin: 0.9rem 0 0.5rem; padding-inline-start: 1.1rem; font-size: 0.9rem; color: #e3edf3; }
.dispenser a { color: #9fd8f0; }

.scenarios { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; }
.scenario-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.5rem; margin-bottom: 0.9rem; }
.scenario { display: flex; gap: 0.4rem; align-items: center; padding: 0.45rem 0.6rem; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.scenario.selected { border-color: var(--accent); background: var(--accent-soft); }
.scenario-detail { border-inline-start: 3px solid var(--accent); padding: 0.25rem 0.9rem; margin-bottom: 0.9rem; }
.scenario-detail ol { margin: 0.25rem 0 0.5rem; padding-inline-start: 1.2rem; }
.recent { margin-top: 0.5rem; }
