/* ══════════════════════════════════════════════════════════════════════════
   Psymep CRM — foaie de stil unică
   Paletă: hârtie caldă + verde Psymep. Temă clară / întunecată.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  --paper: #F1F3F1;
  --surface: #FFFFFF;
  --surface-2: #E9ECEA;
  --surface-3: #DEE3DF;
  --ink: #141918;
  --ink-2: #3F4947;
  --ink-3: #6B7773;
  --ink-4: #98A29E;
  --rule: #D8DEDA;
  --rule-strong: #B9C1BC;
  --accent: #0A6058;
  --accent-2: #0E7E73;
  --accent-soft: #DCEBE8;
  --accent-line: #9BC7C0;
  --warn: #8A5600;
  --warn-soft: #F8EDD6;
  --warn-line: #E0C88E;
  --danger: #96271D;
  --danger-soft: #FAE6E3;
  --danger-line: #E3B2AA;
  --info: #2C4C7A;
  --info-soft: #E3EAF5;
  --info-line: #AFC3E0;
  --ok: #1F6B3F;
  --ok-soft: #DFF0E5;
  --ok-line: #A5CFB5;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --rail: 15.5rem;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 25, 24, .05), 0 8px 24px -12px rgba(20, 25, 24, .18);
  --shadow-lg: 0 2px 6px rgba(20, 25, 24, .07), 0 24px 60px -24px rgba(20, 25, 24, .32);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0D1110; --surface: #151A19; --surface-2: #1C2321; --surface-3: #262E2C;
    --ink: #E7EBE9; --ink-2: #B2BCB9; --ink-3: #8A9592; --ink-4: #6C7773;
    --rule: #293230; --rule-strong: #3A4441;
    --accent: #5CC4B4; --accent-2: #7BD6C8; --accent-soft: #113330; --accent-line: #2C5C56;
    --warn: #DDA94B; --warn-soft: #2E2412; --warn-line: #574220;
    --danger: #E88C82; --danger-soft: #331C19; --danger-line: #5D322D;
    --info: #8FB3E0; --info-soft: #182337; --info-line: #2C3D5C;
    --ok: #6FC58C; --ok-soft: #13291C; --ok-line: #2A4A34;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
    --shadow-lg: 0 2px 6px rgba(0,0,0,.5), 0 24px 60px -24px rgba(0,0,0,.75);
  }
}

:root[data-theme="dark"] {
  --paper: #0D1110; --surface: #151A19; --surface-2: #1C2321; --surface-3: #262E2C;
  --ink: #E7EBE9; --ink-2: #B2BCB9; --ink-3: #8A9592; --ink-4: #6C7773;
  --rule: #293230; --rule-strong: #3A4441;
  --accent: #5CC4B4; --accent-2: #7BD6C8; --accent-soft: #113330; --accent-line: #2C5C56;
  --warn: #DDA94B; --warn-soft: #2E2412; --warn-line: #574220;
  --danger: #E88C82; --danger-soft: #331C19; --danger-line: #5D322D;
  --info: #8FB3E0; --info-soft: #182337; --info-line: #2C3D5C;
  --ok: #6FC58C; --ok-soft: #13291C; --ok-line: #2A4A34;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.5), 0 24px 60px -24px rgba(0,0,0,.75);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--rule-strong); border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Boot ─────────────────────────────────────────────────────────────── */
.app-loading { display: grid; place-items: center; height: 100vh; }
.boot { text-align: center; }
.boot-mark { font-weight: 600; letter-spacing: -.02em; font-size: 1.4rem; color: var(--accent); margin-bottom: .9rem; }
.boot-bar { width: 160px; height: 3px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.boot-bar span { display: block; height: 100%; width: 40%; background: var(--accent); border-radius: 3px; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }

/* ── Autentificare ────────────────────────────────────────────────────── */
.login-wrap { display: grid; place-items: center; min-height: 100vh; padding: 2rem; }
.login-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--rule);
  border-radius: 14px; padding: 2rem; box-shadow: var(--shadow-lg);
}
.login-card h1 { margin: 0 0 .2rem; font-size: 1.35rem; letter-spacing: -.02em; }
.login-card .sub { color: var(--ink-3); margin-bottom: 1.5rem; font-size: .87rem; }
.login-hint {
  margin-top: 1.2rem; padding: .7rem .8rem; background: var(--accent-soft);
  border: 1px solid var(--accent-line); border-radius: var(--radius);
  font-size: .8rem; color: var(--ink-2);
}
.login-hint code { font-family: var(--mono); font-size: .78rem; }

