/* ============ Design tokens ============ */
:root {
  color-scheme: light;
  --side: #0C2E28;
  --side-ink: #B9D3CB;
  --side-hover: rgba(255,255,255,.06);
  --bg: #F3F6F4;
  --surface: #FFFFFF;
  --surface-2: #F8FAF9;
  --ink: #142A26;
  --muted: #5B6E69;
  --line: #DFE7E3;
  --brand: #128062;
  --brand-dark: #0D6650;
  --brand-soft: #E3F3EC;
  --saffron: #E9A23B;
  --saffron-soft: #FDF1DC;
  --saffron-ink: #7A4B07;
  --danger: #C2412D;
  --danger-soft: #FBE7E2;
  --chat-bg: #ECE5DD;
  --bubble-user: #D9FDD3;
  --bubble-bot: #FFFFFF;
  --shadow: 0 1px 2px rgba(16,40,34,.05), 0 4px 16px rgba(16,40,34,.05);
  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 7px;
  --font: "Manrope", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --side: #08110F;
    --side-ink: #95ABA4;
    --bg: #0F1715;
    --surface: #16211E;
    --surface-2: #1B2925;
    --ink: #E4EEEA;
    --muted: #93A6A0;
    --line: #26332F;
    --brand: #2BB38A;
    --brand-dark: #24997A;
    --brand-soft: #143A2F;
    --saffron-soft: #3A2B12;
    --saffron-ink: #F3C77E;
    --danger: #EF7A64;
    --danger-soft: #3A1E19;
    --chat-bg: #0B1412;
    --bubble-user: #005C4B;
    --bubble-bot: #1F2C33;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
h1 { font-size: 1.75rem; font-weight: 800; margin: 0 0 6px; letter-spacing: -0.02em; line-height: 1.2; }
h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 14px; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ic { width: 19px; height: 19px; flex: none; }

/* ============ Shell ============ */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.side-top { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 11px; color: #fff; font-weight: 800; text-decoration: none; padding: 4px 8px 22px; line-height: 1.2; }
.brand small { display: block; font-weight: 500; font-size: .78rem; color: var(--side-ink); }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--saffron); color: #2B1B03; }
.menu-btn { display: none; background: none; border: 0; color: #fff; padding: 8px; border-radius: 8px; cursor: pointer; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: .76rem; font-weight: 600; color: #6F8C83; padding: 16px 12px 6px; }
.side nav a { display: flex; align-items: center; gap: 11px; color: var(--side-ink); text-decoration: none; padding: 9px 12px; border-radius: var(--r-sm); font-weight: 600; font-size: .93rem; }
.side nav a:hover { background: var(--side-hover); color: #fff; }
.side nav a.on { background: rgba(43,179,138,.16); color: #fff; box-shadow: inset 3px 0 0 var(--saffron); }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 2px; border-top: 1px solid rgba(255,255,255,.08); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #1D4A41; color: #fff; font-weight: 700; font-size: .85rem; }
.who { flex: 1; color: #fff; font-weight: 600; font-size: .9rem; }
.side-foot a { color: var(--side-ink); display: grid; place-items: center; padding: 6px; border-radius: 6px; }
.side-foot a:hover { background: var(--side-hover); color: #fff; }

.main { padding: 32px 40px 72px; max-width: 1120px; width: 100%; }
.page-head { margin-bottom: 24px; }
.page-head p { margin: 0; color: var(--muted); max-width: 68ch; }

/* ============ Panels ============ */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px 24px; margin-bottom: 20px; box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); box-shadow: none; }
.count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; margin-left: 6px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: .75rem; font-weight: 700; vertical-align: 2px; }

/* ============ Forms ============ */
.form { display: flex; flex-direction: column; gap: 18px; }
.form.narrow { max-width: 440px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.span2 { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
label small { font-weight: 500; color: var(--muted); font-size: .82rem; line-height: 1.45; }
label.check { flex-direction: row; align-items: center; gap: 9px; align-self: end; padding-bottom: 10px; }
input, select, textarea { font: inherit; font-weight: 500; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; width: 100%; transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
textarea { resize: vertical; line-height: 1.5; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.btn:focus-visible, a:focus-visible, .switch:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.end { display: flex; justify-content: flex-end; }
.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline input { flex: 1; min-width: 200px; }

/* Upload dropzone */
.drop { position: relative; border: 1.5px dashed color-mix(in srgb, var(--brand) 45%, var(--line)); background: var(--brand-soft); border-radius: var(--r-md); padding: 26px 16px; text-align: center; align-items: center; cursor: pointer; transition: background .15s; }
.drop:hover { background: color-mix(in srgb, var(--brand-soft) 70%, var(--surface)); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-title { color: var(--brand); font-weight: 700; }
.drop-name { font-weight: 500; color: var(--muted); font-size: .85rem; word-break: break-word; }

/* ============ Buttons ============ */
.btn { font: inherit; font-weight: 700; font-size: .9rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 9px 17px; border-radius: var(--r-sm); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 7px; transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.small { padding: 5px 11px; font-size: .82rem; }
.btn.wide { width: 100%; justify-content: center; padding: 11px; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row-actions form { margin: 0; }

/* Switch */
.switch { position: relative; width: 42px; height: 24px; border-radius: 12px; border: 0; background: var(--line); cursor: pointer; padding: 0; transition: background .2s; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch.on { background: var(--brand); }
.switch.on .knob { transform: translateX(18px); }

/* ============ Feedback ============ */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r-md); margin-bottom: 20px; font-weight: 600; font-size: .92rem; }
.flash.ok { background: var(--brand-soft); color: var(--brand); }
.flash.err { background: var(--danger-soft); color: var(--danger); }
.flash span { color: var(--ink); }
.note { background: var(--saffron-soft); color: var(--ink); border-left: 4px solid var(--saffron); padding: 12px 16px; border-radius: var(--r-sm); margin: 0 0 20px; font-size: .92rem; }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 9px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); vertical-align: middle; }
.tag.high { background: var(--saffron-soft); border-color: transparent; color: var(--saffron-ink); }

/* ============ Dashboard ============ */
.setup { display: flex; gap: 32px; align-items: center; }
.ring { --p: 0; flex: none; width: 128px; height: 128px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--line) 0); }
.ring span { width: 100px; height: 100px; border-radius: 50%; background: var(--surface); display: flex; align-items: baseline; justify-content: center; padding-top: 30px; font-size: 1rem; color: var(--muted); font-weight: 600; }
.ring b { font-size: 2rem; color: var(--ink); font-weight: 800; }
.setup-body { flex: 1; }
.steps { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; counter-reset: s; }
.steps li { counter-increment: s; }
.steps li a { display: flex; flex-direction: column; padding: 12px 14px 12px 48px; border: 1px solid var(--line); border-radius: var(--r-md); text-decoration: none; color: var(--ink); position: relative; transition: border-color .15s; }
.steps li a:hover { border-color: var(--brand); }
.steps li a::before { content: counter(s); position: absolute; left: 14px; top: 13px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 800; border: 1.5px solid var(--line); color: var(--muted); }
.steps li a span { color: var(--muted); font-size: .84rem; }
.steps li.done a { background: var(--surface-2); }
.steps li.done a::before { content: "✓"; background: var(--brand); border-color: var(--brand); color: #fff; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 4px; }
a.stat:hover { border-color: var(--brand); }
.stat span { color: var(--muted); font-size: .85rem; font-weight: 600; }
.stat b { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.cta-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 24px; border-radius: var(--r-lg); background: var(--side); color: #fff; text-decoration: none; }
.cta-card h2 { margin: 0 0 4px; color: #fff; }
.cta-card p { margin: 0; color: var(--side-ink); }
.cta-card .btn.primary { background: var(--saffron); border-color: var(--saffron); color: #2B1B03; white-space: nowrap; }

/* ============ Rules ============ */
.rule-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rule { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 13px 16px; border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.rule.is-high { border-left-color: var(--saffron); }
.rule.off { opacity: .55; }
.rule-title { font-weight: 700; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rule-text { color: var(--muted); font-size: .92rem; margin-top: 2px; }
.rule .row-actions { flex: none; }

/* ============ Knowledge ============ */
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.filters a { text-decoration: none; padding: 5px 13px; border-radius: 20px; border: 1px solid var(--line); color: var(--ink); font-size: .85rem; font-weight: 600; }
.filters a:hover { border-color: var(--brand); }
.filters a.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.table-wrap { overflow-x: auto; margin: 0 -8px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 12px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; color: var(--muted); border-top: 0; font-weight: 700; }
tbody tr:hover { background: var(--surface-2); }
td a { font-weight: 700; text-decoration: none; }
.hit { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; margin-top: 10px; background: var(--surface-2); }
.hit-head { font-weight: 700; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .9rem; }
.hit-head a { text-decoration: none; }
.score { color: var(--muted); font-weight: 600; font-size: .8rem; margin-left: auto; }
pre { white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: .87rem; margin: 6px 0 0; color: var(--ink); }

/* ============ Test bot (WhatsApp jaisa) ============ */
.chat-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--side); color: #fff; }
.chat-head small { display: block; color: var(--side-ink); font-size: .8rem; }
.chat-avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--saffron); color: #2B1B03; font-weight: 800; }
.chat { height: 62vh; overflow-y: auto; padding: 20px 18px; display: flex; flex-direction: column; gap: 6px; background-color: var(--chat-bg);
  background-image: radial-gradient(color-mix(in srgb, var(--ink) 6%, transparent) 1px, transparent 1px); background-size: 18px 18px; }
.chat .empty { margin: auto; color: var(--muted); background: var(--surface); padding: 8px 14px; border-radius: 8px; font-size: .9rem; }
.bubble { max-width: 72%; padding: 7px 10px 6px 11px; border-radius: 9px; white-space: pre-wrap; font-size: .94rem; box-shadow: 0 1px .5px rgba(0,0,0,.13); position: relative; animation: pop .16s ease-out; }
.bubble .time { display: block; text-align: right; font-size: .68rem; color: var(--muted); margin-top: 2px; }
.bubble.user { align-self: flex-end; background: var(--bubble-user); border-top-right-radius: 2px; }
.bubble.bot { align-self: flex-start; background: var(--bubble-bot); border-top-left-radius: 2px; }
.bubble.typing { color: var(--muted); font-style: italic; }
.bubble.err { align-self: center; background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.meta { align-self: flex-start; max-width: 72%; font-size: .82rem; display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.meta details { background: color-mix(in srgb, var(--surface) 85%, transparent); border-radius: 7px; padding: 5px 10px; }
.meta summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.meta .hit { background: var(--surface); }
.meta .tag.high { white-space: normal; padding: 6px 10px; border-radius: 7px; line-height: 1.4; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--surface-2); }
.chat-input input { flex: 1; border-radius: 22px; padding: 11px 16px; }
.chat-input .btn { border-radius: 22px; }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ============ Login ============ */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px;
  background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--brand) 18%, transparent), transparent), var(--bg); }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 32px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; box-shadow: var(--shadow); }
.login-card .brand { color: var(--ink); padding: 0; }
.login-card .brand small { color: var(--muted); }
.login-card p { margin: 0; }

/* ============ Mobile ============ */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 10; height: auto; padding: 10px 12px; }
  .brand { padding: 4px; }
  .menu-btn { display: grid; }
  .side nav, .side-foot { display: none; }
  .side.open nav, .side.open .side-foot { display: flex; }
  .side.open nav { padding-top: 8px; }
  .main { padding: 22px 16px 56px; }
  h1 { font-size: 1.45rem; }
  .cols, .grid2, .steps { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .setup { flex-direction: column; align-items: stretch; text-align: left; }
  .ring { align-self: center; }
  .rule { flex-direction: column; align-items: stretch; }
  .cta-card { flex-direction: column; align-items: flex-start; }
  .bubble, .meta { max-width: 88%; }
  .chat-input { flex-wrap: wrap; }
  .chat-input input { flex: 1 1 100%; min-width: 0; }
  .chat-input .btn { flex: 1; justify-content: center; }
  .panel { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ============ Soul: apni headings ============ */
.sections { display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }
.section-card { border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--r-md); padding: 14px 16px; background: var(--surface-2); scroll-margin-top: 80px; }
.section-card.off { border-left-color: var(--line); opacity: .6; }
.section-card .form { gap: 10px; }
.section-top { display: flex; gap: 12px; align-items: center; }
.section-heading { font-weight: 800; font-size: 1rem; background: transparent; border-color: transparent; padding: 6px 8px; margin-left: -8px; }
.section-heading:hover { border-color: var(--line); }
.section-top label.check { padding: 0; white-space: nowrap; font-weight: 600; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--line); }
.add-section { border-top: 1px dashed var(--line); padding-top: 20px; scroll-margin-top: 80px; }
.add-section h2 { margin: 0; }
.ideas { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { font: inherit; font-size: .82rem; font-weight: 600; padding: 5px 12px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
#sections { scroll-margin-top: 80px; }
.recommend { display: flex; align-items: center; justify-content: space-between; gap: 20px; background: var(--brand-soft); border-color: transparent; box-shadow: none; }
.recommend h2 { margin: 0 0 4px; }
.recommend p { margin: 0; }
.recommend .btn { white-space: nowrap; }
@media (max-width: 860px) { .recommend { flex-direction: column; align-items: flex-start; } }

/* ============ Nav badge, section titles ============ */
.side nav a .badge { margin-left: auto; font-style: normal; background: var(--saffron); color: #2B1B03; font-size: .72rem; font-weight: 800; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; }
.section-title { font-size: .9rem; color: var(--muted); margin: 6px 0 10px; }
.stat small { color: var(--muted); font-size: .8rem; font-weight: 600; }
.stat b small { font-size: 1rem; }
.stat.alert { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.stat.alert b { color: var(--danger); }
.tag-defs { display: flex; flex-direction: column; gap: 8px; }

/* ============ Inbox ============ */
.main:has(.inbox) { max-width: none; padding: 0; }
.inbox { display: grid; grid-template-columns: 370px 1fr; height: 100vh; }
.inbox-list { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.inbox-list-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 18px 10px; }
.inbox-list-head h1 { margin: 0; font-size: 1.45rem; }
.inbox-filters { padding: 0 18px 14px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); }
.inbox-filters input[name=q] { border-radius: 20px; padding: 9px 15px; background: var(--surface-2); }
.filter-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.filter-row select { flex: 1; min-width: 0; padding: 6px 8px; font-size: .84rem; }
.filter-row .check { padding: 0; font-size: .84rem; font-weight: 600; }
.grow { flex: 1; }
.conv-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.conv-empty { padding: 28px 20px; color: var(--muted); text-align: center; }
.conv { display: flex; gap: 12px; padding: 12px 18px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.conv:hover { background: var(--surface-2); }
.conv.on { background: var(--brand-soft); }
.conv-avatar { flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--surface-2); border: 2px solid var(--line); color: var(--ink); }
.conv-avatar.mood-happy { border-color: #3BB273; }
.conv-avatar.mood-upset { border-color: var(--danger); }
.conv-avatar.mood-neutral { border-color: #9AAAA5; }
.conv-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.conv-top { display: flex; justify-content: space-between; gap: 8px; }
.conv-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-top time { flex: none; font-size: .76rem; color: var(--muted); }
.conv-preview { font-size: .86rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv.unread .conv-top b, .conv.unread .conv-preview { color: var(--ink); font-weight: 800; }
.conv.unread .conv-top time { color: var(--brand); font-weight: 700; }
.conv-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag.urgent { background: var(--danger); color: #fff; border-color: transparent; }
.tag.open { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.tag.converted { background: #DFF5E6; color: #17653A; border-color: transparent; }

.inbox-chat { display: flex; flex-direction: column; min-height: 0; background-color: var(--chat-bg);
  background-image: radial-gradient(color-mix(in srgb, var(--ink) 6%, transparent) 1px, transparent 1px); background-size: 18px 18px; }
.inbox-empty { margin: auto; text-align: center; display: flex; flex-direction: column; gap: 6px; max-width: 340px; color: var(--muted); background: var(--surface); padding: 22px 26px; border-radius: var(--r-lg); }
.inbox-empty b { color: var(--ink); font-size: 1.05rem; }
.chat-top { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chat-top .back { display: none; text-decoration: none; font-size: 1.3rem; color: var(--ink); padding: 0 4px; }
.chat-top-name { flex: 1; min-width: 160px; }
.chat-top-name small { display: block; color: var(--muted); font-size: .8rem; }
.analysis { background: var(--surface); border-bottom: 1px solid var(--line); padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.analysis p { margin: 0; }
.analysis-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.analysis-grid div { background: var(--surface-2); border-radius: var(--r-sm); padding: 8px 12px; }
.analysis-grid span { display: block; font-size: .76rem; color: var(--muted); font-weight: 600; }
.analysis-grid b { font-size: .95rem; }
.mood-happy-text { color: #1E8A50; }
.mood-upset-text { color: var(--danger); }
.summary { font-size: .93rem; }
.urgent-box { background: var(--danger-soft); color: var(--ink); border-left: 4px solid var(--danger); padding: 8px 12px; border-radius: var(--r-sm); font-size: .9rem; }
.urgent-box b { color: var(--danger); }
.tag-edit summary { cursor: pointer; font-weight: 700; font-size: .88rem; color: var(--brand); }
.tag-edit .form { margin-top: 12px; gap: 12px; }
.tag-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.tag-checks .check { padding: 0; font-weight: 600; font-size: .86rem; }
.thread { flex: 1; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 6px; }
.thread .day { align-self: center; background: var(--surface); color: var(--muted); font-size: .76rem; font-weight: 700; padding: 3px 12px; border-radius: 8px; margin: 6px 0; }
.bubble.in { align-self: flex-start; background: var(--bubble-bot); border-top-left-radius: 2px; }
.bubble.out { align-self: flex-end; background: var(--bubble-user); border-top-right-radius: 2px; }
.bubble.unknown { box-shadow: 0 0 0 2px var(--saffron); }
.thread .bubble { animation: none; }
.unknown-note { align-self: flex-end; max-width: 72%; background: var(--saffron-soft); color: var(--ink); font-size: .82rem; padding: 6px 10px; border-radius: 7px; }
.unknown-note a { font-weight: 700; }
.thread-foot { text-align: center; padding: 8px; margin: 0; background: var(--surface); border-top: 1px solid var(--line); }

@media (max-width: 860px) {
  .inbox { grid-template-columns: 1fr; height: auto; min-height: calc(100vh - 60px); }
  .inbox.has-current .inbox-list { display: none; }
  .inbox:not(.has-current) .inbox-chat { display: none; }
  .inbox-chat { min-height: calc(100vh - 60px); }
  .chat-top .back { display: block; }
  .analysis-grid { grid-template-columns: 1fr 1fr; }
  .thread { padding: 14px; }
  .unknown-note { max-width: 88%; }
}
.main:has(.inbox) > .flash { margin: 12px 18px 0; }

/* ============ WhatsApp page ============ */
.wa-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.wa-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 2px; }
.wa-tile:hover { border-color: var(--brand); }
.wa-tile span { font-size: .8rem; color: var(--muted); font-weight: 700; }
.wa-tile b { font-size: 1.05rem; }
.wa-tile small { color: var(--muted); font-size: .76rem; }
.ok-text { color: var(--brand); }
#qr, #api, #hook, #test, #bot, #alerts { scroll-margin-top: 20px; }
.qr-box { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px; background: var(--surface-2); margin-bottom: 12px; }
.qr-left { display: flex; flex-direction: column; gap: 12px; }
.qr-status { font-weight: 800; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.qr-status::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--saffron); }
.qr-status.ok::before { background: #2BB673; box-shadow: 0 0 0 4px rgba(43,182,115,.2); }
.qr-status.warn::before { background: var(--danger); }
.qr-img { background: #fff; padding: 12px; border-radius: var(--r-md); width: max-content; border: 1px solid var(--line); }
.qr-img img { display: block; width: 260px; height: 260px; }
.qr-steps { margin: 0; padding-left: 20px; color: var(--muted); }
.qr-steps b { color: var(--ink); }
.log-box { margin-top: 10px; }
.log-box summary { cursor: pointer; color: var(--muted); font-weight: 700; font-size: .85rem; }
.log-box pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px; font-family: ui-monospace, Consolas, monospace; font-size: .78rem; max-height: 220px; overflow: auto; }
.log-box form { margin-top: 12px; }
.small-note { font-size: .85rem; margin-top: 14px; margin-bottom: 0; }
.sub-panel { border-top: 1px dashed var(--line); margin-top: 20px; padding-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.sub-panel h3 { margin: 0; font-size: .98rem; }
.sub-panel p { margin: 0; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .85em; background: var(--surface-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; }
.mini-log { list-style: none; margin: 0; padding: 0; font-size: .84rem; display: flex; flex-direction: column; gap: 4px; }
.mini-log span { color: var(--muted); }
.mini-log em, .st { font-style: normal; font-size: .72rem; font-weight: 800; padding: 1px 7px; border-radius: 10px; background: var(--surface-2); color: var(--muted); }
.st-ok { background: var(--brand-soft) !important; color: var(--brand) !important; }
.st-failed { background: var(--danger-soft) !important; color: var(--danger) !important; }
.st-ignored { background: var(--saffron-soft) !important; color: var(--saffron-ink) !important; }
.nowrap { white-space: nowrap; }
#apiForm { margin-bottom: 10px; }

/* ============ No answer (Pending) ============ */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); font-weight: 700; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--saffron); }
.pending-list { display: flex; flex-direction: column; gap: 14px; }
.pending-card { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--saffron); border-radius: var(--r-md); padding: 16px 18px; scroll-margin-top: 20px; }
.pending-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pid { font-weight: 800; color: var(--saffron-ink); background: var(--saffron-soft); padding: 2px 9px; border-radius: 8px; }
.pending-head .who { font-weight: 700; }
.pending-head time { color: var(--muted); font-size: .82rem; margin-right: auto; }
.pending-q { font-size: 1rem; font-weight: 600; margin: 10px 0 12px; white-space: pre-wrap; }
.pending-card .form { gap: 10px; }
.pending-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pending-actions .check { padding: 0; font-weight: 600; font-size: .86rem; }
.pending-a { background: var(--brand-soft); border-radius: var(--r-sm); padding: 10px 12px; white-space: pre-wrap; }

/* ============ Inbox: staff reply ============ */
.composer { display: flex; gap: 8px; padding: 10px 14px; background: var(--surface); border-top: 1px solid var(--line); align-items: flex-end; }
.composer textarea { flex: 1; resize: none; border-radius: 20px; padding: 10px 16px; min-height: 42px; max-height: 140px; field-sizing: content; }
.composer .btn { border-radius: 20px; }
.paused-bar { background: var(--saffron-soft); color: var(--saffron-ink); text-align: center; font-size: .84rem; font-weight: 700; padding: 6px; }

@media (max-width: 860px) {
  .wa-tiles { grid-template-columns: 1fr 1fr; }
  .qr-box { flex-direction: column; }
  .qr-img img { width: 220px; height: 220px; }
  .copy-row { flex-direction: column; }
}
#api .ideas { margin: 4px 0 14px; }

/* ============ Live: patti, awaaz, refresh ============ */
.down-bar { background: var(--danger); color: #fff; font-weight: 700; font-size: .9rem; padding: 10px 16px; border-radius: var(--r-md); margin-bottom: 16px; }
.down-bar a { color: #fff; text-decoration: underline; margin-left: 6px; }
.main:has(.inbox) > .down-bar { border-radius: 0; margin: 0; }
.down-bar[hidden], .badge[hidden] { display: none !important; }
.sound-btn { background: none; border: 0; color: var(--side-ink); padding: 6px; border-radius: 6px; cursor: pointer; display: grid; place-items: center; }
.sound-btn:hover { background: var(--side-hover); color: #fff; }
.sound-btn.off { opacity: .4; }
.sound-btn.off .ic { stroke-dasharray: 2 2; }
.refresh-bar { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--surface); border: 0; font: inherit; font-weight: 700; padding: 11px 20px; border-radius: 24px; box-shadow: 0 6px 24px rgba(0,0,0,.25); cursor: pointer; }

/* ============ Business hours, backup ============ */
.hours-now { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-left: 5px solid var(--line); }
.hours-now h2 { margin: 2px 0 0; font-size: 1.2rem; }
.hours-now p { margin: 4px 0 0; }
.hours-now.is-open { border-left-color: #2BB673; }
.hours-now.is-closed { border-left-color: var(--danger); }
.day-checks { margin-top: 8px; }
.lbl { font-weight: 600; font-size: .9rem; }
.keep-form { margin-top: 16px; }
.keep-form input { width: 90px; flex: none; min-width: 0; }
.plain-steps { margin: 0 0 10px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.tag.urgent { white-space: normal; }
@media (max-width: 860px) { .hours-now { flex-direction: column; align-items: flex-start; } }
.form > label.check, .grid2 > label.check.span2 { align-self: flex-start; padding-bottom: 0; }

/* ============ Customers ============ */
.cust-list, .chat-history, .order-list { list-style: none; margin: 0; padding: 0; }
.cust { display: flex; gap: 12px; padding: 12px 6px; border-top: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.cust-list li:first-child .cust { border-top: 0; }
.cust:hover { background: var(--surface-2); }
.cust-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cust-head { display: flex; gap: 16px; align-items: center; }
.cust-head p { margin: 2px 0 0; }
.conv-avatar.big { width: 64px; height: 64px; font-size: 1.6rem; }
.bot-view { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; font-size: .86rem; }
.mt { margin-top: 20px; }
.order-list li { padding: 8px 0; border-top: 1px solid var(--line); font-size: .92rem; }
.order-list time { color: var(--muted); font-size: .8rem; display: block; }
.chat-history li a { display: flex; flex-direction: column; gap: 4px; padding: 12px 6px; border-top: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.chat-history li a:hover { background: var(--surface-2); }
.chat-history .muted { font-size: .9rem; }
.danger-zone { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.profile-link { font-size: .78rem; font-weight: 700; margin-left: 8px; text-decoration: none; background: var(--brand-soft); padding: 2px 9px; border-radius: 10px; }

/* ============ Photo / voice in chat ============ */
.bubble.has-media { padding: 4px 4px 6px; }
.bubble.has-media .msg-text { display: block; padding: 4px 6px 0; font-size: .88rem; }
.chat-img { display: block; max-width: 260px; max-height: 320px; width: 100%; object-fit: cover; border-radius: 7px; cursor: zoom-in; }
.bubble audio { display: block; width: 260px; max-width: 100%; height: 40px; }
@media (max-width: 860px) { .chat-img { max-width: 200px; } .cust-head { align-items: flex-start; } }

/* ============ Dashboard period + Reports ============ */
.dash-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0 10px; }
.dash-head .section-title { margin: 0; color: var(--ink); font-size: 1rem; }
.period-filter { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.period-filter select { width: auto; padding: 7px 10px; font-size: .88rem; }
.custom-dates { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.custom-dates[hidden] { display: none; }
.custom-dates input { width: auto; padding: 6px 8px; font-size: .86rem; }
.test-check { padding: 0; font-size: .84rem; font-weight: 600; color: var(--muted); }
.stats-wide { grid-template-columns: repeat(4, 1fr); }
.stat.good b { color: var(--brand); }
.report-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 18px; }
.report-tabs { overflow-x: auto; flex-wrap: nowrap; }
.report-tabs a { white-space: nowrap; }
.summary-box h2 { margin-bottom: 4px; }
.summary-box p { margin: 6px 0; }
.sum-block { margin-top: 10px; }
.sum-block ul { margin: 6px 0 0; padding-left: 18px; }
.sum-block li { margin: 3px 0; }
.report-table td { font-size: .9rem; }
.report-table td .tag.urgent { margin-left: 6px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin: 0; }
.facts div { background: var(--surface-2); border-radius: var(--r-sm); padding: 6px 10px; }
.facts dt { font-size: .74rem; color: var(--muted); font-weight: 700; }
.facts dd { margin: 0; font-size: .9rem; font-weight: 600; }
.facts:not(:has(div)) { display: none; }
@media (max-width: 860px) { .stats-wide { grid-template-columns: 1fr 1fr; } .report-bar { flex-direction: column; align-items: flex-start; } }


/* ============ Fixes: sidebar scroll, inbox height, bubble khali jagah ============ */
.side { overflow: hidden; }
.side nav { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; margin: 0 -4px; padding: 0 4px; }
.side nav::-webkit-scrollbar { width: 6px; }
.side nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 3px; }
.side-foot { flex: none; }
.main:has(.inbox) { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.main:has(.inbox) > .inbox { flex: 1; min-height: 0; height: auto; }
.inbox-list, .inbox-chat { min-height: 0; overflow: hidden; }
.bubble { white-space: normal; }
.bubble .msg-text { white-space: pre-wrap; word-break: break-word; }
.bubble .time { white-space: nowrap; }
.who-line { font-size: .76rem; color: var(--muted); margin-top: 4px; }
.who-cell { font-size: .82rem; min-width: 190px; }
.cat-list { list-style: none; margin: 0 0 14px; padding: 0; }
.cat-list li { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.cat-list li:first-child { border-top: 0; }
.cat-name { font-weight: 700; flex: 1; }
.cat-del { display: flex; gap: 6px; align-items: center; }
.cat-del select { width: auto; padding: 5px 8px; font-size: .84rem; }
.cat-add input { max-width: 340px; }
@media (max-width: 860px) {
  .side { overflow: visible; }
  .side nav { overflow: visible; }
  .main:has(.inbox) { height: calc(100vh - 60px); }
}

/* ============ Message gaya ya nahi ============ */
.ticks { margin-left: 4px; font-weight: 700; }
.ticks.ok { color: #34B7F1; letter-spacing: -2px; }
.ticks.ok em { font-style: normal; letter-spacing: 0; color: var(--muted); font-size: .66rem; margin-left: 4px; }
.ticks.bad { color: var(--danger); }
.bubble.failed { box-shadow: 0 0 0 2px var(--danger); }
.resend { align-self: flex-end; max-width: 72%; display: flex; gap: 8px; align-items: center; background: var(--danger-soft); color: var(--danger); font-size: .8rem; font-weight: 600; padding: 6px 10px; border-radius: 7px; }
.resend span { flex: 1; }
#order { scroll-margin-top: 20px; }
.ticks.ok { font-size: .85rem; } .ticks.ok em { font-size: .68rem; }

/* ============ Popup (toast) messages ============ */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 10px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 12px 12px 12px 14px; border-radius: var(--r-md); background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-left: 5px solid var(--brand); box-shadow: 0 10px 30px rgba(0,0,0,.18); font-size: .9rem; font-weight: 600; animation: toast-in .22s ease-out; }
.toast.err { border-left-color: var(--danger); }
.toast.ok .ic { color: var(--brand); }
.toast.err .ic { color: var(--danger); }
.toast span { flex: 1; line-height: 1.45; }
.toast-x { background: none; border: 0; font-size: 1.3rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.toast-x:hover { color: var(--ink); }
.toast.hide { opacity: 0; transform: translateX(20px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@media (max-width: 860px) { .toasts { top: auto; bottom: 16px; right: 16px; left: 16px; width: auto; } }

.hook-check { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; font-size: .9rem; display: flex; flex-direction: column; gap: 6px; }
.hook-result { font-weight: 700; }

.test-banner { display: block; margin: 0 18px 10px; padding: 8px 12px; border-radius: var(--r-sm); background: var(--saffron-soft); color: var(--saffron-ink); font-size: .8rem; font-weight: 700; text-decoration: none; line-height: 1.4; }
.test-banner:hover { text-decoration: underline; }
.test-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 18px; background: var(--saffron-soft); color: var(--saffron-ink); font-size: .84rem; font-weight: 700; border-bottom: 1px solid var(--line); }
.test-bar span { flex: 1; min-width: 200px; }

/* ============ Ek number = ek chat ============ */
.sess-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: .68rem; font-weight: 800; vertical-align: 1px; }
.session-sep { align-self: stretch; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; text-align: center; margin: 12px 0 4px; padding: 6px 10px; border-top: 1px dashed color-mix(in srgb, var(--ink) 25%, transparent); font-size: .78rem; color: var(--muted); }
.session-sep b { color: var(--ink); }
.session-sep .sep-sum { flex-basis: 100%; font-style: italic; }
.session-sep a { font-weight: 700; }

.meta .timing { color: var(--muted); font-size: .78rem; font-weight: 600; }
.warn-text { color: var(--danger) !important; font-weight: 700 !important; }

/* ============ Inbox list: zyada jagah ============ */
.inbox-list-head { padding: 16px 18px 8px; gap: 8px; }
.inbox-list-head .row-actions { flex-wrap: nowrap; }
.test-chip { font-size: .74rem; font-weight: 800; text-decoration: none; padding: 4px 9px; border-radius: 12px; background: var(--saffron-soft); color: var(--saffron-ink); white-space: nowrap; }
.inbox-filters { padding: 0 18px 10px; gap: 6px; }
.more-filters { display: flex; flex-direction: column; gap: 6px; }
.more-filters[hidden] { display: none; }
.load-more { padding: 14px; text-align: center; }
.test-bar { padding: 6px 18px; font-size: .8rem; }
.test-bar span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ Sidebar chhota (sirf icon) ============ */
.side-toggle { background: none; border: 0; color: var(--side-ink); padding: 6px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; margin-bottom: 18px; transition: transform .2s; }
.side-toggle:hover { background: var(--side-hover); color: #fff; }
.side-top { align-items: flex-start; }
html.side-mini .shell { grid-template-columns: 72px 1fr; }
html.side-mini .side { padding: 18px 10px; }
html.side-mini .brand > span:not(.brand-mark),
html.side-mini .nav-group,
html.side-mini .side nav a span,
html.side-mini .who,
html.side-mini .sound-btn { display: none; }
html.side-mini .brand { padding: 4px 0 10px; justify-content: center; }
html.side-mini .side-top { flex-direction: column; align-items: center; gap: 4px; }
html.side-mini .side-toggle { transform: rotate(180deg); margin-bottom: 10px; }
html.side-mini .side nav a { justify-content: center; padding: 10px 0; position: relative; }
html.side-mini .side nav a .badge { position: absolute; top: 2px; right: 4px; min-width: 16px; height: 16px; font-size: .62rem; padding: 0 4px; }
html.side-mini .side-foot { flex-direction: column; gap: 6px; padding: 10px 0 0; }
@media (max-width: 860px) {
  .side-toggle { display: none; }
  html.side-mini .shell { grid-template-columns: 1fr; }
  html.side-mini .side nav a span, html.side-mini .nav-group, html.side-mini .brand > span:not(.brand-mark), html.side-mini .who { display: revert; }
}

/* ============ Pages (1 2 3 Next) ============ */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: .86rem; }
.pager-info { color: var(--muted); font-weight: 600; }
.pager-pages { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.pg { min-width: 32px; height: 32px; padding: 0 10px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 700; background: var(--surface); }
a.pg:hover { border-color: var(--brand); color: var(--brand); }
.pg.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.pg-gap { color: var(--muted); padding: 0 2px; }
.pager-size { flex-direction: row; align-items: center; gap: 6px; font-weight: 600; color: var(--muted); font-size: .84rem; }
.pager-size select { width: auto; padding: 5px 8px; }
.older-btn { align-self: center; font-size: .8rem; font-weight: 700; text-decoration: none; background: var(--surface); color: var(--brand); padding: 6px 14px; border-radius: 14px; margin-bottom: 6px; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ============ Chat ke andar dhoondho ============ */
.chat-find { display: flex; align-items: center; gap: 4px; }
.chat-find input { width: 180px; padding: 6px 10px; font-size: .84rem; border-radius: 16px; }
.chat-find .btn { padding: 4px 9px; }
mark.find { background: #FFE28A; color: inherit; border-radius: 3px; padding: 0 1px; }
mark.find.cur { background: var(--saffron); color: #2B1B03; }
@media (max-width: 860px) { .chat-find { order: 3; flex-basis: 100%; } .chat-find input { flex: 1; width: auto; } }

/* ============ Chat ke liye zyada jagah ============ */
.chat-top { padding: 8px 14px; gap: 10px; flex-wrap: nowrap; }
.chat-top .conv-avatar { width: 36px; height: 36px; }
.chat-top-name { min-width: 0; overflow: hidden; }
.chat-top-name small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-actions { flex: none; flex-wrap: nowrap; gap: 4px; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: 8px; width: 34px; height: 34px; display: inline-grid; place-items: center; cursor: pointer; font-size: 1rem; color: var(--ink); list-style: none; }
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); }
summary.icon-btn::-webkit-details-marker { display: none; }
.more-menu { position: relative; }
.more-menu .menu { position: absolute; right: 0; top: 38px; z-index: 20; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: 6px; min-width: 190px; }
.menu-item { width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 6px; font: inherit; font-weight: 600; cursor: pointer; color: var(--ink); }
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--danger); }
.chat-find { display: flex; padding: 6px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.chat-find[hidden] { display: none; }
.chat-find input { flex: 1; width: auto; max-width: 360px; }
.analysis-wrap { background: var(--surface); border-bottom: 1px solid var(--line); }
.analysis-wrap > summary { cursor: pointer; padding: 7px 14px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: .84rem; list-style: none; }
.analysis-wrap > summary::-webkit-details-marker { display: none; }
.analysis-wrap > summary::before { content: "▸"; color: var(--muted); }
.analysis-wrap[open] > summary::before { content: "▾"; }
.analysis-wrap .sum-title { font-weight: 800; }
.analysis-wrap .analysis { border-bottom: 0; padding-top: 4px; max-height: 45vh; overflow-y: auto; }
html.chat-wide .inbox { grid-template-columns: 1fr; }
html.chat-wide .inbox-list { display: none; }
#wideToggle { font-size: .95rem; }
html.chat-wide #wideToggle { background: var(--brand-soft); color: var(--brand); }
@media (max-width: 860px) { #wideToggle { display: none; } .chat-top { flex-wrap: wrap; } }
.close-menu > summary { list-style: none; cursor: pointer; }
.close-menu > summary::-webkit-details-marker { display: none; }
.close-form { display: flex; flex-direction: column; gap: 8px; min-width: 280px; padding: 12px; }
.close-form .check { padding: 0; font-weight: 500; font-size: .86rem; }
.close-info { font-size: .84rem; color: var(--muted); }
.close-info b { color: var(--ink); }
.analysis .resend { align-self: stretch; max-width: none; }

/* ============ Sidebar chhota ho ya bada: content poori jagah le, beech mein rahe ============ */
.main { max-width: 1440px; margin-inline: auto; padding-left: clamp(16px, 3vw, 40px); padding-right: clamp(16px, 3vw, 40px); }
.main:has(.inbox) { max-width: none; margin: 0; padding: 0; }
/* Lambe padhne wale form zyada chaude na hon */
.form.narrow, .login-card { max-width: 440px; }
.page-head p { max-width: 80ch; }
/* Badi screen par boxes zyada ek line mein */
@media (min-width: 1500px) {
  .stats-wide { grid-template-columns: repeat(8, 1fr); }
  .wa-tiles { grid-template-columns: repeat(4, 1fr); }
}
.cta-card { margin-bottom: 22px; }

/* ============ Mobile: kuch bhi screen se bahar na jaye ============ */
.shell > .main, .side, .panel, .cols > *, .grid2 > *, .table-wrap { min-width: 0; }
.table-wrap { max-width: 100%; }
@media (max-width: 860px) {
  .table-wrap { margin: 0; }
  table { font-size: .84rem; }
  th, td { padding: 9px 6px; }
  .report-table td, .report-table th { white-space: nowrap; }
  .filters, .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .filters a, .tabs a { flex: none; }
  .panel-head { align-items: flex-start; }
  .chat-top-name small { white-space: normal; }
  .pager { justify-content: center; }
  .pager-info { width: 100%; text-align: center; }
  .wa-tiles { grid-template-columns: 1fr 1fr; }
  .copy-row input { font-size: .78rem; }
  .qr-box { padding: 12px; }
  .toasts { left: 10px; right: 10px; bottom: 10px; }
  .composer { padding: 8px; }
  .bubble { max-width: 85%; }
  h1 { font-size: 1.35rem; }
  .cust-head { gap: 10px; }
  .conv-avatar.big { width: 48px; height: 48px; font-size: 1.2rem; }
}
@media (max-width: 860px) {
  /* Phone par "chhota sidebar" setting ka asar nahi: upar normal patti */
  html.side-mini .side { padding: 10px 12px; }
  html.side-mini .side-top { flex-direction: row; align-items: center; justify-content: space-between; gap: 0; }
  html.side-mini .brand { justify-content: flex-start; padding: 4px; }
  html.side-mini .brand > span:not(.brand-mark) { display: block; }
  html.side-mini .side nav a { justify-content: flex-start; padding: 6px 10px; }
  html.side-mini .side-foot { flex-direction: row; }
}

/* ============ Saaf, gehre rang (aankhon ko aaram, border saaf dikhe) ============ */
:root {
  --bg: #ECF0EE;
  --surface-2: #F5F8F7;
  --line: #CFDAD6;
  --line-strong: #B8C7C2;
  --muted: #4C5F5A;
  --ink: #0F2420;
  --shadow: 0 1px 2px rgba(15,36,32,.06), 0 6px 18px rgba(15,36,32,.07);
}
@media (prefers-color-scheme: dark) {
  :root { --line: #2E3D39; --line-strong: #3E504B; --muted: #A3B5AF; --surface-2: #1C2A26; }
}
.panel, .stat, .kpi, .wa-tile, .chat-wrap { border-color: var(--line); box-shadow: var(--shadow); }
input, select, textarea { border-color: var(--line-strong); }
th { color: var(--muted); }
th, td { border-top-color: var(--line); }
.btn { border-color: var(--line-strong); }

/* ============ Naya dashboard ============ */
.dash-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.dash-top h1 { margin: 0; }
.dash-top p { margin: 2px 0 0; }
.dash-section { font-size: 1rem; margin: 22px 0 12px; }
.dash-section .muted { font-weight: 600; }
.ready-strip { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--r-lg); background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent); flex-wrap: wrap; }
.ready-strip span:nth-child(2) { flex: 1; }
.ready-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: #fff; font-weight: 800; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi { position: relative; display: grid; grid-template-columns: 42px 1fr; grid-template-rows: auto auto auto; column-gap: 12px; align-items: center; padding: 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); transition: transform .15s, box-shadow .15s, border-color .15s; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--k); }
a.kpi:hover { transform: translateY(-2px); border-color: var(--k); box-shadow: 0 10px 24px rgba(15,36,32,.10); }
.kpi-ico { grid-row: 1 / span 3; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--k) 14%, transparent); color: var(--k); }
.kpi-ico svg { width: 22px; height: 22px; }
.kpi-label { font-size: .82rem; font-weight: 700; color: var(--muted); }
.kpi b { font-size: 1.75rem; font-weight: 800; line-height: 1.15; letter-spacing: -0.02em; }
.kpi small { font-size: .76rem; color: var(--muted); font-weight: 600; }
.kpi.hot { background: color-mix(in srgb, var(--k) 8%, var(--surface)); border-color: var(--k); }
.kpi.hot b { color: var(--k); }
.k-blue { --k: #2563EB; } .k-green { --k: #12805C; } .k-amber { --k: #C27C0E; } .k-orange { --k: #E0661B; }
.k-purple { --k: #7C3AED; } .k-rose { --k: #DB2777; } .k-red { --k: #D92D20; } .k-slate { --k: #52677F; }
@media (prefers-color-scheme: dark) {
  .k-blue { --k: #60A5FA; } .k-green { --k: #34D399; } .k-amber { --k: #FBBF24; } .k-orange { --k: #FB923C; }
  .k-purple { --k: #A78BFA; } .k-rose { --k: #F472B6; } .k-red { --k: #F87171; } .k-slate { --k: #94A3B8; }
}
.quick .kpi-ico { grid-row: auto; }
.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-top: 16px; }
.dash-grid .panel { margin: 0; }
.conv-big { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 6px 0 12px; }
.conv-big b { font-size: 2.4rem; font-weight: 800; color: var(--brand); letter-spacing: -0.03em; }
.conv-big span { color: var(--muted); font-weight: 600; }
.conv-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--line); }
.cb-ok { background: var(--brand); }
.cb-lost { background: #E8A33D; }
.conv-legend { display: flex; gap: 18px; margin-top: 10px; font-size: .85rem; color: var(--muted); flex-wrap: wrap; }
.conv-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.lg-ok { background: var(--brand); } .lg-lost { background: #E8A33D; }
.quick-panel { display: flex; flex-direction: column; gap: 8px; }
.quick-panel h2 { margin-bottom: 6px; }
.quick { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-md); border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.quick:hover { border-color: var(--brand); background: var(--surface-2); }
.quick > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.quick small { color: var(--muted); font-size: .8rem; }
.quick em { font-style: normal; color: var(--muted); font-size: 1.3rem; }
.quick.need { border-color: #E8A33D; background: var(--saffron-soft); }
.kpis-4 { grid-template-columns: repeat(4, 1fr); }
@media (min-width: 1500px) { .kpis:not(.kpis-4) { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } .dash-grid { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .kpi { grid-template-columns: 36px 1fr; padding: 12px; } .kpi-ico { width: 36px; height: 36px; } .kpi b { font-size: 1.4rem; } }

/* ============ Apna confirm popup ============ */
.modal-wrap { position: fixed; inset: 0; z-index: 200; background: rgba(10,20,18,.45); display: grid; place-items: center; padding: 20px; animation: fade .15s ease-out; }
.modal-wrap.out { opacity: 0; transition: opacity .15s; }
.modal { background: var(--surface); color: var(--ink); border-radius: 16px; padding: 22px; width: min(420px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.3); text-align: center; animation: pop-in .18s ease-out; }
.modal-ico { width: 44px; height: 44px; border-radius: 50%; margin: 0 auto 10px; display: grid; place-items: center; background: var(--saffron-soft); color: var(--saffron-ink); font-weight: 900; font-size: 1.3rem; }
.modal-msg { margin: 0 0 18px; font-weight: 600; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-actions .btn { min-width: 120px; justify-content: center; }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.95); } }

/* ============ Ho raha hai ============ */
.btn.busy, button.busy { opacity: .7; cursor: progress; }

/* ============ Customer avatar ke rang ============ */
.conv-avatar.hue { background: hsl(var(--h) 70% 92%); color: hsl(var(--h) 55% 28%); }
html[data-theme="dark"] .conv-avatar.hue { background: hsl(var(--h) 35% 22%); color: hsl(var(--h) 70% 80%); }
@media (prefers-color-scheme: dark) { html:not([data-theme="light"]) .conv-avatar.hue { background: hsl(var(--h) 35% 22%); color: hsl(var(--h) 70% 80%); } }

/* ============ Khaali jagah ============ */
.empty-state { text-align: center; padding: 34px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-state .es-ico { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); font-size: 1.6rem; }
.empty-state b { color: var(--ink); font-size: 1rem; }
.empty-state p { margin: 0; max-width: 44ch; }
.empty-state .btn { margin-top: 6px; }

/* ============ Ek jaisa design: purane boxes bhi naye jaise ============ */
.stat, .wa-tile, .analysis-grid > div { position: relative; overflow: hidden; border: 1px solid var(--line); }
.stat::before, .wa-tile::before, .analysis-grid > div::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--k, var(--line-strong)); }
.analysis-grid > div { background: var(--surface); border-radius: var(--r-md); padding: 8px 12px 8px 14px; }
.wa-tile b.ok-text { color: var(--k-ok, var(--brand)); }
.wa-tile.st-good { --k: #12805C; } .wa-tile.st-warn { --k: #C27C0E; } .wa-tile.st-bad { --k: #D92D20; } .wa-tile.st-off { --k: #8A9A96; }
.wa-tile.st-bad { background: color-mix(in srgb, #D92D20 6%, var(--surface)); }
.wa-tile.st-bad b { color: #D92D20; }
.wa-tile.st-warn b { color: #C27C0E; }
.wa-tile .st-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--k); margin-right: 6px; vertical-align: 1px; }

/* ============ Dark / Light khud chuno (computer ki setting ke upar) ============ */
html[data-theme="light"] {
  color-scheme: light;
  --side: #0C2E28; --side-ink: #B9D3CB; --bg: #ECF0EE; --surface: #FFFFFF; --surface-2: #F5F8F7; --ink: #0F2420; --muted: #4C5F5A;
  --line: #CFDAD6; --line-strong: #B8C7C2; --brand: #128062; --brand-dark: #0D6650; --brand-soft: #E3F3EC;
  --saffron-soft: #FDF1DC; --saffron-ink: #7A4B07; --danger: #C2412D; --danger-soft: #FBE7E2;
  --chat-bg: #ECE5DD; --bubble-user: #D9FDD3; --bubble-bot: #FFFFFF;
  --shadow: 0 1px 2px rgba(15,36,32,.06), 0 6px 18px rgba(15,36,32,.07);
}
html[data-theme="light"] .k-blue { --k: #2563EB; } html[data-theme="light"] .k-green { --k: #12805C; } html[data-theme="light"] .k-amber { --k: #C27C0E; }
html[data-theme="light"] .k-orange { --k: #E0661B; } html[data-theme="light"] .k-purple { --k: #7C3AED; } html[data-theme="light"] .k-rose { --k: #DB2777; }
html[data-theme="light"] .k-red { --k: #D92D20; } html[data-theme="light"] .k-slate { --k: #52677F; }
html[data-theme="dark"] {
  color-scheme: dark;
  --side: #08110F; --side-ink: #95ABA4; --bg: #0F1715; --surface: #16211E; --surface-2: #1C2A26; --ink: #E4EEEA; --muted: #A3B5AF;
  --line: #2E3D39; --line-strong: #3E504B; --brand: #2BB38A; --brand-dark: #24997A; --brand-soft: #143A2F;
  --saffron-soft: #3A2B12; --saffron-ink: #F3C77E; --danger: #EF7A64; --danger-soft: #3A1E19;
  --chat-bg: #0B1412; --bubble-user: #005C4B; --bubble-bot: #1F2C33; --shadow: none;
}
html[data-theme="dark"] .k-blue { --k: #60A5FA; } html[data-theme="dark"] .k-green { --k: #34D399; } html[data-theme="dark"] .k-amber { --k: #FBBF24; }
html[data-theme="dark"] .k-orange { --k: #FB923C; } html[data-theme="dark"] .k-purple { --k: #A78BFA; } html[data-theme="dark"] .k-rose { --k: #F472B6; }
html[data-theme="dark"] .k-red { --k: #F87171; } html[data-theme="dark"] .k-slate { --k: #94A3B8; }
.theme-btn { font-size: .95rem; }
.wa-tabs { position: sticky; top: 0; z-index: 5; background: var(--bg); padding-top: 4px; }
section[data-tab][hidden] { display: none; }

/* ============ Reports tab ke rang ============ */
.report-tabs a { display: inline-flex; align-items: center; gap: 6px; }
.tab-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--k); display: inline-block; }
.report-tabs a.on { border-bottom-color: var(--k); }

/* ============ Graph ============ */
.chart-panel { margin-top: 16px; }
.bars { display: flex; gap: 4px; align-items: stretch; height: 180px; padding-top: 8px; }
.bar-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.bar-area { position: relative; flex: 1; border-bottom: 1px solid var(--line-strong); }
.bar-chat, .bar-ord { position: absolute; bottom: 0; left: 12%; right: 12%; border-radius: 5px 5px 0 0; }
.bar-chat { background: color-mix(in srgb, #2563EB 28%, transparent); }
.bar-ord { background: var(--brand); left: 30%; right: 30%; }
.bar-area em { position: absolute; left: 0; right: 0; text-align: center; font-style: normal; font-size: .7rem; font-weight: 800; color: var(--muted); }
.bar-col small { text-align: center; font-size: .68rem; color: var(--muted); font-weight: 700; white-space: nowrap; overflow: hidden; }
.bar-col:hover .bar-chat { background: color-mix(in srgb, #2563EB 45%, transparent); }
.lg-chat { background: color-mix(in srgb, #2563EB 35%, transparent); }

/* ============ Ready jawab ============ */
.quick-replies { flex: none; }
.quick-replies .menu { bottom: 44px; top: auto; left: 0; right: auto; width: min(360px, 80vw); max-height: 320px; overflow-y: auto; }
.qr-menu .menu-item { display: flex; flex-direction: column; gap: 2px; }
.qr-menu .menu-item small { color: var(--muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.qr-menu a.menu-item { text-decoration: none; color: var(--brand); }

/* Dark mode (computer ki setting se): upar wale "gehre rang" light tokens ko dark se badlo */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    color-scheme: dark;
    --side: #08110F; --side-ink: #95ABA4; --bg: #0F1715; --surface: #16211E; --surface-2: #1C2A26; --ink: #E4EEEA; --muted: #A3B5AF;
    --line: #2E3D39; --line-strong: #3E504B; --brand: #2BB38A; --brand-dark: #24997A; --brand-soft: #143A2F;
    --saffron-soft: #3A2B12; --saffron-ink: #F3C77E; --danger: #EF7A64; --danger-soft: #3A1E19;
    --chat-bg: #0B1412; --bubble-user: #005C4B; --bubble-bot: #1F2C33; --shadow: none;
  }
}
.inline-check { display: flex; align-items: center; gap: 6px; } .inline-check .small { font-weight: 600; color: var(--muted); }

/* ============ Bot Exam ============ */
.exam-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.exam-progress { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 240px; }
.exam-hist { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.exam-hist small { font-weight: 500; opacity: .8; }
.exam-list { display: flex; flex-direction: column; gap: 10px; }
.exam-item { display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line-strong); border-radius: var(--r-md); padding: 12px 14px; box-shadow: var(--shadow); scroll-margin-top: 20px; }
.exam-item.pass { border-left-color: #12805C; }
.exam-item.fail { border-left-color: #D92D20; }
.exam-status { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 900; background: var(--surface-2); color: var(--muted); }
.exam-item.pass .exam-status { background: #DFF5E6; color: #12805C; }
.exam-item.fail .exam-status { background: #FBE4E1; color: #D92D20; }
.exam-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.exam-edit input { font-size: .9rem; padding: 7px 10px; }
.exam-ans { font-size: .88rem; background: var(--surface-2); border-radius: var(--r-sm); padding: 8px 10px; }
.exam-reason { font-size: .84rem; font-weight: 700; color: var(--muted); }
.exam-item.fail .exam-reason { color: var(--danger); }
.fix-tip { margin: 0; }
.exam-edit { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
@media (max-width: 860px) { .exam-edit { grid-template-columns: 1fr; } }

/* ============ Tools / Orders ============ */
.api-list { display: flex; flex-direction: column; gap: 8px; }
.api-row { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); }
.api-row.pending { opacity: .6; border-style: dashed; }
.api-info { min-width: 220px; }
.api-test { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.api-test input { width: 170px; padding: 6px 9px; font-size: .84rem; }
.api-raw { max-height: 380px; overflow: auto; font-family: ui-monospace, Consolas, monospace; font-size: .78rem; }
.order-cards { display: flex; flex-direction: column; gap: 12px; }
.order-card { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line-strong); border-radius: var(--r-md); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.order-card.new { border-left-color: #E8A33D; } .order-card.placed { border-left-color: #12805C; } .order-card.cancel { border-left-color: #8A9A96; opacity: .8; }
.oc-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.oc-actions { display: flex; flex-direction: column; gap: 8px; border-top: 1px dashed var(--line); padding-top: 10px; }
.oc-actions .inline input { max-width: 300px; }

.small-strip { margin: 0 0 14px; font-size: .88rem; }
.warn-bar { background: #C27C0E; }
.bubble.wait-msg { opacity: .8; font-style: italic; }

/* ============ Bot ki sehat ============ */
.health { padding: 0; margin-bottom: 4px; }
.health > summary { display: flex; align-items: center; gap: 10px; padding: 14px 18px; cursor: pointer; list-style: none; flex-wrap: wrap; }
.health > summary::-webkit-details-marker { display: none; }
.health[open] > summary { border-bottom: 1px solid var(--line); }
.health-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--line-strong); box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 0%, transparent); }
.health-dot.good { background: #12805C; } .health-dot.warn { background: #E8A33D; } .health-dot.bad { background: #D92D20; } .health-dot.off { background: #A7B4B0; }
summary .health-dot.bad { animation: pulse-dot 1.4s infinite; }
@keyframes pulse-dot { 50% { box-shadow: 0 0 0 6px rgba(217,45,32,.18); } }
.health-group { padding: 10px 18px 12px; display: flex; flex-direction: column; gap: 6px; }
.health-group + .health-group { border-top: 1px dashed var(--line); }
.health-group h3 { margin: 4px 0; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.health-row { display: grid; grid-template-columns: 14px minmax(140px, 200px) 1fr auto; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 8px; font-size: .88rem; }
.health-row.bad { background: color-mix(in srgb, #D92D20 7%, transparent); }
.health-row.warn { background: color-mix(in srgb, #E8A33D 9%, transparent); }
.h-name { font-weight: 700; }
.h-detail { color: var(--muted); min-width: 0; }
.health-row.bad .h-detail { color: var(--danger); font-weight: 600; }
@media (max-width: 700px) { .health-row { grid-template-columns: 14px 1fr; } .h-detail, .health-row .btn { grid-column: 2; } .health-row .btn { justify-self: start; } }
.ready-strip + .health, .setup + .health, .down-bar + .health { margin-top: 14px; }

/* ============ Bot ki sehat: chhoti patti ============ */
.hbar { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid #12805C; border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 10px 14px; margin: 0 0 6px; display: flex; flex-direction: column; gap: 8px; }
.hbar.warn { border-left-color: #E8A33D; } .hbar.bad { border-left-color: #D92D20; }
.hbar-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hchips { display: flex; gap: 6px; flex-wrap: wrap; }
.hchip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 5px 10px; border-radius: 16px; font-size: .8rem; text-decoration: none; color: var(--ink); border: 1px solid var(--line); background: var(--surface-2); }
.hchip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; color: var(--muted); }
.hchip.bad { background: color-mix(in srgb, #D92D20 8%, var(--surface)); border-color: color-mix(in srgb, #D92D20 35%, transparent); }
.hchip.bad span:last-child { color: var(--danger); font-weight: 600; }
.hchip.warn { background: color-mix(in srgb, #E8A33D 10%, var(--surface)); border-color: color-mix(in srgb, #E8A33D 40%, transparent); }
.hchip:hover { border-color: var(--brand); }
.hchip .health-dot, .hitem .health-dot { width: 9px; height: 9px; }
.hgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 18px; padding-top: 8px; border-top: 1px dashed var(--line); }
.hgrid[hidden] { display: none; }
.hcol { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hcol h3 { margin: 2px 0 4px; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.hitem { display: grid; grid-template-columns: 10px auto 1fr; gap: 8px; align-items: center; padding: 4px 6px; border-radius: 6px; font-size: .82rem; text-decoration: none; color: var(--ink); min-width: 0; }
.hitem:hover { background: var(--surface-2); }
.hi-name { font-weight: 700; white-space: nowrap; }
.hi-detail { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hitem.bad .hi-detail { color: var(--danger); }
@media (max-width: 1100px) { .hgrid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .hgrid { grid-template-columns: 1fr; } .hchip span:last-child { max-width: 28ch; } }
.hbar + .dash-section { margin-top: 18px; }
.setup + .hbar, .down-bar + .hbar { margin-top: 14px; }

/* ============ Tasks / Agents ============ */
.row-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.task-list, .agent-list { display: flex; flex-direction: column; gap: 12px; }
.task-card, .agent-card { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid #E8A33D; border-radius: var(--r-md); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; scroll-margin-top: 20px; }
.task-card.src-api_error { border-left-color: #D92D20; }
.task-card.src-order_request { border-left-color: #12805C; }
.task-card.done { border-left-color: #8A9A96; opacity: .9; }
.tc-head, .ag-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tc-head a.mono { text-decoration: none; font-weight: 700; color: var(--brand); }
.tc-reason { margin: 0; font-size: .9rem; }
.tc-result { margin: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tc-done > summary { cursor: pointer; font-weight: 700; color: var(--brand); padding: 4px 0; }
.tc-done form { margin-top: 10px; }
.agent-card { border-left-color: var(--brand); }
.agent-card.off { opacity: .6; border-left-color: #8A9A96; }
.ag-forms { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.ag-forms input { width: 160px; padding: 6px 9px; font-size: .84rem; }
.report-table tr.sel td { background: var(--brand-soft); }
.good-text { color: var(--brand); font-weight: 800; }

.app-ver { font-size: .7rem; font-weight: 800; color: var(--side-ink); opacity: .7; padding: 2px 6px; border: 1px solid currentColor; border-radius: 8px; }
html.side-mini .app-ver { display: none; }

/* ============ Order tests ============ */
.sc-log { display: flex; flex-direction: column; gap: 6px; }
.sc-line { border: 1px solid var(--line); border-left: 4px solid #12805C; border-radius: 8px; padding: 8px 10px; font-size: .86rem; display: flex; flex-direction: column; gap: 4px; }
.sc-line.bad { border-left-color: #D92D20; background: color-mix(in srgb, #D92D20 5%, var(--surface)); }
.sc-sent { font-weight: 700; }
.sc-reply { color: var(--muted); white-space: pre-wrap; }
.sc-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.fix-box summary { cursor: pointer; font-size: .8rem; font-weight: 700; color: var(--accent); }
.fix-box textarea { width: 100%; margin: 6px 0; font: inherit; font-size: .85rem; }
.fix-box { margin-bottom: 4px; }
.fix-modes { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.bad-text { color: #B42318; font-weight: 700; }
.team-today { width: 100%; border-collapse: collapse; font-size: .88rem; }
.team-today th, .team-today td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.team-today .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #98A2B3; margin-right: 6px; }
.team-today .dot.on { background: #12B76A; }
.wait-panel { border-left: 4px solid #F79009; }
.wait-row { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; font-size: .88rem; }
.wait-row.warn b { color: #B54708; } .wait-row.late b { color: #B42318; }
.wait-row .grow { flex: 1; min-width: 120px; }
.kpis-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 900px) { .kpis-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.todo.start b { color: #B54708; }
.chat-row { text-decoration: none; color: inherit; }
.chat-row:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
/* Neeche naam wala gol nishaan (sidebar par saaf dikhe) */
.me-avatar { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--saffron, #F59E0B); color: #2B1B03; font-weight: 800; font-size: .85rem; line-height: 1; }
.side-foot .theme-btn { color: var(--side-ink); display: grid; place-items: center; }
html.side-mini .me-avatar { width: 28px; height: 28px; }

/* ============ Sidebar: saaf teal rang (light aur dark dono mein, kaala nahi) ============ */
:root { --side-grad: linear-gradient(180deg, #0F4C45 0%, #12665C 100%); --side-ink: #CFE6DF; --side-hover: rgba(255,255,255,.09); }
html[data-theme="light"] { --side-grad: linear-gradient(180deg, #0F4C45 0%, #12665C 100%); --side-ink: #CFE6DF; }
html[data-theme="dark"] { --side-grad: linear-gradient(180deg, #16302F 0%, #1B4442 100%); --side-ink: #BFD8D2; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --side-grad: linear-gradient(180deg, #16302F 0%, #1B4442 100%); --side-ink: #BFD8D2; } }
.side { background: var(--side-grad, var(--side)); }
.side nav a.on { background: rgba(255,255,255,.12); }

/* ============ Neeche ka hissa: do line, logout hamesha dikhe ============ */
.side-foot { flex-wrap: wrap; row-gap: 8px; }
.side-foot .who { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foot-actions { flex: 1 0 100%; display: flex; align-items: center; gap: 6px; }
.foot-actions .logout-btn { margin-left: auto; display: flex !important; align-items: center; gap: 6px; padding: 6px 10px !important; border: 1px solid rgba(255,255,255,.18); border-radius: 8px; font-size: .82rem; font-weight: 700; text-decoration: none; }
.foot-actions .logout-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
html.side-mini .foot-actions { flex-direction: column; flex: 1 0 100%; }
html.side-mini .foot-actions .logout-btn { margin-left: 0; padding: 6px !important; }
html.side-mini .foot-actions .logout-btn span, html.side-mini .side-foot .who { display: none; }

/* ============ Panel ka look ============ */
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.preset { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); cursor: pointer; font: inherit; font-size: .82rem; font-weight: 700; color: var(--ink); }
.preset.on, .preset:hover { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 25%, transparent); }
.preset .pv { width: 100%; height: 38px; border-radius: 6px; display: flex; align-items: flex-end; gap: 4px; padding: 5px; box-sizing: border-box; }
.preset .pv i { width: 14px; height: 6px; border-radius: 3px; }
.row-color { display: flex; align-items: center; gap: 10px; }
.row-color input[type=color] { width: 56px; height: 36px; padding: 2px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.sample-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 16px 0 6px; padding: 12px; border: 1px dashed var(--line); border-radius: var(--r-md); }
.sample-row a { color: var(--brand); font-weight: 700; }
.ip-form { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px dashed var(--line); border-radius: var(--r-sm); }
.ip-form textarea { width: 100%; font-size: .82rem; }
.note.warn { background: var(--saffron-soft); color: var(--saffron-ink); padding: 10px 12px; border-radius: var(--r-sm); }
.ip-choice { border: 1px dashed var(--line); border-radius: var(--r-sm); padding: 10px 12px; margin: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.ip-choice legend { font-weight: 800; padding: 0 6px; }
.ip-own { display: flex; flex-direction: column; gap: 6px; }
.ip-own textarea { width: 100%; }
.ses-box { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 6px; }
.ses-box.many { border-color: #F79009; background: color-mix(in srgb, #F79009 7%, var(--surface)); }
.ses-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .85rem; }
.ses-row .grow { flex: 1; min-width: 120px; }

/* Agents kaard: sab ek ke neeche ek, IP ke option ek line mein */
.agent-card .ag-forms { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
.agent-card .ag-forms > form.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.agent-card .ag-forms > form.inline input { flex: 1; min-width: 150px; }
.agent-card .ip-form { order: 3; }
.ip-form label.inline-check, .ip-choice label.inline-check { display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; text-align: left; font-weight: 600; margin: 0; }
.ip-form label.inline-check input, .ip-choice label.inline-check input { width: auto; margin: 0; flex: none; }

/* ============ Agents: ek line = ek agent ============ */
.agent-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.agent-table th { text-align: left; font-size: .76rem; text-transform: none; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.agent-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.agent-table tr:hover td { background: color-mix(in srgb, var(--brand) 4%, transparent); }
.agent-table tr.sel td { background: color-mix(in srgb, var(--saffron) 14%, transparent); }
.agent-table tr.off td { opacity: .55; }
.agent-table .health-dot { margin-right: 6px; }
.agent-table .row-actions { white-space: nowrap; text-align: right; }
.agent-table .row-actions .btn { margin-left: 4px; }
.many-tag { background: color-mix(in srgb, #F79009 14%, transparent); color: #93370D; padding: 2px 6px; border-radius: 6px; font-weight: 700; }
.agent-form.editing { border: 2px solid var(--saffron); }
.agent-form .end .grow { flex: 1; }
.agent-table td { white-space: nowrap; }
.agent-table td:nth-child(4) { white-space: normal; min-width: 180px; }
.agent-table .row-actions .btn { padding: 4px 9px; font-size: .78rem; }
.agent-table .health-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #98A2B3; vertical-align: middle; }
.agent-table .health-dot.good { background: #12B76A; box-shadow: 0 0 0 3px color-mix(in srgb, #12B76A 20%, transparent); }
.agent-table .many-tag { font-size: .8rem; display: inline-block; }
.agent-table .tag { font-size: .74rem; }
.agent-table .row-actions { width: 1%; }
.agent-table .row-actions .btn { display: inline-flex; white-space: nowrap; float: none; }
.agent-table .row-actions { display: table-cell; }
.agent-table td.row-actions > * { vertical-align: middle; }
.opt-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; font-size: .9rem; }
.opt-row.off { border-left: 4px solid #F79009; background: color-mix(in srgb, #F79009 7%, var(--surface)); }
.code-box { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; overflow-x: auto; }
.code-box code { flex: 1; font-family: var(--mono, monospace); font-size: .85rem; white-space: nowrap; }
.nudge-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 8px; }
.nudge-stats > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.nudge-stats b { font-size: 1.4rem; }
.nudge-stats span { font-size: .78rem; color: var(--muted); }
@media (max-width: 700px) { .nudge-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ============ AI Providers ============ */
.prov-table td { vertical-align: top; }
.prov-table tr.off td { opacity: .55; }
.prov-table .nowrap { white-space: nowrap; }
.prov-bar { height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 4px 0; max-width: 160px; }
.prov-bar i { display: block; height: 100%; background: var(--brand); }
.prov-bar i.hot { background: #F79009; }
.model-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; max-height: 180px; overflow-y: auto; }
.model-chips span { border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; cursor: pointer; background: var(--surface-2); }
.model-chips span:hover { border-color: var(--brand); }
.prov-check label.inline-check { flex-direction: row; font-weight: 600; margin: 0; }
.prov-check label.inline-check input { width: auto; min-width: 0; flex: none; margin: 0; }
.prov-check label.inline-check input[name=time] { width: 80px; }

/* ============ Bot ki diary (Trace) ============ */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.trace-top { display: flex; flex-direction: column; gap: 10px; }
.trace-thread { max-width: 900px; }
.trace-box { margin: 2px 0 14px auto; max-width: 92%; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 8px 12px; }
.trace-box.bad { border-color: #D92D20; box-shadow: 0 0 0 2px color-mix(in srgb, #D92D20 18%, transparent); }
.trace-box > summary { cursor: pointer; font-weight: 700; font-size: .88rem; color: var(--brand); }
.trace-grid { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.tr-row { display: grid; grid-template-columns: 150px 1fr; gap: 10px; font-size: .86rem; align-items: start; }
.tr-row > b { color: var(--muted); font-size: .8rem; }
.tr-pre { white-space: pre-wrap; word-break: break-word; margin: 0; font-size: .78rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; max-height: 320px; overflow: auto; }
.trace-mark { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.trace-mark textarea { width: 100%; }
.trace-none { text-align: right; margin: -4px 0 10px; }
.why-link { margin-left: 6px; font-size: .72rem; text-decoration: none; opacity: .8; }
.why-link:hover { opacity: 1; text-decoration: underline; }
@media (max-width: 700px) { .tr-row { grid-template-columns: 1fr; gap: 2px; } .trace-box { max-width: 100%; } }
