:root {
    color-scheme: light;
    --bg: #eef3f8;
    --panel: #ffffff;
    --panel-soft: #f7fafc;
    --line: #d8e2ec;
    --text: #17212f;
    --muted: #64748b;
    --brand: #1769aa;
    --brand-strong: #0f4f82;
    --ok: #14825f;
    --warn: #a76300;
    --danger: #b42318;
    --shadow: 0 10px 26px rgba(23, 33, 47, 0.08);
    --radius: 8px;
}

* { box-sizing: border-box; }

body.t3-page {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
    letter-spacing: 0;
}

.t3-shell {
    width: min(1180px, 100%);
    margin: 0 auto;
    min-height: 100vh;
    padding: 24px clamp(16px, 3vw, 32px) 32px;
    border-left: 1px solid #dfe7ef;
    border-right: 1px solid #dfe7ef;
}

.t3-header,
.t3-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.t3-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px;
    margin-bottom: 16px;
}

.t3-kicker {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: 26px;
    line-height: 1.2;
}

h2 {
    font-size: 17px;
    line-height: 1.25;
    margin-bottom: 12px;
}

.t3-mode {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #eaf4fc;
    color: var(--brand-strong);
    font-size: 12px;
    font-weight: 800;
}

body.t3-remove-mode .t3-mode {
    background: #fff1f0;
    color: var(--danger);
    border: 1px solid #f4b5af;
}

.t3-mode-banner {
    margin: -4px 0 16px;
    padding: 12px 14px;
    border: 2px solid #d92d20;
    border-radius: var(--radius);
    background: #fff1f0;
    color: #912018;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.35;
    box-shadow: var(--shadow);
}

.t3-card {
    padding: 16px;
    margin-bottom: 16px;
}

.t3-content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    gap: 16px;
    align-items: start;
}

.t3-main-column,
.t3-side-column {
    min-width: 0;
}

.t3-main-column {
    display: grid;
    gap: 16px;
}

.t3-content-grid .t3-card {
    margin-bottom: 0;
}

.t3-history-card {
    position: sticky;
    top: 16px;
}

.t3-scan-card {
    border-color: #b8cee2;
}

body.t3-remove-mode .t3-scan-card {
    border-color: #d92d20;
    background: #fff8f7;
}

.t3-scan-label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 8px;
}

body.t3-remove-mode .t3-scan-label {
    color: #912018;
}

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

.t3-scan-input {
    width: 100%;
    min-height: 60px;
    border: 2px solid #9db8d4;
    border-radius: 8px;
    padding: 0 14px;
    color: var(--text);
    background: #ffffff;
    font: inherit;
    font-size: 24px;
    letter-spacing: 0;
}

.t3-primary,
.t3-action,
.t3-secondary {
    min-height: 48px;
    border-radius: 6px;
    padding: 0 18px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}

.t3-primary,
.t3-action {
    border: 0;
    color: #ffffff;
}

.t3-primary {
    background: var(--brand);
    min-width: 112px;
}

.t3-action {
    background: #2d4055;
}

.t3-primary:hover,
.t3-action:hover,
.t3-secondary:hover {
    filter: brightness(0.96);
}

.t3-secondary {
    border: 1px solid #b8c8d7;
    background: #ffffff;
    color: var(--text);
}

.t3-alert {
    min-height: 0;
    margin: 0 0 16px;
    padding: 0;
    font-weight: 800;
}

