/* Ablpa科技改变未来 - 主样式表 */

/* ===== 基础重置与变量 ===== */
:root {
    --primary-color: #1890ff;
    --primary-hover: #40a9ff;
    --success-color: #52c41a;
    --warning-color: #faad14;
    --danger-color: #ff4d4f;
    --text-primary: #262626;
    --text-secondary: #8c8c8c;
    --border-color: #d9d9d9;
    --bg-color: #f5f5f5;
    --white: #ffffff;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.2);
    --transition: all 0.3s ease;
    --sidebar-width: 250px;
    --topbar-height: 60px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: #f5f5f5;
    overflow-x: hidden;
}

html.auth-pending #app-screen,
#app-screen[hidden] {
    display: none !important;
    visibility: hidden !important;
}

/* ===== 屏幕切换 ===== */
.screen {
    display: none;
}

#app-screen {
    display: none;
}

#app-screen.active {
    display: block;
}

#login-screen {
    display: none;
}

#login-screen.active {
    display: flex;
}

/* ===== 登录界面 ===== */
#login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    cursor: crosshair;
    background:
        radial-gradient(ellipse at 18% 18%, rgba(14, 165, 233, 0.22), transparent 34%),
        radial-gradient(ellipse at 78% 62%, rgba(37, 99, 235, 0.2), transparent 38%),
        radial-gradient(circle at 36% 52%, rgba(56, 189, 248, 0.14), transparent 18%),
        linear-gradient(135deg, #030814 0%, #07182e 42%, #041f3f 100%);
    z-index: 1000;
}

#login-screen::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        linear-gradient(rgba(147,197,253,0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(96,165,250,0.035) 1px, transparent 1px);
    background-size: 72px 72px;
    mask-image: linear-gradient(90deg, rgba(0,0,0,0.75), rgba(0,0,0,0.25));
}

#login-screen::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: linear-gradient(100deg, transparent 0%, rgba(59,130,246,0.1) 48%, transparent 55%);
    animation: loginScan 9s linear infinite;
}

@keyframes loginScan {
    0% { transform: translateX(-80%); }
    100% { transform: translateX(80%); }
}

/* 粒子动画画布 */
#login-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* 装饰形状 */
.login-bg-shapes {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.shape {
    position: absolute;
    opacity: 0.18;
    border: 1px solid rgba(96, 165, 250, 0.38);
    background:
        linear-gradient(90deg, rgba(59,130,246,0.18) 1px, transparent 1px),
        linear-gradient(rgba(125,211,252,0.14) 1px, transparent 1px);
    background-size: 18px 18px;
    box-shadow: inset 0 0 28px rgba(59,130,246,0.1);
}

.shape-1 {
    width: 420px; height: 220px;
    top: 9%; left: 6%;
    clip-path: polygon(0 0, 88% 0, 100% 22%, 100% 100%, 12% 100%, 0 78%);
    animation: shapeFloat 10s ease-in-out infinite;
}

.shape-2 {
    width: 360px; height: 160px;
    bottom: 12%; right: 34%;
    clip-path: polygon(6% 0, 100% 0, 94% 100%, 0 100%);
    animation: shapeFloat 12s ease-in-out infinite reverse;
}

.shape-3 {
    width: 240px; height: 240px;
    top: 38%; right: -40px;
    border-radius: 50%;
    background: repeating-conic-gradient(from 0deg, rgba(96,165,250,0.26) 0deg 8deg, transparent 8deg 18deg);
    animation: shapeFloat 8s ease-in-out infinite;
}

@keyframes shapeFloat {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-30px) scale(1.05); }
}

/* ===== 左侧品牌区 ===== */
.login-brand {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 60px 80px;
    position: relative;
    z-index: 1;
    color: white;
}

.brand-logo-wrap {
    width: min(680px, 48vw);
    height: 250px;
    margin: 0 0 36px -14px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    isolation: isolate;
    pointer-events: none;
}

.brand-logo-wrap::before,
.brand-logo-wrap::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.brand-logo-wrap::before {
    width: 590px;
    height: 178px;
    border: 1px solid rgba(125,211,252,0.48);
    box-shadow:
        0 0 48px rgba(56,189,248,0.34),
        0 0 90px rgba(37,99,235,0.18),
        inset 0 0 48px rgba(125,211,252,0.15);
    animation: logoOrbit 7s linear infinite;
}

.brand-logo-wrap::after {
    width: 660px;
    height: 235px;
    background:
        radial-gradient(ellipse at center, rgba(125,211,252,0.34), rgba(59,130,246,0.16) 40%, transparent 72%);
    filter: blur(4px);
    z-index: -1;
    animation: logoEnergyBreath 4.6s ease-in-out infinite;
}

.brand-logo {
    width: min(640px, 47vw);
    height: auto;
    max-height: 238px;
    object-fit: contain;
    opacity: 0.98;
    filter:
        brightness(1.18)
        contrast(1.08)
        saturate(1.22)
        drop-shadow(0 0 20px rgba(191, 239, 255, 1))
        drop-shadow(0 0 58px rgba(59, 130, 246, 0.78));
    animation: logoPulse 3s ease-in-out infinite;
}

.brand-logo-light {
    display: none;
}

@keyframes logoPulse {
    0%, 100% {
        opacity: 0.98;
        filter: brightness(1.12) contrast(1.06) saturate(1.16) drop-shadow(0 0 18px rgba(191, 239, 255, 0.9)) drop-shadow(0 0 48px rgba(59, 130, 246, 0.62));
        transform: scale(1);
    }
    50% {
        opacity: 1;
        filter: brightness(1.24) contrast(1.1) saturate(1.28) drop-shadow(0 0 30px rgba(224, 247, 255, 1)) drop-shadow(0 0 82px rgba(59, 130, 246, 0.92));
        transform: scale(1.035);
    }
}

