/* ACE CRM: dark Singer theme (mockup Mk6hTCtjia8sPrT8YuDDxY). One accent = Singer red; green only for Bot ON; amber for waiting. */
:root {
  --ground: #0E0B0C; --panel: #1A1517; --input: #221B1E; --line: #30272B; --line2: #2A2226; --card: #251E21; --chip: #2B2427;
  --text: #F5EFEA; --text2: #CFC5BE; --muted: #A3988F; --red: #E5394B; --red-soft: #2E141A; --red-deep: #3B1820; --maroon: #7A1424;
  --green: #3FC271; --green-text: #62D891; --green-bg: #12291B; --amber: #F2BA5C; --amber-bg: #33260F;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(900px 420px at 15% -8%, rgba(229, 57, 75, .22), transparent 70%), radial-gradient(700px 380px at 100% 0%, rgba(122, 20, 36, .35), transparent 70%), var(--ground);
  background-attachment: fixed; color: var(--text); font: 14px/1.45 "Plus Jakarta Sans", system-ui, sans-serif; font-variant-numeric: tabular-nums;
}
a { color: var(--red); } a:hover { color: #FF7080; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.sr { position: absolute; left: -9999px; }
b, strong, h1, h2, h3 { font-weight: 800; }
h1, h2, h3 { margin: 0; }

/* header */
.top { display: flex; align-items: center; gap: 14px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 32px; height: 32px; border-radius: 8px; background: var(--red); color: #fff; display: grid; place-items: center; font-weight: 800; }
.brand small { color: var(--red); font-size: 13px; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 8px 14px; border-radius: 8px; color: var(--text2); text-decoration: none; font-weight: 600; }
.nav a.on { background: var(--red-deep); color: var(--red); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--text2); }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 13px; border: 0; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.pill.on { background: var(--green-bg); color: var(--green-text); } .pill.on .dot { background: var(--green); }
.pill.off { background: var(--red-soft); color: var(--red); } .pill.off .dot { background: var(--red); }

/* 3-column inbox */
.app { display: flex; height: calc(100vh - 53px); min-height: 0; }
.list { flex: 0 0 360px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.chat { flex: 1 1 520px; min-width: 0; display: flex; flex-direction: column; }
.side { flex: 0 0 320px; min-width: 0; background: var(--panel); border-left: 1px solid var(--line); padding: 16px; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 14px; }
.list-head { padding: 14px 14px 10px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line2); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { padding: 10px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.stat span { font-size: 12px; color: var(--muted); } .stat b { display: block; font-size: 22px; }
.stat.hot { background: var(--red-soft); border-color: #4A1C25; } .stat.hot span, .stat.hot b { color: var(--red); }
.search { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--input); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 7px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--text2); font-size: 13px; min-height: 34px; }
.chip.on { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
select.chip { appearance: none; padding-right: 22px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 12px) 15px, calc(100% - 8px) 15px; background-size: 4px 4px; background-repeat: no-repeat; }
.rows { overflow: auto; flex: 1; }
.row { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line2); text-decoration: none; color: var(--text); border-left: 4px solid transparent; }
.row:hover { background: #211A1D; }
.row.sel { background: var(--red-soft); }
.row.needs { border-left-color: var(--red); }
.av { width: 40px; height: 40px; border-radius: 50%; background: var(--chip); color: var(--text2); display: grid; place-items: center; font-weight: 800; flex: none; }
.row.needs .av { background: #4A1C25; color: var(--red); }
.row-main { flex: 1; min-width: 0; }
.row-top { display: flex; justify-content: space-between; gap: 6px; }
.row-top b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 13px; color: var(--text2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--chip); color: #DDD3CC; }
.tag.org { background: var(--card); color: var(--muted); font-weight: 400; }
.tag.bot { background: var(--green-bg); color: var(--green-text); }
.tag.you { background: var(--amber-bg); color: var(--amber); }
.tag.test { background: #1E2433; color: #9DB4E8; }
.time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.timer { font-size: 12px; font-weight: 800; white-space: nowrap; }
.t-green { color: var(--green-text); } .t-amber { color: var(--amber); } .t-red { color: var(--red); }
.more { margin: 12px; }
.empty { padding: 28px 18px; color: var(--muted); text-align: center; }

/* chat */
.chat-head { padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.chat-head .who { flex: 1; min-width: 180px; } .chat-head .who div { font-size: 13px; color: var(--muted); }
.back { display: none; }
.thread { flex: 1; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.b { max-width: min(70%, 560px); padding: 9px 13px; border-radius: 14px; font-size: 14px; white-space: pre-wrap; word-wrap: break-word; }
.b.in { align-self: flex-start; background: var(--panel); border-radius: 4px 14px 14px 14px; box-shadow: 0 1px 0 var(--line); }
.b.bot { align-self: flex-end; background: var(--red-deep); border-radius: 14px 4px 14px 14px; }
.b.human { align-self: flex-end; background: #2C2326; border: 1px solid #4A3E43; border-radius: 14px 4px 14px 14px; }
.b .meta { font-size: 11px; margin-top: 4px; color: var(--muted); } .b.bot .meta { color: var(--red); }
.b .media { font-size: 12px; color: var(--muted); font-style: italic; }
.sys { align-self: center; font-size: 12px; color: var(--muted); background: #211A1D; padding: 4px 10px; border-radius: 999px; text-align: center; max-width: 90%; }
.sys.hot { color: var(--red); background: var(--red-soft); font-weight: 600; }
.composer { padding: 12px 18px; background: var(--panel); border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.blank { flex: 1; display: grid; place-items: center; color: var(--muted); padding: 40px; text-align: center; }

/* buttons + boxes */
.btn { padding: 10px 16px; border-radius: 10px; border: 1px solid #4A3E43; background: var(--panel); color: var(--text); font-weight: 600; min-height: 42px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.small { padding: 6px 10px; min-height: 34px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.box { border: 1px solid var(--line); border-radius: 12px; background: var(--card); padding: 12px; }
.label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.cell { padding: 8px; border-radius: 8px; background: var(--input); font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
.cell span { color: var(--muted); display: block; font-size: 12px; }
.stages { display: flex; gap: 6px; flex-wrap: wrap; }
.st { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--card); color: var(--muted); border: 1px solid var(--line); }
.st.done { background: var(--chip); color: #DDD3CC; } .st.now { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }
.st.side { border-style: dashed; }
.field { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--input); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hint { font-size: 12px; color: var(--muted); }

/* pages (Ads, Bot) */
.page { max-width: 1100px; margin: 0 auto; padding: 22px 18px 60px; display: flex; flex-direction: column; gap: 16px; }
.page h1 { font-size: 22px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.card { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card .big { font-size: 28px; font-weight: 800; }
.bar { height: 8px; border-radius: 99px; background: var(--input); overflow: hidden; } .bar i { display: block; height: 100%; background: var(--red); }
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
table { border-collapse: collapse; width: 100%; min-width: 760px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line2); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; }
td input { width: 100%; min-width: 90px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--input); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; z-index: 20; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.notice { border: 1px solid #4A1C25; background: var(--red-soft); color: #FFD9DD; padding: 12px 14px; border-radius: 12px; }

/* phone: list -> chat (2 taps to any lead) */
@media (max-width: 1100px) { .side { display: none; } .side.open { display: flex; position: fixed; inset: 53px 0 0 auto; width: min(360px, 92vw); z-index: 6; box-shadow: -10px 0 30px rgba(0,0,0,.5); } }
@media (min-width: 1101px) { .info-btn { display: none; } }
@media (max-width: 760px) {
  .top { padding: 10px 12px; gap: 10px; } .brand small, .top-right .cost { display: none; }
  .nav a { padding: 8px 10px; }
  .app { height: calc(100vh - 53px); }
  .list { flex: 1 1 auto; border-right: 0; }
  .app.has-chat .list { display: none; }
  .app:not(.has-chat) .chat { display: none; }
  .back { display: inline-flex; }
  .b { max-width: 85%; }
}
