/* ===== CSS Variables / Design Tokens ===== */
:root {
  --bg-base: #0c0e14;
  --bg-surface: #13161f;
  --bg-surface-hover: #191d28;
  --bg-surface-raised: #1c2030;
  --bg-input: #10121a;
  --border: #232839;
  --border-light: #2a3048;
  --border-focus: #6366f1;
  --text-primary: #e8eaf0;
  --text-secondary: #8b92a8;
  --text-muted: #5c6380;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-soft: rgba(99,102,241,.12);
  --accent-glow: rgba(99,102,241,.25);
  --success: #22c55e;
  --danger: #ef4444;
  --danger-soft: rgba(239,68,68,.1);
  --warning: #f59e0b;
  --highlight: #facc15;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.45);
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --transition: 180ms ease;
  --sidebar-w: 52px;
}
.app-shell.sidebar-expanded { --sidebar-w: 220px; }

/* ===== Light theme overrides ===== */
:root[data-theme="light"] {
  --bg-base: #f6f7fb;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f2f4fa;
  --bg-surface-raised: #ffffff;
  --bg-input: #ffffff;
  --border: #e2e6f3;
  --border-light: #d7dced;
  --border-focus: #6366f1;
  --text-primary: #131826;
  --text-secondary: #39435a;
  --text-muted: #6b7280;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79,70,229,.12);
  --accent-glow: rgba(79,70,229,.18);
  --success: #16a34a;
  --danger: #dc2626;
  --danger-soft: rgba(220,38,38,.10);
  --warning: #d97706;
  --highlight: #fde047;
  --shadow-sm: 0 1px 3px rgba(15,23,42,.08);
  --shadow-md: 0 6px 18px rgba(15,23,42,.10);
  --shadow-lg: 0 18px 50px rgba(15,23,42,.14);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}
::selection { background: var(--accent-soft); color: var(--accent-hover); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ===== Utility ===== */
.hidden { display: none !important; }
.flex-grow { flex: 1 1 auto; }
.small-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; }

/* ===== Toast ===== */
.toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 10px 16px; border-radius: var(--radius-md);
  background: var(--bg-surface-raised); border: 1px solid var(--border-light);
  color: var(--text-primary); font-size: .85rem; font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn .3s ease forwards;
  max-width: 360px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }
.toast.leaving { animation: toastOut .25s ease forwards; }
@keyframes toastIn  { from { opacity:0; transform: translateX(40px); } to { opacity:1; transform: translateX(0); } }
@keyframes toastOut { to   { opacity:0; transform: translateX(40px); } }

/* ===== Login Overlay ===== */
.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  /* body ha overflow:hidden: se la card supera l’altezza finestra si può scorrere l’overlay */
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: clamp(16px, 4vh, 40px) 16px;
  box-sizing: border-box;
  background: radial-gradient(ellipse at 30% 20%, rgba(99,102,241,.08) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 80%, rgba(99,102,241,.05) 0%, transparent 50%),
              var(--bg-base);
}
.login-card {
  width: 400px; max-width: 92vw;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px 36px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .5s ease;
  flex-shrink: 0;
}
/* Recupero password: link ben visibile (non dipende da btn-ghost sullo sfondo scuro/chiaro) */
.login-forgot-wrap {
  text-align: center;
  margin-top: 4px;
  margin-bottom: 2px;
}
.login-forgot-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0 auto;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.login-forgot-btn:hover {
  color: var(--accent-hover);
  background: var(--accent-soft);
}

.login-oauth { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.login-oauth-divider {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
}
.login-oauth-divider::before, .login-oauth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.btn-oauth {
  width: 100%; justify-content: center; font-weight: 600;
  background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--border);
}
.btn-oauth:hover { background: var(--bg-surface-hover); border-color: var(--border-light); }
.btn-oauth-ms { border-color: rgba(0, 120, 212, .35); }
.btn-oauth-google { border-color: rgba(234, 67, 53, .35); }
.oauth-icon {
  width: 18px; height: 18px; flex-shrink: 0; display: inline-block; background-size: contain; background-repeat: no-repeat;
}
.oauth-icon-ms {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 23 23'%3E%3Cpath fill='%23f35325' d='M1 1h10v10H1z'/%3E%3Cpath fill='%2381bc06' d='M12 1h10v10H12z'/%3E%3Cpath fill='%2305a6f0' d='M1 12h10v10H1z'/%3E%3Cpath fill='%23ffba08' d='M12 12h10v10H12z'/%3E%3C/svg%3E");
}
.oauth-icon-google {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath fill='%23EA4335' d='M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z'/%3E%3Cpath fill='%234285F4' d='M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z'/%3E%3Cpath fill='%23FBBC05' d='M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z'/%3E%3Cpath fill='%2334A853' d='M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z'/%3E%3C/svg%3E");
}
.login-policy-hint {
  font-size: .78rem; color: var(--text-muted); text-align: center; line-height: 1.4; margin: 0 0 10px;
}
.app-shell:not(.sidebar-expanded) .customer-only { display: none; }
.login-subpane .btn-block { margin-top: 10px; }
.login-subpane .btn-block:first-of-type { margin-top: 0; }
@keyframes fadeUp { from { opacity:0; transform: translateY(20px); } to { opacity:1; transform: translateY(0); } }

