:root {
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #111b21;
  background: #f0f2f5;
  font-synthesis: none;
  --green-dark: #075e54;
  --green: #008069;
  --green-bright: #25d366;
  --green-soft: #d9fdd3;
  --surface: #ffffff;
  --surface-soft: #f0f2f5;
  --chat-bg: #efeae2;
  --text: #111b21;
  --muted: #667781;
  --border: #e9edef;
  --danger: #c54432;
  --shadow: 0 2px 16px rgba(11, 20, 26, .08);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--surface-soft); }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { outline-color: var(--green); outline-offset: 3px; }
button { cursor: pointer; border: 0; border-radius: 8px; background: var(--green); color: #fff; padding: 11px 17px; font-weight: 650; transition: background .18s, transform .18s, box-shadow .18s; }
button:hover { background: #006e5b; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
a { color: var(--green); }
input, textarea, select { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); }
input:focus, textarea:focus, select:focus { border-color: #7bbdac; box-shadow: 0 0 0 3px rgba(0, 128, 105, .1); outline: none; }
textarea { resize: vertical; }
label { display: block; font-size: 12px; font-weight: 650; margin: 18px 0 8px; color: #3b4a54; }
label input, label textarea, label select { margin-top: 7px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 28px; font-weight: 650; letter-spacing: -.7px; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.55; }
.eyebrow { color: var(--green); font-size: 10px; font-weight: 750; letter-spacing: 1.35px; margin-bottom: 8px; }
.secondary { background: #fff; border: 1px solid #d7dde0; color: #3b4a54; font-size: 12px; }
.secondary:hover { background: #f5f7f8; color: var(--green); }
[hidden] { display: none !important; }

/* Login */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(460px, 45%) 1fr; background: var(--surface); }
.login-panel { display: grid; place-items: center; padding: 50px; position: relative; z-index: 1; }
.login-card { width: min(100%, 420px); }
.login-logo { display: block; width: 132px; height: 132px; object-fit: contain; margin: 0 0 42px; }
.security-note { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 16px; padding: 7px 11px; border-radius: 999px; background: #e9f8f3; color: var(--green-dark); font-size: 11px; font-weight: 650; }
.security-note span { color: var(--green-bright); font-size: 9px; }
.login-card h1 { margin-bottom: 12px; font-size: clamp(34px, 4vw, 48px); line-height: 1.06; letter-spacing: -1.6px; }
.login-card > .muted { max-width: 370px; font-size: 14px; }
.login-card form { margin-top: 34px; }
.login-card form button { width: 100%; margin-top: 22px; padding: 14px 18px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0, 128, 105, .2); }
#login-error { min-height: 20px; margin-top: 14px; color: var(--danger); font-size: 12px; }
.login-art { position: relative; display: grid; place-items: center; overflow: hidden; min-height: 100vh; background: linear-gradient(145deg, #075e54 0%, #008069 58%, #10a481 100%); }
.login-art::before, .login-art::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; }
.login-art::before { width: 660px; height: 660px; right: -210px; top: -190px; }
.login-art::after { width: 420px; height: 420px; left: -150px; bottom: -145px; }
.art-glow { position: absolute; width: 520px; height: 520px; border-radius: 50%; background: rgba(37, 211, 102, .22); filter: blur(40px); }
.preview-window { position: relative; width: min(72%, 590px); aspect-ratio: 1.04; border: 1px solid rgba(255,255,255,.42); border-radius: 28px; background: rgba(255,255,255,.96); box-shadow: 0 36px 90px rgba(0, 40, 34, .4); transform: rotate(-2deg); overflow: hidden; }
.preview-bar { height: 72px; display: flex; align-items: center; gap: 8px; padding: 0 22px; background: #f0f2f5; border-bottom: 1px solid var(--border); }
.preview-bar span { width: 38px; height: 38px; border-radius: 50%; background: #b8d9d0; margin-right: auto; }
.preview-bar i { width: 7px; height: 7px; border-radius: 50%; background: #8696a0; }
.preview-chat { height: calc(100% - 72px); display: flex; flex-direction: column; gap: 18px; padding: 42px 34px; background-color: var(--chat-bg); background-image: radial-gradient(rgba(17,27,33,.045) 1px, transparent 1px); background-size: 17px 17px; }
.preview-bubble { width: 48%; height: 56px; border-radius: 5px 14px 14px 14px; background: #fff; box-shadow: 0 1px 1px rgba(11,20,26,.13); }
.preview-bubble.wide { width: 68%; }
.preview-bubble.short { width: 34%; }
.outgoing-preview { align-self: flex-end; background: var(--green-soft); border-radius: 14px 5px 14px 14px; }

/* Header */
.app-header { height: 76px; display: flex; align-items: center; gap: 28px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.header-brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; min-width: 170px; }
.header-brand img { width: 52px; height: 52px; object-fit: contain; }
.header-brand span { padding-left: 11px; border-left: 1px solid var(--border); color: var(--green); font-size: 13px; font-weight: 750; letter-spacing: .4px; }
nav { display: flex; align-self: stretch; gap: 2px; flex: 1; }
.nav { position: relative; border-radius: 0; background: transparent; color: var(--muted); font-size: 13px; padding: 0 17px; }
.nav:hover { background: #f7f9f9; color: var(--text); }
.nav.active { background: transparent; color: var(--green); }
.nav.active::after { content: ""; position: absolute; height: 3px; left: 15px; right: 15px; bottom: 0; border-radius: 3px 3px 0 0; background: var(--green); }
.header-actions { display: flex; align-items: center; gap: 13px; }
.header-link { color: var(--muted); font-size: 12px; text-decoration: none; }
.header-link:hover { color: var(--green); }
.icon-button { width: 39px; height: 39px; display: grid; place-items: center; padding: 0; border-radius: 50%; background: var(--surface-soft); color: var(--muted); font-size: 20px; }
.icon-button:hover { background: #e5e9eb; color: var(--green); }

/* Inbox columns */
.layout { height: calc(100vh - 76px); display: grid; grid-template-columns: 340px minmax(390px, 1fr) 300px; background: var(--surface); }
.chat-list { min-height: 0; display: flex; flex-direction: column; padding: 24px 0 12px; border-right: 1px solid var(--border); background: var(--surface); }
.list-heading { padding: 0 22px; }
.list-heading h1 { margin-bottom: 17px; }
.count { display: inline-grid; place-items: center; min-width: 25px; height: 25px; padding: 0 7px; border-radius: 14px; background: #e7f5f1; color: var(--green); font-size: 11px; vertical-align: middle; }
.search-wrap { position: relative; margin: 0 16px; }
.search-wrap span { position: absolute; left: 14px; top: 8px; color: var(--muted); font-size: 20px; transform: rotate(-18deg); pointer-events: none; }
.search-wrap input { height: 40px; padding-left: 42px; border: 0; border-radius: 9px; background: var(--surface-soft); font-size: 12px; }
.filters { display: flex; gap: 7px; padding: 13px 16px 10px; border-bottom: 1px solid var(--border); }
.chip { padding: 7px 11px; border: 1px solid var(--border); border-radius: 16px; background: #fff; color: var(--muted); font-size: 11px; font-weight: 550; }
.chip:hover { background: #f5f7f8; color: var(--green); }
.chip.selected { border-color: #d1eee5; background: #e7f5f1; color: var(--green); }
#chats { flex: 1; overflow: auto; }
.chat { width: 100%; display: block; padding: 13px 17px; margin: 0; border-radius: 0; border-bottom: 1px solid #f3f5f6; background: #fff; color: var(--text); text-align: left; }
.chat:hover { background: #f5f7f8; }
.chat.selected { background: #f0f2f5; }
.chat-top { display: flex; align-items: center; gap: 12px; }
.avatar, .heading-avatar { display: grid; place-items: center; flex-shrink: 0; border-radius: 50%; background: linear-gradient(145deg, #c7e8df, #8dc8b8); color: #075e54; font-weight: 700; }
.avatar { width: 45px; height: 45px; font-size: 16px; }
.chat-name { flex: 1; overflow: hidden; color: var(--text); font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.badge { min-width: 20px; padding: 3px 6px; border-radius: 11px; background: var(--green-bright); color: #053d35; font-size: 10px; text-align: center; }
.preview { margin: -10px 0 0 57px; overflow: hidden; color: var(--muted); font-size: 11px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.attention { margin: 6px 0 0 57px; color: #bc6c25; font-size: 10px; }
.list-footer { display: flex; justify-content: space-between; padding: 12px 17px 0; border-top: 1px solid var(--border); font-size: 10px; }

/* Conversation */
.conversation { min-width: 0; min-height: 0; background-color: var(--chat-bg); background-image: radial-gradient(rgba(17,27,33,.035) 1px, transparent 1px); background-size: 18px 18px; }
.empty-state { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; background: #f7f9fa; text-align: center; }
.empty-state::after { content: ""; width: 58px; height: 3px; margin-top: 28px; border-radius: 2px; background: var(--green-bright); }
.empty-state p { max-width: 320px; color: var(--muted); font-size: 13px; }
.empty-icon { display: grid; place-items: center; width: 82px; height: 82px; margin-bottom: 24px; border-radius: 50%; background: #e2f3ef; font-size: 34px; }
#chat-content { height: 100%; display: flex; flex-direction: column; }
.conversation-heading { min-height: 73px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 20px; border-bottom: 1px solid #dfe4e7; background: var(--surface-soft); }
.conversation-person { min-width: 0; display: flex; align-items: center; gap: 12px; }
.heading-avatar { width: 43px; height: 43px; font-size: 15px; }
.conversation-heading h2 { overflow: hidden; margin-bottom: 2px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-heading p { margin: 0; font-size: 11px; }
.handling-control { display: flex; align-items: center; gap: 11px; flex-shrink: 0; }
.handling-status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 650; white-space: nowrap; }
.handling-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #f1a33c; box-shadow: 0 0 0 3px rgba(241,163,60,.15); }
.handling-status.ai { color: var(--green); }
.handling-status.ai::before { background: var(--green-bright); box-shadow: 0 0 0 3px rgba(37,211,102,.17); }
#takeover { padding: 8px 12px; border-color: #cbd3d7; background: #fff; }
#messages { flex: 1; display: flex; flex-direction: column; gap: 8px; overflow: auto; padding: 24px 7%; }
.message { max-width: min(76%, 650px); align-self: flex-start; }
.message.outgoing { align-self: flex-end; }
.bubble { position: relative; padding: 8px 11px; border-radius: 4px 10px 10px 10px; background: #fff; box-shadow: 0 1px 1px rgba(11,20,26,.14); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.outgoing .bubble { border-radius: 10px 4px 10px 10px; background: var(--green-soft); }
.message-meta { margin-top: 4px; color: #76858d; font-size: 9px; }
.outgoing .message-meta { text-align: right; }
.message-error { margin-top: 5px; color: var(--danger); font-size: 10px; }
.message-actions { display: flex; gap: 5px; margin-top: 7px; }
.message-actions button { padding: 6px 9px; font-size: 10px; }
.attachment { display: block; margin-top: 8px; font-size: 11px; font-weight: 650; text-decoration: none; }
#reply-form { padding: 10px 16px 12px; border-top: 1px solid #dfe4e7; background: var(--surface-soft); }
#window-note { margin: 0 5px 7px; font-size: 10px; }
.composer { display: flex; align-items: flex-end; gap: 9px; }
.composer textarea { min-height: 43px; max-height: 130px; padding: 12px 14px; border: 0; border-radius: 11px; background: #fff; font-size: 13px; resize: none; }
.composer button { width: 43px; height: 43px; display: grid; place-items: center; flex: 0 0 43px; padding: 0; border-radius: 50%; font-size: 17px; }
.composer-footer { margin: 6px 5px 0; }
.composer-footer span { color: var(--muted); font-size: 9px; }

/* Buyer panel and knowledge */
.buyer-panel { overflow: auto; padding: 27px 22px; border-left: 1px solid var(--border); background: var(--surface); }
.buyer-panel label { font-size: 11px; }
.buyer-panel input, .buyer-panel select, .buyer-panel textarea { border-color: #dfe4e7; background: #f9fbfb; font-size: 12px; }
.buyer-panel form button { width: 100%; }
.task-heading { margin-top: 30px; padding-top: 24px; border-top: 1px solid var(--border); }
.task { margin-bottom: 10px; padding: 12px; border: 1px solid #f0dfbd; border-radius: 9px; background: #fff8e9; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.task button { margin-top: 8px; padding: 6px 10px; font-size: 10px; }
.empty { padding: 30px 8px; color: var(--muted); font-size: 12px; text-align: center; }
.property { max-width: 970px; margin: 35px auto; padding: 42px; border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.property textarea { font-size: 13px; line-height: 1.6; }
.property button { margin-top: 15px; }
.property h3 { margin-top: 35px; }
#versions { display: flex; flex-wrap: wrap; gap: 10px; }
#old-facts { padding: 20px; border: 1px solid var(--border); background: #f8fafb; font-size: 12px; white-space: pre-wrap; }
#notice { position: fixed; z-index: 10; top: 88px; left: 50%; transform: translateX(-50%); padding: 11px 20px; border-radius: 9px; background: #111b21; box-shadow: 0 8px 28px rgba(0,0,0,.24); color: #fff; font-size: 12px; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 290px 1fr; height: auto; }
  .buyer-panel { grid-column: 1 / -1; border-top: 1px solid var(--border); border-left: 0; }
  .chat-list, .conversation { height: calc(100vh - 76px); }
  .header-brand { min-width: auto; }
  .header-link { display: none; }
}

@media (max-width: 760px) {
  .login { grid-template-columns: 1fr; }
  .login-panel { min-height: 100vh; padding: 32px 24px; }
  .login-logo { width: 108px; height: 108px; margin-bottom: 28px; }
  .login-art { display: none; }
  .app-header { height: auto; min-height: 70px; flex-wrap: wrap; gap: 8px; padding: 9px 13px 0; }
  .header-brand { flex: 1; }
  .header-brand img { width: 46px; height: 46px; }
  .header-actions { margin-left: auto; }
  nav { order: 3; width: 100%; height: 43px; flex-basis: 100%; }
  .nav { flex: 1; padding: 0 8px; }
  .layout { display: block; }
  .chat-list { height: 310px; }
  .conversation { height: 650px; }
  .conversation-heading { align-items: flex-start; padding: 11px 13px; }
  .handling-control { align-items: flex-end; flex-direction: column; gap: 5px; }
  #messages { padding: 18px 12px; }
  .message { max-width: 88%; }
  .buyer-panel { padding: 28px 20px; }
  .property { margin: 0; padding: 28px 20px; border-radius: 0; }
}
