/* ==========================================================================
   Tufwud Console — design system
   Brand: deep navy, rust orange, warm cream. One typeface: Inter.
   ========================================================================== */

:root {
  /* ---- ramps ---- */
  --navy-950:#070E22; --navy-900:#0B1430; --navy-850:#101B3D; --navy-800:#16224A;
  --navy-700:#1E2D5C; --navy-600:#2B3F76; --navy-500:#3E5591; --navy-400:#5D74AD;
  --navy-300:#8C9CC2; --navy-200:#BAC4DA; --navy-100:#DEE4EF;

  --rust-800:#8F3A11; --rust-700:#B04818; --rust-600:#C9531D; --rust-500:#DD5F26;
  --rust-400:#E87B43; --rust-300:#F19C6E; --rust-200:#F8C6AB; --rust-100:#FCE2D3;
  --rust-50:#FEF3EC;

  --cream-50:#FFFFFF;  --cream-100:#FDFBF8; --cream-200:#F9F6F0;
  --cream-300:#F4F0E8; --cream-400:#EAE4D8; --cream-500:#D9D0BE; --cream-600:#B9AC93;

  --ok-700:#1F6B4A;  --ok-600:#2A7F59; --ok-100:#DCF0E6; --ok-50:#EDF8F2;
  --warn-700:#8A5B12; --warn-600:#A76E18; --warn-100:#FBEBD2; --warn-50:#FDF6EA;
  --bad-700:#9B2C20;  --bad-600:#BC3A2B; --bad-100:#FADCD8; --bad-50:#FDEEEC;
  --info-700:#1F4E85; --info-600:#2A64A8; --info-100:#DBE8F7; --info-50:#EFF5FC;

  /* ---- semantic (light) ---- */
  --bg:            var(--cream-300);
  --bg-alt:        var(--cream-200);
  --surface:       var(--cream-50);
  --surface-2:     var(--cream-200);
  --surface-3:     var(--cream-300);
  --border:        var(--cream-400);
  --border-strong: var(--cream-500);
  --text:          var(--navy-900);
  --text-2:        #55617C;
  --text-3:        #8A93A8;
  --accent:        var(--rust-600);
  --accent-hover:  var(--rust-700);
  --accent-soft:   var(--rust-50);
  --accent-line:   var(--rust-200);
  --on-accent:     #ffffff;

  --nav-bg:        var(--navy-900);
  --nav-bg-2:      var(--navy-850);
  --nav-text:      var(--navy-300);
  --nav-active-bg: rgba(221,95,38,.15);
  --nav-border:    rgba(255,255,255,.07);

  --thread-bg:     #EDE7DA;
  --bubble-in:     var(--cream-50);
  --bubble-out:    var(--navy-800);
  --bubble-out-tx: #ffffff;
  /* Outbound, but not sent from this console. */
  --bubble-ai:     #1B3A63;
  --bubble-phone:  #24503E;
  --bubble-auto:   #3A2C5E;

  --ok-bg: var(--ok-50);   --ok-fg: var(--ok-700);   --ok-bd: var(--ok-100);
  --wa-bg: var(--warn-50); --wa-fg: var(--warn-700); --wa-bd: var(--warn-100);
  --ba-bg: var(--bad-50);  --ba-fg: var(--bad-700);  --ba-bd: var(--bad-100);
  --in-bg: var(--info-50); --in-fg: var(--info-700); --in-bd: var(--info-100);

  --r-xs:5px; --r-sm:8px; --r:11px; --r-lg:15px; --r-xl:20px; --r-full:999px;
  --sh-1: 0 1px 2px rgba(11,20,48,.05);
  --sh-2: 0 1px 3px rgba(11,20,48,.07), 0 1px 2px rgba(11,20,48,.04);
  --sh-3: 0 4px 12px rgba(11,20,48,.08), 0 2px 4px rgba(11,20,48,.04);
  --sh-4: 0 18px 40px rgba(11,20,48,.16), 0 4px 12px rgba(11,20,48,.08);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);

  --nav-w: 244px;
  --ease: cubic-bezier(.32,.72,0,1);
  --fast: .14s var(--ease);
  --med: .24s var(--ease);
}

:root[data-theme="dark"] {
  --bg:            var(--navy-950);
  --bg-alt:        var(--navy-900);
  --surface:       var(--navy-900);
  --surface-2:     var(--navy-850);
  --surface-3:     var(--navy-800);
  --border:        #1A2647;
  --border-strong: var(--navy-700);
  --text:          #EDF0F7;
  --text-2:        var(--navy-300);
  --text-3:        #6A7BA0;
  --accent:        var(--rust-400);
  --accent-hover:  var(--rust-300);
  --accent-soft:   rgba(232,123,67,.13);
  --accent-line:   rgba(232,123,67,.32);

  --nav-bg:        #050A1A;
  --nav-bg-2:      var(--navy-900);
  --nav-active-bg: rgba(232,123,67,.18);

  --thread-bg:     var(--navy-950);
  --bubble-in:     var(--navy-800);
  --bubble-out:    var(--rust-600);

  --ok-bg: rgba(42,127,89,.16);  --ok-fg:#63C89B;  --ok-bd: rgba(42,127,89,.3);
  --wa-bg: rgba(167,110,24,.18); --wa-fg:#E5B85F;  --wa-bd: rgba(167,110,24,.32);
  --ba-bg: rgba(188,58,43,.16);  --ba-fg:#F0897B;  --ba-bd: rgba(188,58,43,.3);
  --in-bg: rgba(42,100,168,.18); --in-fg:#78AEEC;  --in-bd: rgba(42,100,168,.32);

  --sh-1: 0 1px 2px rgba(0,0,0,.4);
  --sh-2: 0 1px 3px rgba(0,0,0,.45);
  --sh-3: 0 4px 12px rgba(0,0,0,.5);
  --sh-4: 0 18px 40px rgba(0,0,0,.6);
}

/* ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: Inter, -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 14px; line-height: 1.55; letter-spacing: -.006em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0; font-weight: 650; letter-spacing: -.022em; }
::selection { background: var(--accent); color: #fff; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full);
  border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* icons ------------------------------------------------------------------ */
.i   { width: 18px; height: 18px; flex: 0 0 auto; stroke-width: 1.75; }
.i-sm{ width: 15px; height: 15px; flex: 0 0 auto; stroke-width: 1.9; }
.i-xs{ width: 13px; height: 13px; flex: 0 0 auto; stroke-width: 2; }
.i-lg{ width: 22px; height: 22px; flex: 0 0 auto; stroke-width: 1.6; }
.i-xl{ width: 30px; height: 30px; flex: 0 0 auto; stroke-width: 1.4; }

/* type helpers ----------------------------------------------------------- */
.eyebrow { font-size: 10.5px; text-transform: uppercase; letter-spacing: .14em;
           font-weight: 700; color: var(--accent); }
.muted  { color: var(--text-2); }
.dim    { color: var(--text-3); }
.mono   { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- controls */

.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  border: 1px solid transparent; border-radius: var(--r-sm);
  padding: 8px 14px; font: inherit; font-weight: 600; font-size: 13.5px;
  cursor: pointer; background: var(--accent); color: var(--on-accent);
  transition: background var(--fast), border-color var(--fast),
              transform .08s var(--ease), box-shadow var(--fast), opacity var(--fast);
  white-space: nowrap; box-shadow: 0 1px 2px rgba(143,58,17,.22);
  letter-spacing: -.004em;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-ghost { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--text-3); }
.btn-quiet { background: transparent; color: var(--text-2); border-color: transparent; padding: 7px; box-shadow: none; }
.btn-quiet:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--bad-600); box-shadow: none; }
.btn-danger:hover { background: var(--bad-700); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: var(--r-xs); }
.btn-lg { padding: 11px 20px; font-size: 14.5px; border-radius: var(--r); }
.btn-block { width: 100%; }

