:root {
    --bg: #f4f6f9;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --line: #e4e8ef;
    --line-strong: #d2d8e3;
    --ink: #1f2633;
    --muted: #667085;
    --muted-soft: #98a2b3;
    --primary: #4f63d9;
    --primary-soft: #eef1ff;
    --primary-strong: #3446a8;
    --success: #12805c;
    --success-soft: #e8f7f1;
    --warning: #a76500;
    --warning-soft: #fff6e4;
    --danger: #b42318;
    --danger-soft: #fff0f0;
    --shadow: 0 10px 26px rgba(35, 48, 70, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 1180px;
    color: var(--ink);
    background: var(--bg);
    font-family: Arial, "Microsoft YaHei", sans-serif;
    font-size: 14px;
    letter-spacing: 0;
}

button,
select,
input,
textarea {
    font: inherit;
}

button {
    border: 0;
}

.app-shell {
    min-height: 100vh;
}

.topbar {
    height: 64px;
    display: grid;
    grid-template-columns: 260px 1fr auto;
    align-items: center;
    gap: 18px;
    padding: 0 22px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(10px);
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
}

.brand-mark {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: #ffffff;
    background: var(--primary);
    font-weight: 700;
}

.brand strong,
.brand span:not(.brand-mark) {
    display: block;
}

.brand strong {
    font-size: 16px;
}

.brand span:not(.brand-mark) {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.top-nav {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.top-nav button {
    height: 38px;
    padding: 0 14px;
    border-radius: 8px;
    color: #303847;
    background: transparent;
    cursor: pointer;
}

.top-nav button.active {
    color: var(--primary-strong);
    background: var(--primary-soft);
    box-shadow: inset 0 0 0 1px #dbe1ff;
    font-weight: 700;
}

.topbar-actions,
.chat-actions,
.field-inline,
.reply-toolbar,
.filter-row,
.check-row,
.tag-row {
    display: flex;
    align-items: center;
}

.topbar-actions {
    gap: 10px;
}

.field-inline {
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
}

select,
input,
textarea {
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: #ffffff;
}

select,
input {
    height: 38px;
    padding: 0 12px;
}

textarea {
    width: 100%;
    resize: none;
    padding: 12px;
    line-height: 1.5;
}

textarea:focus,
select:focus,
input:focus,
button:focus {
    outline: 3px solid rgba(79, 99, 217, 0.2);
    outline-offset: 1px;
}

.message-page {
    padding: 22px;
}

.module-panel {
    padding: 22px;
}

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

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 14px;
}

.page-heading h1 {
    margin: 0;
    font-size: 24px;
}

.page-heading p {
    margin: 5px 0 0;
    color: var(--muted);
}

.metric-strip {
    display: grid;
    grid-template-columns: repeat(4, 112px);
    gap: 8px;
}

.metric {
    min-height: 62px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.metric b {
    display: block;
    font-size: 20px;
}

.metric span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.filter-panel {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.filter-row {
    gap: 8px;
}

.filter-row select {
    min-width: 132px;
}

.search-input {
    min-width: 320px;
    flex: 1;
}

.check-row {
    gap: 16px;
    margin-top: 10px;
    color: var(--muted);
    font-size: 13px;
}

.check-row label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.check-row input {
    width: 15px;
    height: 15px;
    padding: 0;
}

.workspace {
    min-height: calc(100vh - 190px);
    display: grid;
    grid-template-columns: 54px 360px minmax(480px, 1fr) 380px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.platform-rail {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 8px;
    border-right: 1px solid var(--line);
    background: #fbfcff;
}

.platform-pill {
    width: 38px;
    min-height: 42px;
    border-radius: 8px;
    color: #344054;
    background: #ffffff;
    border: 1px solid var(--line);
    cursor: pointer;
    font-weight: 700;
}

.platform-pill.active {
    color: #ffffff;
    border-color: var(--primary);
    background: var(--primary);
}

.platform-pill.taobao.active {
    background: #d65a21;
    border-color: #d65a21;
}

.platform-pill.doudian.active {
    background: #151924;
    border-color: #151924;
}

.platform-pill.xiaohongshu.active {
    background: #c6252f;
    border-color: #c6252f;
}

.conversation-pane,
.detail-pane {
    min-height: 0;
    background: var(--panel);
}

.conversation-pane {
    border-right: 1px solid var(--line);
    display: grid;
    grid-template-rows: auto 1fr;
}

.pane-head {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-bottom: 1px solid var(--line);
}

.pane-head strong {
    display: block;
}

.pane-head span {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.conversation-list {
    overflow: auto;
}

.conversation-item {
    width: 100%;
    min-height: 138px;
    padding: 14px 12px;
    border-bottom: 1px solid var(--line);
    background: #ffffff;
    text-align: left;
    cursor: pointer;
}

.conversation-item.active {
    background: #f7f8ff;
    box-shadow: inset 3px 0 0 var(--primary);
}

.conversation-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.conversation-main {
    min-width: 0;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 10px;
}

.avatar,
.avatar-lg {
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: #ffffff;
    font-weight: 700;
}

.avatar {
    width: 38px;
    height: 38px;
    font-size: 14px;
}

.avatar-lg {
    width: 46px;
    height: 46px;
    font-size: 17px;
}

.avatar.doudian,
.avatar-lg.doudian {
    background: #151924;
}

.avatar.taobao,
.avatar-lg.taobao {
    background: #d65a21;
}

.avatar.xiaohongshu,
.avatar-lg.xiaohongshu {
    background: #c6252f;
}

.conversation-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.conversation-title strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-preview {
    margin-top: 6px;
    color: #40495a;
    font-size: 13px;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.conversation-tags,
.cap-line,
.order-tags,
.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.conversation-tags {
    margin-top: 10px;
}

.conversation-meta {
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
}

.time-text {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 2px 8px;
    border-radius: 999px;
    color: var(--primary-strong);
    background: var(--primary-soft);
    font-size: 12px;
    white-space: nowrap;
}

.badge.ok {
    color: var(--success);
    background: var(--success-soft);
}

.badge.warning {
    color: var(--warning);
    background: var(--warning-soft);
}

.badge.danger {
    color: var(--danger);
    background: var(--danger-soft);
}

.chat-pane {
    min-width: 0;
    display: grid;
    grid-template-rows: auto auto auto 1fr auto auto;
    background: #f7f9fc;
}

.chat-header {
    min-height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}

.chat-title {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-title h2 {
    margin: 0;
    font-size: 18px;
}

.chat-title p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.chat-actions {
    gap: 8px;
}

.workflow-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}

.workflow-tabs button {
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #475467;
    background: #ffffff;
    cursor: pointer;
}

.workflow-tabs button.active {
    border-color: #f0d38c;
    color: #7c4b00;
    background: #fff9e8;
    font-weight: 700;
}

.error-banner {
    margin: 10px 14px 0;
    padding: 10px 12px;
    border: 1px solid #f5c2c0;
    border-radius: 8px;
    color: var(--danger);
    background: var(--danger-soft);
    font-size: 13px;
}

.message-stream {
    overflow: auto;
    padding: 16px 18px;
}

.timeline-marker {
    display: inline-flex;
    margin-bottom: 12px;
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: #ffffff;
    font-size: 12px;
}

.message {
    display: flex;
    margin-bottom: 14px;
}

.message.in {
    justify-content: flex-start;
}

.message.out {
    justify-content: flex-end;
}

.bubble {
    max-width: min(620px, 78%);
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 5px 16px rgba(31, 38, 51, 0.05);
}

.message.out .bubble {
    border-color: #cfd7ff;
    background: #eef1ff;
}

.bubble.failed {
    border-color: #f0c7c2;
    background: #fff8f7;
}

.bubble-text {
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.bubble-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
}

.failure-card {
    margin-bottom: 14px;
    padding: 12px;
    border: 1px solid #efd9a7;
    border-radius: 8px;
    background: #fff8e8;
}

.failure-card strong {
    display: block;
    color: #7c4b00;
}

.failure-card p {
    margin: 6px 0 0;
    color: #7c4b00;
    line-height: 1.45;
}

.retry-link {
    margin-top: 8px;
    color: var(--danger);
    background: transparent;
    cursor: pointer;
    padding: 0;
}

.reply-library {
    border-top: 1px solid var(--line);
    background: var(--panel);
}

.reply-toolbar {
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px 8px;
}

.reply-tabs {
    display: flex;
    gap: 6px;
}

.reply-tabs button,
.ghost-button,
.primary-button,
.icon-button {
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
}

.reply-tabs button,
.ghost-button {
    color: #344054;
    background: #ffffff;
}

.reply-tabs button {
    height: 32px;
    padding: 0 12px;
}

.reply-tabs button.active {
    color: var(--primary-strong);
    border-color: #dbe1ff;
    background: var(--primary-soft);
    font-weight: 700;
}

.reply-search {
    width: 190px;
    height: 32px;
}

.quick-replies {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding: 0 14px 12px;
}

.quick-reply {
    min-height: 72px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    text-align: left;
    cursor: pointer;
}

.quick-reply strong {
    display: block;
    font-size: 13px;
}

.quick-reply span {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.composer {
    display: grid;
    grid-template-columns: 1fr 88px;
    gap: 10px;
    padding: 12px 14px 14px;
    border-top: 1px solid var(--line);
    background: var(--panel);
}

.send-button {
    min-height: 72px;
}

.ghost-button,
.primary-button {
    min-height: 36px;
    padding: 0 12px;
}

.ghost-link {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #344054;
    background: #ffffff;
    text-decoration: none;
}

.ghost-button.small {
    min-height: 30px;
    padding: 0 10px;
    font-size: 12px;
}

.primary-button {
    color: #ffffff;
    border-color: var(--primary);
    background: var(--primary);
    font-weight: 700;
}

.primary-button:disabled,
.ghost-button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.icon-button {
    width: 36px;
    height: 36px;
    color: #344054;
    background: #ffffff;
}

.detail-pane {
    display: grid;
    grid-auto-rows: max-content;
    gap: 14px;
    padding: 14px;
    border-left: 1px solid var(--line);
    overflow: auto;
}

.detail-pane section,
.customer-card {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.section-kicker,
.section-title {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.customer-card h3 {
    margin: 5px 0 0;
    font-size: 17px;
}

.muted {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.empty-block {
    padding: 18px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.side-list,
.shop-list {
    display: grid;
    gap: 8px;
}

.side-row,
.shop-row {
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.side-row strong,
.shop-row strong {
    display: block;
    margin-bottom: 5px;
}

.side-row p,
.shop-row p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.order-card {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 10px;
}

.product-thumb {
    width: 58px;
    height: 58px;
    border: 1px solid #d8dde7;
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(79, 99, 217, 0.18), rgba(198, 37, 47, 0.12)),
        repeating-linear-gradient(45deg, #d8dde7 0, #d8dde7 4px, #eef1f5 4px, #eef1f5 8px);
}

.note-form {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.dashboard-grid,
.admin-grid {
    display: grid;
    gap: 14px;
    margin-bottom: 14px;
}

.dashboard-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.admin-grid.two {
    grid-template-columns: minmax(360px, 480px) minmax(0, 1fr);
}

.admin-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel-card {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 6px 18px rgba(31, 38, 51, 0.04);
}

.panel-card h2 {
    margin: 0 0 12px;
    font-size: 16px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.form-grid label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
}

.form-grid label.full,
.form-grid h2,
.form-actions,
.form-grid > button {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    gap: 8px;
}

.data-list,
.mini-list,
.data-table {
    display: grid;
    gap: 8px;
}

.data-row {
    display: grid;
    gap: 5px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

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

.data-row strong {
    font-size: 13px;
}

.data-row p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.row-actions button {
    min-height: 28px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #344054;
    background: #ffffff;
    cursor: pointer;
    font-size: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    display: inline-block;
    border-radius: 50%;
    background: var(--muted-soft);
}

.status-dot.ok {
    background: var(--success);
}

.status-dot.warning {
    background: var(--warning);
}

.status-dot.danger {
    background: var(--danger);
}

@media (max-width: 1320px) {
    body {
        min-width: 1000px;
    }

    .workspace {
        grid-template-columns: 52px 320px minmax(420px, 1fr) 340px;
    }

    .quick-replies {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-grid,
    .admin-grid.three {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