@keyframes logoOrbit {
    0% { transform: translate(-50%, -50%) rotate(0deg) scaleX(1); }
    100% { transform: translate(-50%, -50%) rotate(360deg) scaleX(1); }
}

@keyframes logoTextGlow {
    0%, 100% {
        color: #bfefff;
        text-shadow: 0 0 10px rgba(191,239,255,0.82), 0 0 28px rgba(56,189,248,0.72), 0 0 64px rgba(37,99,235,0.56);
        transform: scale(1);
    }
    50% {
        color: #ffffff;
        text-shadow: 0 0 14px rgba(255,255,255,1), 0 0 38px rgba(125,211,252,0.98), 0 0 86px rgba(59,130,246,0.86);
        transform: scale(1.025);
    }
}

@keyframes logoEnergyBreath {
    0%, 100% { opacity: 0.58; transform: translate(-50%, -50%) scale(0.96); }
    50% { opacity: 0.95; transform: translate(-50%, -50%) scale(1.06); }
}

.brand-text h2 {
    font-size: 42px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 12px;
    line-height: 1.2;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.brand-text p {
    font-size: 16px;
    color: rgba(255,255,255,0.7);
    margin-bottom: 48px;
}

.brand-features {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 14px;
    color: rgba(255,255,255,0.85);
    font-size: 15px;
    padding: 10px 16px;
    background: rgba(255,255,255,0.07);
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(4px);
    transition: all 0.3s ease;
}

.feature-item:hover {
    background: rgba(255,255,255,0.13);
    transform: translateX(6px);
    border-color: rgba(45,212,191,0.48);
}

.feature-icon {
    font-size: 20px;
    width: 32px;
    text-align: center;
}

/* ===== 右侧登录面板 ===== */
.login-panel {
    width: 460px;
    min-width: 460px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px 48px;
    position: relative;
    z-index: 1;
    background: rgba(8,17,31,0.32);
    border-left: 1px solid rgba(45,212,191,0.14);
    backdrop-filter: blur(20px);
    cursor: default;
}

.login-card {
    width: 100%;
    background: rgba(255,255,255,0.96);
    border-radius: 8px;
    padding: 40px 36px;
    box-shadow: 0 22px 70px rgba(0,0,0,0.42), 0 0 0 1px rgba(45,212,191,0.14);
}

.login-card-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 24px;
}

.login-card-logo img {
    width: 132px;
    height: 48px;
    object-fit: contain;
    border-radius: 0;
    box-shadow: none;
}

.form-title {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a2e;
    text-align: center;
    margin-bottom: 6px;
}

.form-subtitle {
    font-size: 13px;
    color: #8c8c8c;
    text-align: center;
    margin-bottom: 28px;
}

.login-footer {
    margin-top: 24px;
    font-size: 12px;
    color: rgba(255,255,255,0.4);
    text-align: center;
}

.login-footer a {
    color: inherit;
    text-decoration: none;
}

.login-footer a:hover {
    text-decoration: underline;
}

/* ===== 表单 ===== */
.form-content {
    display: none;
}

.form-content.active {
    display: block;
}

.form-group {
    margin-bottom: 18px;
    position: relative;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #4a4a6a;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #eaeaf0;
    border-radius: 8px;
    font-size: 14px;
    color: #1a1a2e;
    background: #f8f9ff;
    transition: all 0.3s ease;
    outline: none;
}

.form-group input:focus {
    border-color: #14b8a6;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(20,184,166,0.12);
}

.form-group.focused input {
    border-color: #14b8a6;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(20,184,166,0.12);
}

/* 登录按钮 */
.btn-login {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, #0f766e, #0ea5e9);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 8px;
    letter-spacing: 2px;
    box-shadow: 0 4px 16px rgba(20,184,166,0.35);
}

.btn-login:hover {
    background: linear-gradient(135deg, #14b8a6, #38bdf8);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(14,165,233,0.42);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login-arrow {
    font-size: 18px;
    transition: transform 0.3s;
}

.btn-login:hover .btn-login-arrow {
    transform: translateX(4px);
}

/* 修改密码链接 */
.form-toggle {
    text-align: center;
    margin-top: 16px;
}

.form-toggle a {
    color: #1890ff;
    text-decoration: none;
    font-size: 13px;
    transition: all 0.2s;
}

.form-toggle a:hover {
    color: #40a9ff;
    text-decoration: underline;
}

/* ===== 主应用界面 ===== */
#app-screen {
    display: flex;
    min-height: 100vh;
    background: #fff;  /* 覆盖body灰色背景，防止透明露出登录背景 */
}

/* 响应式：移动端隐藏品牌区 */
@media (max-width: 900px) {
    .login-brand { display: none; }
    .login-panel {
        width: 100%;
        min-width: 0;
        border-left: none;
        padding: 40px 24px;
    }
}

/* 通用表单 select 样式（用于主应用界面） */
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    transition: var(--transition);
}

.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

/* ===== 顶部导航栏 ===== */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #d9d9d9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-logo-img {
    width: 112px;
    height: 42px;
    object-fit: contain;
}

