/* Taito.ai-derived design tokens: pure monochrome — warm stone surfaces, ink text */
:root {
  --surface: #fafaf9;
  --surface-secondary: #f2f1f0;
  --surface-tertiary: #e5e5e3;
  --ink: #0f0e0d;
  --ink-hover: #33312c;
  --muted: #6e6a65;
  --secondary-fg: #524f49;
  --border: #e5e5e3;
  --radius-sm: .25rem;
  --radius-md: .375rem;
  --radius-lg: .5rem;
  --radius-xl: .75rem;
  --shadow: 0 1px 2px rgb(15 14 13 / .05), 0 4px 16px rgb(15 14 13 / .06);
  --font: "Suisse Intl", "Inter", -apple-system, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface: #0f0e0d;
    --surface-secondary: #1f1d1a;
    --surface-tertiary: #33312c;
    --ink: #fafaf9;
    --ink-hover: #e5e5e3;
    --muted: #8f8b85;
    --secondary-fg: #cccac6;
    --border: #33312c;
    --shadow: 0 1px 2px rgb(0 0 0 / .4);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--ink); text-underline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-md);
  background: var(--ink); color: var(--surface);
  font-weight: 500; letter-spacing: .01em;
  transition: background .15s;
}
.btn:hover { background: var(--ink-hover); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-ghost {
  background: transparent; color: var(--secondary-fg);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-secondary); color: var(--ink); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: var(--radius-sm); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: .03em;
  padding: 2px 8px; border-radius: 999px;
  background: var(--surface-secondary); color: var(--secondary-fg);
  text-transform: uppercase;
}
.chip.strong { background: var(--ink); color: var(--surface); }
.chip.outline { background: transparent; border: 1px solid var(--border); color: var(--muted); }

/* ---------- App layout ---------- */
.app { display: grid; grid-template-columns: 340px 1fr 320px; height: 100vh; overflow: hidden; }
.pane { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.pane + .pane { border-left: 1px solid var(--border); }

/* ---------- List pane ---------- */
.list-pane { background: var(--surface); }
.brand {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 10px; flex-wrap: wrap; gap: 6px;
}
.brand h1 { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.brand h1 span { color: var(--muted); }
.agent-select {
  border: 1px solid var(--border); background: var(--surface-secondary);
  border-radius: var(--radius-md); padding: 5px 8px; font-size: 12.5px;
  max-width: 150px;
}
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding: 4px 16px 12px;
}
.stat {
  background: var(--surface-secondary); border-radius: var(--radius-lg);
  padding: 8px 10px;
}
.stat b { display: block; font-size: 17px; font-weight: 650; letter-spacing: -.02em; }
.stat span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat.alert { outline: 1px solid var(--ink); outline-offset: -1px; }

.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 8px 10px; font-size: 13px; font-weight: 550; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }
.tab .count {
  font-size: 11px; background: var(--surface-tertiary); color: var(--secondary-fg);
  border-radius: 999px; padding: 0 6px; margin-left: 4px;
}
.tab.active .count { background: var(--ink); color: var(--surface); }