.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-icon { font-size: 48px; color: var(--accent); }
.login-logo h1 { font-size: 1.5rem; font-weight: 700; margin: 8px 0 4px; letter-spacing: -.02em; }
.login-logo .subtitle { color: var(--text-muted); font-size: .85rem; }

.login-eplay-dev { margin-top: 12px; }
.login-eplay-dev .btn { margin-bottom: 8px; }
.login-eplay-dev-out {
  margin: 0;
  padding: 10px 12px;
  max-height: 240px;
  overflow: auto;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.45;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Barra loghi: una sola riga (Art&sofT · ePlay · Babylon) */
.company-logos-bar {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 0 0 1.35rem;
}
.company-logos-bar img {
  display: block;
  height: 36px;
  width: auto;
  max-width: min(90px, 26vw);
  object-fit: contain;
  object-position: center;
  flex: 0 0 auto;
}
/* Login: niente filtro invert (con i PNG reali poteva azzerare la visibilità); leggero pannello per contrasto */
.login-overlay .company-logos-bar {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.login-overlay .company-logos-bar img {
  filter: none;
  opacity: 1;
}
.company-logos-bar--sidebar {
  flex-wrap: nowrap;
  gap: 0.4rem;
  margin: 0 0 2px;
  padding: 6px 8px 12px;
  border-bottom: 1px solid var(--border);
  justify-content: center;
}
.company-logos-bar--sidebar img {
  height: 20px;
  max-width: 64px;
  filter: none;
  opacity: 0.95;
}
:root[data-theme="light"] .company-logos-bar--sidebar img {
  opacity: 1;
}

.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: .82rem; color: var(--text-secondary); }

.input-icon {
  position: relative; display: flex; align-items: center;
}
.input-icon .material-symbols-rounded {
  position: absolute; left: 10px; font-size: 18px; color: var(--text-muted); pointer-events: none;
}
.input-icon input { padding-left: 36px; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: var(--font-sans);
  font-size: .875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }

.select-wrap { position: relative; }
.select-wrap select { appearance: none; padding-right: 32px; cursor: pointer; }
.select-wrap .select-arrow {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 18px; color: var(--text-muted); pointer-events: none;
}

.form-error { color: var(--danger); font-size: .8rem; margin-top: 10px; min-height: 1em; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-sans); font-weight: 600; font-size: .82rem;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 8px 16px; cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.3;
}
.btn .material-symbols-rounded { font-size: 17px; }
.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: 0 0 12px var(--accent-glow); }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.btn-icon { background: transparent; color: var(--text-secondary); border: none; padding: 6px; border-radius: var(--radius-sm); }
.btn-icon:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-add-round {
  width: 34px;
  height: 34px;
  padding: 0;
  justify-content: center;
  border-radius: 10px;
  flex-shrink: 0;
}
.btn-add-round .material-symbols-rounded { font-size: 22px; }
.btn-add-round:hover { transform: scale(1.04); }
.panel-header-actions .btn-add-round { box-shadow: 0 2px 8px rgba(99, 102, 241, .35); }
.panel-header-actions .btn-add-round.active { box-shadow: 0 0 0 3px var(--accent-soft), 0 2px 10px rgba(99, 102, 241, .45); }
.btn-xs { padding: 4px 8px; font-size: .75rem; }
.btn-block { width: 100%; justify-content: center; padding: 10px; }
.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover { background: var(--danger-soft); }

.checkbox-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .82rem; color: var(--text-secondary); cursor: pointer; white-space: nowrap;
}
.checkbox-label input[type="checkbox"] { width: auto; accent-color: var(--accent); }