.logo h2 {
    font-size: 20px;
    color: #1890ff;
    font-weight: 600;
    margin: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info span {
    color: #8c8c8c;
}

/* ===== 主容器 ===== */
.main-container {
    margin-top: var(--topbar-height);
    margin-left: var(--sidebar-width);
    min-height: calc(100vh - var(--topbar-height));
    width: calc(100% - var(--sidebar-width));
}

/* 窄屏收起左侧边栏时：主容器边距归零 */
@media (max-width: 1200px) {
    html body .main-container {
        margin-left: 0 !important;
        width: 100% !important;
    }
}

/* ===== 主内容区 ===== */
.content {
    overflow-y: auto;
    padding: 15px;
    background: #f5f5f5;
    width: 100%;
    box-sizing: border-box;
    min-height: calc(100vh - var(--topbar-height));
}

.content.ai-chat-content {
    height: calc(100vh - var(--topbar-height));
    min-height: 0;
    overflow: hidden;
    padding: 0;
}

body.ai-chat-page {
    overflow: hidden;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

#ai-chat.view.active {
    height: 100%;
    overflow: hidden;
}

#ai-chat.view.has-view-toolbar {
    height: 100%;
    overflow: hidden;
}

#ai-chat.view.has-view-toolbar .view-header {
    margin: 0 15px 12px;
}

#ai-chat.view.has-view-toolbar .ai-chat-shell {
    height: calc(100% - 72px);
}

/* ===== 文档编辑器视图 ===== */
.document-toolbar {
    position: fixed;
    top: var(--topbar-height);
    left: var(--sidebar-width);
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: var(--white);
    border-radius: 0;
    margin-bottom: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 999;
}


.view.has-view-toolbar {
    padding-top: 60px;
    box-sizing: border-box;
}

.view-toolbar {
    position: fixed;
    top: var(--topbar-height);
    left: var(--sidebar-width);
    right: 0;
    z-index: 999;
}

.view-toolbar .search-input {
    min-width: 260px;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.document-container {
    display: flex;
    gap: 15px;
    height: auto;
    padding-left: var(--sidebar-width) !important;
    padding-top: 60px;
    padding-right: 15px;
    min-height: calc(100vh - var(--topbar-height));
    width: 100%;
    box-sizing: border-box;
}

/* ===== 文档结构树 ===== */
.document-outline {
    position: fixed;
    top: calc(var(--topbar-height) + 55px);
    left: var(--sidebar-width);
    width: 220px;
    max-height: calc(100vh - var(--topbar-height) - 70px);
    background: var(--white);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    flex-shrink: 0;
    z-index: 998;
}

.document-outline h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.outline-tree {
    font-size: 13px;
}

.outline-item {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
    margin-bottom: 4px;
}

.outline-item:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.outline-item.active {
    background: var(--primary-color);
    color: var(--white);
}

.outline-item.has-warning {
    color: var(--danger-color);
}

.outline-item.has-warning.active {
    background: var(--danger-color);
    color: var(--white);
}

.outline-warning-icon {
    float: right;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--danger-color);
    color: var(--white);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    margin-left: 8px;
}

.outline-item.has-warning.active .outline-warning-icon {
    background: var(--white);
    color: var(--danger-color);
}

.expand-icon {
    margin-right: 8px;
    font-size: 10px;
}

/* ===== 文档编辑器区域 ===== */
.document-editor-area {
    flex: 1;
    display: flex;
    gap: 20px;
    overflow: hidden;
    min-width: 0; /* 防止flex子项溢出 */
}

.editor-container {
    flex: 1;
    background: var(--white);
    border-radius: 8px;
    padding: 30px;
    box-shadow: var(--shadow);
    overflow: visible;
    max-width: none;
    height: auto;
    min-width: 0; /* 允许收缩 */
}

/* ===== 文档标题区域 ===== */
.doc-title-section {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 2px solid var(--border-color);
}

.doc-main-title {
    width: 100%;
    max-width: 600px;
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    padding: 10px;
    margin: 0 auto 16px;
    color: var(--text-secondary);
}

.doc-subtitle-hint {
    font-size: 14px;
    color: var(--text-secondary);
}

.doc-title-input {
    width: 100%;
    max-width: 600px;
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px;
    margin-bottom: 16px;
    transition: var(--transition);
}

.doc-title-input:focus {
    outline: none;
    border-bottom-color: var(--primary-color);
}

.doc-subtitle-input {
    width: 100%;
    max-width: 500px;
    font-size: 18px;
    text-align: center;
    border: none;
    border-bottom: 1px solid transparent;
    padding: 8px;
    color: var(--text-secondary);
    transition: var(--transition);
}

.doc-subtitle-input:focus {
    outline: none;
    border-bottom-color: var(--primary-color);
}

/* ===== 编辑器区块 ===== */
.editor-section {
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
}

.section-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
    display: inline-block;
}

.section-content {
    padding-left: 20px;
}

.subsection {
    margin-bottom: 24px;
}

.subsection h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

/* 小节标题行（带按钮） */
.subsection-header-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: nowrap;
}
.subsection-header-row h3,
.subsection-header-row h4 {
    margin: 0;
    flex-shrink: 0;
}

/* 小小节（4.3.1 / 4.3.2） */
.subsection-sub {
    margin-bottom: 16px;
}
.subsection-sub h4 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

/* 物料参数表 - 参数值单元格 */
.material-params-table td input[type="text"],
.material-params-table td select {
    width: 100%;
    min-width: 80px;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 3px 6px;
    font-size: 13px;
}
.material-param-select {
    width: 100%;
    min-width: 80px;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 3px 4px;
    font-size: 13px;
}

/* 备品备件表 */
.spare-parts-table {
    table-layout: fixed;
}

.spare-parts-table input[type="text"] {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 3px 6px;
    font-size: 13px;
}