.convo-list { flex: 1; overflow-y: auto; }
.convo-item {
  display: block; width: 100%; text-align: left;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.convo-item:hover { background: var(--surface-secondary); }
.convo-item.active { background: var(--surface-secondary); box-shadow: inset 2px 0 0 var(--ink); }
.convo-top { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.convo-name { font-weight: 600; font-size: 13.5px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-time { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.convo-snippet {
  font-size: 12.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 6px;
}
.convo-meta { display: flex; gap: 5px; flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot.negative { background: var(--ink); }
.dot.positive { background: transparent; border: 1.5px solid var(--muted); }
.dot.neutral { background: var(--surface-tertiary); }

/* ---------- Thread pane ---------- */
.thread-pane { background: var(--surface-secondary); }
.thread-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.thread-header .title { flex: 1; min-width: 0; }
.thread-header h2 { font-size: 15px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-header .sub { font-size: 12px; color: var(--muted); }
.thread { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 68%; display: flex; flex-direction: column; gap: 3px; }
.msg .bubble {
  padding: 9px 13px; border-radius: var(--radius-xl);
  background: var(--surface); box-shadow: var(--shadow);
  font-size: 13.5px; white-space: pre-wrap; word-wrap: break-word;
}
.msg .who { font-size: 11px; color: var(--muted); padding: 0 4px; display: flex; gap: 6px; align-items: center; }
.msg.customer { align-self: flex-start; }
.msg.agent, .msg.ai { align-self: flex-end; align-items: flex-end; }
.msg.agent .bubble { background: var(--ink); color: var(--surface); border-bottom-right-radius: var(--radius-sm); }
.msg.ai .bubble {
  background: var(--surface); border: 1px dashed var(--muted);
  box-shadow: none; border-bottom-right-radius: var(--radius-sm);
}
.msg.customer .bubble { border-bottom-left-radius: var(--radius-sm); }
.msg.system { align-self: center; max-width: 90%; }
.msg.system .bubble {
  background: none; box-shadow: none; color: var(--muted);
  font-size: 11.5px; text-align: center; padding: 2px 8px;
}
.msg .translated { font-size: 12px; color: var(--muted); font-style: italic; padding: 0 4px; }

.composer { background: var(--surface); border-top: 1px solid var(--border); padding: 12px 16px; }
.assist-row { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; align-items: center; }
.composer textarea {
  width: 100%; min-height: 64px; resize: vertical;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 10px 12px; background: var(--surface); color: var(--ink);
  outline: none;
}
.composer textarea:focus { border-color: var(--muted); }
.composer-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.suggestion-box {
  background: var(--surface-secondary); border: 1px dashed var(--muted);
  border-radius: var(--radius-lg);
  padding: 10px 12px; margin-bottom: 8px; font-size: 13px;
  display: flex; gap: 10px; align-items: flex-start;
}
.suggestion-box .txt { flex: 1; white-space: pre-wrap; }

.empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); gap: 8px;
}
.empty-state .big { font-size: 40px; }

/* ---------- Context pane ---------- */
.context-pane { background: var(--surface); overflow-y: auto; }
.ctx-section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.ctx-section h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin-bottom: 8px; font-weight: 650;
}
.customer-card { display: flex; gap: 10px; align-items: center; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 650; font-size: 14px; color: var(--surface);
  background: var(--ink);
}
.customer-card .info { min-width: 0; }
.customer-card .name { font-weight: 650; font-size: 14px; }
.customer-card .detail { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kv { display: flex; justify-content: space-between; font-size: 12.5px; padding: 3px 0; gap: 8px; }
.kv .k { color: var(--muted); }
.summary-box {
  background: var(--surface-secondary); border-radius: var(--radius-lg);
  padding: 10px 12px; font-size: 12.5px; color: var(--secondary-fg); white-space: pre-wrap;
}
.order-row { font-size: 12.5px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.order-row:last-child { border-bottom: none; }
.order-row b { font-weight: 600; }
.prev-row { display: block; width: 100%; text-align: left; font-size: 12.5px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.prev-row:hover { color: var(--ink); text-decoration: underline; }
.prev-row:last-child { border-bottom: none; }
.note { background: var(--surface-secondary); border-radius: var(--radius-md); padding: 8px 10px; font-size: 12.5px; margin-bottom: 6px; }
.note .by { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.note-input { display: flex; gap: 6px; margin-top: 8px; }
.note-input input {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 6px 10px; background: var(--surface); outline: none; font-size: 12.5px;
}

.kb-hit { padding: 6px 0; font-size: 12.5px; border-bottom: 1px dashed var(--border); }
.kb-hit b { display: block; font-size: 12px; }
.kb-hit span { color: var(--muted); }

select.mini {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-sm); font-size: 12px; padding: 3px 6px;
}
/* ---------- User box & modal ---------- */
.user-box { display: flex; align-items: center; gap: 6px; min-width: 0; }
.user-box .chip { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: none; }
.user-box .btn-sm { padding: 3px 8px; font-size: 12px; white-space: nowrap; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgb(15 14 13 / .4);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  width: 640px; max-width: calc(100vw - 40px); max-height: 85vh;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 15px; font-weight: 650; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-sub { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; font-weight: 650; }
.users-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.users-table th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 650; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--border);
}
.users-table td { padding: 7px 8px 7px 0; border-bottom: 1px solid var(--border); vertical-align: middle; }
.users-table tr.inactive td { color: var(--muted); }
.users-table .row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.user-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.user-form input, .user-form select {
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 7px 10px; background: var(--surface); outline: none; font-size: 12.5px;
}
.user-form input:focus { border-color: var(--muted); }
.user-form button { grid-column: span 2; justify-content: center; }
.modal-msg { font-size: 12.5px; color: var(--muted); margin-top: 10px; min-height: 18px; }

.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--surface-tertiary); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