.input, .select, .textarea {
  width: 100%; padding: 9px 12px; font: inherit; font-size: 13.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  transition: border-color var(--fast), box-shadow var(--fast), background var(--fast);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--ring);
}
.input:disabled, .textarea:disabled { background: var(--surface-2); color: var(--text-3); cursor: not-allowed; }
.textarea { resize: vertical; min-height: 82px; line-height: 1.6; }
.select { appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A93A8' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 15px; }

.label { display: block; font-size: 10.5px; font-weight: 700; color: var(--text-2);
         margin-bottom: 6px; text-transform: uppercase; letter-spacing: .1em; }
.field { margin-bottom: 17px; }
.field:last-child { margin-bottom: 0; }
.hint { font-size: 12.5px; color: var(--text-3); margin-top: 6px; line-height: 1.45; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }

.search { position: relative; }
.search > .i, .search > .i-sm { position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
                                color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 35px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 38px; height: 22px; border-radius: var(--r-full); background: var(--border-strong);
                 transition: background var(--fast); flex: 0 0 auto; }
.switch .knob { position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%;
                background: #fff; box-shadow: var(--sh-1); transition: transform var(--med); }
.switch input:checked ~ .track { background: var(--accent); }
.switch input:checked ~ .knob { transform: translateX(16px); }

/* chips ------------------------------------------------------------------ */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px;
  border-radius: var(--r-full); font-size: 11.5px; font-weight: 650;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
  letter-spacing: .005em; white-space: nowrap;
}
.chip-ok   { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-bd); }
.chip-warn { background: var(--wa-bg); color: var(--wa-fg); border-color: var(--wa-bd); }
.chip-bad  { background: var(--ba-bg); color: var(--ba-fg); border-color: var(--ba-bd); }
.chip-info { background: var(--in-bg); color: var(--in-fg); border-color: var(--in-bd); }
.chip-accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.chip-btn { cursor: pointer; transition: all var(--fast); }
.chip-btn:hover { border-color: var(--text-3); color: var(--text); }
.chip-btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* notification bell ------------------------------------------------------ */
.bell { position: relative; }
.bell .count {
  position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: var(--r-full); background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
.hrow.unseen { background: var(--accent-soft); }

/* who is handling a conversation ---------------------------------------- */
.assigned-row { display: flex; align-items: center; gap: 8px; }
.assigned-row .select { flex: 1; }
.mine { border-left: 3px solid var(--accent); }

/* filter bar -------------------------------------------------------------
   Segments and tags used to sit as two loose rows of chips with nothing saying
   which was which. They are now menus with a named button, and whatever is
   active is restated underneath as "Segment: Hotels" so the kind is never in
   doubt. */
.filterbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

.fdrop { position: relative; }
.fdrop > .fbtn {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px;
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); cursor: pointer; white-space: nowrap;
  transition: border-color var(--fast), color var(--fast), background var(--fast);
}
.fdrop > .fbtn:hover { border-color: var(--text-3); color: var(--text); }
.fdrop > .fbtn .i-xs { color: var(--text-3); }
.fdrop.on > .fbtn { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.fdrop.on > .fbtn .i-xs { color: var(--accent); }
.fbtn .fcount {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: var(--r-full);
  background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 700;
}

.fmenu {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0;
  min-width: 232px; max-width: 320px; max-height: 340px; overflow-y: auto;
  padding: 7px; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r); box-shadow: var(--sh-3);
}
.fmenu[hidden] { display: none !important; }
.fmenu-head {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px 7px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: var(--text-3);
}
.fmenu-head .lnk { margin-left: auto; text-transform: none; letter-spacing: 0;
                   font-size: 11.5px; font-weight: 600; color: var(--accent);
                   background: none; border: 0; cursor: pointer; padding: 0; }
.fmenu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 8px;
  font: inherit; font-size: 13px; color: var(--text); text-align: left;
  background: none; border: 0; border-radius: var(--r-sm); cursor: pointer;
}
.fmenu-item:hover { background: var(--surface-2); }
.fmenu-item .n { margin-left: auto; font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.fmenu-item input[type=checkbox], .fmenu-item input[type=radio] {
  accent-color: var(--accent); width: 14px; height: 14px; flex: 0 0 auto; cursor: pointer; }
.fmenu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.fmenu .search { margin: 2px 4px 6px; }
.fmenu .search .input { padding: 6px 10px 6px 30px; font-size: 12.5px; }
.fmenu .search > .i-sm { left: 9px; }

.fscrim { position: fixed; inset: 0; z-index: 39; }

.activefilters { display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
                 padding: 10px 16px; border-bottom: 1px solid var(--border);
                 background: var(--surface-2); }
.fpill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 5px 3px 9px;
  border-radius: var(--r-full); font-size: 11.5px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-2);
}
.fpill b { font-weight: 700; color: var(--text); }
.fpill .k { color: var(--text-3); font-weight: 600; }
.fpill button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border: 0; padding: 0; border-radius: 50%;
  background: none; color: var(--text-3); cursor: pointer; font-size: 13px; line-height: 1;
}
.fpill button:hover { background: var(--surface-2); color: var(--text); }
.fpill.is-seg { border-color: var(--accent-line); background: var(--accent-soft); }
.fpill.is-seg b, .fpill.is-seg .k { color: var(--accent); }
.fpill.is-tag { border-color: var(--border-strong); }

/* tags page -------------------------------------------------------------- */
.tagsplit { display: grid; grid-template-columns: 268px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .tagsplit { grid-template-columns: 1fr; } }

.taglist { display: flex; flex-direction: column; gap: 2px; padding: 7px; }
.taglist .tl {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px;
  font: inherit; text-align: left; background: none; border: 0;
  border-radius: var(--r-sm); cursor: pointer; color: var(--text);
  transition: background var(--fast);
}
.taglist .tl:hover { background: var(--surface-2); }
.taglist .tl.on { background: var(--accent-soft); }
.taglist .tl.on .tl-name { color: var(--accent); font-weight: 700; }
.tl-name { font-size: 13.5px; font-weight: 600; overflow: hidden;
           text-overflow: ellipsis; white-space: nowrap; }
.tl-n { margin-left: auto; font-size: 11.5px; font-weight: 650; color: var(--text-3); }
.tl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
          flex: 0 0 auto; opacity: .45; }
.taglist .tl.on .tl-dot { opacity: 1; }

.tagdetail-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tagdetail-head h2 { margin: 0; }

/* tag input --------------------------------------------------------------
   Looks like a text field but holds chips. The real input sits inside it and
   grows, so the caret is always where the next tag will land. */
.taginput {
  display: flex; flex-wrap: wrap; gap: 5px; align-items: center;
  width: 100%; padding: 6px 8px; min-height: 38px; cursor: text;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  transition: border-color var(--fast), box-shadow var(--fast);
}
.taginput:hover { border-color: var(--text-3); }
.taginput.focus { border-color: var(--accent); box-shadow: var(--ring); }
.taginput input {
  flex: 1 1 70px; min-width: 70px; border: 0; outline: none; background: none;
  font: inherit; font-size: 13.5px; color: var(--text); padding: 2px 2px;
}
.taginput input::placeholder { color: var(--text-3); }
.taginput .chip { padding-right: 4px; }
.taginput .tagx {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border: 0; padding: 0; border-radius: 50%;
  background: none; color: inherit; cursor: pointer; opacity: .55;
  font-size: 13px; line-height: 1;
}
.taginput .tagx:hover { opacity: 1; background: rgba(0,0,0,.09); }

.tagsug { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }

/* tags shown in a table cell wrap rather than stretching the row */
.tagcell { display: flex; flex-wrap: wrap; gap: 4px; max-width: 210px; }

.dotstat { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.dotstat.live { background: var(--ok-600); box-shadow: 0 0 0 3px var(--ok-bg); animation: pulse 2.4s infinite; }
.dotstat.warn { background: var(--warn-600); box-shadow: 0 0 0 3px var(--wa-bg); }
.dotstat.bad  { background: var(--bad-600); box-shadow: 0 0 0 3px var(--ba-bg); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.45} }

/* surfaces --------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border);
        border-radius: var(--r-lg); box-shadow: var(--sh-2); }
.card-pad { padding: 19px; }

.banner { display: flex; gap: 11px; align-items: flex-start; padding: 12px 15px;
          border-radius: var(--r-sm); font-size: 13px; border: 1px solid; line-height: 1.5; }
.banner .i { margin-top: 1px; }
.banner-warn { background: var(--wa-bg); border-color: var(--wa-bd); color: var(--wa-fg); }
.banner-bad  { background: var(--ba-bg); border-color: var(--ba-bd); color: var(--ba-fg); }
.banner-ok   { background: var(--ok-bg); border-color: var(--ok-bd); color: var(--ok-fg); }
.banner-info { background: var(--in-bg); border-color: var(--in-bd); color: var(--in-fg); }

.avatar {
  width: 38px; height: 38px; border-radius: var(--r-full); flex: 0 0 auto;
  display: grid; place-items: center; font-weight: 700; font-size: 13.5px; color: #fff;
  background: linear-gradient(145deg, var(--navy-600), var(--navy-850));
  letter-spacing: .01em; user-select: none;
}
.avatar-sm { width: 30px; height: 30px; font-size: 11.5px; }
.avatar-lg { width: 60px; height: 60px; font-size: 21px; }

.empty { display: grid; place-items: center; gap: 8px; padding: 54px 24px;
         text-align: center; color: var(--text-3); }
.empty .i-xl { color: var(--border-strong); margin-bottom: 4px; }
.empty strong { color: var(--text-2); font-weight: 650; font-size: 14.5px; }
.empty p { margin: 0; max-width: 340px; font-size: 13px; line-height: 1.55; }
.empty .btn { margin-top: 10px; }

/* skeletons -------------------------------------------------------------- */
.sk { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
      background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: var(--r-xs); }
@keyframes shimmer { 0%{background-position:100% 0} 100%{background-position:0 0} }
.sk-line { height: 11px; margin-bottom: 8px; }
.sk-row { display: flex; gap: 12px; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--border); }

