/* ========== design tokens ========== */
:root {
  --bg: #f4f6fb; --surface: #ffffff; --surface-2: #f6f7fb; --surface-3: #eef1f7; --text: #101828; --text-2: #344054; --muted: #7a8599;
  --border: #e6e9f0; --border-strong: #d5dae4;
  --accent: #2b7de9; --accent-hover: #1f6bd3; --accent-soft: #e9f2fe; --accent-text: #1d5fbf;
  --red: #e5484d; --red-soft: #fdecec; --orange: #d97706; --orange-soft: #fef3e2; --green: #16a34a; --green-soft: #e7f6ec; --violet: #7c5cff; --violet-soft: #f0ecff;
  --bubble-in: #ffffff; --bubble-out: #e3f0ff; --chat-bg: #eef2f8; --mark: #fff0a6;
  --radius: 14px; --radius-sm: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06); --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, .25);
  --side: 236px;
  font: 14px/1.5 "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; color: var(--text);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116; --surface: #161a22; --surface-2: #1b2029; --surface-3: #222833; --text: #e8ebf1; --text-2: #c3c9d4; --muted: #8b95a7;
    --border: #262c37; --border-strong: #323a47; --accent: #4c8dff; --accent-hover: #6aa0ff; --accent-soft: #1c2a44; --accent-text: #8db6ff;
    --red: #ff6369; --red-soft: #3a1f23; --orange: #f5a524; --orange-soft: #36291a; --green: #3dd68c; --green-soft: #17322a; --violet: #9e8cff; --violet-soft: #272246;
    --bubble-in: #1e2430; --bubble-out: #23406e; --chat-bg: #10141b; --mark: #5a4d17; --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1116; --surface: #161a22; --surface-2: #1b2029; --surface-3: #222833; --text: #e8ebf1; --text-2: #c3c9d4; --muted: #8b95a7;
  --border: #262c37; --border-strong: #323a47; --accent: #4c8dff; --accent-hover: #6aa0ff; --accent-soft: #1c2a44; --accent-text: #8db6ff;
  --red: #ff6369; --red-soft: #3a1f23; --orange: #f5a524; --orange-soft: #36291a; --green: #3dd68c; --green-soft: #17322a; --violet: #9e8cff; --violet-soft: #272246;
  --bubble-in: #1e2430; --bubble-out: #23406e; --chat-bg: #10141b; --mark: #5a4d17; --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ========== base ========== */
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; margin: 0; }
h3 { font-size: 16px; font-weight: 600; margin: 0 0 10px; }
h4 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; }
h5 { font-size: 13px; margin: 0 0 6px; }
pre { white-space: pre-wrap; font: inherit; margin: 6px 0; }
code { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; font-size: 12px; }
mark { background: var(--mark); color: inherit; border-radius: 4px; padding: 0 3px; }
.ico { flex-shrink: 0; }
.muted { color: var(--muted); } .small { font-size: 12px; } .grow { flex: 1; } .pad { padding: 16px; } .center { display: block; margin: 8px auto; }
.danger-text { color: var(--red); } .warn-text { color: var(--orange); } .ok-text { color: var(--green); }
.wrap { white-space: normal; word-break: break-word; max-width: 360px; }
::selection { background: var(--accent-soft); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ========== controls ========== */
button, .button {
  font: inherit; font-weight: 500; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: var(--radius-sm);
  padding: 7px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: background .15s, border-color .15s, color .15s; line-height: 1.3;
}
button:hover, .button:hover { background: var(--surface-2); border-color: var(--border-strong); text-decoration: none; }
button:focus-visible, .button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { color: var(--red); border-color: transparent; background: var(--red-soft); }
button.ghost { border-color: transparent; background: transparent; }
button.ghost:hover { background: var(--surface-3); }
button.small, .button.small { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
button.link { border: 0; background: none; color: var(--accent-text); padding: 0; font-weight: 500; }
button.link:hover { text-decoration: underline; background: none; }
button.icon { border: 0; background: none; padding: 4px; color: var(--muted); border-radius: 8px; font-size: 18px; line-height: 1; }
button.icon:hover { background: var(--surface-3); color: var(--text); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
select { cursor: pointer; }

/* ========== app shell ========== */
.layout { display: flex; min-height: 100vh; }
.side {
  width: var(--side); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column;
  padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; gap: 2px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #37aee2, #1e96c8); }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: 0; }
.nav-item { display: flex; align-items: center; gap: 10px; color: var(--text-2); padding: 8px 10px; border-radius: 10px; font-weight: 500; position: relative; }
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item .ico { color: var(--muted); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); }
.nav-item.active .ico { color: var(--accent); }
.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; font-weight: 600; border-radius: 10px; padding: 0 7px; line-height: 18px; }
.nav-group { margin-top: 14px; }
.nav-group > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); border-radius: 8px; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { color: var(--text-2); }
.nav-group > summary .ico { transition: transform .2s; }
.nav-group:not([open]) > summary .ico { transform: rotate(-90deg); }
.me { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 12px 8px 4px; border-top: 1px solid var(--border); }
.me-row { display: flex; align-items: center; gap: 10px; }
.me-row b { display: block; font-size: 13px; } .me-row small { color: var(--muted); font-size: 12px; text-transform: capitalize; }
.me-actions { display: flex; gap: 4px; }
.me select { padding: 5px 8px; font-size: 12px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--muted); }
.status-dot.online { background: var(--green); } .status-dot.break { background: var(--orange); }