/* ===== App Shell Layout ===== */
.app-shell {
  display: flex; height: 100vh; overflow: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 20;
}
.sidebar-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo-icon-sm { font-size: 24px; color: var(--accent); flex-shrink: 0; }
.sidebar-brand {
  font-size: 1.05rem; font-weight: 700; letter-spacing: -.02em;
  flex: 1; min-width: 0; white-space: nowrap; overflow: hidden;
  opacity: 0; width: 0; transition: opacity var(--transition), width var(--transition);
}
.app-shell.sidebar-expanded .sidebar-brand { opacity: 1; width: auto; }
.sidebar-expand-btn { margin-left: auto; flex-shrink: 0; }
.app-shell.sidebar-expanded .sidebar-expand-btn .material-symbols-rounded { transform: rotate(180deg); }
.app-shell:not(.sidebar-expanded) .company-logos-bar--sidebar,
.app-shell:not(.sidebar-expanded) .nav-label,
.app-shell:not(.sidebar-expanded) .user-info,
.app-shell:not(.sidebar-expanded) .identity-selector .small-label,
.app-shell:not(.sidebar-expanded) .sidebar-actions .btn:not(#sidebarToggleBtn) { display: none; }
.app-shell:not(.sidebar-expanded) .sidebar-header { justify-content: center; }
.app-shell:not(.sidebar-expanded) .sidebar-expand-btn { margin-left: 0; }
.app-shell:not(.sidebar-expanded) .nav-item { justify-content: center; padding: 10px; }
.app-shell:not(.sidebar-expanded) .sidebar-footer { padding: 8px 6px; align-items: center; }
.app-shell:not(.sidebar-expanded) .identity-select { max-width: 44px; font-size: 0; padding: 6px 4px; }

.sidebar-nav { flex: 1; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px;
  background: none; border: none; border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-sans); font-size: .85rem; font-weight: 500;
  cursor: pointer; transition: all var(--transition); text-align: left;
}
.nav-item .material-symbols-rounded { font-size: 20px; }
.nav-item:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-soft); color: var(--accent-hover);
}

.sidebar-footer {
  padding: 12px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px;
}
.user-badge {
  display: flex; align-items: center; gap: 10px; padding: 4px 0;
}
.avatar {
  width: 32px; height: 32px; border-radius: var(--radius-full);
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .82rem; flex-shrink: 0;
  position: relative; overflow: hidden;
}
.avatar.avatar-sm { width: 24px; height: 24px; font-size: .7rem; }
.avatar-img {
  width: 100%; height: 100%; object-fit: cover; display: none;
  border-radius: inherit;
}
.avatar.has-photo .avatar-img { display: block; }
.avatar.has-photo .avatar-letter { display: none; }
.avatar-letter { line-height: 1; }
.msg-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.msg-author { display: inline-flex; align-items: center; gap: 6px; }
.msg-author-name { text-transform: none; letter-spacing: 0; }
.item-row .avatar { flex-shrink: 0; }
.user-info { display: flex; flex-direction: column; overflow: hidden; }
.user-name { font-weight: 600; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { font-size: .72rem; color: var(--text-muted); }
.sidebar-actions { display: flex; gap: 6px; align-items: flex-end; }
.identity-selector { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.identity-select {
  padding: 5px 8px; font-size: .78rem; border-radius: var(--radius-sm);
}

/* ===== Main Content ===== */
.main-content {
  flex: 1; overflow: hidden; position: relative;
  background: var(--bg-base);
}

/* ===== Panels ===== */
.panel {
  display: none; height: 100%; flex-direction: column;
  animation: panelIn .25s ease;
}
.panel.active { display: flex; }
@keyframes panelIn { from { opacity:0; } to { opacity:1; } }

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-header h2 {
  display: flex; align-items: center; gap: 8px;
  font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em;
}
.panel-header h2 .material-symbols-rounded { font-size: 22px; color: var(--accent); }
.panel-header--compact { padding: 10px 14px 8px; }
.panel-header--compact h2 { font-size: .92rem; }
.panel-header-actions { display: flex; align-items: center; gap: 4px; }

.panel-header-title-row {
  display: flex; align-items: center; gap: 6px;
  min-width: 0; flex: 1;
}
.panel-header-title-row h2 { min-width: 0; }

.panel-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.input-sm { padding: 6px 10px; font-size: .8rem; min-width: 0; }
.search-full { flex: 1; }
.search-full input { width: 100%; }

/* ===== Scroll lists ===== */
.scroll-list {
  flex: 1; overflow-y: auto; padding: 12px 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.scroll-list--dense { padding: 8px 12px; gap: 4px; }
.message-scroll { gap: 4px; }

/* ===== Card grid ===== */
.card-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  align-content: start;
}

/* ===== List Items ===== */
.item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left; width: 100%;
  font-family: var(--font-sans);
  color: var(--text-primary);
}
.item:hover { background: var(--bg-surface-hover); border-color: var(--border-light); }
.item.active { border-color: var(--accent); background: var(--accent-soft); }
.item .item-title { font-weight: 600; font-size: .88rem; margin-bottom: 2px; }
.item .item-sub { color: var(--text-secondary); font-size: .78rem; display: flex; justify-content: space-between; gap: 6px; }
.item .item-body { color: var(--text-secondary); font-size: .8rem; margin-top: 4px; line-height: 1.45; }
.item .item-id { font-family: var(--font-mono); font-size: .68rem; color: var(--text-muted); }
.item .item-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.search-item .item-row { justify-content: flex-start; }

/* Tags / Badges */
.tag {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: var(--radius-full);
  font-size: .7rem; font-weight: 600; letter-spacing: .02em;
}
.tag-supplier { background: rgba(99,102,241,.15); color: var(--accent-hover); }
.tag-customer { background: rgba(34,197,94,.12); color: var(--success); }
.tag-admin    { background: rgba(245,158,11,.12); color: var(--warning); }
.tag-member   { background: rgba(139,146,168,.1); color: var(--text-secondary); }
.tag-in       { background: rgba(34,197,94,.12); color: var(--success); }
.tag-out      { background: rgba(99,102,241,.12); color: var(--accent); }

.user-list-toolbar {
  padding: 0 12px 8px;
  min-height: 0;
  border-bottom: none;
}
.user-list-grouped {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px 12px 12px;
}
.user-group-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.user-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 0 2px;
}
.user-group-grid {
  padding: 0;
}