/* motion ----------------------------------------------------------------- */
.fade-in { animation: fadeIn .26s var(--ease) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.stagger > * { animation: fadeIn .3s var(--ease) both; }
.stagger > *:nth-child(1){animation-delay:.02s} .stagger > *:nth-child(2){animation-delay:.05s}
.stagger > *:nth-child(3){animation-delay:.08s} .stagger > *:nth-child(4){animation-delay:.11s}
.stagger > *:nth-child(5){animation-delay:.14s} .stagger > *:nth-child(6){animation-delay:.17s}
.stagger > *:nth-child(7){animation-delay:.2s}  .stagger > *:nth-child(8){animation-delay:.23s}

/* ---------------------------------------------------------------- login */

#login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
@media (max-width: 940px) { #login { grid-template-columns: 1fr; } #login .login-art { display: none; } }

.login-art {
  position: relative; overflow: hidden; padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(780px 420px at 12% 8%, rgba(221,95,38,.20), transparent 62%),
    radial-gradient(640px 520px at 92% 88%, rgba(43,63,118,.55), transparent 60%),
    var(--navy-950);
  color: #fff;
}
.login-art::before {   /* blueprint grid, nods to door schedules */
  content: ''; position: absolute; inset: 0; opacity: .4;
  background-image:
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 30% 30%, #000 10%, transparent 78%);
}
.login-art::after {    /* soft arc */
  content: ''; position: absolute; width: 620px; height: 620px; right: -220px; top: -180px;
  border: 1px solid rgba(232,123,67,.28); border-radius: 50%;
}
.login-art > * { position: relative; z-index: 1; }
.login-art .mark { display: flex; align-items: center; gap: 11px; }
.login-art h1 { font-size: clamp(30px, 3.4vw, 43px); line-height: 1.1; letter-spacing: -.034em;
                font-weight: 700; margin: 0 0 16px; }
.login-art h1 em { font-style: normal; color: var(--rust-400); }
.login-art p { color: var(--navy-200); font-size: 14.5px; line-height: 1.65; max-width: 42ch; margin: 0; }
.login-stats { display: flex; gap: 34px; flex-wrap: wrap; padding-top: 30px;
               border-top: 1px solid rgba(255,255,255,.1); margin-top: 30px; }
.login-stats .v { font-size: 25px; font-weight: 700; letter-spacing: -.028em; line-height: 1.1; }
.login-stats .v sup { font-size: 13px; color: var(--rust-400); font-weight: 650; margin-left: 2px; top: -.5em; }
.login-stats .k { font-size: 10px; text-transform: uppercase; letter-spacing: .13em;
                  color: var(--navy-300); font-weight: 650; margin-top: 5px; }
.login-foot { font-size: 12px; color: var(--navy-400); display: flex; gap: 18px; flex-wrap: wrap; }

.login-form { display: grid; place-items: center; padding: 40px 28px; background: var(--bg-alt); }
.login-box { width: min(392px, 100%); }
.login-box h2 { font-size: 25px; letter-spacing: -.03em; margin: 0 0 5px; }
.login-box .sub { color: var(--text-3); font-size: 13.5px; margin: 0 0 26px; }
.login-secure { display: flex; align-items: center; gap: 7px; font-size: 12px;
                color: var(--text-3); margin-top: 16px; justify-content: center; }
.login-mobile-mark { display: none; align-items: center; gap: 10px; margin-bottom: 26px; }
@media (max-width: 940px) { .login-mobile-mark { display: flex; } }

.brand-mark { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--rust-400), var(--rust-700)); color: #fff;
  box-shadow: 0 5px 16px rgba(176,72,24,.38); flex: 0 0 auto; overflow: hidden; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-name { font-size: 15.5px; font-weight: 700; letter-spacing: -.018em; line-height: 1.15; }
.brand-sub  { font-size: 9.5px; color: var(--text-3); text-transform: uppercase;
              letter-spacing: .16em; font-weight: 700; margin-top: 2px; }
.login-art .brand-name { color: #fff; }
.login-art .brand-sub  { color: var(--rust-300); }

/* ---------------------------------------------------------------- shell */

#app { display: grid; grid-template-columns: var(--nav-w) 1fr; height: 100vh; }

nav {
  background: linear-gradient(178deg, var(--nav-bg), var(--nav-bg-2));
  color: var(--nav-text); display: flex; flex-direction: column;
  padding: 15px 11px; gap: 2px; min-height: 0; border-right: 1px solid rgba(0,0,0,.2);
}
.nav-brand { display: flex; align-items: center; gap: 11px; padding: 5px 8px 18px; }
.nav-brand .brand-name { color: #fff; }
.nav-brand .brand-sub { color: var(--rust-300); }

.nav-section { font-size: 9.5px; text-transform: uppercase; letter-spacing: .16em;
               color: var(--navy-500); font-weight: 700; padding: 17px 11px 7px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 11px; padding: 9px 11px;
  border-radius: var(--r-sm); color: var(--nav-text); cursor: pointer; font-weight: 500;
  border: 0; background: none; width: 100%; text-align: left; font-family: inherit;
  font-size: 13.5px; transition: background var(--fast), color var(--fast);
}
.nav-item:hover { background: rgba(255,255,255,.055); color: #fff; }
.nav-item.active { background: var(--nav-active-bg); color: #fff; font-weight: 600; }
.nav-item.active::before { content:''; position: absolute; left: -11px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 19px; border-radius: 0 3px 3px 0; background: var(--rust-500); }
.nav-item.active .i { color: var(--rust-400); }
.nav-item .count { margin-left: auto; background: var(--rust-500); color: #fff;
  border-radius: var(--r-full); font-size: 10.5px; font-weight: 700; padding: 1px 7px; min-width: 20px;
  text-align: center; }
.nav-foot { margin-top: auto; padding-top: 11px; border-top: 1px solid var(--nav-border); }
.nav-health { display: flex; align-items: center; gap: 9px; padding: 9px 11px; margin-bottom: 4px;
  border-radius: var(--r-sm); background: rgba(255,255,255,.04); font-size: 11.5px; color: var(--navy-300); }

main { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
       background: var(--bg); }
.topbar { display: flex; align-items: center; gap: 15px; padding: 0 24px; height: 64px;
          border-bottom: 1px solid var(--border); background: var(--surface); flex: 0 0 auto; }
.topbar h1 { font-size: 18px; letter-spacing: -.028em; line-height: 1.2; }
.topbar .sub { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.topbar .spacer { margin-left: auto; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }

.page { flex: 1 1 auto; overflow-y: auto; padding: 24px; min-height: 0; }
.page-flush { padding: 0; overflow: hidden; }
.page-max { max-width: 900px; }

/* ---------------------------------------------------------------- dashboard */

.stat-grid { display: grid; gap: 15px; grid-template-columns: repeat(auto-fit, minmax(202px, 1fr));
             margin-bottom: 18px; }
.stat { padding: 17px 18px; position: relative; overflow: hidden;
        transition: transform var(--fast), box-shadow var(--fast); }
.stat:hover { transform: translateY(-1px); box-shadow: var(--sh-3); }
.stat .top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.stat .lbl { font-size: 10px; color: var(--text-2); font-weight: 700;
             text-transform: uppercase; letter-spacing: .11em; }
.stat .ico { width: 31px; height: 31px; border-radius: 9px; display: grid; place-items: center;
             background: var(--accent-soft); color: var(--accent); }
.stat .val { font-size: 29px; font-weight: 700; letter-spacing: -.034em; line-height: 1.08; }
.stat .foot { font-size: 12px; color: var(--text-3); margin-top: 4px; display: flex;
              align-items: center; gap: 5px; }
.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 650; font-size: 11.5px; }
.trend.up { color: var(--ok-fg); } .trend.down { color: var(--ba-fg); } .trend.flat { color: var(--text-3); }

.panel-head { display: flex; align-items: center; gap: 11px; padding: 15px 18px;
              border-bottom: 1px solid var(--border); }
.panel-head h2 { font-size: 14px; font-weight: 650; letter-spacing: -.016em; }
.panel-head .sub { font-size: 12px; color: var(--text-3); }
.panel-body { padding: 18px; }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

.chart { display: flex; align-items: flex-end; gap: 8px; padding-top: 6px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px;
              min-width: 0; cursor: default; }
.chart .bars { width: 100%; display: flex; gap: 3px; align-items: flex-end;
               justify-content: center; height: 150px; }
.chart .bar { width: 45%; max-width: 18px; border-radius: 3px 3px 0 0; min-height: 3px;
              transition: height .45s var(--ease), opacity var(--fast); }
.chart .col:hover .bar { opacity: .75; }
.chart .bar.in  { background: var(--accent); }
.chart .bar.out { background: var(--navy-200); }
:root[data-theme="dark"] .chart .bar.out { background: var(--navy-600); }
.chart .day { font-size: 10.5px; color: var(--text-3); white-space: nowrap; }
.legend { display: flex; gap: 15px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 2.5px; }

.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 11px; padding: 12px 18px; border-bottom: 1px solid var(--border);
             align-items: flex-start; }
.feed-item:last-child { border-bottom: 0; }
.feed-item .when { margin-left: auto; font-size: 11px; color: var(--text-3); white-space: nowrap; }

.hlist { display: flex; flex-direction: column; }
.hrow { display: flex; align-items: center; gap: 11px; padding: 11px 18px;
        border-bottom: 1px solid var(--border); font-size: 13px; }
.hrow:last-child { border-bottom: 0; }
.hrow .k { color: var(--text-2); }
.hrow .v { margin-left: auto; font-weight: 600; }

/* ---------------------------------------------------------------- tables */

.tablewrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .11em;
            color: var(--text-3); font-weight: 700; padding: 11px 16px;
            border-bottom: 1px solid var(--border); white-space: nowrap;
            background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--fast); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.sel { background: var(--accent-soft); }
.table .actions { text-align: right; white-space: nowrap; opacity: 0; transition: opacity var(--fast); }
.table tr:hover .actions, .table tr.sel .actions { opacity: 1; }
.table input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
/* The contacts table gained a Tags column, and a name is the one thing that
   must stay on one line. The wrapper already scrolls sideways. */
.table .c-name { min-width: 190px; white-space: nowrap; }

.bulkbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px;
           background: var(--accent-soft); border-bottom: 1px solid var(--accent-line);
           font-size: 13px; font-weight: 600; color: var(--accent); }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 15px; }
.tagbar { display: flex; gap: 7px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- inbox */

.inbox { display: grid; grid-template-columns: 324px 1fr 300px; height: 100%; min-height: 0; }
.inbox > * { min-width: 0; min-height: 0; }
.col-convs { border-right: 1px solid var(--border); background: var(--surface);
             display: flex; flex-direction: column; }
.convs-head { padding: 13px 13px 0; flex: 0 0 auto; }
.convs-filters { display: flex; gap: 5px; padding: 11px 13px; flex-wrap: wrap; }
.conv-list { overflow-y: auto; flex: 1 1 auto; }
.conv {
  display: flex; gap: 11px; padding: 12px 14px; cursor: pointer;
  border-bottom: 1px solid var(--border); border-left: 3px solid transparent;
  transition: background var(--fast);
}
.conv:hover { background: var(--surface-2); }
.conv.active { background: var(--accent-soft); border-left-color: var(--accent); }
.conv .meta { flex: 1; min-width: 0; }
.conv .row1 { display: flex; align-items: baseline; gap: 8px; }
.conv .nm { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.conv .tm { margin-left: auto; font-size: 10.5px; color: var(--text-3); white-space: nowrap; }
.conv .pv { font-size: 12.5px; color: var(--text-2); overflow: hidden;
            text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.conv .row3 { display: flex; gap: 5px; margin-top: 5px; }
.conv .unread { background: var(--accent); color: #fff; border-radius: var(--r-full);
                font-size: 10.5px; font-weight: 700; padding: 1px 7px; align-self: center; min-width: 19px;
                text-align: center; }

.col-thread { display: flex; flex-direction: column; background: var(--thread-bg); }
.thread-head { display: flex; align-items: center; gap: 11px; padding: 11px 18px;
               border-bottom: 1px solid var(--border); background: var(--surface); flex: 0 0 auto; }
.msgs { flex: 1 1 auto; overflow-y: auto; padding: 20px 22px; display: flex;
        flex-direction: column; gap: 3px; scroll-behavior: smooth; }
.day-sep { align-self: center; margin: 15px 0 11px; font-size: 10px; font-weight: 700;
           color: var(--text-3); background: var(--surface); border: 1px solid var(--border);
           padding: 3px 13px; border-radius: var(--r-full);
           text-transform: uppercase; letter-spacing: .11em; }
.msg { max-width: min(580px, 76%); padding: 9px 13px; border-radius: 13px;
       white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
       box-shadow: var(--sh-1); font-size: 13.5px; line-height: 1.5;
       animation: msgIn .22s var(--ease) both; }
@keyframes msgIn { from { opacity:0; transform: translateY(5px) scale(.99); } to { opacity:1; transform:none; } }
.msg.in  { background: var(--bubble-in); align-self: flex-start;
           border: 1px solid var(--border-strong); border-bottom-left-radius: 4px;
           box-shadow: var(--sh-2); }
.msg.out { background: var(--bubble-out); color: var(--bubble-out-tx);
           align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.tpl { border: 1px dashed rgba(255,255,255,.3); }
.msg .meta { display: flex; align-items: center; gap: 5px; justify-content: flex-end;
             font-size: 10px; margin-top: 4px; opacity: .7; }
.msg.in .meta { color: var(--text-3); }

.composer { flex: 0 0 auto; border-top: 1px solid var(--border);
            background: var(--surface); padding: 12px 18px; }
.composer .row { display: flex; gap: 9px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; max-height: 140px; min-height: 42px;
                     border-radius: var(--r-lg); padding: 10px 15px; }
.quickbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 9px; }
.quick { font-size: 12px; padding: 4px 10px; border-radius: var(--r-full); cursor: pointer;
         background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
         transition: all var(--fast); font-family: inherit; }
.quick:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.col-info { border-left: 1px solid var(--border); background: var(--surface);
            overflow-y: auto; padding: 19px; }
.info-block { margin-bottom: 21px; }
.info-block h3 { font-size: 10px; text-transform: uppercase; letter-spacing: .13em;
                 color: var(--text-3); font-weight: 700; margin: 0 0 10px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0;
      font-size: 12.5px; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--text-2); }
.kv strong { font-weight: 650; text-align: right; }

@media (max-width: 1220px) { .inbox { grid-template-columns: 300px 1fr; } .col-info { display: none; } }
@media (max-width: 880px) {
  #app { grid-template-columns: 1fr; }
  nav { position: fixed; inset: 0 auto 0 0; width: var(--nav-w); z-index: 50;
        transform: translateX(-100%); transition: transform var(--med); }
  nav.open { transform: none; box-shadow: var(--sh-4); }
  .nav-scrim { position: fixed; inset: 0; background: rgba(7,14,34,.5); z-index: 49;
               animation: fadeIn .2s ease both; }
  .inbox { grid-template-columns: 1fr; }
  .inbox:not(.viewing) .col-thread { display: none; }
  .inbox.viewing .col-convs { display: none; }
  .page { padding: 16px; }
  .topbar { padding: 0 14px; }
}
.nav-toggle { display: none; }
@media (max-width: 880px) { .nav-toggle { display: inline-flex; } }

/* ---------------------------------------------------------------- templates */

.tpl-grid { display: grid; gap: 15px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.tpl { padding: 17px; display: flex; flex-direction: column; gap: 11px;
       transition: transform var(--fast), box-shadow var(--fast); }
.tpl:hover { transform: translateY(-2px); box-shadow: var(--sh-3); }
.tpl .hd { display: flex; align-items: flex-start; gap: 9px; }
.tpl .nm { font-weight: 650; word-break: break-word; font-size: 13.5px; }
.tpl .preview { background: var(--surface-2); border: 1px solid var(--border);
                border-radius: var(--r-sm); padding: 12px; font-size: 12.5px; color: var(--text-2);
                white-space: pre-wrap; max-height: 140px; overflow: auto; line-height: 1.55; }
.tpl .preview var { background: var(--accent-soft); color: var(--accent); font-style: normal;
                    padding: 0 4px; border-radius: 3px; font-weight: 650; }
.tpl .ft { display: flex; align-items: center; gap: 8px; margin-top: auto; }

/* ---------------------------------------------------------------- modal */

.modal-bg { position: fixed; inset: 0; background: rgba(7,14,34,.55); backdrop-filter: blur(4px);
            display: grid; place-items: center; z-index: 70; padding: 20px;
            animation: fadeIn .16s ease both; }
.modal { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-4);
         width: min(560px, 100%); max-height: 88vh; display: flex; flex-direction: column;
         border: 1px solid var(--border); animation: modalIn .24s var(--ease) both; }
@keyframes modalIn { from { opacity:0; transform: translateY(10px) scale(.985);} to {opacity:1;transform:none;} }
.modal-head { display: flex; align-items: center; gap: 11px; padding: 16px 19px;
              border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 15.5px; letter-spacing: -.02em; }
.modal-head .i { color: var(--accent); }
.modal-body { padding: 19px; overflow-y: auto; }
.modal-foot { display: flex; gap: 9px; justify-content: flex-end; padding: 14px 19px;
              border-top: 1px solid var(--border); background: var(--surface-2);
              border-radius: 0 0 var(--r-lg) var(--r-lg); }

.pick-list { border: 1px solid var(--border-strong); border-radius: var(--r-sm);
             max-height: 250px; overflow-y: auto; }
.pick { display: flex; align-items: center; gap: 11px; padding: 9px 12px; cursor: pointer;
        border-bottom: 1px solid var(--border); transition: background var(--fast); }
.pick:last-child { border-bottom: 0; }
.pick:hover { background: var(--surface-2); }
.pick input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ---------------------------------------------------------------- toast */

#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 90;
          display: flex; flex-direction: column; gap: 9px; pointer-events: none; }
.toast { background: var(--surface); border: 1px solid var(--border);
         border-left: 3px solid var(--accent); border-radius: var(--r-sm);
         box-shadow: var(--sh-4); padding: 12px 15px; display: flex; gap: 10px;
         align-items: center; min-width: 258px; max-width: 380px; pointer-events: auto;
         animation: toastIn .26s var(--ease) both; font-size: 13px; }
@keyframes toastIn { from { opacity:0; transform: translateX(18px) scale(.97);} to {opacity:1;transform:none;} }
.toast.out { animation: toastOut .2s var(--ease) both; }
@keyframes toastOut { to { opacity:0; transform: translateX(18px); } }
.toast .i { color: var(--accent); }
.toast.bad { border-left-color: var(--bad-600); } .toast.bad .i { color: var(--bad-600); }
.toast.ok  { border-left-color: var(--ok-600); }  .toast.ok .i  { color: var(--ok-600); }
.toast.warn { border-left-color: var(--warn-600); } .toast.warn .i { color: var(--warn-600); }

.progress { height: 6px; background: var(--surface-2); border: 1px solid var(--border);
            border-radius: var(--r-full); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .4s var(--ease); }

/* ---------------------------------------------------------------- settings */

.logo-drop { display: flex; align-items: center; gap: 16px; padding: 16px;
             border: 1px dashed var(--border-strong); border-radius: var(--r);
             transition: border-color var(--fast), background var(--fast); }
.logo-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.logo-prev { width: 60px; height: 60px; border-radius: var(--r); overflow: hidden; flex: 0 0 auto;
             display: grid; place-items: center; color: #fff;
             background: linear-gradient(145deg, var(--rust-400), var(--rust-700)); }
.logo-prev img { width: 100%; height: 100%; object-fit: cover; }

/* ---------------------------------------------------------- template bubble */

/* AI agent / handset replies — outbound, but not sent from this console */
.msg-by { display: flex; align-items: center; gap: 5px; font-size: 10.5px;
          font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
          opacity: .72; margin-bottom: 5px; }
.msg.via-ai_agent { background: var(--bubble-ai); }
.msg.via-phone    { background: var(--bubble-phone); }

.msg.via-auto { background: var(--bubble-auto); }
.msg.ai-stub .stub { font-style: italic; opacity: .78; }
.msg.ai-stub { max-width: min(320px, 60%); }

/* The "Who is answering" action can carry a long label; let it wrap rather
   than spill out of the card. */
#answerBox .btn { white-space: normal; line-height: 1.35; text-align: left;
                  height: auto; padding-top: 8px; padding-bottom: 8px; font-size: 12.5px; }
#answerBox .btn .i-xs { flex: 0 0 auto; }

/* Full-logo branding: one wide image instead of the icon + name lockup */
.nav-brand.brand-full { display: block; }
.brand-wide { display: flex; align-items: center; }
.brand-wide img { height: 100%; width: auto; max-width: 100%; object-fit: contain; display: block; }
input[type="range"] { accent-color: var(--accent); height: 30px; }

/* Inbox: who answers this one customer */
.whoswitch { display: grid; gap: 6px; }
.whoswitch .btn { justify-content: flex-start; white-space: normal; text-align: left;
                  height: auto; padding-top: 7px; padding-bottom: 7px; font-size: 12.5px; }
.whoswitch .btn:disabled { opacity: 1; }
.whoswitch .btn.btn-ghost:disabled { opacity: .45; cursor: not-allowed; }

.daybar { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 9px; }
.daybar .chip { min-width: 42px; justify-content: center; }

/* Sending an attachment */
.att-preview img { display: block; max-width: 100%; max-height: 260px;
                   border-radius: 9px; object-fit: contain; background: var(--surface-2); }
.composer .row .btn-quiet { flex: 0 0 auto; align-self: flex-end; height: 42px; padding: 0 11px; }
.varrow [data-idesc][hidden] { display: none !important; }

/* Attachments a customer sent */
.msg.att { padding: 7px 7px 9px; }
.msg.att .meta { padding: 0 5px; }
.att-img { display: block; }
.att-img img { display: block; width: 100%; max-height: 340px; object-fit: cover;
               border-radius: 9px; background: rgba(0,0,0,.08); }
.att-media { display: block; width: 100%; max-height: 340px; border-radius: 9px; background: #000; }
.att-audio { display: flex; align-items: center; gap: 8px; padding: 3px 4px; }
.att-audio audio { height: 34px; max-width: 240px; }

.att-doc { display: flex; align-items: center; gap: 10px; padding: 9px 10px;
           border-radius: 9px; text-decoration: none; color: inherit;
           background: rgba(255,255,255,.1); transition: background var(--fast); }
.msg.in .att-doc { background: var(--surface-2); }
.att-doc:hover { background: rgba(255,255,255,.18); }
.msg.in .att-doc:hover { background: var(--surface); }
.att-ext { flex: 0 0 auto; font-size: 10.5px; font-weight: 800; letter-spacing: .04em;
           padding: 7px 8px; border-radius: 6px; background: var(--accent); color: #fff; }
.att-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px;
            font-size: 12.5px; line-height: 1.3; overflow: hidden; }
.att-name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-name .dim { font-size: 11px; }
.att-gone { display: flex; gap: 7px; align-items: flex-start; font-size: 12px;
            opacity: .8; padding: 6px 4px; }

/* Assistant: engine picker, stat grid, reply preview */
.engines { display: grid; gap: 9px; }
.engine { display: flex; gap: 11px; align-items: flex-start; cursor: pointer;
          border: 1px solid var(--border); border-radius: var(--r-sm);
          padding: 12px 14px; transition: all var(--fast); }
.engine:hover { border-color: var(--text-3); }
.engine.on { border-color: var(--accent); background: var(--accent-soft); }
.engine input { margin-top: 2px; accent-color: var(--accent); flex: 0 0 auto; }
.engine strong { font-size: 13.5px; }

.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.statgrid .stat { border: 1px solid var(--border); border-radius: var(--r-sm);
                  padding: 11px 13px; background: var(--surface-2); }
.statgrid .stat .v { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.statgrid .stat .k { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

.thread-preview { background: var(--bubble-out); color: var(--bubble-out-tx);
                  border-radius: 13px; border-bottom-right-radius: 4px;
                  padding: 11px 14px; font-size: 13.5px; line-height: 1.5;
                  white-space: pre-wrap; max-width: 520px; margin-left: auto;
                  box-shadow: var(--sh-1); }
.msg.via-ai { background: var(--bubble-ai); }

/* Template variable editor: {{n}} | source | value */
.varrow { display: grid; grid-template-columns: 52px 168px 1fr; gap: 8px;
          align-items: center; margin-bottom: 8px; }
.varrow .varnum { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px;
                  font-weight: 700; color: var(--accent); text-align: center;
                  background: var(--accent-soft); border: 1px solid var(--accent-line);
                  border-radius: var(--r-xs); padding: 5px 0; }
.varrow .input[hidden] { display: none !important; }
@media (max-width: 560px) { .varrow { grid-template-columns: 46px 1fr; }
  .varrow .select { grid-column: 2; } .varrow .input { grid-column: 2; } }

/* Settings › Webhook diagnostics */
.hooklog { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow-y: auto; }
.hook { border: 1px solid var(--border); border-radius: var(--r-sm);
        background: var(--surface-2); overflow: hidden; flex: 0 0 auto; }
.hook > summary { display: flex; align-items: center; gap: 9px; padding: 8px 11px;
                  cursor: pointer; list-style: none; font-size: 12.5px; }
.hook > summary::-webkit-details-marker { display: none; }
.hook > summary:hover { background: var(--surface); }
.hook[open] > summary { border-bottom: 1px solid var(--border); }
.hook-sum { flex: 1; color: var(--text-2); overflow: hidden; text-overflow: ellipsis;
            white-space: nowrap; }
.hook-tm { color: var(--text-3); font-size: 11.5px; white-space: nowrap; }
.hook pre { margin: 0; padding: 11px 13px; font-size: 11.5px; line-height: 1.5;
            font-family: ui-monospace, Menlo, Consolas, monospace;
            background: var(--surface); color: var(--text-2);
            overflow-x: auto; max-height: 300px; }
.hlist-flush .hrow { padding-left: 0; padding-right: 0; }

.msg .tpl-img { display: block; width: 100%; max-height: 230px; object-fit: cover;
                border-radius: 8px; margin: -1px 0 8px; background: rgba(255,255,255,.06); }
.msg .tpl-head { font-weight: 700; margin-bottom: 6px; }
.msg .tpl-foot { font-size: 11.5px; opacity: .62; margin-top: 7px; }
.msg .tpl-btns { margin-top: 9px; padding-top: 3px;
                 border-top: 1px solid rgba(255,255,255,.16);
                 display: flex; flex-direction: column; }
.msg.in .tpl-btns { border-top-color: var(--border); }
.msg .tpl-btn { display: flex; align-items: center; justify-content: center; gap: 6px;
                padding: 7px 4px; font-size: 13px; font-weight: 600; color: #8FC2FF;
                border-top: 1px solid rgba(255,255,255,.10); text-decoration: none; }
.msg .tpl-btn:first-child { border-top: 0; }
.msg.in .tpl-btn { color: var(--info-600); border-top-color: var(--border); }
.msg .tpl-btn:hover { text-decoration: underline; }

/* WhatsApp text formatting */
.msg b, .msg strong { font-weight: 700; }
.msg i, .msg em { font-style: italic; }
.msg s { opacity: .7; }
.msg code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px;
            background: rgba(255,255,255,.12); padding: 1px 4px; border-radius: 4px; }
.msg.in code { background: var(--surface-2); }

/* ==================================================== the broadcast report */

.rpt-top { display: flex; align-items: center; justify-content: space-between;
           gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.rpt-actions { display: flex; gap: 8px; }
.rpt-head { margin-bottom: 14px; }
.rpt-head h2 { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }

/* The message as the customer saw it, in the same shape as an outbound bubble. */
.bubble-preview {
  background: var(--bubble-out, var(--navy-800)); color: #fff;
  padding: 11px 13px; border-radius: 14px 14px 14px 4px;
  max-width: 460px; font-size: 14.5px; line-height: 1.45; white-space: pre-wrap;
}
.bubble-preview b, .bubble-preview strong { font-weight: 700; }
.bubble-preview i, .bubble-preview em { font-style: italic; }

/* ------------------------------------------------------------------ print */

/* "Download PDF" is the browser's own Save as PDF, which is why the page has to
   print properly: everything that is furniture rather than report is dropped,
   colours are forced through, and a table is not allowed to break mid-row. */
@media print {
  @page { margin: 14mm; }

  .nav, .topbar, .rpt-top, .tabbar, #modalHost, .toast,
  .nav-foot, .fab { display: none !important; }

  html, body, .app, .main, #page {
    background: #fff !important; color: #000 !important;
    height: auto !important; overflow: visible !important;
    display: block !important; margin: 0 !important; padding: 0 !important;
  }

  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .card { border: 1px solid #d8d8d8 !important; box-shadow: none !important;
          break-inside: avoid; background: #fff !important; }
  .tablewrap { overflow: visible !important; }
  table.table { width: 100% !important; font-size: 10.5pt; }
  table.table thead { display: table-header-group; }   /* repeat on every page */
  table.table tr { break-inside: avoid; }

  .bubble-preview { background: #f2f2f2 !important; color: #000 !important;
                    border: 1px solid #ddd; max-width: none; }
  .progress { border: 1px solid #ccc; }
  .hint, .dim { color: #444 !important; }
  a[href]:after { content: ""; }
}

/* The running build, so "I uploaded it and nothing changed" has an answer. */
.nav-build { font-size: 10.5px; color: var(--navy-400); padding: 0 11px 6px;
             letter-spacing: .02em; font-variant-numeric: tabular-nums; }

/* ===================================================================== pager */

.pager {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 11px 14px; border-top: 1px solid var(--border);
}
.pager-size { display: flex; align-items: center; gap: 7px;
              font-size: 12.5px; color: var(--text-2); }
.pager-size .select { width: auto; padding: 5px 26px 5px 9px; font-size: 12.5px; }
.pager-nav { display: flex; align-items: center; gap: 4px; margin: 0 auto; }
.pager-of { font-size: 12.5px; }

.pgbtn {
  min-width: 31px; height: 31px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); font-size: 12.5px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pgbtn:hover:not(:disabled):not(.on) { background: var(--surface-2); }
.pgbtn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.pgbtn:disabled { opacity: .4; cursor: default; }
.pggap { padding: 0 3px; color: var(--text-3); font-size: 12.5px; }

@media (max-width: 720px) {
  .pager { justify-content: center; }
  .pager-nav { margin: 0; order: -1; width: 100%; justify-content: center; }
}

/* A small segmented control — used for the activity window on the Team page. */
.seg { display: inline-flex; border: 1px solid var(--border-strong);
       border-radius: var(--r-sm); overflow: hidden; }
.segbtn { padding: 5px 11px; border: 0; background: var(--surface);
          color: var(--text-2); font-size: 12px; font-weight: 600; }
.segbtn + .segbtn { border-left: 1px solid var(--border-strong); }
.segbtn:hover:not(.on) { background: var(--surface-2); }
.segbtn.on { background: var(--accent); color: #fff; }
.panel-head .seg { margin-left: auto; }

/* The activity trail is a reference, not the page. It scrolls inside a fixed
   box so a busy week cannot push everything else off the screen. */
.auditlist { max-height: 360px; overflow-y: auto; }

/* The state filters on a broadcast report. */
.rpt-filters { display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
               padding: 13px 15px; border-bottom: 1px solid var(--border); }
.rpt-filters .chip-btn .n { font-variant-numeric: tabular-nums; opacity: .7;
                            margin-left: 3px; font-weight: 700; }
.rpt-filters .chip-btn.on { background: var(--accent); border-color: var(--accent);
                            color: #fff; }
.rpt-filters .chip-btn.on .n { opacity: .85; }
.rpt-filters .chip-btn:disabled { opacity: .45; cursor: default; }
.rpt .table td.actions { white-space: nowrap; text-align: right; }

/* ==========================================================================
   Dashboard overhaul
   --------------------------------------------------------------------------
   One visual language: white cards on warm cream, a single rust accent, soft
   tinted icon tiles, and a right-hand rail. Layout and colour only - every
   panel still renders the same data from the same calls.
   ========================================================================== */

:root {
  --tile-peach: #FDECE1;
  --tile-blue:  #E9F0FB;
  --tile-green: #E6F5ED;
  --tile-ink:   #1F4E85;
  --rail-w: 304px;
}

/* ------------------------------------------------------------------ topbar */

.topbar { gap: 12px; }
.topbar .titleblock { min-width: 0; }
.topbar .titleblock[hidden] { display: none; }

/* The search: always there, never a page you have to go to. */
.omni { position: relative; display: flex; align-items: center; gap: 9px;
        flex: 1 1 520px; max-width: 620px; min-width: 0;
        height: 40px; padding: 0 12px; border-radius: var(--r-full);
        border: 1px solid var(--border-strong); background: var(--surface-2);
        transition: border-color var(--fast), background var(--fast); }
.omni:focus-within { background: var(--surface); border-color: var(--accent);
                     box-shadow: 0 0 0 3px var(--accent-soft); }
.omni > .i-sm { color: var(--text-3); flex: 0 0 auto; }
.omni input { flex: 1; min-width: 0; border: 0; background: none; outline: none;
              font-size: 13.5px; color: var(--text); }
.omni input::placeholder { color: var(--text-3); }
.kbd { flex: 0 0 auto; font-size: 10.5px; font-weight: 650; color: var(--text-3);
       border: 1px solid var(--border-strong); border-bottom-width: 2px;
       border-radius: 6px; padding: 2px 6px; background: var(--surface);
       font-family: inherit; }

.omni-menu { position: absolute; top: calc(100% + 7px); left: 0; right: 0; z-index: 60;
             background: var(--surface); border: 1px solid var(--border);
             border-radius: var(--r); box-shadow: var(--sh-3); overflow: hidden;
             max-height: 380px; overflow-y: auto; }
.omni-group { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
              color: var(--text-3); padding: 10px 13px 5px; }
.omni-item { display: flex; align-items: center; gap: 10px; width: 100%;
             padding: 8px 13px; border: 0; background: none; text-align: left; }
.omni-item:hover, .omni-item.on { background: var(--surface-2); }
.omni-item .t { font-weight: 600; font-size: 13px; }
.omni-item .s { font-size: 11.5px; color: var(--text-3); }
.omni-empty { padding: 16px 13px; font-size: 12.5px; color: var(--text-3); }

/* Who is signed in. */
.who { display: flex; align-items: center; gap: 9px; padding: 5px 9px 5px 5px;
       border: 1px solid transparent; border-radius: var(--r-full);
       background: none; color: var(--text); flex: 0 0 auto; }
.who:hover { background: var(--surface-2); border-color: var(--border); }
.who-av { width: 31px; height: 31px; border-radius: 50%; display: grid; place-items: center;
          background: var(--navy-800); color: #fff; font-weight: 700; font-size: 12.5px;
          flex: 0 0 auto; }
.who-txt { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.who-name { font-size: 12.5px; font-weight: 650; }
.who-role { font-size: 11px; color: var(--text-3); }
@media (max-width: 1080px) { .who-txt { display: none; } .omni { flex-basis: 260px; } }
@media (max-width: 760px)  { .omni { display: none; } }

/* ------------------------------------------------------------ page heading */

.dash-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap;
             margin-bottom: 18px; }
.dash-head h1 { font-size: 25px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; }
.dash-head p { font-size: 13.5px; color: var(--text-2); margin-top: 4px; }
.dash-head .picker { margin-left: auto; }

.pillsel { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px;
           border: 1px solid var(--border-strong); border-radius: var(--r-sm);
           background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; }
.pillsel select { border: 0; background: none; outline: none; font: inherit; color: inherit;
                  padding-right: 2px; }

/* ------------------------------------------------------------ the two rails */

.dash { display: grid; grid-template-columns: minmax(0, 1fr) var(--rail-w);
        gap: 16px; align-items: start; }
@media (max-width: 1240px) { .dash { grid-template-columns: minmax(0, 1fr); } }

/* ------------------------------------------------------------------ stats */

.stat-grid { grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 14px; }
.stat { padding: 16px 17px; }
.stat .top { align-items: flex-start; margin-bottom: 9px; }
.stat .lbl { font-size: 10px; letter-spacing: .1em; color: var(--text-3); }
.stat .ico { width: 42px; height: 42px; border-radius: 13px; }
.stat .ico .i-sm { width: 19px; height: 19px; }
.stat .val { font-size: 31px; }
/* Tints alternate so six cards read as a set rather than a wall. */
.stat.t-peach .ico { background: var(--tile-peach); color: var(--accent); }
.stat.t-blue  .ico { background: var(--tile-blue);  color: var(--tile-ink); }
.stat.t-green .ico { background: var(--tile-green); color: var(--ok-fg); }

/* ------------------------------------------------------------ chart header */

.legend { display: flex; align-items: center; gap: 14px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* -------------------------------------------------------- connection panel */

.conn .hrow { display: flex; align-items: center; gap: 11px; padding: 11px 16px; }
.conn .hrow + .hrow { border-top: 1px solid var(--border); }
.conn .ci { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
            background: var(--surface-2); color: var(--text-2); flex: 0 0 auto; }
.conn .k { font-size: 13px; color: var(--text-2); }
.conn .v { margin-left: auto; display: flex; align-items: center; gap: 7px; }
.conn .num { font-weight: 650; font-size: 13px; font-variant-numeric: tabular-nums; }
.conn-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
              font-weight: 650; color: var(--ok-fg); background: var(--ok-bg);
              border: 1px solid var(--ok-bd); border-radius: var(--r-full); padding: 3px 10px; }
.conn-state.bad { color: var(--ba-fg); background: var(--ba-bg); border-color: var(--ba-bd); }

/* ------------------------------------------------------------------- tabs */

.tabs { display: flex; align-items: center; gap: 2px; padding: 0 16px;
        border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab-btn { position: relative; padding: 13px 12px; border: 0; background: none;
           font-size: 13px; font-weight: 600; color: var(--text-3); }
.tab-btn:hover { color: var(--text); }
.tab-btn.on { color: var(--accent); }
.tab-btn.on::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px;
                     height: 2px; border-radius: 2px 2px 0 0; background: var(--accent); }
.tab-btn .n { margin-left: 6px; font-size: 10.5px; font-weight: 700; padding: 1px 6px;
              border-radius: var(--r-full); background: var(--accent-soft); color: var(--accent); }
.tabs .spacer { margin-left: auto; }

/* --------------------------------------------------------------- the rail */

.rail { display: flex; flex-direction: column; gap: 14px; }

.promo { position: relative; overflow: hidden; border-radius: var(--r); color: #fff;
         background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-850) 55%, #20304f 100%);
         padding: 20px 18px 18px; min-height: 196px; display: flex; flex-direction: column; }
.promo::after { content: ""; position: absolute; right: -38px; top: -38px;
                width: 168px; height: 168px; border-radius: 50%;
                background: radial-gradient(circle at 30% 30%, rgba(221,95,38,.42), transparent 70%); }
.promo h3 { font-size: 20px; font-weight: 700; letter-spacing: -.028em; line-height: 1.2;
            position: relative; z-index: 1; }
.promo p { font-size: 12.5px; color: var(--navy-300); margin-top: 8px; position: relative; z-index: 1; }
.promo .brandrow { display: flex; align-items: center; gap: 9px; margin-top: auto;
                   padding-top: 16px; position: relative; z-index: 1; }
.promo .brandrow .pm { width: 30px; height: 30px; border-radius: 9px;
                       background: var(--accent); display: grid; place-items: center; }
.promo .brandrow b { font-size: 13.5px; font-weight: 650; }

.rail-card { background: var(--surface); border: 1px solid var(--border);
             border-radius: var(--r); box-shadow: var(--sh-1); padding: 16px; }
.rail-card > h3 { font-size: 14px; font-weight: 650; letter-spacing: -.014em; margin-bottom: 13px; }

.qa { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qa-btn { display: flex; flex-direction: column; align-items: center; justify-content: center;
          gap: 9px; padding: 16px 8px; border: 1px solid var(--border);
          border-radius: var(--r-sm); background: var(--surface); color: var(--text);
          font-size: 12.5px; font-weight: 600; text-align: center;
          transition: border-color var(--fast), background var(--fast), transform var(--fast); }
.qa-btn:hover { border-color: var(--accent-line); background: var(--accent-soft);
                color: var(--accent); transform: translateY(-1px); }
.qa-btn .i { width: 20px; height: 20px; }

.usage-line { display: flex; align-items: baseline; gap: 6px; font-size: 13.5px;
              font-variant-numeric: tabular-nums; }
.usage-line b { font-size: 17px; font-weight: 700; }
.usage-bar { height: 7px; border-radius: 4px; background: var(--surface-2);
             border: 1px solid var(--border); overflow: hidden; margin-top: 10px; }
.usage-bar i { display: block; height: 100%; border-radius: 4px;
               background: linear-gradient(90deg, #2FA36B, #7FBF4F); }
.usage-bar i.warn { background: linear-gradient(90deg, #E8A33D, var(--rust-500)); }
.usage-bar i.over { background: var(--ba-fg); }
.usage-foot { display: flex; align-items: center; margin-top: 7px;
              font-size: 11.5px; color: var(--text-3); }
.usage-foot .pct { margin-left: auto; font-weight: 650; color: var(--text-2); }

.help-card { display: flex; gap: 12px; background: var(--accent-soft);
             border: 1px solid var(--accent-line); border-radius: var(--r); padding: 15px; }
.help-card .hc-ico { width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto;
                     display: grid; place-items: center; background: var(--accent); color: #fff; }
.help-card h3 { font-size: 13.5px; font-weight: 650; }
.help-card p { font-size: 12px; color: var(--text-2); margin: 4px 0 10px; }

/* --------------------------------------- dashboard corrections and the plot */

/* Six across once there is room for six, rather than four-then-two. The rail
   takes 304px, so the break is set where the main column can actually hold
   them at a readable width. */
@media (min-width: 1460px) {
  .dash .stat-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (min-width: 1240px) and (max-width: 1459px) {
  .dash .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.stat .val { font-size: 29px; }
.stat .foot { font-size: 11.5px; }

/* A value the API has not told us. Neither good news nor bad, so neither
   colour - a chip here would claim a state we do not know. */
.unknown { color: var(--text-3); font-size: 13px; }

/* The plot gets an axis and gridlines, so a bar can be read rather than
   compared by eye. */
.plot { display: flex; gap: 12px; }
.plot .yaxis { display: flex; flex-direction: column; justify-content: space-between;
               height: 150px; padding-bottom: 19px; flex: 0 0 auto;
               font-size: 10.5px; color: var(--text-3); text-align: right;
               font-variant-numeric: tabular-nums; }
.plot .area { position: relative; flex: 1; min-width: 0; }
.plot .grid { position: absolute; left: 0; right: 0; top: 0; height: 150px;
              display: flex; flex-direction: column; justify-content: space-between;
              pointer-events: none; }
.plot .grid i { display: block; height: 1px; background: var(--border); opacity: .85; }
.plot .grid i:last-child { background: var(--border-strong); }
.chart { position: relative; z-index: 1; padding-top: 0; }
.chart .bars { align-items: flex-end; }
.chart .bar.out { background: var(--navy-300); }

/* ------------------------------------------------ dashboard fit and finish */

/* The Connection panel carries numbers and pills that must not be cut off, so
   it gets a floor rather than a share of whatever is left. */
.dash .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(300px, 0.62fr); }
@media (max-width: 1100px) { .dash .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* Six labels of different lengths would otherwise push six numbers to six
   different heights. Two lines are reserved whether or not they are used. */
.stat .lbl { display: block; min-height: 26px; line-height: 1.3; }
.stat .top { gap: 10px; }
.stat .ico { flex: 0 0 auto; }
.stat .foot { min-height: 30px; align-items: flex-start; }

.conn .k { flex: 0 0 auto; }
.conn .v { min-width: 0; justify-content: flex-end; }
.conn .num { white-space: nowrap; }

/* ------------------------------------------- header order and chart height */

/* The section name reads first, then the search. A search bar ahead of the
   page title made every page look like it belonged to the search box. */
.topbar .titleblock { flex: 0 0 auto; }
.omni { flex: 0 1 320px; max-width: 320px; margin-left: 4px; }
@media (max-width: 1240px) { .omni { flex-basis: 240px; } }

/* The plot and the connection panel are side by side, so they should finish at
   the same line. The bars carry the extra height rather than the padding, and
   stretch keeps them level if either panel gains a row later. */
.dash .grid-2 { align-items: stretch; }
.dash .grid-2 > .card { display: flex; flex-direction: column; }
.dash .grid-2 > .card .panel-body { flex: 1; display: flex; flex-direction: column; }
.dash .plot { flex: 1; align-items: stretch; }
.dash .plot .yaxis { height: auto; }
.dash .plot .grid { height: calc(100% - 19px); }
.dash .chart { height: 100%; }
.dash .chart .col { justify-content: flex-end; height: 100%; }
.dash .chart .bars { height: auto; flex: 1; }
.dash .plot .area { min-height: 210px; }
.chart .bar { min-height: 3px; }

/* ==========================================================================
   Choosing who a broadcast goes to
   --------------------------------------------------------------------------
   Segments and tags are different things, so they are shown as different
   things: their own heading, their own row, and a line saying what each one
   means. Select all and Clear are actions and sit apart from both.
   ========================================================================== */

.pk-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 11px; }
.pk-count { margin-left: auto; flex: 0 0 auto; font-size: 12.5px; font-weight: 650;
            color: var(--text-3); background: var(--surface-2);
            border: 1px solid var(--border); border-radius: var(--r-full);
            padding: 5px 12px; font-variant-numeric: tabular-nums; }
.pk-count.on { color: var(--accent); background: var(--accent-soft);
               border-color: var(--accent-line); }

.pk-groups { border: 1px solid var(--border); border-radius: var(--r-sm);
             background: var(--surface-2); overflow: hidden; margin-bottom: 11px; }
.pk-group { padding: 11px 13px; }
.pk-group + .pk-group { border-top: 1px solid var(--border); }
.pk-glabel { display: flex; align-items: center; gap: 6px; margin-bottom: 8px;
             font-size: 10.5px; font-weight: 700; letter-spacing: .09em;
             text-transform: uppercase; color: var(--text-2); }
.pk-note { text-transform: none; letter-spacing: 0; font-weight: 500;
           font-size: 11.5px; color: var(--text-3); margin-left: 2px; }
.pk-chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* One chip = one group. Lit while everybody in it is selected, so the row of
   chips reads back the selection instead of only adding to it. */
.pk-chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px 4px 8px;
           border: 1px solid var(--border-strong); border-radius: var(--r-full);
           background: var(--surface); color: var(--text); font-size: 12.5px;
           font-weight: 600; max-width: 100%; }
.pk-chip:hover:not(:disabled) { border-color: var(--accent-line); background: var(--accent-soft); }
.pk-chip:disabled { opacity: .45; cursor: default; }
.pk-chip .pk-dot { width: 13px; height: 13px; border-radius: 50%; flex: 0 0 auto;
                   border: 1.5px solid var(--border-strong); background: var(--surface);
                   position: relative; transition: background var(--fast), border-color var(--fast); }
.pk-chip .n { font-size: 11px; font-weight: 700; color: var(--text-3);
              font-variant-numeric: tabular-nums; }
.pk-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.pk-chip.on .n { color: rgba(255,255,255,.8); }
.pk-chip.on .pk-dot { background: #fff; border-color: #fff; }
.pk-chip.on .pk-dot::after { content: ""; position: absolute; inset: 3px;
                             border-radius: 50%; background: var(--accent); }

.pk-more { border: 1px dashed var(--border-strong); border-radius: var(--r-full);
           background: none; color: var(--text-2); font-size: 12px; font-weight: 600;
           padding: 4px 11px; }
.pk-more:hover { border-color: var(--accent); color: var(--accent); }

/* Actions, kept away from the groups so the two cannot be mistaken. */
.pk-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 9px; }
.pk-search { flex: 1 1 240px; min-width: 180px; }
.pk-only { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px;
           color: var(--text-2); white-space: nowrap; }

.pk-foot { display: flex; align-items: center; gap: 10px; margin-top: 8px;
           font-size: 12px; color: var(--text-3); }
.pk-foot .dim { margin-left: auto; }

/* A row hidden by the search must not leave a gap in the list. */
.pick[hidden] { display: none; }

/* ==========================================================================
   Template builder
   --------------------------------------------------------------------------
   Numbered steps down the left, a phone on the right that updates as you type.
   Every limit Meta enforces is shown as a counter rather than discovered as a
   rejection.
   ========================================================================== */

.tb { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
@media (max-width: 1180px) { .tb { grid-template-columns: minmax(0, 1fr); } }

.tb-form { max-width: 760px; }
.tb-top { margin-bottom: 18px; }
.tb-top h2 { font-size: 21px; font-weight: 700; letter-spacing: -.026em; margin-top: 10px; }

.tb-sec { background: var(--surface); border: 1px solid var(--border);
          border-radius: var(--r); box-shadow: var(--sh-1);
          padding: 17px 18px; margin-bottom: 14px; }
.tb-h { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 650;
        letter-spacing: -.012em; margin-bottom: 13px; }
.tb-n { width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto;
        display: grid; place-items: center; background: var(--accent-soft);
        color: var(--accent); font-size: 11.5px; font-weight: 700; }
.tb-opt { font-size: 11.5px; font-weight: 500; color: var(--text-3); margin-left: 2px; }

.tb-count { font-size: 11.5px; color: var(--text-3); text-align: right; margin-top: 4px;
            font-variant-numeric: tabular-nums; }
.tb-count.over { color: var(--ba-fg); font-weight: 650; }
.tb-row { display: flex; align-items: center; gap: 12px; margin-top: 6px; flex-wrap: wrap; }
.tb-row .tb-count { margin: 0 0 0 auto; }

.tb-bad { margin-top: 9px; font-size: 12.5px; color: var(--ba-fg);
          background: var(--ba-bg); border: 1px solid var(--ba-bd);
          border-radius: var(--r-sm); padding: 8px 11px; line-height: 1.5; }

/* Category: a choice with its consequence written next to it. */
.tb-cats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 9px; }
@media (max-width: 620px) { .tb-cats { grid-template-columns: 1fr; } }
.tb-cat { text-align: left; padding: 12px 13px; border: 1px solid var(--border-strong);
          border-radius: var(--r-sm); background: var(--surface); color: var(--text); }
.tb-cat strong { display: block; font-size: 13.5px; font-weight: 650; }
.tb-cat span { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 3px;
               line-height: 1.45; }
.tb-cat:hover { border-color: var(--accent-line); }
.tb-cat.on { border-color: var(--accent); background: var(--accent-soft); }
.tb-cat.on strong { color: var(--accent); }

.tb-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.tb-pill { padding: 6px 13px; border: 1px solid var(--border-strong);
           border-radius: var(--r-full); background: var(--surface);
           color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.tb-pill:hover { border-color: var(--accent-line); color: var(--accent); }
.tb-pill.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.tb-file { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

.tb-ex { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.tb-var { flex: 0 0 auto; font-size: 12px; font-weight: 700; color: var(--accent);
          background: var(--accent-soft); border: 1px solid var(--accent-line);
          border-radius: var(--r-sm); padding: 5px 9px; font-family: ui-monospace, monospace; }

.tb-btns { display: flex; flex-direction: column; gap: 10px; margin-bottom: 11px; }
.tb-btn { border: 1px solid var(--border); border-radius: var(--r-sm);
          padding: 11px 12px; background: var(--surface-2);
          display: flex; flex-direction: column; gap: 8px; }
.tb-btn-h { display: flex; align-items: center; gap: 5px; }
.tb-btn-h .chip { margin-right: auto; }
.tb-add { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }

.tb-submit { margin-top: 4px; }
.tb-submit .banner { margin-bottom: 12px; }

/* ------------------------------------------------------------- the preview */

.tb-preview { position: sticky; top: 16px; }
.tb-plabel { font-size: 10.5px; font-weight: 700; letter-spacing: .09em;
             text-transform: uppercase; color: var(--text-3); margin-bottom: 9px; }

.bp-phone { border: 1px solid var(--border-strong); border-radius: 22px; overflow: hidden;
            background: var(--thread-bg); box-shadow: var(--sh-2); }
.bp-bar { display: flex; align-items: center; gap: 9px; padding: 13px 13px 11px;
          background: var(--navy-900); color: #fff; }
.bp-av { width: 29px; height: 29px; border-radius: 50%; display: grid; place-items: center;
         background: rgba(255,255,255,.16); font-size: 12px; font-weight: 700; }
.bp-nm { font-size: 13px; font-weight: 650; }
.bp-on { font-size: 10.5px; color: var(--navy-300); }
.bp-body { padding: 14px 12px 20px; min-height: 230px; }

.bp-bubble { background: var(--bubble-in); border-radius: 9px 9px 9px 2px;
             padding: 7px 9px 5px; box-shadow: 0 1px 1px rgba(11,20,48,.12);
             max-width: 94%; font-size: 13.5px; line-height: 1.45; }
.bp-head { font-weight: 700; margin-bottom: 4px; }
.bp-media { width: 100%; border-radius: 6px; margin-bottom: 6px; display: block;
            max-height: 150px; object-fit: cover; }
.bp-media-empty { height: 104px; display: grid; place-items: center; gap: 5px;
                  background: var(--cream-400); color: var(--text-3);
                  font-size: 11px; font-weight: 650; letter-spacing: .06em; }
.bp-text { white-space: pre-wrap; word-break: break-word; }
.bp-foot { font-size: 11.5px; color: var(--text-3); margin-top: 5px; }
.bp-time { font-size: 10px; color: var(--text-3); text-align: right; margin-top: 2px; }

.bp-btns { display: flex; flex-direction: column; gap: 3px; margin-top: 3px; max-width: 94%; }
.bp-btn { background: var(--bubble-in); border-radius: 7px; padding: 8px;
          text-align: center; font-size: 13px; font-weight: 600; color: #0B7FD4;
          box-shadow: 0 1px 1px rgba(11,20,48,.12);
          display: flex; align-items: center; justify-content: center; gap: 6px; }
