:root {
    color-scheme: light;
    font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
    background: #edf2f7;
    color: #172033;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(18, 121, 109, .18), transparent 34%),
        linear-gradient(315deg, rgba(201, 82, 44, .15), transparent 30%),
        #edf2f7;
}

button,
input,
select {
    font: inherit;
}

button {
    min-height: 48px;
    border: 0;
    border-radius: 8px;
    background: #12796d;
    color: white;
    font-weight: 700;
    cursor: pointer;
}

button:disabled {
    opacity: .58;
    cursor: not-allowed;
}

input,
select {
    width: 100%;
    min-height: 48px;
    border: 1px solid #cad3df;
    border-radius: 8px;
    padding: 0 14px;
    background: #fff;
    color: #172033;
}

.agent-search-button {
    min-height: 42px;
    margin-top: -4px;
}

#agentField,
.record-search {
    display: grid;
    grid-template-columns: 1fr 92px;
    align-items: end;
    column-gap: 10px;
}

#agentField > select {
    grid-column: 1 / -1;
}

#agentField > .agent-field-title {
    grid-column: 1 / -1;
}

#agentSearch {
    grid-column: 1;
}

#agentSearchButton,
.record-search button {
    grid-column: 2;
    min-height: 48px;
    margin-top: 0;
}

.record-search input {
    grid-column: 1;
}

.shell {
    width: min(100%, 520px);
    min-height: 100vh;
    margin: 0 auto;
    padding: max(20px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.panel {
    border: 1px solid rgba(23, 32, 51, .08);
    border-radius: 8px;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 18px 42px rgba(23, 32, 51, .12);
}

#loginView {
    margin-top: 12vh;
    padding: 26px 20px 22px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.brand-logo {
    width: 76px;
    height: 76px;
    flex: 0 0 auto;
    border-radius: 8px;
    object-fit: contain;
    background: #fff;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 24px;
    line-height: 1.25;
}

h2 {
    font-size: 18px;
}

.brand p,
.eyebrow {
    color: #66758a;
    font-size: 13px;
}

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

.form label {
    display: grid;
    gap: 7px;
    color: #40506a;
    font-size: 14px;
    font-weight: 700;
}

.compact-form {
    margin-top: 16px;
}

.message {
    min-height: 20px;
    color: #b42318;
    font-size: 14px;
    line-height: 1.4;
}

.message.success {
    color: #12796d;
}

.hidden {
    display: none !important;
}

.app-view {
    display: grid;
    gap: 14px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
}

.top-identity {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 10px;
}

.top-logo {
    width: 48px;
    height: 48px;
    flex: 0 0 auto;
    border-radius: 8px;
    object-fit: contain;
    background: #fff;
}

.topbar strong {
    display: block;
    margin-top: 3px;
    font-size: 20px;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ghost-button,
.icon-button {
    border: 1px solid #cad3df;
    background: rgba(255, 255, 255, .74);
    color: #172033;
}

.ghost-button {
    padding: 0 16px;
}

.top-actions .ghost-button {
    min-height: 42px;
    padding: 0 12px;
    white-space: nowrap;
}

.tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 4px;
    border: 1px solid #cad3df;
    border-radius: 8px;
    background: rgba(255, 255, 255, .68);
}

.tab {
    background: transparent;
    color: #40506a;
}

.tab.active {
    background: #172033;
    color: #fff;
}

.work-panel {
    padding: 14px;
}

.scan-box {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    border-radius: 8px;
    background: #172033;
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-hint {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 18px;
    color: rgba(255, 255, 255, .82);
    text-align: center;
}

.scan-box::after {
    content: "";
    position: absolute;
    inset: 22%;
    border: 2px solid rgba(255, 255, 255, .78);
    border-radius: 8px;
    box-shadow: 0 0 0 999px rgba(0, 0, 0, .28);
    pointer-events: none;
}

.actions {
    display: grid;
    grid-template-columns: 1fr 92px;
    gap: 10px;
    margin-top: 12px;
}

.record-search {
    margin-top: 12px;
}

.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 20px;
}

.icon-button {
    width: 44px;
    min-height: 40px;
    font-size: 21px;
}

.scan-list {
    display: grid;
    gap: 9px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.scan-list li {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid #e1e7ef;
    border-radius: 8px;
    background: #fff;
}

.scan-list strong {
    overflow-wrap: anywhere;
}

.scan-list span {
    color: #66758a;
    font-size: 13px;
}

.tracking-summary {
    border-color: rgba(18, 121, 109, .28) !important;
    background: #f5fbfa !important;
}

.tracking-flow strong {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.tracking-flow strong span {
    color: inherit;
    font-size: inherit;
}

.flow-badge {
    flex: 0 0 auto;
    min-width: 54px;
    border-radius: 999px;
    padding: 3px 9px;
    background: #172033;
    color: #fff;
    font-size: 12px;
    font-style: normal;
    text-align: center;
}

.flow-badge.inbound {
    background: #12796d;
}

.flow-badge.outbound {
    background: #c9522c;
}

@media (max-width: 360px) {
    .shell {
        padding-left: 10px;
        padding-right: 10px;
    }

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

    .topbar {
        align-items: flex-start;
    }

    .top-actions {
        flex-direction: column;
        align-items: stretch;
    }
}
