:root {
  color-scheme: light;
  --font-scale: 1;
  --ink: #172033; --muted: #4b5563; --subtle: #5f6b7a;
  --canvas: #f3f6fa; --rail: #fff; --panel: #fff; --panel-2: #eef5ff;
  --line: #b9c6d5; --line-soft: #d9e1ea;
  --accent: #f5a400; --accent-soft: #fff1c9; --blue: #174ea6; --blue-soft: #e7f0ff;
  --green: #087a55; --red: #b42318; --shadow: 0 12px 32px rgba(36,52,71,.1);
}
html[data-text-size="large"] { --font-scale: 1.15; }
html[data-text-size="largest"] { --font-scale: 1.3; }
* { box-sizing: border-box; }
html { font-size: calc(18px * var(--font-scale)); }
html, body { margin: 0; min-height: 100%; }
body { font-family: Arial, Helvetica, system-ui, sans-serif; background: var(--canvas); color: var(--ink); line-height: 1.5; }
button, input, textarea { font: inherit; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
a { color: var(--blue); }
:focus-visible { outline: 4px solid #1b65c9; outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.workspace-body { display: grid; grid-template-columns: 280px minmax(0,1fr); min-height: 100vh; }
.app-rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 22px; background: var(--rail); border-right: 2px solid var(--line-soft); }
.brand-lockup { display: flex; align-items: center; gap: 13px; color: var(--ink); text-decoration: none; min-width: 0; }
.brand-lockup > span:last-child { display: grid; min-width: 0; }
.brand-lockup strong { font-size: 1.1rem; }
.brand-lockup small { color: var(--muted); font-size: .83rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 14px; background: var(--accent); color: #17130b; font-size: .9rem; font-weight: 800; }
.primary-nav { display: grid; gap: 12px; margin-top: 40px; }
.primary-nav a { position: relative; display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 10px; min-height: 58px; padding: 0 16px; border: 2px solid transparent; border-radius: 12px; color: #334155; text-decoration: none; font-size: 1rem; font-weight: 700; }
.primary-nav a:hover { color: var(--ink); background: #f1f5f9; border-color: var(--line-soft); }
.primary-nav a.active { color: #1f2937; background: var(--accent-soft); border-color: #e0b545; }
.nav-icon { font-size: 1.25rem; text-align: center; }
.nav-count, .unread-dot { display: grid; place-items: center; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px; background: #b42318; color: #fff; font-size: .78rem; font-weight: 800; }
.rail-footer { margin-top: auto; padding-top: 22px; border-top: 2px solid var(--line-soft); }
.text-size-control { margin-bottom: 20px; }
.text-size-control > span { display: block; margin-bottom: 8px; color: var(--muted); font-size: .83rem; font-weight: 700; }
.text-size-buttons { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; }
.text-size-buttons button { min-height: 46px; border: 2px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); cursor: pointer; font-weight: 700; }
.text-size-buttons button[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-soft); color: #0c3f86; }
.user-chip { display: flex; align-items: center; gap: 11px; margin-bottom: 14px; min-width: 0; }
.user-chip > span:last-child { display: grid; min-width: 0; }
.user-chip small { color: var(--muted); font-size: .78rem; }
.user-chip strong { font-size: .95rem; text-transform: capitalize; overflow: hidden; text-overflow: ellipsis; }
.avatar { flex: 0 0 auto; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: #dbeafe; border: 2px solid #8ab4ed; color: #123c73; font-weight: 800; font-size: 1rem; }
.avatar.large { width: 54px; height: 54px; }
.quiet-button { width: 100%; min-height: 50px; padding: 8px 12px; border: 2px solid var(--line); border-radius: 10px; color: #334155; background: #fff; cursor: pointer; font-weight: 700; }
.quiet-button:hover { color: var(--ink); border-color: #64748b; background: #f8fafc; }
.app-main { min-width: 0; min-height: 100vh; }
.mobile-header { display: none; }
.notice { position: fixed; z-index: 20; top: 20px; right: 24px; max-width: min(520px,calc(100vw - 32px)); padding: 15px 18px; border-radius: 10px; box-shadow: var(--shadow); font-size: 1rem; font-weight: 700; }
.notice.success { border: 2px solid #17805c; background: #e5f8f0; color: #075b3e; }
.notice.error { border: 2px solid #c9362b; background: #fff0ef; color: #8e1b13; }

/* Messages */
.messages-shell { height: 100vh; display: grid; grid-template-columns: minmax(360px,430px) minmax(0,1fr); overflow: hidden; }
.conversation-panel { min-width: 0; display: flex; flex-direction: column; background: #fff; border-right: 2px solid var(--line); }
.panel-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 30px 24px 20px; }
.eyebrow { margin: 0 0 6px; color: #8a5900; font-size: .82rem; font-weight: 800; }
h1, h2, p { margin-top: 0; }
.panel-heading h1, .page-heading h1 { margin: 0; font-size: 2rem; line-height: 1.15; letter-spacing: -.02em; }
.unread-summary { padding: 5px 9px; border-radius: 999px; background: #fff0ef; color: #8e1b13; font-size: .82rem; font-weight: 700; white-space: nowrap; }
.search-box { display: flex; align-items: center; gap: 10px; margin: 0 18px 16px; padding: 0 14px; border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--muted); }
.search-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,78,166,.16); }
.search-box input { width: 100%; height: 52px; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 1rem; }
.conversation-list { min-height: 0; overflow: auto; padding: 0 10px 20px; }
.conversation-row { position: relative; display: flex; align-items: center; gap: 13px; min-height: 94px; padding: 14px; border: 2px solid transparent; border-radius: 12px; color: var(--ink); text-decoration: none; }
.conversation-row:hover { background: #f4f7fb; border-color: var(--line-soft); }
.conversation-row.selected { background: var(--blue-soft); border-color: #76a7e8; box-shadow: inset 5px 0 var(--blue); }
.conversation-copy { min-width: 0; flex: 1; display: grid; gap: 6px; }
.conversation-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.conversation-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1rem; }
.conversation-title time { flex: 0 0 auto; color: var(--muted); font-size: .78rem; }
.conversation-preview { overflow: hidden; color: var(--muted); font-size: .9rem; text-overflow: ellipsis; white-space: nowrap; }
.sent-arrow { margin-right: 4px; color: var(--blue); }
.conversation-row .unread-dot { min-width: 26px; height: 26px; font-size: .75rem; }
.empty-list, .thread-placeholder { display: grid; justify-items: center; align-content: center; text-align: center; color: var(--muted); }
.empty-list { min-height: 300px; padding: 28px; }
.empty-list > span, .thread-placeholder > span { font-size: 2rem; color: var(--blue); margin-bottom: 12px; }
.empty-list strong { color: var(--ink); font-size: 1rem; }
.empty-list p, .thread-placeholder p { max-width: 360px; margin: 8px 0 0; font-size: .95rem; line-height: 1.55; }
.thread-panel { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0,1fr) auto; background: #f4f7fb; }
.thread-header { min-height: 88px; display: flex; align-items: center; gap: 14px; padding: 14px 28px; border-bottom: 2px solid var(--line-soft); background: #fff; }
.thread-header > div { min-width: 0; }
.thread-header h2 { margin: 0 0 3px; font-size: 1.15rem; }
.thread-header p { margin: 0; color: var(--muted); font-size: .88rem; }
.header-action { margin-left: auto; min-height: 48px; display: inline-flex; align-items: center; padding: 8px 18px; border: 2px solid var(--line); border-radius: 10px; color: var(--blue); background: #fff; font-size: .95rem; font-weight: 700; text-decoration: none; }
.header-action:hover { border-color: var(--blue); background: var(--blue-soft); }
.mobile-back { display: none; text-decoration: none; }
.message-stream { min-height: 0; overflow-y: auto; padding: 30px clamp(22px,5vw,78px); scroll-behavior: smooth; }
.message-row { display: flex; margin: 14px 0; }
.message-row.outbound { justify-content: flex-end; }
.message-bubble { max-width: min(700px,78%); padding: 15px 17px 12px; border: 2px solid #c5ced9; border-radius: 16px 16px 16px 5px; background: #fff; box-shadow: 0 5px 15px rgba(36,52,71,.07); }
.message-row.outbound .message-bubble { border-color: #82ace4; border-radius: 16px 16px 5px 16px; background: var(--blue-soft); }
.message-bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1rem; line-height: 1.55; }
.message-bubble footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 9px; color: #4b6078; font-size: .75rem; }
.delivery.delivered { color: var(--green); font-weight: 700; }
.delivery.failed { color: var(--red); font-weight: 700; }
.composer { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px 12px; padding: 18px clamp(20px,4vw,62px) 20px; border-top: 2px solid var(--line-soft); background: #fff; }
.composer textarea { width: 100%; min-height: 54px; max-height: 160px; resize: none; outline: 0; padding: 13px 15px; border: 2px solid var(--line); border-radius: 11px; background: #fff; color: var(--ink); font-size: 1rem; line-height: 1.45; }
.composer textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,78,166,.16); }
.composer button { min-width: 125px; min-height: 54px; border: 2px solid #c08100; border-radius: 11px; background: var(--accent); color: #17130b; font-weight: 800; cursor: pointer; }
.composer button:hover, .primary-button:hover { filter: brightness(.96); }
.composer > p { grid-column: 1/-1; margin: 0 2px; color: var(--muted); font-size: .78rem; }
.thread-placeholder { grid-row: 1/-1; min-height: 100vh; }

/* Quotes */
.page-wrap { width: min(1500px,100%); margin: 0 auto; padding: 42px clamp(28px,4vw,64px) 70px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading > div > p:last-child { margin: 10px 0 0; color: var(--muted); font-size: 1rem; }
.service-pill { display: inline-flex; align-items: center; gap: 9px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 999px; color: #334155; background: #fff; font-size: .85rem; font-weight: 700; }
.service-pill i { width: 10px; height: 10px; border-radius: 50%; background: var(--green); }
.surface { margin-bottom: 26px; padding: 28px; border: 2px solid var(--line-soft); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.section-heading h2 { margin: 0 0 3px; font-size: 1.25rem; }
.section-heading p { margin: 0; color: var(--muted); font-size: .9rem; }
.section-number { flex: 0 0 auto; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); border: 2px solid #e3bc55; color: #694300; font-size: 1rem; font-weight: 800; }
.form-grid { display: grid; grid-template-columns: 1.25fr 1fr 1fr 1fr; gap: 18px; }
.form-grid label { display: grid; align-content: start; gap: 8px; color: #283548; font-size: .95rem; font-weight: 700; }
.field-hint { display: block; color: var(--muted); font-size: .78rem; font-weight: 400; }
.form-grid input { min-width: 0; height: 54px; padding: 0 14px; border: 2px solid var(--line); border-radius: 10px; outline: 0; background: #fff; color: var(--ink); font-size: 1rem; }
.form-grid input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,78,166,.16); }
.form-grid input[type="file"] { padding: 8px; }
.form-grid input[type="file"]::file-selector-button { height: 34px; margin-right: 10px; border: 1px solid #6b7c90; border-radius: 7px; padding: 4px 10px; background: #edf2f7; color: var(--ink); cursor: pointer; font-weight: 700; }
.form-footer { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-top: 22px; }
.check-row { display: flex; align-items: flex-start; gap: 12px; margin: 12px 0; color: #283548; font-size: .95rem; line-height: 1.4; }
.check-row input { flex: 0 0 auto; width: 24px; height: 24px; accent-color: var(--blue); margin: 1px 0 0; }
.primary-button { min-height: 54px; padding: 12px 20px; border: 2px solid #c08100; border-radius: 10px; background: var(--accent); color: #17130b; font-size: 1rem; font-weight: 800; cursor: pointer; white-space: nowrap; }
.primary-button span { margin-left: 8px; }
.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; }
.quote-history { min-width: 0; overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th { padding: 13px 14px; border-bottom: 2px solid var(--line); color: #39485b; font-size: .83rem; text-align: left; white-space: nowrap; }
td { padding: 17px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td strong { font-size: .95rem; }
td small { margin-top: 4px; color: var(--muted); font-size: .78rem; }
.status-badge { display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 999px; font-size: .78rem; font-weight: 800; }
.status-badge.delivered { color: #056344; background: #ddf5eb; }
.status-badge.pending { color: #694300; background: var(--accent-soft); }
.status-badge.failed { color: #941f16; background: #ffe4e1; }
.status-badge.neutral { color: #334155; background: #e9eef5; }
.row-actions { display: flex; justify-content: flex-end; gap: 8px; }
.row-actions form { margin: 0; }
.icon-button { min-height: 44px; padding: 8px 12px; border: 2px solid var(--line); border-radius: 8px; background: #fff; color: var(--blue); font-size: .82rem; font-weight: 700; cursor: pointer; }
.icon-button:hover { color: #0c3f86; border-color: var(--blue); background: var(--blue-soft); }
.icon-button.danger { color: #a0251b; }
.empty-cell { padding: 50px; text-align: center; color: var(--muted); }

/* Login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #eef3f8; }
.login-card { width: min(100%,500px); padding: 36px; border: 2px solid var(--line); border-radius: 18px; background: #fff; box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 13px; padding-bottom: 24px; border-bottom: 2px solid var(--line-soft); }
.login-brand > span:last-child { display: grid; }
.login-brand strong { font-size: 1.1rem; }
.login-brand small { color: var(--muted); font-size: .83rem; }
.login-heading { margin: 30px 0 24px; }
.login-heading h1 { margin: 0 0 8px; font-size: 2rem; line-height: 1.2; }
.login-heading > p:last-child { margin: 0; color: var(--muted); font-size: 1rem; }
.login-card form label { display: block; margin: 18px 0 8px; color: #283548; font-size: 1rem; font-weight: 700; }
.login-card form input { width: 100%; height: 56px; padding: 0 14px; border: 2px solid var(--line); border-radius: 10px; outline: 0; background: #fff; color: var(--ink); font-size: 1rem; }
.login-card form input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,78,166,.16); }
.login-card form button { width: 100%; min-height: 56px; margin-top: 25px; padding: 12px; border: 2px solid #c08100; border-radius: 10px; background: var(--accent); color: #17130b; font-size: 1rem; font-weight: 800; cursor: pointer; }
.login-error { margin-bottom: 18px; padding: 13px 15px; border: 2px solid #c9362b; border-radius: 9px; background: #fff0ef; color: #8e1b13; font-size: .95rem; }
.login-footnote { margin: 20px 0 0; color: var(--muted); font-size: .82rem; text-align: center; }

@media (max-width: 1100px) {
  .workspace-body { grid-template-columns: 220px minmax(0,1fr); }
  .app-rail { padding: 24px 14px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 800px) {
  .workspace-body { display: block; }
  .app-rail { display: none; }
  .app-main { min-height: 100dvh; }
  .mobile-header { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 14px; border-bottom: 2px solid var(--line); background: #fff; }
  .mobile-header .brand-lockup { gap: 8px; }
  .mobile-header .brand-mark { width: 42px; height: 42px; border-radius: 10px; font-size: .75rem; }
  .mobile-header nav { display: flex; gap: 4px; }
  .mobile-header nav a { min-height: 48px; display: inline-flex; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--blue); font-size: .88rem; font-weight: 700; text-decoration: none; }
  .mobile-header nav a.active { background: var(--accent-soft); color: #3f2a00; }
  .mobile-text-size { min-width: 48px; min-height: 48px; padding: 6px; border: 2px solid var(--line); border-radius: 8px; background: #fff; color: var(--blue); font-size: .82rem; font-weight: 800; }
  .messages-shell { height: calc(100dvh - 74px); display: block; }
  .conversation-panel { height: 100%; border-right: 0; }
  .thread-panel { display: none; height: 100%; }
  .messages-shell.has-selection .conversation-panel { display: none; }
  .messages-shell.has-selection .thread-panel { display: grid; }
  .mobile-back { width: 48px; height: 48px; display: grid; place-items: center; color: var(--blue); font-size: 1.4rem; }
  .thread-header { min-height: 74px; padding: 9px 12px; }
  .thread-header .avatar { display: none; }
  .header-action { min-height: 46px; padding: 7px 12px; }
  .message-stream { padding: 20px 12px; }
  .message-bubble { max-width: 90%; }
  .composer { padding: 11px 12px 13px; }
  .composer button { min-width: 108px; }
  .page-wrap { padding: 28px 14px 46px; }
  .page-heading { align-items: flex-start; }
  .service-pill { display: none; }
  .surface { padding: 19px; border-radius: 13px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-footer { align-items: stretch; flex-direction: column; }
  .primary-button { width: 100%; }
  .quote-history { padding: 19px 0; }
  .quote-history .section-heading { padding: 0 19px; }
  .notice { top: 82px; right: 12px; }
}
@media (max-width: 520px) {
  html { font-size: calc(17px * var(--font-scale)); }
  .mobile-header .brand-lockup strong { display: none; }
  .panel-heading { padding: 24px 18px 17px; }
  .panel-heading h1, .page-heading h1 { font-size: 1.75rem; }
  .conversation-row { min-height: 90px; }
  .section-heading { align-items: flex-start; }
  .composer > p { display: none; }
  table { min-width: 850px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