main { flex: 1; min-width: 0; padding: 28px 32px 40px; }
main > * { max-width: 1440px; margin-left: auto; margin-right: auto; }
main.full { padding: 0; height: 100vh; overflow: hidden; }
main.full > * { max-width: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .actions, .row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-actions { gap: 6px; }

/* ========== surfaces ========== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-head h3, .card-head h4 { margin: 0; }
.card.ai { background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%); border-color: color-mix(in srgb, var(--accent) 25%, var(--border)); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; color: var(--text); box-shadow: var(--shadow); min-width: 0; }
a.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 500; }
.tile-ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.tile b { font-size: 22px; font-weight: 650; letter-spacing: -.02em; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile small.sub { color: var(--muted); font-size: 12px; }
.tile.red .tile-ico { background: var(--red-soft); color: var(--red); } .tile.red b { color: var(--red); }
.tile.green .tile-ico { background: var(--green-soft); color: var(--green); } .tile.green b { color: var(--green); }
.tile.orange .tile-ico { background: var(--orange-soft); color: var(--orange); } .tile.orange b { color: var(--orange); }
.tile.violet .tile-ico { background: var(--violet-soft); color: var(--violet); }
.tile.compact b { font-size: 15px; white-space: normal; }
.section-title { display: flex; align-items: center; gap: 8px; margin: 26px 0 12px; font-size: 15px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 16px; }
.grid-360 { display: grid; grid-template-columns: minmax(340px, 420px) 1fr; gap: 16px; align-items: start; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.list-plain > div { padding: 6px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 8px; }
.list-plain > div:last-child { border-bottom: 0; }

/* ========== tables ========== */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .table-wrap { border: 0; box-shadow: none; border-radius: 0; margin: 0 -6px; }
table { border-collapse: separate; border-spacing: 0; width: 100%; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; }
.card th { background: transparent; }
th.sortable { cursor: pointer; user-select: none; } th.sortable:hover { color: var(--text); }
tr.clickable { cursor: pointer; } tbody tr:hover td { background: var(--surface-2); }
td.empty { text-align: center; color: var(--muted); padding: 36px; }
.cell-person { display: flex; align-items: center; gap: 10px; }
.cell-person b { display: block; font-weight: 600; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 14px 0; color: var(--text-2); }
.bar { position: relative; background: var(--surface-3); border-radius: 6px; height: 22px; min-width: 130px; overflow: hidden; }
.bar > div { background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 30%, transparent), color-mix(in srgb, var(--accent) 55%, transparent)); height: 100%; border-radius: 6px; }
.bar > span { position: absolute; left: 8px; top: 2px; font-size: 12px; font-weight: 500; }

