:root {
  --green: #0c564c;
  --green-dark: #073f38;
  --mint: #e6f3ef;
  --gold: #c58c2a;
  --ink: #173238;
  --muted: #6d7f82;
  --line: #dce7e5;
  --paper: #fbfdfc;
  --white: #ffffff;
  --danger: #a83b3b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #f1f6f5;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top right, #d7f0e8, transparent 44%), var(--paper); }
.login-card { width: min(100%, 430px); padding: 32px; border: 1px solid #d9e3df; border-radius: 22px; background: #fff; box-shadow: 0 18px 55px rgba(17, 58, 50, .14); display: grid; gap: 16px; }
.login-card h1 { margin: 0; }
.login-card p { margin: 0; color: #536b66; line-height: 1.55; }
.login-card label { display: grid; gap: 7px; font-weight: 700; color: #173f37; }
.login-card input { border: 1px solid #bccdc8; border-radius: 10px; min-height: 44px; padding: 0 12px; font: inherit; }
.form-error { min-height: 1.25em; color: #af3131 !important; font-weight: 700; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.app-shell { max-width: 1500px; margin: 0 auto; padding: 28px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 18px; }
.eyebrow { margin: 0 0 5px; font-size: .7rem; letter-spacing: .12em; color: var(--green); font-weight: 800; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.6rem, 3vw, 2.25rem); }
h2 { margin-bottom: 0; font-size: 1.05rem; }
.notice { background: #fff8e8; color: #70520d; border: 1px solid #ead49e; border-radius: 12px; padding: 12px 15px; font-size: .9rem; margin-bottom: 18px; }
.automation-toggle { display: flex; align-items: center; gap: 12px; background: var(--white); border: 1px solid var(--line); padding: 10px 12px; border-radius: 12px; white-space: nowrap; }
.automation-toggle strong, .automation-toggle small { display: block; }
.automation-toggle small { color: var(--muted); font-size: .74rem; margin-top: 2px; }
.automation-toggle input { position: absolute; opacity: 0; }
.switch { width: 42px; height: 24px; background: #bdc9c7; border-radius: 30px; position: relative; transition: .2s; }
.switch::after { content: ""; height: 18px; width: 18px; background: white; border-radius: 50%; position: absolute; top: 3px; left: 3px; transition: .2s; box-shadow: 0 1px 3px #0003; }
.automation-toggle input:checked + .switch { background: var(--green); }
.automation-toggle input:checked + .switch::after { transform: translateX(18px); }
.dashboard { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.dashboard article { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 15px; }
.dashboard span { font-size: .78rem; color: var(--muted); display: block; margin-bottom: 8px; }
.dashboard strong { font-size: 1.35rem; color: var(--green-dark); }
.workspace { min-height: 610px; display: grid; grid-template-columns: minmax(230px, .8fr) minmax(380px, 1.8fr) minmax(230px, .8fr); background: var(--white); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.contacts-panel, .detail-panel { padding: 18px; background: #fbfdfc; }
.contacts-panel { border-right: 1px solid var(--line); }
.detail-panel { border-left: 1px solid var(--line); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 15px; }
.panel-heading.compact { display: block; }
.icon-button { border: 0; border-radius: 50%; width: 34px; height: 34px; font-size: 1.4rem; line-height: 1; background: var(--green); color: var(--white); }
.search-field { display: flex; gap: 6px; align-items: center; border: 1px solid var(--line); padding: 9px 10px; border-radius: 9px; color: var(--muted); }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; min-width: 0; }
.lead-list { margin-top: 13px; display: grid; gap: 7px; }
.lead-item { width: 100%; text-align: left; padding: 10px; display: flex; gap: 9px; background: transparent; border: 1px solid transparent; border-radius: 10px; color: var(--ink); }
.lead-item:hover, .lead-item.active { background: var(--mint); border-color: #c8e1da; }
.avatar { flex: 0 0 auto; width: 36px; height: 36px; display: grid; place-items: center; background: #d6e7e2; color: var(--green-dark); border-radius: 50%; font-weight: 800; }
.lead-item strong, .lead-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-item small { font-size: .73rem; color: var(--muted); margin-top: 3px; }
.chat-panel { position: relative; min-height: 610px; display: flex; flex-direction: column; background: #f5f9f8; }
.empty-state { display: grid; place-content: center; text-align: center; min-height: 610px; padding: 32px; color: var(--muted); }
.empty-state h2 { color: var(--ink); font-size: 1.3rem; margin: 14px 0 7px; }
.empty-state p { max-width: 330px; line-height: 1.5; }
.empty-icon { color: var(--gold); font-size: 2rem; }
.chat-header { display: flex; align-items: center; gap: 10px; min-height: 76px; padding: 14px 18px; background: var(--white); border-bottom: 1px solid var(--line); }
.chat-header p { margin: 3px 0 0; color: var(--muted); font-size: .78rem; }
.simulation-pill { margin-left: auto; font-size: .66rem; font-weight: 800; letter-spacing: .06em; color: var(--green); background: var(--mint); padding: 6px 8px; border-radius: 20px; }
.messages { flex: 1; display: flex; flex-direction: column; gap: 11px; padding: 20px; overflow-y: auto; max-height: 470px; }
.message { width: fit-content; max-width: 84%; padding: 10px 12px; border-radius: 12px; font-size: .92rem; line-height: 1.42; box-shadow: 0 1px 1px #0000000c; }
.message.bot { align-self: flex-start; background: var(--white); border-bottom-left-radius: 3px; }
.message.customer { align-self: flex-end; background: #d8f0e7; border-bottom-right-radius: 3px; }
.message.system { align-self: center; max-width: 95%; background: transparent; color: var(--muted); font-size: .73rem; box-shadow: none; text-align: center; }
.message strong { color: var(--green-dark); }
.file-card { margin-top: 9px; display: flex; align-items: center; gap: 9px; padding: 8px; background: #f3f7f6; border-radius: 8px; font-size: .82rem; }
.file-icon { background: #cc514a; border-radius: 5px; color: white; padding: 4px; font-size: .62rem; font-weight: 900; }
.file-card small { color: var(--muted); display: block; margin-top: 1px; font-size: .67rem; }
.payment-card { margin-top: 9px; border: 1px dashed #b7c7c3; padding: 10px; border-radius: 8px; background: #fafdfc; text-align: center; }
.fake-qr { width: 72px; height: 72px; margin: 4px auto 8px; background: repeating-conic-gradient(#1e3734 0 25%, #fff 0 50%) 50% / 14px 14px; image-rendering: pixelated; }
.payment-card small { color: var(--muted); }
.action-tray { min-height: 84px; background: var(--white); border-top: 1px solid var(--line); padding: 13px 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.action-copy { color: var(--muted); font-size: .82rem; width: 100%; margin-bottom: 2px; }
.primary-button, .secondary-button, .choice-button { border-radius: 9px; padding: 10px 13px; border: 1px solid transparent; font-weight: 700; font-size: .86rem; }
.primary-button { background: var(--green); color: var(--white); }
.primary-button:hover { background: var(--green-dark); }
.secondary-button, .choice-button { background: var(--white); color: var(--green-dark); border-color: #bdcfca; }
.choice-button:hover { border-color: var(--green); background: var(--mint); }
.choice-button.danger { color: var(--danger); }
.hidden { display: none; }
.lead-detail { font-size: .86rem; line-height: 1.5; }
.empty-detail { color: var(--muted); }
.detail-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.detail-row span { display: block; color: var(--muted); font-size: .73rem; margin-bottom: 2px; }
.status-tag { display: inline-block; font-size: .72rem; color: var(--green-dark); background: var(--mint); border-radius: 20px; padding: 4px 7px; font-weight: 700; }
.history { margin: 16px 0 0; padding-left: 18px; color: var(--muted); font-size: .78rem; }
.history li { margin: 6px 0; }
.future-integration { margin-top: 24px; padding: 13px; background: #f4f8f7; border-radius: 11px; }
.future-integration h3 { font-size: .83rem; margin-bottom: 9px; color: var(--green-dark); }
.future-integration ul { padding-left: 17px; margin: 0; font-size: .75rem; color: var(--muted); line-height: 1.55; }
dialog { border: 0; border-radius: 16px; max-width: min(440px, calc(100vw - 32px)); padding: 0; box-shadow: 0 20px 60px #132c2847; }
dialog::backdrop { background: #0f2723aa; }
dialog form { position: relative; padding: 26px; display: grid; gap: 15px; }
dialog h2 { font-size: 1.35rem; }
.dialog-copy { margin: -8px 0 2px; color: var(--muted); font-size: .88rem; }
dialog label { display: grid; gap: 6px; font-size: .82rem; font-weight: 700; color: var(--ink); }
dialog input, dialog select { padding: 10px; border: 1px solid #bdcfca; border-radius: 8px; outline-color: var(--green); font-weight: 400; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 5px; }
.dialog-close { position: absolute; right: 10px; top: 8px; border: 0; background: transparent; font-size: 1.4rem; color: var(--muted); }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 250px 1fr; }
  .detail-panel { display: none; }
}
@media (max-width: 720px) {
  .app-shell { padding: 12px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .dashboard { grid-template-columns: repeat(2, 1fr); }
  .workspace { display: block; min-height: 0; border-radius: 14px; }
  .contacts-panel { border-right: 0; border-bottom: 1px solid var(--line); max-height: 250px; overflow: auto; }
  .chat-panel, .empty-state { min-height: 520px; }
  .messages { max-height: 390px; }
  .message { max-width: 92%; }
}