/* btn-outline */
.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.btn-outline:hover {
    background: var(--primary-color);
    color: #fff;
}

/* ===== 封面信息 ===== */
.cover-form {
    padding: 20px;
    background: #fafafa;
    border-radius: 8px;
}

.cover-form-two-col {
    display: flex;
    gap: 30px;
}

.cover-col {
    flex: 1;
}

.cover-field-group {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: 4px;
    background: #fff;
    border: 1px solid #e8e8e8;
}

.cover-field-group .input-normal {
    flex: 1;
    min-width: 0;
}

.field-label {
    min-width: 90px;
    font-weight: 600;
    font-size: 13px;
    padding: 6px 8px;
    white-space: nowrap;
}

.field-hint {
    margin-left: 12px;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

/* 标签颜色样式 */
.label-red {
    color: #ff4d4f;
    background: rgba(255, 77, 79, 0.1);
    border-left: 3px solid #ff4d4f;
}

.label-yellow {
    color: #faad14;
    background: rgba(250, 173, 20, 0.1);
    border-left: 3px solid #faad14;
}

.label-green {
    color: #52c41a;
    background: rgba(82, 196, 26, 0.1);
    border-left: 3px solid #52c41a;
}

.label-blue {
    color: #1890ff;
    background: rgba(24, 144, 255, 0.1);
    border-left: 3px solid #1890ff;
}

/* 字段提示样式 */
.field-hint.label-red {
    background: rgba(255, 77, 79, 0.1);
    color: #ff4d4f;
}

.field-hint.label-yellow {
    background: rgba(250, 173, 20, 0.1);
    color: #faad14;
}

.field-hint.label-green {
    background: rgba(82, 196, 26, 0.1);
    color: #52c41a;
}

.field-hint.label-blue {
    background: rgba(24, 144, 255, 0.1);
    color: #1890ff;
}

/* 封面图例说明 */
.cover-legend {
    margin-top: 30px;
    padding: 20px;
    background: #f0f5ff;
    border-radius: 8px;
    border: 1px solid #91caff;
}

.cover-legend h4 {
    margin-bottom: 16px;
    color: #1890ff;
    font-size: 16px;
}

.cover-legend ul {
    list-style: none;
    padding: 0;
}

.cover-legend li {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.legend-box {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: inline-block;
}

.legend-box.label-red {
    background: rgba(255, 77, 79, 0.2);
    border: 2px solid #ff4d4f;
}

.legend-box.label-yellow {
    background: rgba(250, 173, 20, 0.2);
    border: 2px solid #faad14;
}

.legend-box.label-green {
    background: rgba(82, 196, 26, 0.2);
    border: 2px solid #52c41a;
}

.legend-box.label-blue {
    background: rgba(24, 144, 255, 0.2);
    border: 2px solid #1890ff;
}

.form-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.form-row label {
    min-width: 100px;
    font-weight: 500;
}

/* ===== 表格容器 ===== */
.table-container {
    margin-top: 16px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}

.data-table th,
.data-table td {
    border: 1px solid var(--border-color);
    padding: 10px 12px;
    text-align: left;
}

.data-table th {
    background: var(--bg-color);
    font-weight: 600;
}

.data-table td input,
.data-table td select {
    width: 100%;
    border: none;
    background: transparent;
    padding: 4px;
}

.data-table td input:focus,
.data-table td select:focus {
    outline: none;
    background: var(--white);
    border: 1px solid var(--primary-color);
    border-radius: 2px;
}

/* 设备参数表格 - 两列等宽 */
.equip-param-table th,
.equip-param-table td {
    width: 50% !important;
}

/* ===== 列表只读文本 ===== */
.display-text {
    display: inline-block;
    padding: 4px 8px;
    min-height: 24px;
    line-height: 1.5;
    color: var(--text-primary);
}

/* ===== 目录预览 ===== */
.toc-preview {
    padding: 20px;
    background: var(--bg-color);
    border-radius: 4px;
    min-height: 100px;
}

.hint-text {
    color: var(--text-secondary);
    text-align: center;
    font-style: italic;
}

/* ===== 快速引用面板 ===== */
.property-panel {
    width: 180px;
    background: var(--white);
    border-radius: 8px;
    padding: 15px;
    box-shadow: var(--shadow);
    overflow-y: auto;
    flex-shrink: 0;
    height: fit-content;
}

.property-panel h3 {
    font-size: 14px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.quick-insert {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.insert-section h4 {
    font-size: 13px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.quick-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition);
}

.color-swatch:hover {
    border-color: var(--primary-color);
    transform: scale(1.1);
}

/* ===== 视图头部 ===== */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.view-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.view-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* ===== 文档网格 ===== */
.document-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.doc-card {
    background: var(--white);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
}

.doc-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-4px);
}

.doc-card-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.doc-card-info {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.doc-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* ===== 库管理视图 ===== */
.library-content {
    background: var(--white);
    border-radius: 8px;
    padding: 24px;
    box-shadow: var(--shadow);
}

/* ===== 设置视图 ===== */
.settings-content {
    background: var(--white);
    border-radius: 8px;
    padding: 24px;
    box-shadow: var(--shadow);
    max-width: 800px;
}

#ai-agreement-document-editor #ai-agreement-editor-host {
    width: 100%;
    padding: 24px 24px 48px;
    box-sizing: border-box;
    background: #e5e7eb;
    overflow-x: auto;
}

#ai-agreement-document-editor #ai-agreement-editor {
    width: 210mm;
    max-width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    padding: 24mm 18mm 20mm;
    box-sizing: border-box;
    border-radius: 0;
    background: #fff;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.18);
}

