/* ===== BrandSearch CRM — back-office UI (dark, Discord-style workspace) ===== */
:root {
  --bg-rail: #0d0f14;
  --bg-list: #141821;
  --bg-main: #1a1f2a;
  --panel: #212734;
  --panel-2: #1c222d;
  --ink: #e7ebf3;
  --ink-soft: #b9c1d1;
  --muted: #7f8aa1;
  --line: #2a3140;
  --line-soft: #232935;
  --brand: #4f7cf7;
  --brand-600: #3f68d8;
  --brand-tint: rgba(79, 124, 247, .16);
  --amber: #f5b544;
  --amber-tint: rgba(245, 181, 68, .14);
  --radius: 12px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-main);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2c3444; border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #3a445a; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Shell ---------- */
.shell { display: flex; height: 100vh; overflow: hidden; }

.rail {
  width: 238px; flex: none;
  background: var(--bg-rail);
  border-right: 1px solid var(--line-soft);
  display: flex; flex-direction: column;
  padding: 16px 12px 12px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px 18px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #7aa2ff);
  color: #fff; font-weight: 800; font-size: 18px;
  display: grid; place-items: center;
}
.brand-name { display: flex; flex-direction: column; font-weight: 700; line-height: 1.15; }
.brand-name small { font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: .02em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 700; padding: 14px 11px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--ink-soft); font-weight: 550;
}
.nav-item:hover { background: #171b24; color: var(--ink); }
.nav-item.active { background: var(--brand-tint); color: #cfdcff; }
.nav-ico { font-size: 15px; width: 18px; text-align: center; }

.rail-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: var(--radius-sm); }
.user-chip:hover { background: #171b24; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--brand-tint); color: #a9c1ff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-meta strong { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { color: var(--muted); font-size: 11.5px; }
.logout { margin-left: auto; color: var(--muted); padding: 4px 6px; border-radius: 6px; }
.logout:hover { color: #ff8a8a; background: rgba(255, 120, 120, .1); }

/* ---------- Conversation list column ---------- */
.list-col {
  width: 336px; flex: none;
  background: var(--bg-list);
  border-right: 1px solid var(--line-soft);
  display: flex; flex-direction: column; min-height: 0;
}
.list-head { padding: 16px 14px 12px; border-bottom: 1px solid var(--line-soft); }
.list-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.list-title h2 { font-size: 17px; }
.counters { display: flex; gap: 6px; }
.counter { font-size: 11.5px; font-weight: 600; color: var(--ink-soft);
  background: #1e2431; border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; }
.counter-alert { color: var(--amber); background: var(--amber-tint); border-color: rgba(245, 181, 68, .25); }

.list-filters { display: flex; flex-direction: column; gap: 8px; }
.filter-row { display: flex; gap: 8px; }
.filter-row .input { flex: 1; min-width: 0; }
.toggle { display: grid; place-items: center; width: 38px; flex: none; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.toggle input { display: none; }
.toggle span { opacity: .45; font-size: 14px; }
.toggle input:checked + span { opacity: 1; }
.toggle:hover { border-color: #3a4356; }

.add-row { display: flex; gap: 7px; margin-top: 10px; }
.add-row .input { flex: 1; min-width: 0; }
.add-row .input-country { max-width: 66px; }

.conv-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 3px; }
.conv-item {
  display: flex; gap: 10px; padding: 10px; border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.conv-item:hover { background: #1a1f2a; }
.conv-item.active { background: var(--brand-tint); border-color: rgba(79, 124, 247, .35); }
.conv-avatar {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  background: #1e2431; border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 16px;
}
.conv-body { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1; }
.conv-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.conv-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 11px; color: var(--muted); flex: none; }
.conv-sub { font-size: 11.5px; color: var(--muted); margin-top: -3px; }
.conv-tagline { display: flex; flex-wrap: wrap; gap: 5px; }
.conv-chips { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- Main column ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg-main); }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 22px; border-bottom: 1px solid var(--line-soft); flex: none;
  background: rgba(20, 24, 33, .6);
}
.topbar h1 { font-size: 17px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.thread-avatar { width: 30px; height: 30px; border-radius: 50%; background: #1e2431;
  border: 1px solid var(--line); display: grid; place-items: center; font-size: 15px; }
.content { padding: 24px 26px 60px; overflow-y: auto; }
.back { color: var(--muted); font-size: 20px; line-height: 1; }
.back:hover { color: var(--ink); }

.convo-grid { flex: 1; display: grid; grid-template-columns: 1fr 320px; min-height: 0; }
.thread-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 0 6px 0 0; }
.thread { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 16px; }
.thread-col .alert { margin: 14px 20px 0; }

.msg { display: flex; gap: 12px; }
.msg-avatar {
  width: 36px; height: 36px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 15px; font-weight: 700;
  background: #232a37; color: var(--ink-soft);
}
.msg.out .msg-avatar { background: var(--brand-tint); color: #a9c1ff; font-size: 12px; }
.msg-body { min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 9px; margin-bottom: 2px; }
.msg-author { font-weight: 650; font-size: 13.5px; }
.msg.out .msg-author { color: #9db6ff; }
.msg-time { font-size: 11px; color: var(--muted); }
.msg-text { color: var(--ink-soft); white-space: pre-wrap; word-break: break-word; }
.msg-attach { display: inline-flex; align-items: center; gap: 8px; margin: 3px 0 4px;
  padding: 7px 11px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-size: 12.5px; }
.msg-attach .muted { font-size: 11px; }
.attach-ico { font-size: 14px; }
.thread-phone { font-size: 12.5px; font-weight: 500; color: var(--muted); }

.composer { display: flex; gap: 8px; padding: 12px 20px 18px; flex: none; }
.composer .input:disabled, .composer .btn:disabled { opacity: .5; cursor: not-allowed; }

.side-col { border-left: 1px solid var(--line-soft); background: var(--panel-2);
  padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }

/* ---------- Cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.side-col .card { padding: 14px 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 0 10px; }
.card-head h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }

.meta { display: grid; grid-template-columns: 92px 1fr; gap: 8px 10px; margin: 0 0 12px; }
.meta dt { color: var(--muted); font-size: 12.5px; }
.meta dd { margin: 0; font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 9px; margin-top: 8px; }
.lbl { font-size: 12px; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.doclist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.doclist li { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 13px; padding: 8px 10px; background: var(--panel-2); border-radius: var(--radius-sm); }
.doclist li.doc { flex-direction: column; align-items: stretch; gap: 8px; }
.doc-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.doc-state { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.doc-state form { margin: 0; }
.doc-state .btn:disabled { opacity: .45; cursor: not-allowed; }
.amount-row { display: flex; gap: 8px; margin-top: 5px; }
.amount-row .input-currency { max-width: 96px; }
.form-card .amount-row .input { margin-top: 0; }

/* ---------- Tags / chips ---------- */
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 7px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .01em; white-space: nowrap;
  border: 1px solid transparent; }
.tag-lg { font-size: 12.5px; padding: 5px 12px; border-radius: 8px; }
.tag-lead     { background: rgba(150, 163, 190, .14); color: #aab5c9; border-color: rgba(150, 163, 190, .22); }
.tag-contract { background: rgba(160, 130, 246, .15); color: #bda5ff; border-color: rgba(160, 130, 246, .28); }
.tag-script   { background: rgba(45, 199, 168, .14); color: #57d9bd; border-color: rgba(45, 199, 168, .26); }
.tag-video    { background: rgba(245, 181, 68, .14); color: #f2bd60; border-color: rgba(245, 181, 68, .26); }
.tag-posted   { background: rgba(79, 124, 247, .16); color: #93b1ff; border-color: rgba(79, 124, 247, .3); }
.tag-sponso   { background: rgba(236, 72, 153, .16); color: #f78fc2; border-color: rgba(236, 72, 153, .3); }
.tag-payment  { background: rgba(255, 138, 76, .15); color: #ff9f6b; border-color: rgba(255, 138, 76, .28); }
.tag-done     { background: rgba(52, 199, 108, .14); color: #5fd68c; border-color: rgba(52, 199, 108, .26); }
.tag-overdue  { background: var(--amber-tint); color: var(--amber); border-color: rgba(245, 181, 68, .32); }

.chip { display: inline-block; padding: 1px 8px; border-radius: 6px;
  background: #232a37; color: var(--ink-soft); font-size: 11px; font-weight: 500; }
.chip-lang { background: var(--brand-tint); color: #a9c1ff; font-weight: 700; }

/* ---------- Forms ---------- */
.input, textarea.input, select.input {
  width: 100%; padding: 9px 12px; font: inherit; color: var(--ink);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  outline: none; transition: border-color .1s, box-shadow .1s;
}
.input::placeholder { color: #6b7488; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 124, 247, .18); }
.input-xs { padding: 7px 9px; font-size: 13px; }
.input-search { padding-left: 12px; }
select.input { cursor: pointer; }
select.input option { background: var(--panel); color: var(--ink); }
textarea.input { resize: vertical; }
label { display: block; font-size: 13px; color: var(--ink-soft); font-weight: 550; }
.form-card { padding: 22px; max-width: 720px; }
.form-card label:not(.toggle) { margin-bottom: 14px; }
.form-card label .input { margin-top: 5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: #262d3b; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
  transition: background .1s, border-color .1s; white-space: nowrap; }
.btn:hover { background: #2e3646; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #262d3b; color: var(--ink); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ---------- Scripts library ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.filters .input { width: auto; min-width: 170px; }
.script-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.script-card { padding: 16px 18px; display: flex; flex-direction: column; }
.script-head { display: flex; gap: 6px; margin-bottom: 8px; }
.script-card h3 { font-size: 15px; margin-bottom: 8px; }
.script-text { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 13px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
  font-family: inherit; color: var(--ink-soft); margin: 0 0 12px; max-height: 220px; overflow: auto; }
.script-card .copy { align-self: flex-start; }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 50px 20px; color: var(--ink); }
.empty.small { padding: 28px 14px; }
.empty p { font-weight: 600; margin: 0 0 4px; }
.placeholder { margin: auto; }
.muted { color: var(--muted); }
.section-intro { color: var(--muted); margin: -4px 0 18px; }
.alert { padding: 11px 15px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 18px; }
.alert.ok { background: rgba(52, 199, 108, .12); color: #5fd68c; border: 1px solid rgba(52, 199, 108, .28); }
.alert.error { background: rgba(255, 90, 90, .12); color: #ff8a8a; border: 1px solid rgba(255, 90, 90, .28); }
.alert.warn { background: var(--amber-tint); color: var(--amber); border: 1px solid rgba(245, 181, 68, .3); }

/* ---------- Stats (dashboard-ish rows) ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat-num { display: block; font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat-lbl { color: var(--muted); font-size: 13px; }

/* ---------- Import ---------- */
.author-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.author-opt { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
.author-opt:hover { border-color: #3a4356; }
.sample { padding: 14px 16px; margin: 8px 0 18px; }
.sample-row { display: flex; gap: 10px; font-size: 12.5px; padding: 5px 0;
  border-bottom: 1px solid var(--line-soft); }
.sample-row:last-child { border-bottom: 0; }
.sample-row span:last-child { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- Login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh;
  background: radial-gradient(900px 500px at 50% -10%, #1d2740, var(--bg-main)); }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow); padding: 30px; display: flex; flex-direction: column; gap: 14px; }
.login-brand { padding: 0 0 6px; }
.login-card h1 { font-size: 22px; }
.login-card .muted { margin: -8px 0 4px; font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-weight: 550; }

@media (max-width: 1100px) {
  .convo-grid { grid-template-columns: 1fr; }
  .side-col { border-left: 0; border-top: 1px solid var(--line-soft); }
  .convo-grid { display: flex; flex-direction: column; overflow-y: auto; }
  .thread { max-height: none; }
}
@media (max-width: 860px) {
  .shell { flex-direction: column; height: auto; overflow: visible; }
  .rail { width: 100%; flex-direction: row; align-items: center; gap: 10px; padding: 10px 12px; }
  .rail .nav { flex-direction: row; align-items: center; }
  .nav-label { display: none; }
  .rail-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .list-col { width: 100%; max-height: 46vh; }
}