.t3-alert:not(:empty) {
    min-height: 42px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.t3-alert--ok { color: var(--ok); border-color: #b9d7c3; background: #edf8f0; }
.t3-alert--warn { color: var(--warn); border-color: #f0c36a; background: #fff6dd; }
.t3-alert--error { color: var(--danger); border-color: #efb4b4; background: #fff0f0; }

.t3-debug {
    margin: 0 0 16px;
    padding: 12px;
    border: 1px solid #c7d4e0;
    border-radius: var(--radius);
    background: #111827;
    color: #e5e7eb;
    overflow: auto;
    white-space: pre-wrap;
}

.t3-debug[hidden] {
    display: none;
}

.t3-muted {
    margin: 0 0 12px;
    color: var(--muted);
    font-weight: 700;
}

.t3-action-required[hidden] {
    display: none;
}

.t3-action-required {
    border-color: #f0c36a;
    background: #fffdf7;
}

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

.t3-prompt-field {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.t3-prompt-field input {
    width: 100%;
    min-height: 46px;
    border: 1px solid #b8c8d7;
    border-radius: 6px;
    padding: 0 12px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
    font-size: 16px;
    text-transform: none;
}

.t3-prompt-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.t3-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.t3-facts {
    display: grid;
    gap: 8px;
    margin: 0;
}

.t3-facts div {
    display: grid;
    gap: 16px;
    padding: 18px 20px;
    border: 1px solid #dfe7ef;
    border-radius: 8px;
    background: var(--panel-soft);
}

.t3-facts dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.t3-facts dd {
    min-width: 0;
    margin: 0;
    color: var(--text);
    font-size: 26px;
    font-weight: 800;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

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

.t3-guidance {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
}

.t3-guidance[hidden] {
    display: none;
}

.t3-guidance div {
    padding: 10px 12px;
    border: 1px solid #f0d391;
    border-radius: 6px;
    background: #fff8e8;
    color: #7a4b00;
    font-weight: 800;
}

.t3-work-state {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.t3-work-state[hidden] {
    display: none;
}

.t3-work-chip {
    display: inline-grid;
    grid-template-columns: auto auto;
    gap: 8px;
    align-items: center;
    min-height: 36px;
    padding: 7px 10px;
    border: 1px solid #b9d7c3;
    border-radius: 999px;
    background: #edf8f0;
    color: var(--ok);
    font-weight: 800;
}

.t3-work-chip span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #326052;
    font-size: 12px;
}

.t3-hierarchy {
    display: grid;
    gap: 10px;
}

.t3-node {
    border: 1px solid #dfe7ef;
    border-radius: 6px;
    background: var(--panel-soft);
    padding: 10px 12px;
    display: grid;
    gap: 10px;
}

.t3-node .t3-node {
    background: #ffffff;
    margin-left: 10px;
}

.t3-node--container {
    background: #f7fbff;
}

.t3-node--pallet {
    border-left: 3px solid #7cc4a5;
}

.t3-node--carton {
    border-left: 3px solid #d2a047;
}

.t3-node--collapsed {
    background: #ffffff;
}

.t3-node--active {
    border-color: #f0b429;
    background: #fffaf0;
    box-shadow: inset 3px 0 0 #f59e0b;
}

.t3-node--active > .t3-node-title {
    color: #1d3557;
}

.t3-node-title {
    color: #33475f;
    font-weight: 800;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.t3-node-title > span:not(.t3-node-icon) {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 2px 7px;
    border: 1px solid #d8e2ec;
    border-radius: 999px;
    background: #f7fafc;
    color: var(--muted);
    font-size: 12px;
}

.t3-node-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    border-radius: 5px;
    color: #ffffff;
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
}

.t3-node-icon--container {
    background: #1769aa;
}

.t3-node-icon--pallet {
    background: #14825f;
}

.t3-node-icon--carton {
    background: #8a5a00;
}

.t3-node-icon--sku {
    background: #6b7280;
}

.t3-line {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    background: #ffffff;
    color: var(--muted);
    font-size: 13px;
}

.t3-line--active {
    border: 1px solid #f0b429;
    background: #fff4d8;
    color: #7a4b00;
    box-shadow: inset 3px 0 0 #f59e0b;
}

.t3-line span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.t3-line strong {
    color: var(--text);
}

.t3-line--active strong {
    color: #111827;
}

.t3-node-action {
    min-height: 32px;
    border: 1px solid #efb4b4;
    border-radius: 6px;
    padding: 0 10px;
    background: #fff0f0;
    color: var(--danger);
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}

.t3-node-action:hover {
    filter: brightness(0.97);
}

.t3-empty {
    color: var(--muted);
    padding: 10px 0;
}

.t3-history {
    display: grid;
    gap: 10px;
}

.t3-history-item {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid #dfe7ef;
    border-radius: 6px;
    background: var(--panel-soft);
}

.t3-history-item--ok {
    border-color: #b9d7c3;
    background: #f2faf5;
}

.t3-history-item--warn {
    border-color: #f0d391;
    background: #fff8e8;
}

.t3-history-item--error {
    border-color: #efb4b4;
    background: #fff4f3;
}

.t3-history-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.t3-history-head strong {
    color: var(--text);
    font-size: 13px;
}

.t3-history-head span {
    overflow-wrap: anywhere;
}

.t3-history-head time {
    color: var(--muted);
}

.t3-history-message {
    color: var(--text);
    font-size: 15px;
    font-weight: 800;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.t3-scan-card--hidden .t3-scan-row {
    display: none;
}

.t3-terminal-note {
    display: block;
    color: var(--muted);
    font-weight: 800;
}

.t3-terminal-note[hidden] {
    display: none;
}

@media (max-width: 760px) {
    .t3-shell {
        width: 100%;
        padding: 10px;
        border-left: 0;
        border-right: 0;
    }

    .t3-header,
    .t3-scan-row,
    .t3-grid,
    .t3-content-grid {
        grid-template-columns: 1fr;
        display: grid;
    }

    .t3-header {
        align-items: start;
    }

    .t3-mode {
        justify-self: start;
    }

    .t3-primary,
    .t3-action,
    .t3-secondary {
        width: 100%;
        min-height: 52px;
    }

    .t3-facts div,
    .t3-step,
    .t3-prompt-fields {
        grid-template-columns: 1fr;
    }

    .t3-scan-input {
        font-size: 22px;
    }

    .t3-content-grid {
        gap: 16px;
    }

    .t3-history-card {
        position: static;
    }

    .t3-line {
        flex-direction: column;
        align-items: flex-start;
    }

    .t3-history-head {
        grid-template-columns: 1fr;
    }
}