#ai-agreement-document-editor .subsection {
    max-width: 100%;
}

#ai-agreement-document-editor .ai-agreement-table-editor {
    width: 100%;
    overflow-x: visible;
}

#ai-agreement-document-editor .ai-agreement-edit-table {
    min-width: 0;
    width: 100%;
    table-layout: fixed;
}

#inquiry-agreement-generator .settings-content {
    max-width: none;
    width: 100%;
    box-sizing: border-box;
}

#inquiry-agreement-generator .settings-section,
#inquiry-agreement-generator .subsection {
    max-width: none;
}

#inquiry-agreement-generator #inquiry-generated-editor-host {
    width: 100%;
    box-sizing: border-box;
}

#inquiry-agreement-generator #ai-agreement-editor {
    max-width: none;
    width: 100%;
    box-sizing: border-box;
}



#ai-agreement-document-editor > .view-header {
    position: relative;
    margin-bottom: 24px;
}

#inquiry-agreement-generator > .view-header {
    position: relative;
    margin-bottom: 24px;
}
.inquiry-section-preview-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.inquiry-section-preview-card {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: #fff;
    padding: 16px;
    min-width: 0;
}

.inquiry-section-preview-card h3 {
    margin: 0 0 12px;
    font-size: 17px;
    color: var(--text-primary);
}

.inquiry-section-preview-content {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.7;
}

.inquiry-section-preview-content h4 {
    margin: 14px 0 8px;
    font-size: 14px;
    color: var(--text-primary);
}

.inquiry-section-preview-content ol {
    margin: 0;
    padding-left: 20px;
}

.inquiry-preview-kv {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 8px 14px;
    margin: 0;
}

.inquiry-preview-kv div {
    min-width: 0;
}

.inquiry-preview-kv dt {
    color: var(--text-muted);
    font-size: 12px;
}

.inquiry-preview-kv dd {
    margin: 2px 0 0;
    color: var(--text-primary);
    word-break: break-word;
}

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

.inquiry-preview-table {
    min-width: 680px;
}

.inquiry-source-checklist {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: #fbfbfb;
    padding: 12px 16px;
    margin-bottom: 16px;
}

.inquiry-source-checklist summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-primary);
}

@media (max-width: 1100px) {
    .inquiry-section-preview-grid {
        grid-template-columns: 1fr;
    }
}

.settings-section {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.settings-section:last-child {
    border-bottom: none;
}

.settings-section h3 {
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.setting-item label {
    min-width: 150px;
    font-weight: 500;
}

/* ===== 预览模态框 - 网页全屏 ===== */
#preview-modal.modal {
    background: #e5e5e5;
}

#preview-modal .modal-content {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
    padding: 0;
    background: #e5e5e5;
    display: flex;
    flex-direction: column;
}

.preview-modal-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-modal-content .modal-header {
    flex-shrink: 0;
    padding: 12px 24px;
    background: #fff;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.preview-container {
    flex: 1;
    overflow-y: auto;
    background: #e5e5e5;
    padding: 30px 20px 50px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
}

.preview-document {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
}

/* A4预览页面 - 标准A4尺寸 210mm × 297mm */
.preview-page {
    width: 210mm;
    height: 297mm;
    padding: 20mm 25mm;
    background: #fff;
    position: relative;
    box-sizing: border-box;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
    overflow: hidden;
}

/* 页眉样式 - 按照模板格式 */
.preview-header {
    position: absolute;
    top: 15mm;
    left: 25mm;
    right: 25mm;
    font-family: 'SimSun', serif;
    font-size: 10pt;
    color: #333;
    border-bottom: 1px solid #333;
    padding-bottom: 2mm;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    line-height: 1.2;
    margin: 0;
    padding: 0;
    min-height: 18px;
}

.header-row-1 {
    margin-bottom: 2px;
}

.header-row-2 {
    margin-bottom: 2px;
}

.header-row-3 {
    margin-bottom: 0;
}

.header-left {
    text-align: left;
    flex: 1;
    line-height: 1.2;
}

.header-right {
    text-align: right;
    position: relative;
}

/* 页眉logo图片样式 - 使用绝对定位不影响行高 */
.header-logo-img {
    height: 50px;
    width: auto;
    position: absolute;
    right: 0;
    top: -15px;
}

/* 页眉内容样式 */
.header-doc-type {
    font-weight: bold;
    font-size: 11pt;
    color: #000;
}

.header-doc-number {
    font-size: 10pt;
    color: #333;
}

.header-project {
    font-size: 10pt;
    color: #333;
}

.header-seller {
    font-size: 10pt;
    color: #333;
}

/* 未填写占位符样式 */
.unfilled {
    color: #bbb;
    font-style: italic;
}

.unfilled-text {
    color: #bbb;
    font-style: italic;
}

/* 页脚样式 */
.preview-footer {
    position: absolute;
    bottom: 15mm;
    left: 25mm;
    right: 25mm;
    height: 12mm;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'SimSun', serif;
    font-size: 10pt;
    color: #333;
    border-top: 1px solid #ccc;
    padding-top: 3mm;
}

.preview-footer-left {
    text-align: left;
    flex: 1;
}

.preview-footer-center {
    text-align: center;
    flex: 1;
}

.preview-footer-right {
    text-align: right;
    flex: 1;
}

.preview-footer-parties {
    font-size: 10pt;
}

.preview-footer-page-num {
    font-size: 10pt;
    color: #333;
}

/* 预览封面样式 - 按照模板格式 */
.preview-cover-template {
    display: flex;
    flex-direction: column;
    padding: 0;
    height: calc(297mm - 45mm - 30mm);
    box-sizing: border-box;
    position: relative;
}