/* Card utente (identità) — evita sovrapposizione nome/tag/id */
.item-user-card {
  cursor: default;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.item-user-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}
.item-user-body {
  flex: 1;
  min-width: 0;
}
.item-user-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.item-user-card .item-title {
  flex: 1 1 8rem;
  min-width: 0;
  margin-bottom: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-user-badges {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex: 0 1 auto;
  max-width: 100%;
}
.item-user-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding-left: 34px;
}
.item-user-details {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: .78rem;
  color: var(--text-secondary);
  min-width: 0;
}
.item-user-details > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.item-user-card .item-id {
  font-size: .66rem;
  line-height: 1.35;
  word-break: break-all;
  max-width: 100%;
}
.tag-pending { background: rgba(180,100,0,.25); color: var(--text); }
#userList.card-grid,
.user-group-grid {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* ===== Chip row (suggestions) ===== */
.chip-row {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px 20px 0;
}
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--radius-full);
  background: var(--bg-surface); border: 1px solid var(--border);
  font-size: .75rem; color: var(--text-secondary);
  cursor: default; transition: all var(--transition);
}
.chip:hover { border-color: var(--border-light); color: var(--text-primary); }
.chip .material-symbols-rounded { font-size: 14px; }

/* ===== Conversation split layout ===== */
.panel-split { display: flex; flex: 1; overflow: hidden; min-height: 0; }
.panel-list {
  width: 300px; flex-shrink: 0; display: flex; flex-direction: column;
  border-right: 1px solid var(--border); overflow: hidden;
}
.panel-detail {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
  position: relative; min-width: 0;
}

.conv-list-tools { overflow: hidden; transition: max-height .25s ease; max-height: 240px; }
.conv-list-tools.collapsed { max-height: 0; border: none; }
.conv-list-tools .panel-toolbar { border-bottom: 1px solid var(--border); }

