:root {
  --ink: #17231d;
  --muted: #66736d;
  --forest: #153f35;
  --forest-2: #205748;
  --mint: #dcece3;
  --cream: #f5f2eb;
  --paper: #fffdfa;
  --line: #dedbd2;
  --coral: #db6742;
  --gold: #d7ad56;
  --blue: #4a7993;
  --danger: #b5473d;
  --shadow: 0 18px 55px rgba(23, 35, 29, .10);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--cream); }
body { min-height: 100vh; margin: 0; color: var(--ink); background: var(--cream); font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 7px; color: #bbd6c9; font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.eyebrow.ink { color: #7b877f; }
.eyebrow.light { color: #b8d5c7; }

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1.15fr) minmax(420px, .85fr); }
.auth-story { position: relative; min-height: 100vh; overflow: hidden; padding: 42px 7vw; color: white; background: radial-gradient(circle at 72% 30%, rgba(94, 160, 126, .28), transparent 30%), linear-gradient(135deg, #0f352d 0%, #194c3f 62%, #123229 100%); }
.auth-story::after { content: ""; position: absolute; inset: 0; opacity: .16; background-image: linear-gradient(rgba(255,255,255,.12) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.12) 1px, transparent 1px); background-size: 60px 60px; mask-image: linear-gradient(to bottom, transparent, #000 40%, transparent); }
.brand { position: relative; z-index: 2; display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; letter-spacing: .18em; }
.brand-mark { display: grid; place-items: center; width: 39px; height: 39px; border: 1px solid currentColor; border-radius: 50%; font: 700 21px/1 Georgia, serif; letter-spacing: 0; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; }
.brand small { margin-top: 2px; opacity: .62; font-size: 8px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.story-copy { position: relative; z-index: 2; max-width: 700px; margin-top: 25vh; }
.story-copy h1 { max-width: 650px; margin: 0 0 24px; font: 500 clamp(42px, 5.2vw, 76px)/1.02 Georgia, "Times New Roman", serif; letter-spacing: -.035em; }
.story-copy > p:last-child { max-width: 540px; color: #cbded5; font-size: 17px; }
.story-orbit { position: absolute; right: -170px; bottom: -220px; width: 520px; height: 520px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; }
.story-orbit span { position: absolute; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; }
.story-orbit span:nth-child(1) { inset: 60px; }
.story-orbit span:nth-child(2) { inset: 130px; }
.story-orbit span:nth-child(3) { inset: 210px; background: var(--coral); border: 0; }
.auth-panel { display: grid; place-items: center; min-height: 100vh; padding: 38px; background: var(--paper); }
.auth-form { width: min(390px, 100%); }
.auth-form h2, .invite-dialog h2 { margin: 0; font: 500 36px/1.12 Georgia, serif; letter-spacing: -.02em; }
.form-intro { margin: 12px 0 30px; color: var(--muted); }
label { display: block; color: #445049; font-size: 12px; font-weight: 700; }
input, select { width: 100%; margin-top: 7px; padding: 12px 13px; color: var(--ink); background: #fff; border: 1px solid #d6d8d2; border-radius: 10px; outline: none; transition: border .2s, box-shadow .2s; }
input:focus, select:focus { border-color: var(--forest-2); box-shadow: 0 0 0 3px rgba(32, 87, 72, .12); }
.auth-form label + label, .invite-dialog label + label { margin-top: 17px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 12px; min-height: 42px; padding: 10px 16px; border: 1px solid transparent; border-radius: 10px; font-weight: 750; }
.button.primary { color: #fff; background: var(--coral); box-shadow: 0 8px 22px rgba(219, 103, 66, .22); }
.button.primary:hover { background: #c85836; }
.button.secondary { color: var(--forest); background: white; border-color: var(--line); }
.button.wide { width: 100%; margin-top: 24px; }
.text-button { padding: 10px; color: var(--forest-2); background: transparent; border: 0; font-weight: 700; }
.text-button.compact { padding: 5px; font-size: 12px; }
.auth-form > .text-button { display: block; margin: 9px auto 0; }
.form-error { min-height: 20px; margin: 8px 0 -12px; color: var(--danger); font-size: 12px; }
.form-message { padding: 11px 13px; color: var(--forest); background: var(--mint); border-radius: 9px; }
.mobile-brand { display: none; }

.app-shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; z-index: 20; display: flex; flex-direction: column; height: 100vh; padding: 28px 20px 20px; color: white; background: var(--forest); }
.sidebar .brand { margin: 0 10px 44px; }
.main-nav { display: grid; gap: 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 13px; color: #c0d3ca; text-align: left; background: transparent; border: 0; border-radius: 10px; font-weight: 650; }
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.11); }
.nav-item.active::after { content: ""; width: 5px; height: 5px; margin-left: auto; background: var(--coral); border-radius: 50%; }
.nav-icon { display: inline-grid; place-items: center; width: 20px; color: #a9c7b8; font-size: 18px; }
.sidebar-foot { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 13px; background: rgba(0,0,0,.12); border-radius: 11px; }
.sidebar-foot strong, .sidebar-foot small { display: block; }
.sidebar-foot strong { font-size: 11px; }
.sidebar-foot small { color: #adc7bb; font-size: 9px; }
.status-dot { width: 8px; height: 8px; background: #6fc88d; border: 2px solid rgba(255,255,255,.25); border-radius: 50%; box-shadow: 0 0 0 4px rgba(111,200,141,.11); }
.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; min-height: 86px; padding: 17px clamp(20px, 3vw, 42px); background: rgba(245,242,235,.9); border-bottom: 1px solid rgba(222,219,210,.8); backdrop-filter: blur(16px); }
.topbar h1 { margin: 0; font: 500 28px/1 Georgia, serif; }
.topbar-actions { display: flex; align-items: center; gap: 18px; margin-left: auto; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; color: var(--forest); background: rgba(255,255,255,.7); border: 1px solid var(--line); border-radius: 50%; font-size: 17px; }
.menu-button { display: none; margin-right: 12px; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-menu strong, .user-menu small { display: block; }
.user-menu strong { font-size: 12px; }
.user-menu small { color: var(--muted); font-size: 10px; text-transform: capitalize; }
.avatar { display: grid; flex: 0 0 auto; place-items: center; width: 36px; height: 36px; color: #fff; background: var(--forest-2); border-radius: 50%; font-weight: 800; }
.content { padding: 32px clamp(20px, 3vw, 42px) 60px; }
.view { display: none; }
.active-view { display: block; animation: enter .25s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(4px); } }

.hero-card { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 30px; overflow: hidden; min-height: 190px; padding: 34px clamp(28px, 4vw, 52px); color: white; background: radial-gradient(circle at 80% 30%, #2f6b57, transparent 32%), var(--forest); border-radius: 22px; box-shadow: var(--shadow); }
.hero-card::after { content: ""; position: absolute; right: 22%; bottom: -110px; width: 250px; height: 250px; border: 1px solid rgba(255,255,255,.13); border-radius: 50%; }
.hero-card h2 { position: relative; z-index: 1; max-width: 620px; margin: 0; font: 500 clamp(26px, 3vw, 42px)/1.1 Georgia, serif; }
.hero-card p:last-child { max-width: 600px; margin-bottom: 0; color: #c3d8ce; }
.hero-metric { position: relative; z-index: 1; min-width: 170px; padding-left: 30px; border-left: 1px solid rgba(255,255,255,.2); }
.hero-metric span, .hero-metric small { display: block; }
.hero-metric span { font: 500 58px/1 Georgia, serif; }
.hero-metric small { max-width: 120px; margin-top: 7px; color: #c3d8ce; line-height: 1.25; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 20px 0; }
.metric-card { min-height: 126px; padding: 21px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.metric-card .metric-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.metric-card .metric-icon { display: grid; place-items: center; width: 29px; height: 29px; color: var(--forest-2); background: var(--mint); border-radius: 8px; font-size: 15px; }
.metric-card strong { display: block; margin: 15px 0 3px; font: 500 34px/1 Georgia, serif; }
.metric-card small { color: var(--muted); }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.panel { min-width: 0; padding: 24px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 7px 24px rgba(23,35,29,.035); }
.panel-wide { grid-column: 1 / -1; }
.panel-head, .section-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.panel-head { margin-bottom: 22px; }
.panel-head h3 { margin: 0; font: 500 22px/1.2 Georgia, serif; }
.section-toolbar { margin-bottom: 22px; }
.section-toolbar h2 { margin: 0 0 5px; font: 500 30px/1.1 Georgia, serif; }
.section-toolbar p { margin: 0; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 15px; color: var(--muted); font-size: 10px; }
.legend span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; }
.legend-msg::before { background: var(--blue); }.legend-rec::before { background: var(--gold); }.legend-ok::before { background: var(--coral); }
.activity-chart { display: grid; grid-template-columns: repeat(14, minmax(18px, 1fr)); align-items: end; gap: 8px; min-height: 190px; padding-top: 14px; border-bottom: 1px solid var(--line); }
.chart-day { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 175px; }
.chart-bars { display: flex; align-items: end; gap: 2px; height: 145px; }
.chart-bar { width: clamp(4px, .65vw, 9px); min-height: 2px; border-radius: 4px 4px 0 0; }
.chart-bar.msg { background: var(--blue); }.chart-bar.rec { background: var(--gold); }.chart-bar.ok { background: var(--coral); }
.chart-day small { margin-top: 7px; color: var(--muted); font-size: 9px; }
.bar-list { display: grid; gap: 14px; }
.bar-row-head { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 11px; }
.bar-row-head span:last-child { color: var(--muted); }
.bar-track { height: 7px; overflow: hidden; background: #eceae4; border-radius: 8px; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--forest-2), #64a184); border-radius: inherit; }
.bar-fill.negative { margin-left: auto; background: var(--coral); }
.queue-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.queue-chip { padding: 14px; background: var(--cream); border-radius: 11px; }
.queue-chip strong, .queue-chip small { display: block; }.queue-chip strong { font: 500 25px/1 Georgia, serif; }.queue-chip small { margin-top: 5px; color: var(--muted); text-transform: capitalize; }

.search-field { display: flex; align-items: center; gap: 8px; min-width: 250px; padding: 0 10px; background: white; border: 1px solid var(--line); border-radius: 10px; }
.search-field.full { min-width: 0; }
.search-field input { margin: 0; padding: 10px 4px; background: transparent; border: 0; box-shadow: none; }
.toggle { display: flex; align-items: center; gap: 9px; font-size: 12px; }
.toggle input { position: absolute; opacity: 0; width: 1px; }
.toggle span { position: relative; width: 36px; height: 20px; background: #d8d8d2; border-radius: 20px; transition: .2s; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; background: white; border-radius: 50%; transition: .2s; }
.toggle input:checked + span { background: var(--forest-2); }.toggle input:checked + span::after { transform: translateX(16px); }
.table-panel { padding: 0; overflow: hidden; }
.table-panel > .panel-head { padding: 22px 24px 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 13px 17px; color: #78837d; text-align: left; background: #f0eee8; border-bottom: 1px solid var(--line); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }
td { padding: 15px 17px; border-bottom: 1px solid #ebe8e1; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfaf6; }
.cell-main { display: block; font-weight: 750; }.cell-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; color: #59635e; background: #ecece7; border-radius: 99px; font-size: 9px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
.badge.ok { color: #276343; background: #dbefe2; }.badge.warn { color: #8a6320; background: #f6e9c8; }.badge.bad { color: #8c3d36; background: #f5dbd7; }.badge.info { color: #315e75; background: #dcebf2; }
.row-button { padding: 6px 9px; color: var(--forest-2); background: transparent; border: 1px solid var(--line); border-radius: 8px; font-size: 10px; font-weight: 750; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; }
.empty-state { padding: 34px; color: var(--muted); text-align: center; }
.notice { margin-bottom: 16px; padding: 12px 15px; color: var(--forest); background: var(--mint); border: 1px solid #c9dfd2; border-radius: 11px; }
.notice.warning { color: #77531c; background: #f8eccf; border-color: #ead7aa; }

.conversation-layout { display: grid; grid-template-columns: 310px minmax(0, 1fr); min-height: 610px; padding: 0; overflow: hidden; }
.contact-column { padding: 17px; border-right: 1px solid var(--line); }
.contact-list { max-height: 550px; margin-top: 12px; overflow-y: auto; }
.contact { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px; color: var(--ink); text-align: left; background: transparent; border: 0; border-radius: 10px; }
.contact:hover, .contact.active { background: var(--mint); }
.contact .avatar { width: 32px; height: 32px; font-size: 11px; }
.contact strong, .contact small { display: block; }.contact strong { font-size: 11px; }.contact small { color: var(--muted); font-size: 9px; }
.thread-column { display: flex; flex-direction: column; min-width: 0; background: #eeece5; }
.thread-head { display: flex; align-items: center; gap: 11px; padding: 16px 20px; background: var(--paper); border-bottom: 1px solid var(--line); }
.thread-head strong, .thread-head small { display: block; }.thread-head small { color: var(--muted); font-size: 10px; }
.thread { display: flex; flex: 1; flex-direction: column; gap: 9px; max-height: 550px; padding: 24px; overflow-y: auto; }
.bubble { max-width: min(72%, 620px); padding: 10px 13px; white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 13px; box-shadow: 0 2px 7px rgba(23,35,29,.06); }
.bubble.user { align-self: flex-end; color: white; background: var(--forest-2); border-bottom-right-radius: 4px; }
.bubble.assistant { align-self: flex-start; background: white; border-bottom-left-radius: 4px; }
.bubble time { display: block; margin-top: 5px; opacity: .62; font-size: 8px; text-align: right; }

dialog { max-width: calc(100vw - 30px); padding: 0; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(13,35,29,.53); backdrop-filter: blur(3px); }
.detail-dialog { width: min(820px, calc(100vw - 30px)); max-height: 88vh; overflow: auto; }
.invite-dialog { width: min(480px, calc(100vw - 30px)); padding: 30px; }
.dialog-close { position: sticky; z-index: 2; top: 12px; float: right; display: grid; place-items: center; width: 32px; height: 32px; margin: 12px 12px -44px 0; color: var(--muted); background: #f1efe9; border: 0; border-radius: 50%; font-size: 19px; }
#detail-content { padding: 34px; }
.detail-header { padding-right: 40px; }.detail-header h2 { margin: 0; font: 500 32px/1.1 Georgia, serif; }.detail-header p { color: var(--muted); }
.detail-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 22px 0; }
.detail-stat { padding: 13px; background: var(--cream); border-radius: 10px; }.detail-stat strong, .detail-stat small { display: block; }.detail-stat strong { font: 500 23px/1 Georgia, serif; }.detail-stat small { margin-top: 5px; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.vector-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }.vector-card { padding: 15px; background: #f5f3ed; border-radius: 11px; }
.vector-card h4 { margin: 0 0 12px; }.vector-row { margin-top: 9px; }
.vector-axis { position: relative; height: 7px; overflow: hidden; background: #e3e1da; border-radius: 8px; }.vector-axis::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: #bdbbb4; }
.vector-value { position: absolute; top: 0; bottom: 0; background: var(--forest-2); border-radius: 8px; }.vector-value.neg { background: var(--coral); }
.detail-section { margin-top: 24px; }.detail-section h3 { font: 500 21px/1 Georgia, serif; }.json-block { max-height: 220px; overflow: auto; padding: 14px; color: #d9eee4; background: #15372f; border-radius: 10px; font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.invite-result { text-align: center; }.invite-result .success-ring { display: grid; place-items: center; width: 54px; height: 54px; margin: 5px auto 18px; color: white; background: var(--forest-2); border-radius: 50%; font-size: 23px; }.invite-link { display: flex; gap: 7px; margin-top: 15px; }.invite-link input { margin: 0; font-size: 10px; }
.toast { position: fixed; z-index: 100; right: 24px; bottom: 24px; max-width: 360px; padding: 12px 16px; color: white; background: var(--forest); border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s; }.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .conversation-layout { grid-template-columns: 260px minmax(0, 1fr); }
}
@media (max-width: 780px) {
  .auth-shell { display: block; }.auth-story { display: none; }.auth-panel { padding: 24px; }.mobile-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 55px; color: var(--forest); font-weight: 800; letter-spacing: .15em; }
  .app-shell { display: block; }.sidebar { position: fixed; left: 0; transform: translateX(-100%); width: 236px; transition: .2s; }.sidebar.open { transform: translateX(0); box-shadow: 20px 0 60px rgba(0,0,0,.25); }.menu-button { display: grid; }
  .topbar { min-height: 76px; }.topbar .eyebrow { display: none; }.topbar h1 { font-size: 23px; }.user-menu > span:last-child, #logout-button { display: none; }
  .content { padding-top: 22px; }.hero-card { align-items: flex-start; flex-direction: column; }.hero-metric { padding: 20px 0 0; border-top: 1px solid rgba(255,255,255,.2); border-left: 0; }
  .dashboard-grid { grid-template-columns: 1fr; }.panel-wide { grid-column: auto; }.section-toolbar { align-items: stretch; flex-direction: column; }.search-field { min-width: 0; }
  .conversation-layout { display: block; }.contact-column { border-right: 0; border-bottom: 1px solid var(--line); }.contact-list { max-height: 190px; }.thread { min-height: 420px; }
}
@media (max-width: 520px) {
  .metric-grid { grid-template-columns: 1fr; }.panel { padding: 18px; }.table-panel { padding: 0; }.legend { display: none; }.activity-chart { gap: 3px; }.chart-day small { transform: rotate(-45deg); }.vector-grid, .detail-stats { grid-template-columns: 1fr; }.topbar-actions { gap: 8px; }.hero-card { padding: 28px 24px; }
}