/* 封面上半部分：内容居中 */
.cover-main {
    position: absolute;
    top: 30%;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.cover-doc-type {
    font-size: 36px;
    font-weight: bold;
    font-family: 'SimSun', serif;
    margin-bottom: 50px;
}

.cover-doc-number {
    font-size: 32px;
    font-weight: bold;
    font-family: 'SimSun', serif;
    margin-bottom: 70px;
}

.cover-buyer {
    display: none; /* 删除买方名称单独行 */
}

.cover-project-system {
    font-size: 28px;
    font-weight: bold;
    font-family: 'SimSun', serif;
    margin-bottom: 30px;
    white-space: nowrap;
}

.cover-date {
    font-size: 18px;
    font-weight: bold;
    font-family: 'SimSun', serif;
    margin: 40px 0;
}

/* 封面底部：买方卖方在75%位置左对齐 */
.cover-parties {
    position: absolute;
    top: 82%;
    left: 25mm;
    right: 15mm;
    text-align: left;
    padding-left: 0.5em;
}

.party-item {
    font-size: 22px;
    font-weight: bold;
    font-family: 'SimSun', serif;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.party-label {
    display: inline-block;
    min-width: 60px;
    flex-shrink: 0;
}

.party-name {
    display: inline-block;
    min-width: 200px;
    border-bottom: 1px solid #333;
    padding-bottom: 2px;
    margin-left: 10px;
}

/* 预览目录样式 - 适配页眉页脚 */
.preview-toc {
    padding-top: 20mm;
    min-height: calc(297mm - 45mm - 20mm);
}

.toc-title {
    text-align: center;
    font-size: 26px;
    font-weight: bold;
    font-family: 'SimSun', serif;
    margin-bottom: 50px;
    letter-spacing: 0.2em;
}

.toc-list {
    padding-left: 15mm;
    padding-right: 15mm;
}

.toc-item {
    display: flex;
    align-items: baseline;
    font-family: 'SimSun', serif;
    margin-bottom: 18px;
    font-size: 14pt;
}

.toc-item-title {
    color: #333;
    white-space: nowrap;
}

.toc-item-dots {
    flex: 1;
    border-bottom: 1px dotted #666;
    margin: 0 8px 4px 8px;
    min-width: 20px;
}

.toc-item-page {
    color: #333;
    font-size: 14pt;
    min-width: 30px;
    text-align: right;
}

/* 预览章节样式 - 适配页眉页脚 */
.preview-section {
    padding-top: 25mm;
    min-height: calc(297mm - 45mm - 25mm);
}

.preview-section .section-title {
    font-size: 22px;
    font-weight: bold;
    color: #333;
    margin-bottom: 25px;
    padding-bottom: 10px;
    border-bottom: 2px solid #333;
    font-family: 'SimSun', serif;
}

.preview-section .subsection-title {
    font-size: 16px;
    font-weight: bold;
    color: #444;
    margin-top: 20px;
    margin-bottom: 12px;
    font-family: 'SimSun', serif;
}

.preview-section .section-text {
    font-size: 14px;
    line-height: 1.8;
    color: #333;
    text-align: justify;
    margin-bottom: 15px;
    font-family: 'SimSun', serif;
    text-indent: 2em;
}

.preview-section .empty-hint {
    font-size: 14px;
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 40px 0;
}

/* 打印样式 */
@media print {
    .preview-page {
        box-shadow: none;
        margin: 0;
        page-break-after: always;
    }
}

/* ===== 模态框 ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-hover);
}

.modal-lg {
    max-width: 800px;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.modal-actions .btn-primary,
.modal-actions .btn-normal {
    padding: 8px 16px;
    font-size: 14px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--danger-color);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.search-box {
    margin-bottom: 16px;
}

.library-items {
    max-height: 400px;
    overflow-y: auto;
}

.library-item {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.library-item:hover {
    border-color: var(--primary-color);
    background: rgba(24, 144, 255, 0.05);
}

.library-item.selected {
    border-color: var(--primary-color);
    background: rgba(24, 144, 255, 0.1);
}

/* ===== 提示消息 ===== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 24px;
    background: var(--text-primary);
    color: var(--white);
    border-radius: 4px;
    font-size: 14px;
    z-index: 2000;
    opacity: 0;
    transform: translateY(20px);
    transition: var(--transition);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

.toast.warning {
    background: var(--warning-color);
}

/* ===== 图片上传区域 ===== */
.image-upload-area {
    margin-top: 12px;
    padding: 30px;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.image-upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(24, 144, 255, 0.05);
}

.image-upload-area p {
    color: var(--text-secondary);
}

/* ===== 参考资料插入区域 ===== */
.reference-insert {
    margin-bottom: 12px;
}

/* ===== 响应式设计 ===== */
@media (max-width: 1200px) {
    .property-panel {
        width: 240px;
    }
    
    .document-outline {
        width: 200px;
    }
}

/* ===== 窄屏隐藏侧边栏 ===== */
@media (max-width: 1200px) {
    .sidebar {
        display: none !important;
    }
}

/* 侧边栏收起时的基本样式 */
.sidebar.collapsed {
    display: none !important;
}

/* 文档结构栏样式 */
html body .document-outline.collapsed {
    display: none !important;
}

/* 文档结构栏样式 */

/* 左侧栏展开时，文档结构栏弹出位置需要偏移 */
html body .sidebar:not(.collapsed) ~ .main-container 

/* 左侧栏展开时，覆盖层位置也需要调整 */
html body .sidebar:not(.collapsed) ~ .main-container 

/* 文档结构栏展开时，主内容区域留出空间 */

/* 侧边栏收起且文档结构栏也收起时，内容区域填满宽度 */

/* 侧边栏展开但文档结构栏收起时，内容区域只留侧边栏空间 */

/* 文档结构弹出时的覆盖层 */

/* ===== 标准表格 ===== */
.standard-toolbar {
    margin-bottom: 15px;
}

#standards-table {
    width: 100%;
}

#standards-table th,
#standards-table td {
    text-align: left;
    padding: 10px 12px;
}