.conv-detail-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  flex-shrink: 0; min-height: 44px;
}
.back-to-list-btn { display: none; flex-shrink: 0; }
.conv-detail-title-wrap {
  display: flex; align-items: center; gap: 4px;
  flex: 1; min-width: 0;
}
.conv-detail-title {
  font-weight: 700; font-size: .9rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-detail-title-input { flex: 1; min-width: 120px; max-width: 360px; }
.conv-view-tabs--inline {
  padding: 0; border: none; flex-shrink: 0; gap: 2px;
}
.conv-view-tabs--inline .conv-view-tab {
  padding: 6px 8px; border-bottom: none; border-radius: var(--radius-sm);
}
.conv-view-tabs--inline .conv-view-tab.active {
  background: var(--accent-soft); border-bottom-color: transparent;
}

.conv-messages-body {
  flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
}
.load-more-msgs {
  align-self: center; margin: 8px 0 4px; flex-shrink: 0;
}

/* ===== Message composer ===== */
.message-composer {
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px; flex-shrink: 0;
}
.message-composer--bottom {
  border-bottom: none; border-top: 1px solid var(--border);
  padding: 10px 14px; background: var(--bg-surface);
}
.message-composer textarea {
  resize: vertical; min-height: 42px; max-height: 140px;
  font-size: .85rem; line-height: 1.5;
}
.message-composer--bottom textarea { min-height: 36px; max-height: 120px; }
.composer-actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.message-composer--bottom .composer-actions .btn-primary .material-symbols-rounded { margin: 0; }
.message-composer--bottom .composer-actions .btn-primary span:not(.material-symbols-rounded) { display: none; }
.file-label { cursor: pointer; }
.file-hidden { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }

/* ===== Message bubble style ===== */
.msg-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  cursor: pointer;
  transition: all var(--transition);
  max-width: 85%;
}
.msg-bubble:hover { background: var(--bg-surface-hover); }
.msg-bubble.out { margin-left: auto; border-color: rgba(99,102,241,.2); }
.msg-bubble.in  { margin-right: auto; border-color: rgba(34,197,94,.15); }
.msg-bubble.read { opacity: .65; filter: saturate(.85); }
.msg-bubble.hit {
  outline: 2px solid rgba(245,158,11,.55);
  box-shadow: 0 0 0 6px rgba(245,158,11,.10);
  animation: hitPulse .9s ease-out 1;
}
@keyframes hitPulse {
  0% { transform: scale(1); }
  35% { transform: scale(1.01); }
  100% { transform: scale(1); }
}
.msg-bubble .msg-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 4px;
}
.msg-bubble .msg-direction { font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.msg-bubble .msg-time { font-size: .7rem; color: var(--text-muted); font-family: var(--font-mono); }
.msg-bubble .msg-preview { font-size: .82rem; color: var(--text-secondary); line-height: 1.5; word-break: break-word; }
.msg-bubble .msg-more { font-size: .72rem; color: var(--accent); margin-top: 4px; }

/* ===== Zoom panel (message detail) ===== */
.zoom-panel {
  position: absolute; inset: 0; z-index: 10;
  background: var(--bg-base);
  display: flex; flex-direction: column;
  animation: zoomIn .2s ease;
}
@keyframes zoomIn { from { opacity:0; transform: scale(.97); } to { opacity:1; transform: scale(1); } }
.zoom-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.zoom-header h3 { font-size: .95rem; font-weight: 600; }
.zoom-body {
  flex: 1; overflow-y: auto; padding: 20px;
  font-size: .88rem; line-height: 1.7; white-space: pre-wrap; word-break: break-word;
}
.zoom-panel textarea { resize: vertical; min-height: 120px; max-height: 320px; }
.zoom-body hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.zoom-body a { color: var(--accent); text-decoration: none; }
.zoom-body a:hover { text-decoration: underline; }

/* Messaggi salvati come HTML (incolla da email) */
.msg-body-render img { max-width: 100%; height: auto; border-radius: 8px; }
.msg-body-render table { max-width: 100%; border-collapse: collapse; }
.msg-body-render td, .msg-body-render th { border: 1px solid var(--border); padding: 4px 8px; vertical-align: top; }

/* ===== Rich editor (contenteditable) ===== */
.rich-editor {
  width: 100%;
  min-height: 160px;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: .88rem;
  line-height: 1.6;
}
.rich-editor:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}
.rich-editor p { margin: 0 0 8px; }
.rich-editor ul, .rich-editor ol { margin: 0 0 8px 18px; }
.rich-editor code { font-family: var(--font-mono); }