/* ── Shell ────────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); height: 100vh; overflow: hidden; }
.rail {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--rule);
  display: flex; flex-direction: column; padding: 1.1rem .75rem .9rem;
}
.rail-brand { display: flex; align-items: center; gap: .6rem; padding: 0 .5rem .9rem; }
.rail-logo {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 1rem; flex: none;
}
.rail-brand b { display: block; font-size: .95rem; font-weight: 600; letter-spacing: -.01em; line-height: 1.15; }
.rail-brand span { display: block; font-size: .7rem; color: var(--ink-3); }
.rail-nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.rail-group { margin-top: .85rem; padding: 0 .55rem .3rem; font-size: .67rem; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-4); font-weight: 600; }
.rail-link {
  display: flex; align-items: center; gap: .55rem; padding: .42rem .55rem; border-radius: 7px;
  color: var(--ink-2); font-size: .86rem; cursor: pointer; border: 0; background: none;
  width: 100%; text-align: left; transition: background .12s;
}
.rail-link:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.rail-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.rail-link .ico { width: 16px; height: 16px; flex: none; opacity: .85; }
.rail-link .pill {
  margin-left: auto; background: var(--danger); color: #fff; font-size: .66rem;
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px;
  display: grid; place-items: center; font-weight: 600; font-variant-numeric: tabular-nums;
}
.rail-link.active .pill { background: var(--accent); }
.rail-foot { border-top: 1px solid var(--rule); padding-top: .6rem; margin-top: .6rem; }
.rail-user { display: flex; align-items: center; gap: .55rem; padding: .35rem .55rem; font-size: .8rem; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--surface-3); color: var(--ink-2);
  display: grid; place-items: center; font-size: .7rem; font-weight: 600; flex: none;
}
.rail-user .who { min-width: 0; }
.rail-user .who b { display: block; font-weight: 500; font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-user .who span { display: block; font-size: .68rem; color: var(--ink-3); }

.main { min-width: 0; display: flex; flex-direction: column; height: 100vh; }
.topbar {
  z-index: 20; background: var(--surface); border-bottom: 1px solid var(--rule); flex: none;
  padding: .75rem 1.4rem; display: flex; align-items: center; gap: 1rem; min-height: 56px;
}
.topbar h1 { margin: 0; font-size: 1.05rem; font-weight: 600; letter-spacing: -.015em; }
.topbar .crumb { color: var(--ink-3); font-size: .8rem; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.page { padding: 1.4rem; flex: 1; min-width: 0; min-height: 0; overflow-y: auto; }
.page.flush { padding: 0; overflow: hidden; }

/* ── Componente ───────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
.card-head { padding: .8rem 1rem; border-bottom: 1px solid var(--rule); display: flex; align-items: center; gap: .6rem; }
.card-head h2 { margin: 0; font-size: .92rem; font-weight: 600; }
.card-head .right { margin-left: auto; display: flex; gap: .4rem; align-items: center; }
.card-body { padding: 1rem; }
.card-body.tight { padding: .55rem; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem; padding: .42rem .8rem;
  border-radius: 7px; border: 1px solid var(--rule-strong); background: var(--surface);
  color: var(--ink); font-size: .83rem; font-weight: 500; cursor: pointer;
  transition: background .12s, border-color .12s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { color: var(--danger); border-color: var(--danger-line); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: .25rem .55rem; font-size: .78rem; }
.btn-icon { padding: .35rem; }

.input, .select, .textarea {
  width: 100%; padding: .45rem .6rem; border: 1px solid var(--rule-strong);
  border-radius: 7px; background: var(--surface); font-size: .85rem;
}
.textarea { resize: vertical; min-height: 76px; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.field { margin-bottom: .8rem; }
.field label { display: block; font-size: .76rem; font-weight: 500; color: var(--ink-2); margin-bottom: .25rem; }
.field .hint { font-size: .72rem; color: var(--ink-3); margin-top: .25rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 .8rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 .8rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.tight { gap: .3rem; }
.spacer { flex: 1; }
.check { display: flex; align-items: center; gap: .45rem; font-size: .83rem; cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); }

.badge {
  display: inline-flex; align-items: center; gap: .25rem; padding: .1rem .45rem;
  border-radius: 5px; font-size: .72rem; font-weight: 500; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--rule);
}
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.badge.info { background: var(--info-soft); color: var(--info); border-color: var(--info-line); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.badge.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.muted { color: var(--ink-3); }
.small { font-size: .78rem; }
.mono { font-family: var(--mono); font-size: .8em; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center { text-align: center; }
.right { text-align: right; }

/* ── Tabele ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .84rem; }
table.tbl th {
  text-align: left; font-weight: 600; font-size: .72rem; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-3); padding: .5rem .7rem;
  border-bottom: 1px solid var(--rule); white-space: nowrap; background: var(--surface);
  position: sticky; top: 0; z-index: 1;
}
table.tbl td { padding: .5rem .7rem; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr.clickable { cursor: pointer; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl td.num { font-variant-numeric: tabular-nums; text-align: right; }

.empty { padding: 2.5rem 1rem; text-align: center; color: var(--ink-3); }
.empty .big { font-size: 1.6rem; margin-bottom: .4rem; opacity: .6; }

/* ── Statistici ───────────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .7rem; }
.stat {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: .8rem .9rem; min-width: 0;
}
.stat .k { font-size: .72rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat .v { font-size: 1.55rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.stat .s { font-size: .75rem; color: var(--ink-3); }
.stat.accent .v { color: var(--accent); }
.stat.warn .v { color: var(--warn); }
.stat.danger .v { color: var(--danger); }

.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: .9rem; margin-top: .9rem; }

/* pipeline mini-bar */
.pipebar { display: flex; height: 26px; border-radius: 7px; overflow: hidden; border: 1px solid var(--rule); }
.pipebar > div { display: grid; place-items: center; font-size: .7rem; font-weight: 600; color: #fff; min-width: 0; }

.spark { display: flex; align-items: flex-end; gap: 4px; height: 64px; }
.spark-day { flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 0; }
.spark-pair { display: flex; align-items: flex-end; gap: 2px; width: 100%; height: 100%; }
.spark-bar { flex: 1; border-radius: 2px 2px 0 0; min-height: 2px; }
.spark-bar.sent { background: var(--accent); }
.spark-bar.recv { background: var(--accent-line); }

/* ── Kanban ───────────────────────────────────────────────────────────── */
.kanban { display: flex; gap: .7rem; overflow: auto; padding: 1.4rem; align-items: flex-start; height: 100%; }
.kan-col { flex: 0 0 268px; width: 268px; min-width: 0; background: var(--surface-2); border-radius: 10px; display: flex; flex-direction: column; max-height: 100%; }
.kan-head { padding: .55rem .7rem; display: flex; align-items: center; gap: .4rem; font-size: .8rem; font-weight: 600; border-bottom: 1px solid var(--rule); }
.kan-head .n { margin-left: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: 20px; padding: 0 .4rem; font-size: .7rem; color: var(--ink-3); }
.kan-body { padding: .45rem; overflow-y: auto; display: flex; flex-direction: column; gap: .4rem; min-height: 60px; }
.kan-body.drop { background: var(--accent-soft); border-radius: 8px; }
.kan-card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 8px;
  padding: .55rem .65rem; cursor: grab; font-size: .82rem;
}
.kan-card:hover { border-color: var(--rule-strong); }
.kan-card.dragging { opacity: .4; }
.kan-card b { display: block; font-weight: 500; margin-bottom: .15rem; overflow-wrap: anywhere; }
.kan-card .meta { color: var(--ink-3); font-size: .73rem; display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }

/* ── Inbox ────────────────────────────────────────────────────────────── */
.inbox { display: grid; grid-template-columns: 21rem minmax(0, 1fr); height: 100%; min-height: 0; }
.inbox.with-panel { grid-template-columns: 20rem minmax(0, 1fr) 19rem; }
.conv-list { border-right: 1px solid var(--rule); overflow-y: auto; background: var(--surface); }
.conv-filters { padding: .55rem .6rem; border-bottom: 1px solid var(--rule); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.seg { display: flex; gap: 2px; background: var(--surface-2); padding: 2px; border-radius: 7px; }
.seg button {
  flex: 1; border: 0; background: none; padding: .28rem .3rem; border-radius: 5px;
  font-size: .75rem; cursor: pointer; color: var(--ink-3); white-space: nowrap;
}
.seg button.active { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.conv-item { padding: .6rem .7rem; border-bottom: 1px solid var(--rule); cursor: pointer; display: flex; gap: .55rem; }
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--accent-soft); }
.conv-item .who { min-width: 0; flex: 1; }
.conv-item .who b { font-weight: 500; font-size: .85rem; display: block; }
.conv-item .who .prev { color: var(--ink-3); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .side { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; }
.conv-item .time { font-size: .68rem; color: var(--ink-4); white-space: nowrap; }
.unread-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.chat { display: flex; flex-direction: column; min-width: 0; background: var(--paper); }
.chat-head { padding: .6rem .9rem; border-bottom: 1px solid var(--rule); background: var(--surface); display: flex; align-items: center; gap: .6rem; }
.chat-head .who b { display: block; font-size: .9rem; font-weight: 600; }
.chat-head .who span { display: block; font-size: .74rem; color: var(--ink-3); }
.chat-body { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.bubble {
  max-width: min(72%, 560px); padding: .5rem .7rem; border-radius: 12px;
  font-size: .86rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; position: relative;
}
.bubble.in { align-self: flex-start; background: var(--surface); border: 1px solid var(--rule); border-bottom-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: var(--accent-soft); border: 1px solid var(--accent-line); border-bottom-right-radius: 4px; }
.bubble.failed { background: var(--danger-soft); border-color: var(--danger-line); }
.bubble .b-meta { margin-top: .25rem; font-size: .66rem; color: var(--ink-3); display: flex; gap: .35rem; align-items: center; }
.chat-compose { border-top: 1px solid var(--rule); background: var(--surface); padding: .6rem .7rem; }
.chat-compose textarea { width: 100%; border: 1px solid var(--rule-strong); border-radius: 9px; padding: .5rem .6rem; resize: none; min-height: 42px; max-height: 160px; font-size: .86rem; }
.chat-note { font-size: .74rem; color: var(--ink-3); margin-top: .35rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.day-sep { align-self: center; font-size: .7rem; color: var(--ink-3); background: var(--surface-2); padding: .1rem .5rem; border-radius: 20px; }

.side-panel { border-left: 1px solid var(--rule); background: var(--surface); overflow-y: auto; padding: .9rem; }
.side-panel h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); margin: 1.1rem 0 .4rem; }
.side-panel h3:first-child { margin-top: 0; }
.kv { display: grid; grid-template-columns: 5.5rem 1fr; gap: .2rem .5rem; font-size: .8rem; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ── Toggle AI ────────────────────────────────────────────────────────── */
.ai-toggle {
  display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .5rem;
  border-radius: 20px; border: 1px solid var(--rule-strong); font-size: .76rem; cursor: pointer; background: var(--surface);
}
.ai-toggle.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); font-weight: 500; }
.ai-toggle .led { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-4); }
.ai-toggle.on .led { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }

/* ── Simulator telefon ────────────────────────────────────────────────── */
.sim-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 1.2rem; align-items: start; }
.phone {
  width: 372px; margin: 0 auto; background: #0b141a; border-radius: 28px; padding: 10px;
  box-shadow: var(--shadow-lg); border: 1px solid #2a3942;
}
.phone-screen { background: #0b141a; border-radius: 20px; overflow: hidden; display: flex; flex-direction: column; height: 560px; }
.phone-head { background: #202c33; color: #e9edef; padding: .6rem .8rem; display: flex; align-items: center; gap: .55rem; }
.phone-head .pav { width: 30px; height: 30px; border-radius: 50%; background: #3b4a54; display: grid; place-items: center; font-size: .72rem; }
.phone-head b { font-size: .85rem; font-weight: 500; }
.phone-head span { font-size: .68rem; color: #8696a0; display: block; }
.phone-body {
  flex: 1; overflow-y: auto; padding: .7rem; display: flex; flex-direction: column; gap: .35rem;
  background: #0b141a;
  background-image: radial-gradient(circle at 20% 30%, rgba(255,255,255,.02) 0 2px, transparent 2px),
                    radial-gradient(circle at 70% 60%, rgba(255,255,255,.02) 0 2px, transparent 2px);
  background-size: 60px 60px;
}
.wa {
  max-width: 78%; padding: .38rem .55rem .3rem; border-radius: 8px; font-size: .82rem;
  line-height: 1.45; white-space: pre-wrap; word-break: break-word; color: #e9edef;
}
.wa.them { align-self: flex-start; background: #202c33; border-top-left-radius: 2px; }
.wa.us { align-self: flex-end; background: #005c4b; border-top-right-radius: 2px; }
.wa .t { font-size: .62rem; color: #8696a0; text-align: right; margin-top: .1rem; }
.phone-compose { background: #202c33; padding: .5rem; display: flex; gap: .4rem; align-items: flex-end; }
.phone-compose textarea {
  flex: 1; background: #2a3942; border: 0; border-radius: 18px; padding: .45rem .8rem;
  color: #e9edef; resize: none; min-height: 34px; max-height: 90px; font-size: .84rem;
}
.phone-compose textarea::placeholder { color: #8696a0; }
.phone-send { width: 34px; height: 34px; border-radius: 50%; background: #00a884; border: 0; color: #fff; cursor: pointer; display: grid; place-items: center; flex: none; }
.phone-send:disabled { opacity: .5; }
.sim-typing { font-size: .7rem; color: #8696a0; padding: 0 .7rem .3rem; }

/* ── Drawer / modal ───────────────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(10, 14, 13, .42); z-index: 100; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 96vw);
  background: var(--paper); z-index: 101; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: slidein .18s ease-out;
}
@keyframes slidein { from { transform: translateX(30px); opacity: .4; } }
.drawer-head { padding: .85rem 1.1rem; border-bottom: 1px solid var(--rule); background: var(--surface); display: flex; align-items: center; gap: .6rem; }
.drawer-head h2 { margin: 0; font-size: 1rem; font-weight: 600; }
.drawer-body { flex: 1; overflow-y: auto; padding: 1.1rem; }
.drawer-foot { padding: .7rem 1.1rem; border-top: 1px solid var(--rule); background: var(--surface); display: flex; gap: .5rem; }

.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(560px, 94vw); max-height: 88vh; background: var(--surface);
  border-radius: 12px; z-index: 101; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; border: 1px solid var(--rule);
}
.modal.wide { width: min(880px, 96vw); }
.modal-head { padding: .8rem 1rem; border-bottom: 1px solid var(--rule); display: flex; align-items: center; }
.modal-head h2 { margin: 0; font-size: .98rem; font-weight: 600; }
.modal-body { padding: 1rem; overflow-y: auto; }
.modal-foot { padding: .7rem 1rem; border-top: 1px solid var(--rule); display: flex; gap: .5rem; justify-content: flex-end; }

/* ── Timeline ─────────────────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 1.1rem; }
.timeline::before { content: ''; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 1px; background: var(--rule); }
.tl-item { position: relative; padding: 0 0 .9rem; }
.tl-item::before {
  content: ''; position: absolute; left: -1.1rem; top: 6px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--rule-strong);
}
.tl-item.inbound::before { border-color: var(--accent); }
.tl-item.system::before { border-color: var(--ink-4); background: var(--ink-4); }
.tl-item .tl-head { display: flex; gap: .4rem; align-items: baseline; flex-wrap: wrap; font-size: .78rem; }
.tl-item .tl-head b { font-weight: 600; font-size: .82rem; }
.tl-item .tl-body { font-size: .82rem; color: var(--ink-2); white-space: pre-wrap; margin-top: .15rem; overflow-wrap: anywhere; }

/* ── Tab-uri ──────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: .15rem; border-bottom: 1px solid var(--rule); margin-bottom: 1rem; overflow-x: auto; }
.tabs button {
  border: 0; background: none; padding: .45rem .75rem; font-size: .84rem; cursor: pointer;
  color: var(--ink-3); border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }

/* ── Toasts ───────────────────────────────────────────────────────────── */
.toasts { position: fixed; bottom: 1rem; right: 1rem; z-index: 200; display: flex; flex-direction: column; gap: .45rem; max-width: 380px; }
.toast {
  background: var(--surface); border: 1px solid var(--rule); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: .6rem .8rem; box-shadow: var(--shadow-lg); font-size: .84rem;
  animation: toastin .18s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
.toast b { display: block; font-weight: 600; font-size: .82rem; margin-bottom: .1rem; }
@keyframes toastin { from { transform: translateY(8px); opacity: 0; } }

/* ── Diverse ──────────────────────────────────────────────────────────── */
.filters { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; margin-bottom: .8rem; }
.filters .input, .filters .select { width: auto; min-width: 130px; }
.filters .search { min-width: 220px; }
.chip {
  padding: .2rem .55rem; border-radius: 20px; border: 1px solid var(--rule-strong);
  font-size: .76rem; cursor: pointer; background: var(--surface); user-select: none;
}
.chip.active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); font-weight: 500; }
.score { font-variant-numeric: tabular-nums; font-weight: 600; }
.score.hi { color: var(--ok); }
.score.mid { color: var(--warn); }
.score.lo { color: var(--ink-3); }
.progress { height: 5px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); }
pre.code {
  background: var(--surface-2); border: 1px solid var(--rule); border-radius: 7px;
  padding: .6rem .7rem; font-family: var(--mono); font-size: .76rem; overflow-x: auto; margin: 0;
}
.divider { height: 1px; background: var(--rule); margin: 1rem 0; }
.warning-box {
  padding: .6rem .75rem; border-radius: 8px; font-size: .8rem;
  background: var(--warn-soft); border: 1px solid var(--warn-line); color: var(--ink-2);
}
.info-box { padding: .6rem .75rem; border-radius: 8px; font-size: .8rem; background: var(--info-soft); border: 1px solid var(--info-line); color: var(--ink-2); }
.ok-box { padding: .6rem .75rem; border-radius: 8px; font-size: .8rem; background: var(--ok-soft); border: 1px solid var(--ok-line); color: var(--ink-2); }

@media (max-width: 1100px) {
  .inbox.with-panel { grid-template-columns: 18rem minmax(0, 1fr); }
  .inbox.with-panel .side-panel { display: none; }
  .sim-wrap { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; height: auto; overflow: visible; }
  .main { height: auto; }
  .page, .page.flush { overflow: visible; }
  .inbox, .kanban { height: auto; }
  .rail { position: static; height: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--rule); align-items: center; padding: .5rem; }
  .rail-nav { flex-direction: row; flex-wrap: nowrap; }
  .rail-group, .rail-foot { display: none; }
  .inbox { grid-template-columns: 1fr; }
  .inbox .conv-list { display: none; }
  .inbox.show-list .conv-list { display: block; }
  .inbox.show-list .chat { display: none; }
}