/* ===== 标准选择器 ===== */
.standard-picker-layout {
    display: flex;
    gap: 20px;
    height: 400px;
}

.standard-picker-left {
    flex: 1;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.standard-picker-right {
    flex: 1;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.picker-header h4 {
    margin: 0;
    font-size: 14px;
    color: var(--text-primary);
}

.picker-actions {
    display: flex;
    gap: 8px;
}

.standard-picker-left input {
    margin-bottom: 10px;
}

.picker-items {
    flex: 1;
    overflow-y: auto;
}

.picker-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
}

.picker-item:hover {
    background: #f5f5f5;
}

.picker-item.selected {
    background: #e6f7ff;
}

.picker-item .item-name {
    flex: 1;
    font-size: 13px;
}

.picker-item .item-code {
    color: #888;
    font-size: 12px;
}

.selected-standards-list {
    flex: 1;
    overflow-y: auto;
}

.selected-standard-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}

.selected-standard-item .std-info {
    flex: 1;
}

.selected-standard-item .std-code {
    color: #888;
    font-size: 12px;
    margin-left: 10px;
}

.selected-standard-item .btn-remove {
    color: #ff4d4f;
    cursor: pointer;
    padding: 4px 8px;
    border: none;
    background: none;
    font-size: 12px;
}

.selected-standard-item .btn-remove:hover {
    text-decoration: underline;
}

/* ===== 模板列表 ===== */
.template-list {
    max-height: 400px;
    overflow-y: auto;
}

.template-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
}

.template-item:hover {
    background: #f5f5f5;
}

.template-item .template-info {
    flex: 1;
}

.template-item .template-name {
    font-weight: 500;
}

.template-item .template-count {
    font-size: 12px;
    color: #888;
}

.template-item .template-actions {
    display: flex;
    gap: 8px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
}

/* ===== AI 对话 ===== */
.ai-chat-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 0;
    height: 100%;
    min-height: 0;
}

.ai-chat-sidebar,
.ai-chat-panel {
    border: 1px solid #e5e7eb;
    background: #ffffff;
    min-height: 0;
}

.ai-chat-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;
}

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

.ai-chat-logo {
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f766e;
    color: #ffffff;
    font-weight: 700;
    border-radius: 8px;
    letter-spacing: 0;
}

.ai-chat-brand h2,
.ai-chat-header h2 {
    margin: 0;
    font-size: 20px;
}

.ai-chat-brand p,
.ai-chat-header p {
    margin: 4px 0 0;
    color: #667085;
    font-size: 13px;
}

.ai-chat-new,
.ai-chat-composer button {
    border: none;
    background: #0f766e;
    color: #ffffff;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.ai-chat-new {
    height: 40px;
    border-radius: 6px;
}

.ai-chat-new:hover,
.ai-chat-composer button:hover {
    background: #0d9488;
}

.ai-chat-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-weight: 600;
    color: #344054;
}

.ai-chat-field select {
    height: 38px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    padding: 0 10px;
    background: #ffffff;
}

.ai-chat-note {
    margin-top: auto;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    color: #475467;
    font-size: 13px;
    line-height: 1.7;
}

.ai-chat-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-width: 0;
    min-height: 0;
}

.ai-chat-header {
    padding: 18px 22px;
    border-bottom: 1px solid #e5e7eb;
}

.ai-chat-messages {
    overflow-y: auto;
    min-height: 0;
    padding: 22px;
    background: #f8fafc;
    scroll-behavior: smooth;
}

.ai-chat-empty {
    max-width: 620px;
    margin: 70px auto 0;
    text-align: center;
    color: #667085;
}

.ai-chat-empty h3 {
    margin: 0 0 8px;
    color: #111827;
    font-size: 22px;
}

.ai-message {
    display: grid;
    grid-template-columns: 98px minmax(0, 1fr);
    gap: 12px;
    max-width: 960px;
    margin: 0 auto 18px;
}

.ai-message-role {
    width: 90px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #0f766e;
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    padding: 0 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-message.user .ai-message-role {
    background: #2563eb;
}

.ai-message-content {
    min-height: 36px;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    color: #111827;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-message.user .ai-message-content {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.ai-message-loading .ai-message-content {
    color: #667085;
}

.ai-chat-composer {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr) 92px;
    gap: 12px;
    padding: 16px 22px 20px;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
}

.ai-chat-attachment {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid #dbeafe;
    background: #eff6ff;
}

.ai-chat-attachment[hidden] {
    display: none;
}

.ai-chat-attachment img {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
}

.ai-chat-attachment span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-chat-attachment button {
    border: none;
    background: transparent;
    color: #dc2626;
    cursor: pointer;
}

.ai-chat-upload {
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #ffffff;
    color: #344054;
    cursor: pointer;
    font-weight: 600;
}

.ai-chat-upload input {
    display: none;
}

.ai-chat-composer textarea {
    width: 100%;
    min-height: 44px;
    max-height: 180px;
    resize: none;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    padding: 11px 12px;
    line-height: 1.5;
    outline: none;
}

