* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #f6f7fb;
    color: #111827;
}

.app {
    max-width: 960px;
    margin: 0 auto;
    min-height: 100vh;
    padding: 16px;
}

.header {
    text-align: center;
    padding: 10px 0 18px;
}

.title {
    font-size: 26px;
    font-weight: 800;
}

.sub {
    color: #6b7280;
    margin-top: 6px;
    font-size: 13px;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.tab-btn {
    border: none;
    padding: 12px 14px;
    border-radius: 12px;
    background: #e5e7eb;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    color: #111827;
}

.tab-btn.active {
    background: #111827;
    color: #ffffff;
}

.card {
    background: #ffffff;
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 8px 24px rgba(17, 24, 39, 0.06);
    margin-bottom: 14px;
}

.row {
    display: flex;
    gap: 10px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    outline: none;
    background: #ffffff;
    color: #111827;
}

input:focus,
textarea:focus,
select:focus {
    border-color: #111827;
}

textarea {
    min-height: 86px;
    resize: vertical;
}

button {
    border: none;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    cursor: pointer;
}

.primary {
    background: #111827;
    color: #ffffff;
}

.secondary {
    background: #e5e7eb;
    color: #111827;
}

.danger {
    background: #ef4444;
    color: #ffffff;
}

.success {
    background: #10b981;
    color: #ffffff;
}

.btn-link {
    display: inline-block;
    text-decoration: none;
    background: #111827;
    color: #ffffff;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
}

.small {
    font-size: 12px;
    color: #6b7280;
}

.error-text {
    color: #dc2626;
    margin-top: 6px;
}

.section-title {
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 10px;
}

.field-label {
    display: block;
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 6px;
}

.chat-box {
    min-height: 320px;
    max-height: 52vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 6px 2px;
}

.msg {
    max-width: 88%;
    padding: 12px 14px;
    border-radius: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 14px;
}

.msg.user {
    align-self: flex-end;
    background: #111827;
    color: #ffffff;
    border-bottom-right-radius: 6px;
}

.msg.bot {
    align-self: flex-start;
    background: #f3f4f6;
    color: #111827;
    border-bottom-left-radius: 6px;
}

.hidden {
    display: none;
}

.candidate-item,
.list-item {
    border: 1px solid #ececec;
    border-radius: 14px;
    padding: 12px;
    background: #ffffff;
}

.list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.item-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
}

.item-name {
    font-weight: 700;
}

.status {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 999px;
}

.status.todo {
    background: #fef3c7;
    color: #92400e;
}

.status.way {
    background: #dbeafe;
    color: #1d4ed8;
}

.status.ok {
    background: #dcfce7;
    color: #166534;
}

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

.toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 760px;
}

th,
td {
    padding: 10px 8px;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
    vertical-align: top;
}

th {
    color: #6b7280;
    font-weight: 700;
    background: #fafafa;
}

.table-name {
    font-weight: 700;
    margin-bottom: 4px;
}

.tag {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    background: #eef2ff;
    color: #4338ca;
    margin: 2px 6px 0 0;
}

.muted {
    color: #6b7280;
    font-size: 13px;
}

.footer-note {
    text-align: center;
    color: #9ca3af;
    font-size: 12px;
    padding: 10px 0 30px;
}

.mt4 {
    margin-top: 4px;
}

.mt8 {
    margin-top: 8px;
}

.mt10 {
    margin-top: 10px;
}

@media (max-width: 768px) {
    .app {
        padding: 12px;
    }

    .title {
        font-size: 22px;
    }

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

    .row {
        flex-direction: column;
    }

    .item-top {
        flex-direction: column;
        align-items: flex-start;
    }

    .actions {
        flex-direction: column;
    }

    .actions button,
    .btn-link {
        width: 100%;
        text-align: center;
    }

    table {
        min-width: 640px;
    }
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.no-top {
    margin-top: 0;
}

.confirm-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.confirm-value {
    background: #f9fafb;
    border: 1px solid #ececec;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    color: #111827;
}

@media (max-width: 768px) {
    .grid-2,
    .confirm-grid {
        grid-template-columns: 1fr;
    }
}

.quick-check-row {
    display: grid;
    grid-template-columns: 1fr 80px 120px;
    gap: 8px;
    align-items: center;
}

.quick-unit {
    height: 44px;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    background: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #374151;
}

.warn-text {
    color: #b45309;
}

.ok-text {
    color: #166534;
}

@media (max-width: 768px) {
    .quick-check-row {
        grid-template-columns: 1fr;
    }

    .quick-unit {
        justify-content: flex-start;
        padding: 0 12px;
    }
}

.table-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: nowrap;
}

.small-btn {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 10px;
    min-width: 56px;
}

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

/* 物料列表里名称说明更紧凑一点 */
.small {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.4;
}

.sub-section-title {
    font-size: 14px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 8px;
}

.compact-item {
    padding: 10px 12px;
}

.compact-card {
    padding-top: 12px;
    padding-bottom: 12px;
}

.ticker-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
}

.ticker-row {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    min-width: max-content;
}

.ticker-total {
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #111827;
    color: #fff;
    white-space: nowrap;
}

.ticker-tag {
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
    white-space: nowrap;
}

.record-row {
    border: 1px solid #ececec;
    border-radius: 14px;
    background: #fff;
    padding: 12px;
    margin-top: 10px;
}

.record-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.record-name {
    font-size: 15px;
    font-weight: 700;
    color: #111827;
    line-height: 1.3;
}

.record-change {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #dbeafe;
    color: #1d4ed8;
    white-space: nowrap;
}

.record-meta {
    margin-top: 6px;
    font-size: 12px;
    color: #6b7280;
    line-height: 1.4;
}

.record-source {
    margin-top: 4px;
    font-size: 11px;
    color: #9ca3af;
    line-height: 1.3;
}

@media (max-width: 768px) {
    .record-top {
        align-items: flex-start;
    }
}

.status.due {
    background: #fef3c7;
    color: #92400e;
}

.status.late {
    background: #fed7aa;
    color: #c2410c;
}

.status.overdue {
    background: #fee2e2;
    color: #b91c1c;
}

.login-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #f6f7fb;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border-radius: 22px;
    padding: 22px;
    box-shadow: 0 10px 30px rgba(17, 24, 39, 0.08);
}

.login-title {
    font-size: 28px;
    font-weight: 800;
    color: #111827;
}

.login-sub {
    margin-top: 6px;
    font-size: 14px;
    color: #6b7280;
}

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

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.user-chip {
    padding: 8px 12px;
    background: #eef2ff;
    color: #4338ca;
    border-radius: 999px;
    font-size: 12px;
    white-space: nowrap;
}

.logout-btn {
    white-space: nowrap;
}

@media (max-width: 768px) {
    .header-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .login-card {
        padding: 18px;
        border-radius: 18px;
    }

    .login-title {
        font-size: 24px;
    }
}

.hidden {
    display: none !important;
}