:root {
  /* Wine palette shared with the Quotation app: bordeaux #742c42 on warm
     off-white paper, so the workspace reads as part of the same brand. */
  --ink: #2a2226;
  --navy: #6f2940;
  --navy-hover: #582030;
  --wine: #742c42;
  --wine-soft: #f8eef1;
  --wine-line: #ddc3cb;
  --muted: #77727a;
  --line: #e8e3e5;
  --line-strong: #d9cbd1;
  --paper: #ffffff;
  /* Page canvas sits a shade warmer than the cards, the way the Quotation app
     layers white cards on a soft off-white sheet. */
  --page: #fcf9fa;
  --sidebar: #f9f4f5;
  --soft: #faf6f7;
  --selected: #f4e6ea;
  --blue: #742c42;
  --green: #3b6d57;
  --danger: #ac442c;
  --shadow: 0 18px 50px rgba(74, 32, 46, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--page);
}

* { box-sizing: border-box; }

html, body { min-width: 320px; min-height: 100%; margin: 0; }

body { background: var(--page); }

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid rgba(116, 44, 66, .28); outline-offset: 3px; }

.app-shell { display: flex; min-height: 100vh; background: var(--page); }

.sidebar { display: flex; flex: 0 0 272px; flex-direction: column; position: sticky; top: 0; align-self: flex-start; height: 100vh; min-height: 100vh; overflow: hidden; padding: 31px 17px 25px; background: linear-gradient(180deg, #fbf7f8 0%, #f7f1f3 100%); border-right: 1px solid #efe6e9; }
.brand-lockup { display: flex; flex: 0 0 auto; flex-direction: column; align-items: center; gap: 7px; padding: 0 10px; color: var(--wine); text-decoration: none; }
.brand-logo { font-family: Georgia, "Times New Roman", serif; font-size: 50px; font-weight: 500; letter-spacing: -.1em; line-height: .85; }
.brand-name { color: #6f2940; font-size: 12px; font-weight: 600; letter-spacing: .17em; white-space: nowrap; }

.primary-nav { display: grid; align-content: start; gap: 7px; margin: 59px -3px 0; padding: 0 3px; min-height: 0; overflow-y: auto; }
.nav-item, .utility-item { display: flex; align-items: center; gap: 20px; width: 100%; border: 0; border-radius: 13px; padding: 13px 18px; color: #33262b; background: transparent; font-size: 17px; text-align: left; transition: background .18s, color .18s; }
.nav-item:hover, .utility-item:hover { color: var(--wine); background: rgba(240, 228, 232, .8); }
.nav-item-parent { justify-content: flex-start; }
.nav-item-parent .nav-caret { margin-left: auto; color: #a48b93; font-size: 20px; line-height: 1; transition: transform .18s ease; }
.nav-item-parent[aria-expanded="true"] .nav-caret { transform: rotate(180deg); }
.nav-submenu { display: grid; gap: 3px; margin: 0 0 4px 30px; padding-left: 14px; border-left: 1px solid #e7d5da; }
.nav-subitem { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; border: 0; border-radius: 9px; padding: 7px 11px; color: #77656c; background: transparent; font-size: 14px; text-align: left; transition: background .18s, color .18s; }
.nav-subitem:hover { color: var(--wine); background: #f5eaee; }
.nav-subitem.is-active { color: #4d2030; background: #f7e9ee; font-weight: 700; }
.nav-subdot { width: 6px; height: 6px; border-radius: 50%; background: #c9b0b8; }
.nav-subitem.is-active .nav-subdot { background: var(--wine); }
.nav-link { text-decoration: none; }
.nav-link:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.nav-item.is-active { color: var(--wine); background: var(--selected); box-shadow: inset 3px 0 0 var(--wine); }
.nav-icon { display: grid; flex: 0 0 29px; place-items: center; width: 29px; height: 29px; }
.nav-icon svg { width: 27px; height: 27px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.65; }
.sidebar-spacer { flex: 1; min-height: 100px; }
.utility-nav { display: grid; flex: 0 0 auto; gap: 6px; padding: 23px 0 27px; border-top: 1px solid #eadfe2; border-bottom: 1px solid #eadfe2; }
.utility-item { gap: 20px; padding: 9px 18px; font-size: 16px; }
.utility-icon { display: grid; width: 28px; height: 28px; place-items: center; font-size: 27px; line-height: 1; }
.help-icon { border: 1.8px solid currentColor; border-radius: 50%; font-size: 18px; font-weight: 650; }

.main-content { display: flex; flex: 1; min-width: 0; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: flex-end; min-height: 83px; padding: 18px 39px 12px; }
.top-actions { display: flex; align-items: center; gap: 26px; }
.api-status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
.status-dot, .connection-dot, .agent-dot { width: 8px; height: 8px; border-radius: 50%; background: #d7a13d; }
.api-status[data-state="online"] .status-dot { background: #3b6d57; }
.api-status[data-state="offline"] .status-dot { background: var(--danger); }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%; color: var(--ink); background: transparent; font-size: 22px; }
.icon-button:hover { background: var(--selected); }
.notification-button svg { width: 26px; height: 26px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
.mobile-menu, .mobile-title { display: none; }

.workspace { display: flex; flex: 1; min-height: calc(100vh - 83px); flex-direction: column; padding: 6px clamp(28px, 7vw, 105px) 36px; }
.view-panel { display: flex; flex: 1; min-width: 0; flex-direction: column; }
.view-heading { width: min(100%, 940px); margin: 0 auto; padding-top: clamp(10px, 2.2vh, 28px); text-align: center; }
.compact-heading { display: flex; align-items: end; justify-content: space-between; gap: 25px; width: 100%; padding-top: 5vh; text-align: left; }
.eyebrow { margin: 0 0 12px; color: var(--wine); font-size: 11px; font-weight: 800; letter-spacing: .2em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 17px; color: #2b1c22; font-size: clamp(34px, 4.1vw, 57px); font-weight: 650; letter-spacing: -.06em; line-height: 1.07; }
h2 { margin-bottom: 9px; color: var(--ink); font-size: 21px; letter-spacing: -.035em; }
.view-subtitle { margin: 0 auto; max-width: 650px; color: var(--muted); font-size: clamp(16px, 1.5vw, 21px); line-height: 1.55; }
.compact-heading .view-subtitle { margin: 0; max-width: 760px; font-size: 15px; }

.conversation-wrap { display: flex; flex: 1 1 auto; flex-direction: column; width: min(100%, 980px); margin: clamp(18px, 3.2vh, 40px) auto 0; }
.welcome-card { display: grid; place-items: center; margin: auto; padding: 25px 24px; color: var(--muted); text-align: center; }
.welcome-mark { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 15px; border-radius: 13px; color: #fff; background: linear-gradient(135deg, #8d3b53 0%, #6f2940 100%); box-shadow: 0 8px 20px rgba(111, 41, 64, .28); font-size: 21px; }
.welcome-card h2 { margin-bottom: 7px; font-size: 19px; }
.welcome-card p { margin-bottom: 0; font-size: 13px; }
.conversation-panel { width: 100%; max-height: none; overflow: visible; padding: 4px 9px; }
.conversation { display: grid; gap: 17px; }
.message-bubble { max-width: min(780px, 88%); padding: 14px 17px; border: 1px solid var(--line); border-radius: 17px; color: var(--ink); line-height: 1.7; }
.message-user { justify-self: end; border-color: #e6d2d8; background: #faf2f4; }
.message-assistant { justify-self: start; border-left: 3px solid var(--wine); background: #fff; box-shadow: 0 6px 20px rgba(74, 32, 46, .05); }
.message-label { margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .1em; }
.message-content { white-space: normal; font-size: 14px; }
.message-bubble.is-streaming .message-content::after { content: "▍"; margin-left: 2px; color: var(--blue); animation: caret-blink 1s steps(2, start) infinite; }
.stream-placeholder { color: var(--muted); font-size: 13px; }
@keyframes caret-blink { to { opacity: 0; } }
.choice-list { display: grid; gap: 7px; margin-top: 13px; }
.choice-button { border: 1px solid var(--wine-line); border-radius: 9px; padding: 9px 11px; color: var(--wine); background: #fdf7f9; text-align: left; font-size: 12px; font-weight: 700; transition: border-color .18s, background .18s; }
.choice-button:hover { border-color: var(--wine); background: var(--wine-soft); }

.composer { position: relative; width: min(100%, 980px); margin: auto auto 0; border: 1px solid var(--line-strong); border-radius: 18px; background: var(--paper); box-shadow: 0 10px 30px rgba(74, 32, 46, .045); transition: border-color .18s, box-shadow .18s; }
.composer:focus-within { border-color: var(--wine); box-shadow: 0 0 0 4px rgba(116, 44, 66, .09), 0 12px 32px rgba(74, 32, 46, .06); }
.composer textarea { display: block; width: 100%; height: 104px; min-height: 104px; max-height: 46vh; overflow-y: auto; resize: none; border: 0; border-radius: 18px; padding: 18px 23px 6px; color: var(--ink); background: transparent; font-size: 16px; line-height: 1.45; outline: 0; }
.composer textarea::placeholder { color: #9c8f95; }
.composer-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 5px 13px 11px 17px; }
.composer-tools { display: flex; align-items: center; gap: 16px; }
.tool-button { display: grid; place-items: center; width: 31px; height: 31px; border: 0; border-radius: 9px; color: #6f6069; background: transparent; font-size: 23px; line-height: 1; }
.tool-button:hover { color: var(--wine); background: var(--wine-soft); }
.send-button { display: grid; place-items: center; width: 53px; height: 53px; border: 0; border-radius: 50%; color: #fff; background: linear-gradient(135deg, #8d3b53 0%, #6f2940 100%); box-shadow: 0 8px 20px rgba(111, 41, 64, .26); font-size: 29px; line-height: 1; transition: transform .18s, background .18s, box-shadow .18s; }
.send-button:hover { transform: translateY(-1px); background: linear-gradient(135deg, #7c3149 0%, #582030 100%); box-shadow: 0 10px 24px rgba(111, 41, 64, .32); }
.send-button:disabled { opacity: .55; }
.legacy-search { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; clip-path: inset(50%); }
.legacy-search input { width: 1px; height: 1px; }
.legacy-search.is-open { position: relative; display: flex; align-items: center; gap: 8px; width: min(100%, 980px); height: auto; overflow: visible; margin: 12px auto 0; clip: auto; clip-path: none; white-space: normal; }
.legacy-search.is-open label { color: var(--muted); font-size: 11px; font-weight: 800; }
.legacy-search.is-open input { width: auto; min-width: 0; flex: 1; height: 36px; border: 1px solid var(--line); border-radius: 9px; padding: 0 10px; color: var(--ink); background: var(--soft); font-size: 12px; }
.legacy-search.is-open button { height: 36px; border: 0; border-radius: 9px; padding: 0 12px; color: #fff; background: var(--navy); font-size: 11px; font-weight: 800; }
.notice { width: min(100%, 980px); margin: 12px auto 0; padding: 11px 14px; border: 1px solid #efcccc; border-radius: 10px; color: var(--danger); background: #fff8f8; font-size: 12px; }
.loading-line { display: flex; align-items: center; gap: 8px; width: min(100%, 980px); margin: 11px auto 0; color: var(--blue); font-size: 12px; font-weight: 700; }
.spinner { width: 14px; height: 14px; border: 2px solid #ecdde1; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
.loading-elapsed { color: var(--muted); font-size: 12px; font-weight: 600; }
.loading-elapsed[data-slow="true"] { color: #b45309; }
@keyframes spin { to { transform: rotate(360deg); } }

.sources-section { width: min(100%, 980px); margin: 30px auto 0; }
.sources-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; padding-top: 18px; border-top: 1px solid var(--line); }
.sources-heading h2 { margin-bottom: 0; font-size: 15px; }
.sources-heading span { color: var(--muted); font-size: 11px; }
.source-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.source-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); transition: border-color .18s, background .18s; }
.source-item:hover { border-color: var(--wine-line); background: #fdf7f9; }
.source-name { overflow: hidden; color: var(--ink); font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.citation-link { flex: none; color: var(--blue); font-size: 11px; font-weight: 800; text-decoration: none; }
.citation-link:hover { text-decoration: underline; }
.panel-empty { color: var(--muted); font-size: 12px; }

body.modal-open { overflow: hidden; }
.modal-backdrop { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 28px; background: rgba(42, 14, 24, .34); backdrop-filter: blur(6px); }
.application-login-overlay { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 24px; background: #f8f4f5; }
.application-login-card { display: grid; gap: 14px; width: min(420px, 100%); border: 1px solid var(--line); border-radius: 18px; padding: 30px; background: #fff; box-shadow: 0 25px 80px rgba(74, 32, 46, .14); }
.application-login-card h1 { margin: 0; font-size: 32px; }.application-login-card p { margin: 0; color: var(--muted); line-height: 1.6; }
.application-login-card label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 800; }.application-login-card input { min-height: 42px; border: 1px solid var(--line); border-radius: 9px; padding: 0 11px; color: var(--ink); font: inherit; }
.account-profile-panel { width: min(760px, 100%); }.account-profile-form { padding-top: 22px; }.account-profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }.account-profile-grid label, .account-password-form label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 800; }.account-profile-grid input, .account-profile-grid select, .account-password-form input { min-height: 42px; border: 1px solid var(--line); border-radius: 9px; padding: 0 11px; color: var(--ink); background: #fff; font: inherit; }.account-profile-grid input[readonly] { color: var(--muted); background: var(--soft); }.account-profile-wide { grid-column: 1 / -1; }.account-profile-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding-top: 22px; }.account-password-section { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 18px; }.account-password-section summary { cursor: pointer; color: var(--ink); font-weight: 800; }.account-password-form { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 12px; margin-top: 16px; }.account-password-section p { margin: 12px 0 0; color: var(--muted); font-size: 12px; }
.account-admin-panel { width: min(900px, 100%); }.account-admin-create { display: grid; grid-template-columns: 1fr 1.3fr 1fr auto; gap: 8px; margin: 18px 0; }.account-admin-create input, .account-user-list select { min-height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 0 9px; }.account-user-list { display: grid; gap: 7px; }.account-user-list article { display: grid; grid-template-columns: 1fr 1.8fr 110px 62px 80px; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }.account-user-list span { color: var(--muted); font-size: 12px; }.account-user-list button { min-height: 34px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-weight: 700; }
.modal-panel { width: min(760px, 100%); max-height: min(840px, calc(100vh - 56px)); overflow: auto; border: 1px solid var(--line); border-radius: 20px; padding: 26px; background: #fff; box-shadow: 0 25px 80px rgba(74, 32, 46, .2); }
.modal-header { display: flex; align-items: start; justify-content: space-between; gap: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin-bottom: 7px; font-size: 28px; }
.modal-subtitle { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.modal-close { display: grid; flex: none; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%; color: var(--muted); background: var(--soft); font-size: 25px; line-height: 1; }
.modal-close:hover { color: var(--ink); background: var(--selected); }
.settings-section { padding-top: 22px; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.section-title-row h3 { margin: 0; font-size: 16px; }
.server-badge, .local-badge { border-radius: 99px; padding: 6px 9px; color: var(--blue); background: var(--wine-soft); font-size: 10px; font-weight: 800; }
.local-badge { color: var(--green); background: #eef5f1; }
.settings-note { margin: 0 0 13px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.setting-field { min-width: 0; padding: 12px 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--soft); }
.setting-field span, .setting-field strong, .setting-field small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.setting-field span { margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 800; }
.setting-field strong { color: var(--ink); font-size: 12px; }
.setting-field strong[data-state="online"] { color: var(--green); }
.setting-field strong[data-state="offline"] { color: var(--danger); }
.setting-field small { margin-top: 5px; color: #a2939a; font-size: 9px; }
.preference-field { display: grid; grid-template-columns: 180px minmax(0, 1fr); align-items: center; gap: 14px; }
.preference-field > span { color: var(--muted); font-size: 12px; font-weight: 800; }
.preference-field select { min-height: 39px; border: 1px solid var(--line); border-radius: 9px; padding: 0 10px; color: var(--ink); background: var(--soft); font-size: 12px; outline: 0; }
.settings-actions { display: flex; align-items: center; justify-content: end; gap: 8px; margin-top: 13px; }
.save-status { flex: 1; color: var(--green); font-size: 11px; }
.help-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding-top: 22px; }
.guide-card { padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--soft); }
.guide-number { display: inline-grid; place-items: center; width: 28px; height: 22px; margin-bottom: 13px; border-radius: 7px; color: var(--blue); background: var(--wine-soft); font-size: 10px; font-weight: 800; }
.guide-card h3 { margin-bottom: 7px; font-size: 15px; }
.guide-card p, .guide-card li { color: var(--muted); font-size: 11px; line-height: 1.65; }
.guide-card p { margin-bottom: 10px; }
.guide-card ol { margin: 0; padding-left: 17px; }
.guide-warning { display: block; margin-top: 11px; padding-top: 9px; border-top: 1px solid #f0d7b8; color: #8b672d; font-size: 10px; line-height: 1.5; }
.help-workflow { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 9px; margin-top: 17px; padding: 13px; border: 1px solid #eadfe2; border-radius: 11px; color: var(--blue); background: #fdf7f9; font-size: 11px; }
.help-workflow strong { color: var(--ink); }
.help-workflow b { color: #c2a7b1; }

.outline-button, .primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 40px; border-radius: 10px; padding: 0 14px; font-size: 12px; font-weight: 800; text-decoration: none; }
.outline-button { border: 1px solid var(--line-strong); color: var(--ink); background: #fff; }
.outline-button:hover { background: var(--soft); }
.primary-button { border: 0; color: #fff; background: var(--wine); }
.primary-button:hover { background: var(--navy-hover); }
.small-button { min-height: 36px; }
.safety-badge, .draft-badge { display: inline-flex; align-items: center; min-height: 29px; border-radius: 99px; padding: 0 11px; color: #8a651c; background: #fff4d6; font-size: 11px; font-weight: 800; white-space: nowrap; }
.draft-badge { color: var(--blue); background: var(--wine-soft); }
.card-surface { border: 1px solid var(--line); border-radius: 17px; background: #fff; box-shadow: var(--shadow); }
.quotation-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, .85fr); gap: 18px; margin-top: 37px; }
.quotation-chat, .config-card { padding: 23px; }
.embedded-badge, .builder-route { display: inline-flex; align-items: center; min-height: 29px; border-radius: 99px; padding: 0 11px; color: var(--blue); background: var(--wine-soft); font-size: 11px; font-weight: 800; white-space: nowrap; }
.quotation-builder { margin-top: 36px; }
.quotation-builder-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.quotation-builder-heading h2 { margin-bottom: 5px; font-size: 18px; }
.quotation-builder-heading .view-subtitle { margin: 0; max-width: none; font-size: 12px; }
.quotation-builder-frame-wrap { position: relative; min-height: 920px; margin-top: 20px; overflow: visible; background: transparent; }
.quotation-builder-frame-wrap iframe { display: block; width: 100%; min-height: 920px; border: 0; background: #fff; }
.quotation-builder-loading { position: absolute; z-index: 1; inset: 0; display: grid; place-items: center; color: var(--muted); background: #f8f4f5; font-size: 13px; font-weight: 700; }
.agent-label { display: flex; align-items: center; gap: 8px; margin-bottom: 21px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.agent-dot { background: var(--green); }
.quote-message { max-width: 90%; padding: 15px 16px; border-radius: 14px; color: var(--ink); font-size: 14px; line-height: 1.65; }
.quote-message-assistant { border: 1px solid var(--line); background: var(--soft); }
.quotation-conversation { display: grid; gap: 9px; margin-top: 13px; }
.quote-summary { padding: 12px 14px; border-left: 3px solid var(--blue); color: var(--muted); background: #fdf9fa; font-size: 12px; line-height: 1.7; }
.quote-user { border-left-color: #ddc3cb; color: var(--ink); background: #fdf9fa; }
.mini-composer { display: flex; gap: 8px; margin-top: 27px; }
.mini-composer input { min-width: 0; flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--ink); background: var(--soft); font-size: 12px; outline: 0; }
.mini-composer button { display: grid; flex: 0 0 40px; place-items: center; border: 0; border-radius: 10px; color: #fff; background: var(--navy); font-size: 20px; }
.card-title-row { display: flex; align-items: start; justify-content: space-between; gap: 15px; }
.card-title-row h2 { margin-bottom: 0; font-size: 17px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 22px; }
.field-grid label { display: block; }
.field-grid label > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; font-weight: 800; }
.field-grid input, .field-grid select { width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: 9px; padding: 0 10px; color: var(--ink); background: var(--soft); font-size: 12px; outline: 0; }
.field-grid input:focus, .field-grid select:focus { border-color: #cba9b4; box-shadow: 0 0 0 3px rgba(116, 44, 66, .09); }
.field-wide { grid-column: 1 / -1; }
.config-card .primary-button { width: 100%; margin-top: 19px; }
.form-note { margin: 13px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }

.email-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 37px; padding: 16px 18px; box-shadow: none; }
.email-connection { display: flex; align-items: center; gap: 11px; min-width: 0; }
.email-connection .connection-dot { flex: none; background: #d7a13d; }
.email-connection[data-state="connected"] .connection-dot { background: var(--green); }
.email-connection strong, .email-connection span { display: block; }
.email-connection strong { overflow: hidden; color: var(--ink); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.email-connection span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.email-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; }
.email-thread-browser { margin-top: 18px; padding: 18px; box-shadow: none; }
.email-thread-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.email-thread-heading h2 { margin: 0; font-size: 17px; }
.email-thread-rail { display: grid; grid-template-columns: 30px minmax(0, 1fr) 30px; align-items: stretch; gap: 10px; margin-top: 13px; }
.thread-scroll-button { border: 1px solid #e3d3d8; border-radius: 10px; color: var(--ink); background: #fdf7f9; font-size: 23px; font-weight: 700; }
.thread-scroll-button:hover { background: var(--wine-soft); }
.thread-detail { min-height: 410px; margin-top: 18px; padding: 18px; box-shadow: none; }
.small-icon { width: 27px; height: 27px; font-size: 20px; }
.email-list { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 10px; overflow-x: auto; scroll-behavior: smooth; scrollbar-width: none; }
.email-list::-webkit-scrollbar { display: none; }
.email-item { display: grid; align-content: start; min-height: 92px; border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; color: var(--ink); background: var(--soft); text-align: left; }
.email-item:hover, .email-item.is-selected { border-color: #ddc3cb; background: #fdf7f9; box-shadow: inset 0 0 0 1px rgba(116, 44, 66, .04); }
.email-item strong, .email-item span, .email-item time { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-item strong { min-height: 31px; font-size: 12px; line-height: 1.35; white-space: normal; }
.email-item span, .email-item time { margin-top: 4px; color: var(--muted); font-size: 10px; }
.panel-placeholder { color: var(--muted); font-size: 12px; line-height: 1.7; }
.large-placeholder { display: grid; min-height: 365px; place-content: center; justify-items: center; padding: 20px; text-align: center; }
.large-placeholder .welcome-mark { margin-bottom: 12px; }
.large-placeholder h2 { margin-bottom: 6px; }
.large-placeholder p { max-width: 380px; margin-bottom: 0; }
.thread-header { padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.thread-header h2 { margin-bottom: 6px; font-size: 18px; }
.thread-meta { color: var(--muted); font-size: 11px; }
.thread-messages { display: grid; gap: 11px; max-height: 360px; overflow: auto; padding: 15px 0; }
.thread-message { padding: 13px 14px; border-radius: 10px; background: linear-gradient(90deg, #faf5f6 0%, #fdfafa 100%); }
.thread-message.is-draft { background: #f8fbf9; }
.thread-message-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; color: var(--muted); font-size: 10px; }
.thread-message-body { color: var(--ink); font-size: 12px; line-height: 1.65; white-space: pre-wrap; }
.draft-panel { margin-top: 7px; padding-top: 14px; border-top: 1px solid var(--line); }
.draft-panel h3 { margin: 0 0 9px; font-size: 13px; }
.draft-instruction { width: 100%; min-height: 38px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 11px; color: var(--ink); background: #fff; outline: 0; }
.draft-content { padding: 11px 12px; border: 1px solid #eadfe2; border-radius: 10px; background: #fdf7f9; }
.draft-subject { margin-bottom: 7px; color: var(--ink); font-size: 12px; font-weight: 800; }
.draft-body { color: var(--ink); font-size: 12px; line-height: 1.65; white-space: pre-wrap; }
.draft-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 11px; }
.approval-note { color: var(--green); font-size: 10px; font-weight: 800; }
.email-error { margin-top: 14px; }

.business-view-panel { min-height: 0; }
.business-frame-shell { position: relative; flex: 1; min-height: 680px; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: #f6f2f3; box-shadow: var(--shadow); }
.business-frame-shell iframe { display: block; width: 100%; height: max(680px, calc(100vh - 190px)); border: 0; background: #f6f2f3; }
.business-frame-loading { position: absolute; z-index: 1; inset: 0; display: grid; place-items: center; color: var(--muted); background: #f8f4f5; font-size: 13px; font-weight: 700; }

.sales-conversation-wrap { width: min(100%, 980px); margin: 42px auto 0; }
.sales-run-panel { border: 1px solid var(--line); border-radius: 18px; padding: 23px; background: #fff; box-shadow: var(--shadow); }
.sales-run-head { display: flex; align-items: start; justify-content: space-between; gap: 18px; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.sales-run-head .eyebrow { margin-bottom: 7px; }
.sales-run-head h2 { margin-bottom: 7px; font-size: 24px; }
.sales-run-head p { max-width: 720px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.sales-status, .sales-safety { display: inline-flex; align-items: center; border-radius: 99px; padding: 6px 10px; color: var(--blue); background: var(--wine-soft); font-size: 10px; font-weight: 800; white-space: nowrap; }
.sales-safety { color: var(--green); background: #eef5f1; }
.sales-status.state-failed { color: var(--danger); background: #fff1f1; }
.sales-status.state-review { color: #8b672d; background: #fff4d6; }
.sales-summary { display: grid; gap: 5px; margin-top: 16px; padding: 12px 14px; border-radius: 11px; background: var(--soft); }
.sales-summary strong { font-size: 11px; }
.sales-summary span { color: var(--muted); font-size: 12px; line-height: 1.5; }
.sales-step-list { display: grid; gap: 10px; margin-top: 18px; }
.sales-step { display: flex; align-items: start; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.sales-step:last-child { border-bottom: 0; }
.sales-step-dot { flex: none; width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; background: #c8b7bd; }
.sales-step-dot.state-completed { background: var(--green); }
.sales-step-dot.state-running { background: #d7a13d; }
.sales-step-dot.state-failed { background: var(--danger); }
.sales-step strong { font-size: 12px; }
.sales-step p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.sales-error-detail { margin-top: 15px; padding: 12px 14px; border: 1px solid #efcccc; border-radius: 11px; background: #fff8f8; }
.sales-error-detail strong { color: var(--danger); font-size: 12px; }
.sales-error-detail p { margin: 5px 0 0; color: var(--danger); font-size: 11px; }
.sales-event-list { display: grid; gap: 7px; margin-top: 16px; }
.sales-event-list div { display: flex; gap: 10px; color: var(--muted); font-size: 11px; }
.sales-event-list span { color: #a2939a; font-weight: 800; }
.sales-event-list p { margin: 0; line-height: 1.45; }

.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; padding: 0 !important; border: 0 !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; }
[hidden] { display: none !important; }

@media (max-width: 1000px) {
  .sidebar { flex-basis: 225px; }
  .workspace { padding-right: 35px; padding-left: 35px; }
  .quotation-layout { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 10; top: 0; bottom: 0; left: 0; width: 272px; transform: translateX(-102%); transition: transform .2s; box-shadow: 10px 0 35px rgba(74, 32, 46, .14); }
  .sidebar.is-open { transform: translateX(0); }
  .topbar { justify-content: space-between; min-height: 68px; padding: 12px 18px; }
  .mobile-menu, .mobile-title { display: block; }
  .mobile-menu { border: 0; color: var(--ink); background: transparent; font-size: 23px; }
  .mobile-title { color: var(--ink); font-weight: 800; }
  .api-status { display: none; }
  .top-actions { gap: 10px; }
  .workspace { min-height: calc(100vh - 68px); padding: 0 17px 22px; }
  .view-heading, .compact-heading { padding-top: 14px; }
  .compact-heading { align-items: start; flex-direction: column; }
  h1 { font-size: 37px; }
  .view-subtitle { font-size: 15px; }
  .conversation-wrap { margin-top: 18px; }
  .composer textarea { height: 88px; min-height: 88px; padding-right: 15px; padding-left: 15px; }
  .email-toolbar { align-items: start; flex-direction: column; }
  .email-actions { justify-content: start; }
  .email-thread-rail { grid-template-columns: 26px minmax(0, 1fr) 26px; }
  .thread-detail { min-height: 350px; }
  .business-frame-shell { min-height: 620px; }
  .business-frame-shell iframe { height: max(620px, calc(100vh - 210px)); }
  .modal-backdrop { padding: 14px; }
  .modal-panel { max-height: calc(100vh - 28px); padding: 20px; border-radius: 16px; }
  .settings-grid, .help-grid { grid-template-columns: 1fr; }
  .account-profile-grid, .account-password-form { grid-template-columns: 1fr; }
  .preference-field { grid-template-columns: 1fr; gap: 7px; }
  .help-workflow { justify-content: start; }
}

@media (max-width: 460px) {
  .field-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .send-button { width: 47px; height: 47px; }
  .message-bubble { max-width: 95%; }
}


/* Quotation：在根站右侧完整显示 /quote/，不增加外层容器视觉。 */
body.quotation-active .topbar { display: none; }
body.quotation-active .workspace {
  min-height: 100vh;
  padding: 0;
}
.quotation-workspace {
  min-height: 100vh;
}
.quotation-embedded-frame-wrap {
  position: relative;
  flex: 1;
  min-height: 100vh;
  overflow: visible;
  background: transparent;
}
.quotation-embedded-frame-wrap iframe {
  display: block;
  width: 100%;
  min-height: 100vh;
  border: 0;
  background: #fff;
}

/* Sales Agent 与 Contract 均直接呈现完整业务工作台。 */
body.business-active .topbar { display: none; }
body.business-active .workspace {
  min-height: 100vh;
  padding: 0;
}
.business-workspace {
  min-height: 100vh;
}
.business-workspace .business-frame-shell {
  min-height: 100vh;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.business-workspace .business-frame-shell iframe {
  height: 100vh;
  min-height: 100vh;
  background: #fff;
}

@media (max-width: 720px) {
  body.business-active .topbar {
    display: block;
    position: fixed;
    z-index: 11;
    top: 12px;
    left: 12px;
    min-height: 0;
    padding: 0;
  }
  body.business-active .topbar .mobile-title,
  body.business-active .topbar .top-actions { display: none; }
  body.business-active .mobile-menu {
    display: block;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 4px 16px rgba(17, 30, 49, .16);
  }
}