/* ===== Compose zoom (solo editor WYSIWYG) ===== */
.compose-zoom-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 12px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.tiptap-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  flex-shrink: 0;
}
.tiptap-toolbar .tt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.tiptap-toolbar .tt-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}
.tiptap-toolbar .tt-btn .material-symbols-rounded { font-size: 18px; }
.tiptap-toolbar .tt-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}
.compose-attachments-row { padding: 0 !important; flex-shrink: 0; }
.compose-drop-zone {
  position: relative;
  flex: 1;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  overflow: hidden;
}
.compose-drop-zone:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.tiptap-mount {
  flex: 1;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tiptap-mount .ProseMirror {
  flex: 1;
  min-height: 200px;
  max-height: min(52vh, 480px);
  overflow-y: auto;
  padding: 12px 14px;
  outline: none;
  font-size: .88rem;
  line-height: 1.65;
  color: var(--text-primary);
}
.tiptap-mount .ProseMirror p { margin: 0 0 0.65em; }
.tiptap-mount .ProseMirror .is-editor-empty:first-child::before {
  color: var(--text-muted);
}
.tiptap-mount .ProseMirror ul, .tiptap-mount .ProseMirror ol { margin: 0 0 0.65em 1.25em; padding-left: 0.2em; }
.tiptap-mount .ProseMirror h1, .tiptap-mount .ProseMirror h2, .tiptap-mount .ProseMirror h3 {
  margin: 0.4em 0 0.35em;
  font-weight: 700;
  line-height: 1.25;
}
.tiptap-mount .ProseMirror h1 { font-size: 1.35rem; }
.tiptap-mount .ProseMirror h2 { font-size: 1.2rem; }
.tiptap-mount .ProseMirror h3 { font-size: 1.05rem; }
.tiptap-mount .ProseMirror blockquote {
  margin: 0.5em 0;
  padding-left: 12px;
  border-left: 3px solid var(--accent);
  color: var(--text-secondary);
}
.tiptap-mount .ProseMirror pre {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: .82rem;
  overflow-x: auto;
}
.tiptap-mount .ProseMirror table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.5em 0;
  font-size: .86rem;
}
.tiptap-mount .ProseMirror th, .tiptap-mount .ProseMirror td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  vertical-align: top;
}
.tiptap-mount .ProseMirror th { background: var(--bg-surface-hover); }
.tiptap-mount .ProseMirror img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.compose-footer-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-shrink: 0;
  padding-top: 4px;
}
/* Fallback senza TipTap: contenteditable nel riquadro */
.compose-drop-zone .rich-editor {
  flex: 1;
  min-height: 200px;
  max-height: min(52vh, 480px);
  overflow-y: auto;
  border: none;
  border-radius: 0;
  background: transparent;
}
.compose-drop-zone .rich-editor:focus {
  box-shadow: none;
}
.drop-zone { position: relative; }
.drop-zone-hint {
  position: absolute;
  inset: 8px 8px auto 8px;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: rgba(99,102,241,.10);
  border: 1px dashed rgba(99,102,241,.35);
  color: var(--text-secondary);
  font-size: .78rem;
  pointer-events: none;
  z-index: 2;
}
.drop-zone.dragover .drop-zone-hint { display: inline-flex; }

/* ===== Inbox resume (rientro) ===== */
.resume-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, .48);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  backdrop-filter: blur(3px);
}
.resume-overlay.hidden { display: none !important; }
.resume-modal {
  width: min(920px, 100%);
  max-height: min(88vh, 900px);
  display: flex; flex-direction: column;
  background: var(--bg-base);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .28);
  overflow: hidden;
}
.resume-modal-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.resume-modal-header h2 { font-size: 1.08rem; font-weight: 700; margin: 0; letter-spacing: -.02em; }
.resume-modal-sub { margin: 6px 0 0; font-size: .82rem; color: var(--text-muted); line-height: 1.4; }
.resume-modal-header-actions { display: flex; flex-wrap: wrap; gap: 6px; flex-shrink: 0; }
.resume-modal-body {
  overflow-y: auto; padding: 16px 20px 22px;
  flex: 1; min-height: 0;
}
.resume-section { margin-bottom: 22px; }
.resume-section:last-child { margin-bottom: 0; }
.resume-section-title { font-size: .95rem; font-weight: 700; margin: 0 0 10px; color: var(--text-primary); }
.resume-subheading {
  font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); margin: 14px 0 8px;
}
.resume-section-empty { font-size: .84rem; color: var(--text-muted); margin: 0; }
.resume-list { display: flex; flex-direction: column; gap: 10px; }
.resume-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--bg-surface);
  transition: border-color var(--transition);
}
.resume-item:hover { border-color: var(--border-light); }
.resume-item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.resume-item-title { font-weight: 600; font-size: .88rem; flex: 1; min-width: 0; }
.resume-item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .78rem; margin-bottom: 6px; }
.resume-item-preview { font-size: .82rem; color: var(--text-secondary); line-height: 1.45; margin-bottom: 10px; word-break: break-word; }
.resume-item-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.resume-empty { text-align: center; color: var(--text-muted); padding: 28px 12px; font-size: .88rem; }

.sidebar-nav .nav-item { position: relative; }
.nav-badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--radius-full);
  background: #ef4444; color: #fff;
  font-size: .62rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.nav-badge.hidden { display: none !important; }

/* ===== Panel hint ===== */
.panel-hint {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 20px; font-size: .78rem; color: var(--text-muted);
  background: var(--accent-soft); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* ===== Detail empty state ===== */
.detail-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; gap: 12px; color: var(--text-muted); text-align: center;
  padding: 40px;
}
.detail-empty p { font-size: .88rem; max-width: 280px; line-height: 1.5; }