/* ========== badges & chips ========== */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 500; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; line-height: 1.5; }
.badge.red, .badge.refunded, .badge.overdue { background: var(--red-soft); color: var(--red); }
.badge.orange, .badge.created { background: var(--orange-soft); color: var(--orange); }
.badge.green, .badge.paid, .badge.done { background: var(--green-soft); color: var(--green); }
.badge.blue { background: var(--accent-soft); color: var(--accent-text); }
.badge.soft { background: var(--accent-soft); color: var(--accent-text); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }
.badge.seg { background: transparent; border: 1px dashed var(--border-strong); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.chip { border-radius: 999px; padding: 4px 11px; font-size: 12.5px; background: var(--surface); border: 1px solid var(--border); color: var(--text-2); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .count { margin-left: 2px; font-size: 11px; opacity: .7; }
.chip.active .count { opacity: .9; }
.avatar { border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 600; flex-shrink: 0; letter-spacing: .02em; user-select: none; }

/* ========== forms ========== */
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px 16px; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.field.full { grid-column: 1 / -1; }
.field.inline { flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 10px; }
.field small { font-size: 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks label { display: flex; align-items: center; gap: 6px; font-size: 13px; border: 1px solid var(--border); padding: 4px 10px; border-radius: 999px; cursor: pointer; }
.checks label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.checks input { width: 14px; height: 14px; }
.filters { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.filters.compact { display: flex; gap: 10px; background: none; border: 0; padding: 0; margin: 0; box-shadow: none; }
.filters.compact .field { min-width: 150px; }
.filter-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.search-box { position: relative; flex: 1; min-width: 240px; max-width: 460px; }
.search-box .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box input { padding-left: 36px; }
.filter-box { margin-bottom: 16px; }
.filter-box > summary { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 500; margin-bottom: 10px; list-style: none; }
.filter-box > summary::-webkit-details-marker { display: none; }
.filter-box:not([open]) > summary { margin-bottom: 0; }

/* ========== tabs ========== */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab { border: 0; background: none; border-radius: 0; padding: 9px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tab:hover { background: none; color: var(--text); }
.tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }
.tab-count { background: var(--surface-3); color: var(--text-2); border-radius: 999px; font-size: 11px; padding: 0 6px; }

/* ========== modal & toast ========== */
.modal-wrap { position: fixed; inset: 0; background: rgba(8, 12, 20, .45); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding: 7vh 16px; z-index: 50; overflow-y: auto; animation: fade .15s ease-out; }
.modal { background: var(--surface); border-radius: 18px; width: 540px; max-width: 100%; box-shadow: var(--shadow-lg); border: 1px solid var(--border); animation: pop .18s ease-out; }
.modal.wide { width: 780px; }
.modal header, .modal footer { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; }
.modal header { border-bottom: 1px solid var(--border); }
.modal header h3 { margin: 0; font-size: 17px; }
.modal footer { border-top: 1px solid var(--border); justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 18px 18px; }
.modal-body { padding: 20px; max-height: 68vh; overflow-y: auto; }
@keyframes fade { from { opacity: 0; } } @keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 12px; max-width: 420px; box-shadow: var(--shadow-lg); font-weight: 500; animation: pop .2s ease-out; }
.toast.err { background: var(--red); color: #fff; }

/* ========== empty states ========== */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 40px 20px; color: var(--text-2); margin: auto; }
.empty-ico { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 6px; }
.empty p { margin: 0; max-width: 300px; }

/* ========== inbox ========== */
.inbox { display: grid; grid-template-columns: 330px minmax(0, 1fr) 380px; height: 100vh; }
.conv-col { border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--surface); min-height: 0; }
.conv-head { padding: 16px 14px 10px; display: flex; flex-direction: column; gap: 10px; }
.conv-head h2 { font-size: 18px; }
.queues { display: flex; gap: 6px; padding: 0 14px 12px; overflow-x: auto; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.queues .chip { flex-shrink: 0; }
.conv-list { overflow-y: auto; flex: 1; padding: 6px; }
.conv { display: flex; gap: 11px; padding: 10px; border-radius: 12px; color: var(--text); align-items: flex-start; }
.conv:hover { background: var(--surface-2); text-decoration: none; }
.conv.active { background: var(--accent-soft); }
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.conv-top b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-top small { color: var(--muted); font-size: 11.5px; flex-shrink: 0; }
.conv-text { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 1px 0 6px; }
.conv-tags { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.conv-tags small { color: var(--muted); font-size: 11.5px; margin-left: auto; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; margin-top: 6px; }

.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--chat-bg); background-image: radial-gradient(color-mix(in srgb, var(--muted) 14%, transparent) 1px, transparent 1px); background-size: 22px 22px; }
.chat-top { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 18px; display: flex; flex-direction: column; gap: 10px; }
.chat-title { display: flex; align-items: center; gap: 12px; }
.chat-title h3 { margin: 0; font-size: 16px; }
.chat-title .who { flex: 1; min-width: 0; }
.chat-title .who small { color: var(--muted); }
.chat-title .actions { display: flex; gap: 6px; align-items: center; }
.chat-title .actions select { width: auto; padding: 6px 10px; }
.facts { display: flex; gap: 6px; flex-wrap: wrap; }
.fact { display: flex; flex-direction: column; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 5px 10px; flex-shrink: 0; }
.fact small { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.fact b { font-weight: 500; font-size: 13px; white-space: nowrap; }
.timeline-msgs { flex: 1; overflow-y: auto; padding: 20px 8%; display: flex; flex-direction: column; gap: 6px; }
.msg { display: flex; } .msg.out { justify-content: flex-end; }
.msg.system { justify-content: center; margin: 8px 0; }
.msg.system > span { background: color-mix(in srgb, var(--surface) 85%, transparent); color: var(--muted); font-size: 12px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border); text-align: center; }
.bubble { max-width: min(560px, 75%); background: var(--bubble-in); border-radius: 16px 16px 16px 4px; padding: 8px 12px 6px; box-shadow: var(--shadow); }
.msg.out .bubble { background: var(--bubble-out); border-radius: 16px 16px 4px 16px; }
.msg-text { white-space: pre-wrap; word-break: break-word; }
.meta { font-size: 11px; color: var(--muted); margin-top: 2px; text-align: right; }
.att-img { max-width: 100%; width: 300px; max-height: 220px; object-fit: cover; border-radius: 12px; display: block; margin: 2px 0 6px; }
.att-doc { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.composer { padding: 12px 18px 16px; }
.composer-box { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 8px; transition: border-color .15s, box-shadow .15s; }
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea { border: 0; resize: none; min-height: 44px; max-height: 200px; box-shadow: none; padding: 6px 8px; background: transparent; }
.composer textarea:focus { box-shadow: none; }
.tools { display: flex; gap: 2px; flex-wrap: wrap; align-items: center; }
.tool { font-size: 12.5px; padding: 6px 9px; border-color: transparent; background: transparent; color: var(--text-2); }
.tool:hover { background: var(--surface-3); border-color: transparent; }
.tool .ico { color: var(--muted); }
.send-btn { border-radius: 12px; padding: 8px 16px; }
.pending:empty { display: none; } .pending { padding: 2px 6px 6px; }

.client-pane { border-left: 1px solid var(--border); overflow-y: auto; background: var(--surface); }
.client-hero { padding: 22px 18px 14px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; border-bottom: 1px solid var(--border); }
.client-hero h3 { margin: 8px 0 0; font-size: 17px; }
.client-hero .chips { justify-content: center; margin: 6px 0 0; }
.client-pane .tabs-wrap { padding: 0 14px 14px; }
.client-pane .tabs { position: sticky; top: 0; background: var(--surface); z-index: 2; margin: 0 -14px 14px; padding: 0 10px; }
.client-pane .card { padding: 14px; margin-bottom: 12px; box-shadow: none; }
.kvs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.kv { display: flex; flex-direction: column; min-width: 0; } .kv span { font-size: 11.5px; color: var(--muted); } .kv b { font-weight: 500; overflow-wrap: anywhere; }
.ai-tag { font-size: 9.5px; font-weight: 600; background: var(--violet-soft); color: var(--violet); border-radius: 4px; padding: 0 4px; margin-left: 5px; vertical-align: middle; }
.note { background: var(--surface-2); padding: 8px 10px; border-radius: 10px; font-size: 13px; margin: 10px 0 0; }
.suggest { background: var(--accent-soft); color: var(--text); padding: 9px 11px; border-radius: 10px; font-size: 13px; margin: 10px 0 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.suggest .ico { color: var(--accent); }
.warn { background: var(--orange-soft); color: var(--orange); padding: 8px 10px; border-radius: 10px; font-size: 13px; display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.handover { margin-top: 10px; }
.handover summary { cursor: pointer; font-size: 13px; color: var(--accent-text); font-weight: 500; }
.checklist { list-style: none; padding: 0; margin: 10px 0; }
.checklist li { display: flex; gap: 8px; align-items: center; padding: 4px 0; font-size: 13px; }
.tick { width: 22px; height: 22px; padding: 0; justify-content: center; font-size: 12px; border-radius: 7px; }
.checklist li.answered .tick { background: var(--green-soft); color: var(--green); border-color: transparent; }
.checklist li.answered { color: var(--muted); }
.checklist li.not_answered .tick { background: var(--red-soft); color: var(--red); border-color: transparent; }
.task { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); }
.task:last-child { border-bottom: 0; }
.task input { margin-top: 3px; }
.task.overdue .grow > div { color: var(--red); }
.sale { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.sale:last-child { border-bottom: 0; }
.sale > div { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.pick { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); }
.pick:last-child { border-bottom: 0; }
.pick.used { opacity: .45; }
.thumb { width: 56px; height: 42px; object-fit: cover; border-radius: 8px; }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.media-tile { flex-direction: column; padding: 6px; font-size: 11px; gap: 4px; border-radius: 12px; }
.media-tile img { width: 100%; height: 60px; object-fit: cover; border-radius: 8px; }
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline li { padding: 6px 0 6px 18px; font-size: 13px; position: relative; }
.timeline li::before { content: ''; position: absolute; left: 3px; top: 13px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.timeline li::after { content: ''; position: absolute; left: 6px; top: 22px; bottom: -6px; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.mini-chat { max-height: 360px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.mini { padding: 6px 10px; border-radius: 12px; background: var(--surface-2); max-width: 85%; }
.mini.out { background: var(--bubble-out); align-self: flex-end; }
.mini.system { align-self: center; background: none; color: var(--muted); font-size: 12px; }

/* ========== hero (client page) ========== */
.hero { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.hero .who { flex: 1; min-width: 200px; }
.hero .who p { margin: 2px 0 0; color: var(--muted); }

/* ========== journey editor ========== */
.stages { list-style: none; padding: 0; margin: 0; counter-reset: st; }
.stage { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow); }
.stage.off { opacity: .55; } .grip { cursor: grab; color: var(--muted); font-size: 18px; }
.stage-num { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font-weight: 650; flex-shrink: 0; }
.rules { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.rule { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; }
.kpi-edit td, .kpi-edit th { white-space: normal; }

/* ========== login ========== */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 20% -10%, color-mix(in srgb, #37aee2 22%, transparent), transparent), radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--violet) 18%, transparent), transparent), var(--bg); }
.login { width: 380px; max-width: 100%; display: flex; flex-direction: column; gap: 14px; padding: 32px; border-radius: 22px; box-shadow: var(--shadow-lg); }
.login .brand { padding: 0 0 6px; font-size: 20px; }
.login .brand-mark { width: 42px; height: 42px; border-radius: 13px; }
.login button.primary { justify-content: center; padding: 10px; margin-top: 4px; }

/* ========== responsive ========== */
@media (max-width: 1280px) { .inbox { grid-template-columns: 290px minmax(0, 1fr); } .client-pane { display: none; } .grid-360 { grid-template-columns: 1fr; } .timeline-msgs { padding: 16px; } }
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .side { width: 100%; height: 54px; min-height: 54px; position: sticky; top: 0; z-index: 10; flex-direction: row; flex-wrap: nowrap; align-items: center; overflow-x: auto; overflow-y: hidden; padding: 0 8px; gap: 4px; border-right: 0; border-bottom: 1px solid var(--border); }
  .side .brand, .side .me, .nav-group > summary, .nav-group-title { display: none; }
  .nav-group { display: contents; } .nav-item { flex-shrink: 0; white-space: nowrap; padding: 7px 10px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .tile b { font-size: 18px; }
  .page-head { align-items: flex-start; } h2 { font-size: 20px; }
  main { padding: 16px; } main.full { height: auto; overflow: visible; }
  .inbox { grid-template-columns: minmax(0, 1fr); height: auto; } .conv-col { min-width: 0; border-right: 0; } .conv-list { max-height: 40vh; } .chat { min-height: 70vh; }
  .chat-title { flex-wrap: wrap; } .chat-title .actions { width: 100%; } .chat-title .actions select { flex: 1; }
  .bubble { max-width: 88%; } .tool { font-size: 0; gap: 0; padding: 7px; } .tool .ico { width: 18px; height: 18px; }
  .grid-2, .three { grid-template-columns: 1fr; }
}
@media print { .side, .page-head .actions, .pager { display: none; } main { padding: 0; } .card, .tile, .table-wrap { box-shadow: none; } }
