:root {
  color-scheme: light;
  --navy-950: #111a3a;
  --navy-800: #26345f;
  --navy-600: #536184;
  --navy-400: #8994ae;
  --blue-600: #246ff2;
  --blue-100: #eaf2ff;
  --teal-600: #0cae9e;
  --teal-100: #e5f8f5;
  --coral-600: #f04469;
  --coral-100: #fff0f3;
  --amber-600: #d98912;
  --amber-100: #fff6df;
  --violet-600: #7c4ee4;
  --violet-100: #f2edff;
  --surface: #fff;
  --surface-soft: #f7f9fc;
  --surface-tint: #fbfcff;
  --line: #e7ebf3;
  --line-strong: #dbe1ec;
  --shadow-sm: 0 2px 10px rgba(25, 42, 86, .045);
  --shadow-md: 0 14px 36px rgba(25, 42, 86, .08);
  --radius-md: 16px;
  --header-height: 72px;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; color: var(--navy-950); background: var(--surface-soft); font: 14px/1.48 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--blue-600); }

.app-header { position: sticky; z-index: 50; top: 0; min-height: var(--header-height); padding: 0 22px; display: flex; align-items: center; gap: 22px; background: rgba(255,255,255,.94); border-bottom: 1px solid rgba(231,235,243,.9); backdrop-filter: blur(16px); }
.brand { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 10px; color: var(--navy-950); text-decoration: none; }
.brand-logo { width: 44px; height: 44px; display: block; object-fit: contain; border-radius: 13px; background: #fff; box-shadow: 0 7px 16px rgba(25,42,86,.1); }
.brand-copy { display: grid; line-height: 1.05; }
.brand-copy strong { font-size: 16px; letter-spacing: .02em; }
.brand-copy small { margin-top: 4px; color: var(--navy-600); font-size: 10px; white-space: nowrap; }

.primary-nav { min-width: 0; flex: 1; display: flex; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.primary-nav::-webkit-scrollbar { display: none; }
.nav-item { min-height: 42px; padding: 0 11px; display: inline-flex; align-items: center; gap: 7px; border-radius: 12px; color: var(--navy-600); text-decoration: none; font-size: 13px; font-weight: 600; white-space: nowrap; }
.nav-item svg, .icon-button svg, .route-icon svg, .back-link svg, .send-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item--active { color: var(--blue-600); background: var(--blue-100); }
.nav-item--disabled { cursor: default; opacity: .72; }
.header-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 14px; }
.ai-entry { padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--violet-600); background: var(--violet-100); font-weight: 800; font-size: 12px; }
.user-panel { display: flex; align-items: center; gap: 9px; padding-left: 14px; border-left: 1px solid var(--line); }
.user-avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(145deg,#ffe8e5,#ffd2dc); color: var(--coral-600); font-weight: 900; }
.user-copy { display: grid; min-width: 100px; line-height: 1.15; }
.user-copy strong { font-size: 13px; }
.user-copy small { margin-top: 4px; color: var(--navy-600); font-size: 11px; }
.icon-button { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 10px; color: var(--navy-600); background: transparent; cursor: pointer; }
.icon-button:hover { color: var(--coral-600); background: var(--coral-100); }

.app-main { max-width: 1280px; margin: 0 auto; padding: 28px 24px 44px; }
.page-head { margin-bottom: 20px; display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.page-head__copy { min-width: 0; }
.eyebrow { margin: 0 0 6px; color: var(--teal-600); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.page-head h1 { margin: 0; font-size: clamp(25px,3vw,34px); line-height: 1.15; letter-spacing: -.03em; }
.page-subtitle { margin: 7px 0 0; color: var(--navy-600); }
.inbox-summary { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.summary-chip { padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--navy-600); background: #fff; font-size: 12px; }
.summary-chip strong { margin-right: 4px; color: var(--navy-950); }
.summary-chip--alert { color: var(--amber-600); background: var(--amber-100); border-color: transparent; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }

.integration-notice { margin-bottom: 14px; overflow: hidden; }
.integration-notice summary { min-height: 48px; padding: 0 16px; display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; color: #9b5e06; background: var(--amber-100); font-weight: 700; }
.integration-notice summary::-webkit-details-marker { display: none; }
.notice-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber-600); box-shadow: 0 0 0 5px rgba(217,137,18,.11); }
.notice-count { margin-left: auto; padding: 2px 8px; border-radius: 99px; color: #fff; background: var(--amber-600); font-size: 11px; }
.notice-list { padding: 8px 16px 13px; background: #fffdf7; }
.notice-item { padding: 8px 0; color: var(--navy-600); border-top: 1px solid #f2ead7; font-size: 12px; }
.notice-item:first-child { border-top: 0; }
.notice-item strong { color: var(--navy-950); }

.inbox-card { overflow: hidden; }
.inbox-card__header { padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.inbox-card__header h2 { margin: 0; font-size: 17px; }
.inbox-card__header span { color: var(--navy-400); font-size: 12px; }
.conversation-list { display: grid; }
.conversation-row { position: relative; min-height: 90px; padding: 15px 18px; display: grid; grid-template-columns: 46px minmax(0,1fr) auto 20px; align-items: center; gap: 13px; color: inherit; text-decoration: none; border-top: 1px solid var(--line); transition: background 160ms ease; }
.conversation-row:first-child { border-top: 0; }
.conversation-row:hover { background: var(--surface-tint); }
.conversation-row::before { content: ""; position: absolute; inset: 16px auto 16px 0; width: 3px; border-radius: 0 4px 4px 0; background: var(--teal-600); opacity: 0; }
.conversation-row:hover::before, .conversation-row--review::before, .conversation-row--error::before { opacity: 1; }
.conversation-row--review::before { background: var(--amber-600); }
.conversation-row--error::before { background: var(--coral-600); }
.conversation-avatar { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; color: #fff; background: linear-gradient(145deg,#28c5d4,#1789d2); box-shadow: 0 7px 16px rgba(23,137,210,.16); font-weight: 900; font-size: 16px; }
.conversation-main { min-width: 0; }
.conversation-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.conversation-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.conversation-preview { margin-top: 5px; overflow: hidden; color: var(--navy-600); text-overflow: ellipsis; white-space: nowrap; }
.conversation-tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 3px 8px; border-radius: 999px; color: var(--navy-600); background: #f2f4f8; font-size: 10px; font-weight: 700; }
.tag--brand { color: var(--violet-600); background: var(--violet-100); }
.tag--channel { color: #087ea4; background: #e8f8fd; }
.tag--review { color: var(--amber-600); background: var(--amber-100); }
.tag--error { color: var(--coral-600); background: var(--coral-100); }
.conversation-meta { min-width: 145px; display: grid; justify-items: end; gap: 7px; color: var(--navy-600); font-size: 11px; }
.manager-label { max-width: 155px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-label { padding: 4px 9px; border-radius: 999px; color: var(--blue-600); background: var(--blue-100); font-weight: 700; }
.status-label--attention { color: var(--coral-600); background: var(--coral-100); }
.row-arrow { color: var(--navy-400); font-size: 23px; }
.empty-state { padding: 52px 20px; text-align: center; color: var(--navy-600); }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--navy-950); }

.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; color: var(--navy-600); text-decoration: none; font-weight: 700; }
.back-link:hover { color: var(--blue-600); }
.back-link svg { width: 16px; height: 16px; }
.conversation-workspace { display: grid; grid-template-columns: 300px minmax(0,1fr); gap: 16px; align-items: start; }
.customer-card { padding: 20px; position: sticky; top: calc(var(--header-height) + 20px); }
.customer-identity { display: flex; align-items: center; gap: 12px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.customer-avatar { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 16px; color: #fff; background: linear-gradient(145deg,#24c9bb,#0c91b5); font-size: 17px; font-weight: 900; }
.customer-identity h2 { margin: 0; font-size: 17px; line-height: 1.25; }
.customer-identity p { margin: 4px 0 0; color: var(--navy-600); font-size: 12px; }
.customer-section { padding-top: 17px; }
.customer-section + .customer-section { margin-top: 17px; border-top: 1px solid var(--line); }
.section-label { margin: 0 0 11px; color: var(--navy-400); font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.info-list { display: grid; gap: 13px; margin: 0; }
.info-row { display: grid; grid-template-columns: 92px minmax(0,1fr); gap: 8px; }
.info-row dt { color: var(--navy-600); }
.info-row dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-weight: 700; }
.review-card { margin-top: 16px; padding: 12px; border-radius: 12px; color: #925c0b; background: var(--amber-100); font-size: 12px; }
.technical-details { margin-top: 17px; padding-top: 14px; border-top: 1px solid var(--line); }
.technical-details summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; list-style: none; color: var(--navy-600); font-size: 11px; font-weight: 800; }
.technical-details summary::-webkit-details-marker { display: none; }
.technical-details summary span { color: var(--navy-400); font-size: 20px; line-height: 1; transition: transform 160ms ease; }
.technical-details[open] summary span { transform: rotate(90deg); }
.technical-details .info-list { margin-top: 14px; }

.thread-panel { min-width: 0; overflow: hidden; }
.thread-head { min-height: 74px; padding: 15px 19px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.thread-head__title { min-width: 0; }
.thread-head h1 { margin: 0; overflow: hidden; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
.thread-head p { margin: 4px 0 0; color: var(--navy-600); font-size: 12px; }
.route-summary { flex: 0 0 auto; display: flex; align-items: center; gap: 9px; padding: 8px 11px; border-radius: 12px; background: var(--teal-100); color: #087c72; }
.route-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: var(--teal-600); }
.route-icon svg { width: 17px; height: 17px; }
.route-copy { display: grid; line-height: 1.2; }
.route-copy strong { font-size: 11px; }
.route-copy small { margin-top: 3px; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.message-history { min-height: 420px; max-height: calc(100vh - 310px); padding: 22px; overflow-y: auto; background: linear-gradient(180deg,#fbfcff 0%,#f7f9fc 100%); }
.message-row { display: flex; margin: 11px 0; }
.message-row--outbound { justify-content: flex-end; }
.message-bubble { max-width: min(72%,650px); padding: 11px 13px 8px; border: 1px solid var(--line); border-radius: 6px 16px 16px 16px; background: #fff; box-shadow: 0 3px 12px rgba(25,42,86,.045); }
.message-row--outbound .message-bubble { border-color: #cfeee9; border-radius: 16px 6px 16px 16px; background: #eaf9f6; }
.message-text { color: var(--navy-950); overflow-wrap: anywhere; }
.message-meta { margin-top: 7px; display: flex; align-items: center; justify-content: flex-end; gap: 6px; color: var(--navy-400); font-size: 10px; }
.delivery-state { color: var(--teal-600); font-weight: 800; }
.message-error { margin-top: 8px; padding: 7px 9px; border-radius: 9px; color: #a82e4b; background: #ffe5eb; font-size: 11px; }
.attachment-link { display: inline-flex; margin-top: 7px; padding: 6px 8px; border-radius: 8px; color: var(--blue-600); background: var(--blue-100); text-decoration: none; font-size: 11px; font-weight: 700; }

.composer { position: sticky; bottom: 0; padding: 14px 17px 16px; border-top: 1px solid var(--line); background: rgba(255,255,255,.97); backdrop-filter: blur(12px); }
.composer-route { margin-bottom: 10px; display: flex; align-items: center; gap: 8px; color: var(--navy-600); font-size: 11px; }
.route-lock { color: var(--teal-600); }
.composer-route strong { color: var(--navy-950); }
.composer-box { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; align-items: end; }
.composer textarea { width: 100%; min-height: 74px; max-height: 180px; padding: 12px 13px; resize: vertical; border: 1px solid var(--line-strong); border-radius: 13px; color: var(--navy-950); background: var(--surface-tint); outline: none; }
.composer textarea:focus { border-color: #8ab8ff; box-shadow: 0 0 0 4px rgba(36,111,242,.09); background: #fff; }
.send-button { min-width: 112px; height: 44px; padding: 0 15px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 12px; color: #fff; background: linear-gradient(135deg,#19b7bd,#0c9dac); box-shadow: 0 8px 18px rgba(12,157,172,.2); cursor: pointer; font-weight: 800; }
.send-button:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(12,157,172,.27); }
.send-button svg { width: 17px; height: 17px; }

.flash-stack { position: fixed; z-index: 80; top: 84px; right: 20px; width: min(390px,calc(100vw - 40px)); display: grid; gap: 8px; }
.flash { padding: 12px 14px; display: flex; align-items: center; gap: 9px; border: 1px solid #cdebe5; border-radius: 12px; color: #087c72; background: #effbf8; box-shadow: var(--shadow-md); font-weight: 700; }
.flash > span { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--teal-600); }
.flash--error { color: #a82e4b; border-color: #ffd0da; background: #fff2f5; }
.flash--error > span { background: var(--coral-600); }

.auth-body { min-height: 100vh; background: radial-gradient(circle at 15% 15%,#fff1ee 0,transparent 31%), radial-gradient(circle at 82% 20%,#e8f9fb 0,transparent 29%), #f7f9fc; }
.auth-main { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-shell { width: min(960px,100%); min-height: 560px; display: grid; grid-template-columns: 1.05fr .95fr; overflow: hidden; border: 1px solid rgba(231,235,243,.9); border-radius: 26px; background: #fff; box-shadow: 0 26px 70px rgba(25,42,86,.12); }
.login-visual { position: relative; padding: 48px; overflow: hidden; color: #fff; background: linear-gradient(145deg,#152149 0%,#23386f 62%,#176f85 100%); }
.login-visual::before { content: ""; position: absolute; width: 340px; height: 340px; right: -130px; bottom: -140px; border-radius: 50%; background: rgba(255,255,255,.08); }
.login-visual::after { content: ""; position: absolute; width: 210px; height: 210px; right: -50px; top: 70px; border: 42px solid rgba(255,255,255,.055); border-radius: 50%; }
.login-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 11px; }
.login-logo { width: 64px; height: 64px; display: block; object-fit: contain; border-radius: 17px; background: #fff; box-shadow: 0 9px 22px rgba(0,0,0,.16); }
.login-brand strong { display: block; font-size: 18px; letter-spacing: .03em; }
.login-brand small { color: rgba(255,255,255,.7); }
.login-message { position: relative; z-index: 1; max-width: 400px; margin-top: 105px; }
.login-message h1 { margin: 0; font-size: clamp(34px,5vw,50px); line-height: 1.04; letter-spacing: -.045em; }
.login-message p { margin: 18px 0 0; color: rgba(255,255,255,.76); font-size: 16px; }
.login-accent { margin-top: 34px; display: flex; align-items: center; gap: 11px; color: #fff; font-weight: 700; }
.login-accent span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 12px; color: #16395d; background: #d5fbf5; }
.login-form-panel { padding: 56px; display: flex; flex-direction: column; justify-content: center; }
.login-form-panel .eyebrow { margin-bottom: 10px; }
.login-form-panel h2 { margin: 0; font-size: 28px; letter-spacing: -.03em; }
.login-form-panel > p { margin: 8px 0 28px; color: var(--navy-600); }
.form-group { margin-bottom: 17px; }
.form-group label { display: block; margin-bottom: 7px; color: var(--navy-800); font-size: 12px; font-weight: 800; }
.form-group input { width: 100%; height: 47px; padding: 0 13px; border: 1px solid var(--line-strong); border-radius: 12px; color: var(--navy-950); background: var(--surface-tint); outline: none; }
.form-group input:focus { border-color: #8ab8ff; box-shadow: 0 0 0 4px rgba(36,111,242,.09); background: #fff; }
.login-button { width: 100%; height: 48px; margin-top: 5px; border: 0; border-radius: 12px; color: #fff; background: linear-gradient(135deg,var(--blue-600),#4d5fe9); box-shadow: 0 10px 22px rgba(36,111,242,.22); cursor: pointer; font-weight: 800; }
.login-error { margin-bottom: 17px; padding: 10px 12px; border-radius: 10px; color: #a82e4b; background: var(--coral-100); font-size: 12px; }
.login-footnote { margin-top: 23px; color: var(--navy-400); text-align: center; font-size: 11px; }

@media (max-width: 1160px) {
  .brand-copy small, .user-copy, .nav-item--optional { display: none; }
  .nav-item { padding: 0 9px; }
  .user-panel { padding-left: 8px; }
}
@media (max-width: 900px) {
  .app-header { gap: 12px; padding: 0 14px; }
  .nav-item span { display: none; }
  .nav-item { width: 40px; justify-content: center; padding: 0; }
  .ai-entry { display: none; }
  .conversation-workspace { grid-template-columns: 1fr; }
  .customer-card { position: static; }
  .customer-section { display: inline-block; width: calc(50% - 8px); vertical-align: top; }
  .technical-details { margin-top: 17px; }
  .message-history { max-height: none; }
}
@media (max-width: 700px) {
  :root { --header-height: 62px; }
  .app-header { min-height: var(--header-height); }
  .brand-copy, .user-avatar { display: none; }
  .brand-logo { width: 38px; height: 38px; }
  .header-actions { gap: 0; }
  .user-panel { border-left: 0; }
  .app-main { padding: 20px 12px 32px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .inbox-summary { justify-content: flex-start; }
  .conversation-row { grid-template-columns: 42px minmax(0,1fr) 18px; padding: 13px 12px; }
  .conversation-meta { grid-column: 2 / 3; min-width: 0; justify-items: start; display: flex; flex-wrap: wrap; }
  .row-arrow { grid-row: 1 / span 2; grid-column: 3; }
  .thread-head { align-items: flex-start; flex-direction: column; }
  .route-summary { width: 100%; }
  .route-copy small { max-width: 260px; }
  .message-history { min-height: 360px; padding: 14px 10px; }
  .message-bubble { max-width: 88%; }
  .composer-box { grid-template-columns: 1fr; }
  .send-button { width: 100%; }
  .customer-section { display: block; width: 100%; }
  .login-shell { min-height: auto; grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-form-panel { padding: 36px 24px; }
}