/* ===== Identity detail header ===== */
.identity-detail-header h2 { gap: 8px; }
.identity-detail-header .tag { font-size: .72rem; vertical-align: middle; }

/* ===== Detail tabs ===== */
.detail-tabs {
  display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0;
  padding: 0 20px;
}
.detail-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 16px; border: none; background: none;
  color: var(--text-secondary); font-family: var(--font-sans);
  font-size: .84rem; font-weight: 500; cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}
.detail-tab .material-symbols-rounded { font-size: 18px; }
.detail-tab:hover { color: var(--text-primary); }
.detail-tab.active { color: var(--accent-hover); border-bottom-color: var(--accent); }
.tab-count {
  background: var(--bg-surface-hover); border-radius: var(--radius-full);
  padding: 1px 7px; font-size: .72rem; font-weight: 600;
  color: var(--text-muted);
}
.detail-tab.active .tab-count { background: var(--accent-soft); color: var(--accent); }

/* ===== Detail tab content ===== */
.detail-tab-content {
  display: none; flex-direction: column; flex: 1; overflow: hidden;
}
.detail-tab-content.active { display: flex; }

/* ===== Autocomplete ===== */
.autocomplete-wrap { position: relative; }
.autocomplete-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
  max-height: 280px; overflow-y: auto;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  margin-top: 4px;
  animation: dropIn .15s ease;
}
@keyframes dropIn { from { opacity:0; transform: translateY(-6px); } to { opacity:1; transform: translateY(0); } }
.ac-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  cursor: pointer; transition: background var(--transition);
  border-bottom: 1px solid var(--border);
  font-size: .84rem;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.focused { background: var(--accent-soft); }
.ac-item .material-symbols-rounded { font-size: 18px; color: var(--text-muted); flex-shrink: 0; }
.ac-item-info { display: flex; flex-direction: column; min-width: 0; }
.ac-item-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-item-detail { font-size: .72rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-section {
  padding: 6px 14px 3px; font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); background: var(--bg-surface);
}

.chips-row {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 0 0 4px;
}
.chips-row:empty { display: none; }
.chip-sel {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 6px 3px 8px; border-radius: var(--radius-full);
  font-size: .76rem; font-weight: 500; cursor: default;
  border: 1px solid;
  animation: chipIn .15s ease;
}
@keyframes chipIn { from { opacity:0; transform: scale(.9); } to { opacity:1; transform: scale(1); } }
.chip-sel .material-symbols-rounded { font-size: 14px; }
.chip-sel .chip-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: transparent; border: none; cursor: pointer;
  color: inherit; font-size: 14px; padding: 0;
  transition: background var(--transition);
}
.chip-sel .chip-x:hover { background: rgba(255,255,255,.12); }
.chip-identity { background: rgba(34,197,94,.1); border-color: rgba(34,197,94,.3); color: var(--success); }
.chip-user     { background: rgba(99,102,241,.1); border-color: rgba(99,102,241,.3); color: var(--accent-hover); }
.chip-group    { background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.3); color: var(--warning); }

.btn-xs { padding: 2px; }
.btn-xs .material-symbols-rounded { font-size: 16px; }

.new-conv-toolbar { flex-wrap: wrap; }

/* ===== Conv actions ===== */
.conv-actions { display: flex; gap: 4px; align-items: center; }
.conv-filter-bar { padding: 4px 10px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.toggle-label { display: flex; align-items: center; gap: 4px; font-size: .8rem; color: var(--text-muted); cursor: pointer; user-select: none; }
.toggle-label input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: rgba(239,68,68,.12); }
.item.archived-item { opacity: .6; }
.item.archived-item .item-title::after { content: " 📦"; }