.ai-chat-composer textarea:focus {
    border-color: #0f766e;
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.ai-chat-composer button {
    height: 44px;
    border-radius: 8px;
}

.ai-chat-composer button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

@media (max-width: 960px) {
    .content.ai-chat-content {
        height: auto;
        overflow-y: auto;
    }

    .ai-chat-shell {
        grid-template-columns: 1fr;
        height: calc(100vh - var(--topbar-height) - 30px);
        min-height: 620px;
    }

    .ai-chat-sidebar {
        min-height: 0;
    }

    .ai-chat-panel {
        min-height: 0;
    }
}

@media (max-width: 1200px) {
    .view-toolbar {
        left: 0;
    }
}

/* Inquiry recognition workspace width */
#inquiry-upload .settings-content {
    max-width: none;
    width: 100%;
    box-sizing: border-box;
}

#inquiry-upload #inquiry-review {
    max-width: none;
}

#inquiry-upload #inquiry-review .subsection {
    max-width: none;
}

#inquiry-upload #inquiry-review .table-container {
    width: 100%;
    overflow-x: auto;
}

#inquiry-upload #inquiry-review .data-table {
    min-width: 960px;
}

/* ===== Tablet and phone layout ===== */
@media (min-width: 769px) and (max-width: 1200px) {
    :root {
        --sidebar-width: 84px;
    }

    html body .main-container {
        margin-left: 84px !important;
        width: calc(100% - 84px) !important;
    }

    .content {
        padding: 12px;
    }

    .document-toolbar,
    .view-toolbar {
        left: 84px !important;
        padding: 8px 12px;
        gap: 8px;
        flex-wrap: wrap;
        overflow-x: auto;
    }

    .toolbar-left,
    .toolbar-right {
        gap: 8px;
        flex-wrap: wrap;
    }

    .view.has-view-toolbar {
        padding-top: 76px;
    }

    .document-container {
        display: block;
        padding: 76px 12px 16px !important;
        min-height: auto;
    }

    .document-outline {
        position: relative;
        top: auto;
        left: auto;
        width: 100%;
        max-height: 190px;
        margin-bottom: 12px;
    }

    .document-editor-area {
        display: block;
        overflow: visible;
    }

    .editor-container,
    .settings-content,
    .library-content {
        width: 100%;
        max-width: none;
        padding: 20px;
    }

    .inquiry-section-preview-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    :root {
        --topbar-height: 56px;
        --mobile-nav-height: 132px;
    }

    body {
        overflow-x: hidden;
    }

    .top-bar {
        height: var(--topbar-height);
        padding: 0 10px;
        gap: 8px;
    }

    .logo {
        min-width: 0;
        gap: 8px;
    }

    .top-logo-img {
        width: 86px;
        height: 32px;
    }

    .logo h2 {
        font-size: 15px;
        white-space: nowrap;
    }

    .user-info {
        gap: 8px;
        flex-shrink: 0;
    }

    .user-info span {
        display: none;
    }

    html body .main-container {
        margin-top: calc(var(--topbar-height) + var(--mobile-nav-height));
        margin-left: 0 !important;
        width: 100% !important;
        min-height: calc(100vh - var(--topbar-height) - var(--mobile-nav-height));
    }

    .content {
        padding: 10px;
        min-height: calc(100vh - var(--topbar-height) - var(--mobile-nav-height));
    }

    .document-toolbar,
    .view-toolbar {
        top: calc(var(--topbar-height) + var(--mobile-nav-height));
        left: 0 !important;
        right: 0;
        padding: 8px 10px;
        align-items: flex-start;
        gap: 8px;
        flex-wrap: wrap;
        overflow-x: auto;
    }

    .toolbar-left,
    .toolbar-right {
        gap: 6px;
        flex-wrap: wrap;
    }

    .document-toolbar button,
    .view-toolbar button,
    .document-toolbar input,
    .view-toolbar input,
    .view-toolbar select {
        flex: 0 0 auto;
    }

    .view-toolbar .search-input {
        min-width: 180px;
        max-width: 100%;
    }

    .view.has-view-toolbar {
        padding-top: 112px;
    }

    .document-container {
        display: block;
        padding: 112px 8px 12px !important;
        min-height: auto;
    }

    .document-outline {
        position: relative;
        top: auto;
        left: auto;
        width: 100%;
        max-height: 160px;
        margin-bottom: 10px;
        padding: 12px;
    }

    .document-editor-area {
        display: block;
        overflow: visible;
    }

    .editor-container,
    .settings-content,
    .library-content {
        width: 100%;
        max-width: none;
        padding: 14px;
        border-radius: 6px;
    }

    .doc-main-title,
    .doc-title-input {
        font-size: 22px;
    }

    .doc-subtitle-input {
        font-size: 16px;
    }

    .section-content {
        padding-left: 0;
    }

    .section-title {
        font-size: 19px;
        display: block;
    }

    .form-grid,
    .template-controls,
    .picker-header,
    .subsection-header-row {
        grid-template-columns: 1fr;
        flex-wrap: wrap;
    }

    .doc-card-actions {
        flex-wrap: wrap;
    }

    .table-container {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        min-width: 720px;
    }

    .data-table th,
    .data-table td {
        padding: 7px 8px;
        font-size: 12px;
    }

    .inquiry-section-preview-grid,
    .ai-chat-shell {
        grid-template-columns: 1fr;
    }

    .ai-chat-shell {
        height: auto;
        min-height: 620px;
    }

    .standard-picker-layout {
        flex-direction: column;
        height: auto;
    }
}