/* ===== Highlight ===== */
mark { background: var(--highlight); color: #111; border-radius: 2px; padding: 0 2px; }

/* ===== Responsive ===== */
@media (min-width: 1280px) {
  .panel-list { width: 280px; }
}
@media (max-width: 1279px) {
  #conversationPanelSplit.conv-detail-active .panel-list { display: none; }
  #conversationPanelSplit:not(.conv-detail-active) .panel-detail { display: none; }
  #identityPanelSplit.identity-detail-active .panel-list { display: none; }
  #identityPanelSplit:not(.identity-detail-active) .panel-detail { display: none; }
  .back-to-list-btn { display: inline-flex; }
  .panel-list { width: 100%; border-right: none; }
}
@media (max-width: 900px) {
  .panel-header-text { display: none; }
  .item .item-body { display: none; }
  .item { padding: 8px 12px; }
}
@media (max-width: 640px) {
  .card-grid { grid-template-columns: 1fr; }
  .conv-actions .conv-status-select { max-width: 110px; font-size: .72rem; }
}

/* ===== Conversation items ===== */
.conv-view-tabs {
  display: flex; gap: 4px; padding: 8px 20px 0; border-bottom: 1px solid var(--border);
}
.conv-view-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border: none; background: transparent; color: var(--text-muted);
  font-size: .82rem; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent;
}
.conv-view-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.conv-view-pane { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.items-toolbar { padding: 10px 20px; gap: 8px; }
.items-split {
  display: flex; flex: 1; min-height: 0; gap: 0;
  border-top: 1px solid var(--border);
}
.items-list {
  width: 42%; min-width: 220px; max-width: 420px;
  border-right: 1px solid var(--border); padding: 8px;
}
.item-row-btn {
  width: 100%; text-align: left; border: 1px solid transparent;
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 4px;
  background: var(--surface-2); cursor: pointer;
}
.item-row-btn.active { border-color: var(--accent); background: rgba(99,102,241,.08); }
.item-row-btn .item-card-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 2px;
}
.item-row-btn .item-title-text {
  font-weight: 600;
  width: 100%;
  min-width: 0;
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
  overflow: visible;
  text-overflow: unset;
}
.item-row-btn .item-status-tag { flex-shrink: 0; }
.item-row-btn .item-msg-ref {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.item-row-btn .item-msg-ref-label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  font-size: .72rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.item-row-btn .item-msg-ref-label .material-symbols-rounded { font-size: 14px; }
.item-row-btn .item-msg-preview-lines {
  font-size: .78rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.item-row-btn .item-preview {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-preview { font-size: .78rem; color: var(--text-secondary); margin-top: 4px; line-height: 1.35; }
.meta-dual { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.item-detail {
  flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0;
}
.item-detail-header { padding: 14px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.item-detail-title-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.item-detail-title {
  font-weight: 700;
  font-size: .95rem;
  width: 100%;
  min-width: 0;
  white-space: normal;
  word-break: break-word;
  line-height: 1.35;
}
.item-status-select { width: auto; min-width: 7rem; flex-shrink: 0; }
.item-detail-msg-ref {
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.item-detail-msg-ref .item-msg-ref-label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.item-detail-msg-ref .item-msg-preview-lines,
#itemDetailMessagePreview.item-msg-preview-lines {
  font-size: .82rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  width: 100%;
}
.item-detail-msg-ref .search-item-actions,
.item-detail-msg-ref > div:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.item-detail-desc { font-size: .85rem; color: var(--text-secondary); margin-top: 6px; white-space: pre-wrap; }
.item-comments-toolbar { padding: 8px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.item-comments-list { flex: 1; padding: 12px 20px; gap: 10px; }
.item-comment {
  padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface-2);
}
.item-comment.out { border-left: 3px solid var(--accent); }
.item-comment.in { border-left: 3px solid var(--success); }
.item-comment-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.item-comment-body { white-space: pre-wrap; font-size: .88rem; line-height: 1.5; }
.item-comment-composer {
  padding: 12px 20px; border-top: 1px solid var(--border); flex-shrink: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.item-comment-composer textarea { resize: vertical; min-height: 72px; }
.search-mode-tabs {
  display: flex; gap: 4px; padding: 0 20px 10px;
}
.search-mode-tab {
  padding: 6px 12px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-secondary); font-size: .82rem; cursor: pointer;
}
.search-mode-tab.active { border-color: var(--accent); color: var(--accent); background: rgba(99,102,241,.08); }
.search-section { padding: 8px 12px 4px; }
.search-section + .search-section { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 12px; }
.search-section-head {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 8px 4px;
}
.search-section .item { margin-bottom: 8px; }
.search-item-msg-ref {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
  line-height: 1.35;
  margin-top: 4px;
}
.search-msg-preview {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  flex: 1 1 8rem;
}
.search-item-actions {
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
  padding: 0;
  border: none;
}
.toast-undo { display: flex; align-items: center; gap: 12px; max-width: 420px; }
.toast-undo-btn { margin-left: auto; flex-shrink: 0; }
.att-chip { text-decoration: none; font-size: .78rem; }
@media (max-width: 900px) {
  .items-split { flex-direction: column; }
  .items-list { width: 100%; max-width: none; max-height: 40%; border-right: none; border-bottom: 1px solid var(--border); }
}
