/* =========================================================
   PBToolkit — design tokens & global styles
   Hunter green + Manrope palette
   ========================================================= */

:root {
  --c-text:        #111827;
  --c-muted:       #6b7280;
  --c-subtle:      #9ca3af;
  --c-bg:          #f9fafb;
  --c-surface:     #ffffff;
  --c-brand:       #355E3B;
  --c-brand-dark:  #1e3d22;
  --c-brand-light: #edf7ee;
  --c-danger:      #c62828;
  --c-danger-bg:   #fef2f2;
  --c-warn:        #c47c00;
  --c-warn-bg:     #fffbeb;
  --c-ok:          #2e7d32;
  --c-ok-bg:       #f0faf0;
  --c-info:        #1565c0;
  --c-info-bg:     #eff6ff;
  --c-border:      #e5e7eb;
  --c-border-focus:#74b87e;
  --c-bg-hover:    #f3f4f6;

  --r-sm: 3px;
  --r-md: 5px;
  --r-lg: 8px;

  --shadow-card: none;
  --shadow-modal: 0 8px 40px rgba(0,0,0,.18);

  --font: 'Manrope', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--c-text);
  background: var(--c-bg);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Layout ── */
.app-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 32px;
  height: 56px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}

.topbar-logo {
  font-size: 15px;
  font-weight: 700;
  color: var(--c-text);
  letter-spacing: -.3px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: var(--font);
}
.topbar-logo:hover { text-decoration: none; }

/* Logo SVG — inline sizing */
.logo-svg {
  display: inline-block;
  vertical-align: middle;
  height: 22px;
  width: auto;
}

/* Hammer-T swing animation */
.hammer-t {
  transform-origin: 132px 68px;   /* pivot at base of T stem */
  will-change: transform;
}
.hit-o {
  transform-origin: 164px 68px;   /* pivot at bottom-center of first O */
  will-change: transform;
}

.topbar-logo:hover .hammer-t {
  animation: hammer-swing 0.6s cubic-bezier(.36,.07,.19,.97) infinite;
}
.topbar-logo:hover .hit-o {
  animation: o-squish 0.6s cubic-bezier(.36,.07,.19,.97) infinite;
}

@keyframes hammer-swing {
  0%   { transform: rotate(0deg); }
  30%  { transform: rotate(-20deg); }
  55%  { transform: rotate(6deg); }
  70%  { transform: rotate(-3deg); }
  100% { transform: rotate(0deg); }
}

@keyframes o-squish {
  0%   { transform: scale(1, 1); }
  30%  { transform: scale(1, 1); }
  55%  { transform: scale(1.08, 0.88); }
  70%  { transform: scale(0.97, 1.04); }
  100% { transform: scale(1, 1); }
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-dot { color: var(--c-border); }

.topbar-tool-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text);
}

.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ── Datacenter toggle ── */
.dc-toggle {
  display: flex;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.dc-btn {
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--c-muted);
  font-family: var(--font);
  transition: background .15s, color .15s;
  letter-spacing: .03em;
}
.dc-btn:hover { background: var(--c-border); color: var(--c-text); }
.dc-btn.active { background: var(--c-brand-light); color: var(--c-brand); }

.main-content {
  display: grid;
  grid-template-columns: 280px 1fr;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  padding: 32px 24px;
  gap: 24px;
  align-items: start;
}

/* Grid items default to min-width:auto — they expand to fit content rather than
   shrink. Wide content (tables, nowrap summary bars) blows out the 1fr column and
   overflows the viewport. min-width:0 lets the column shrink; child overflow rules
   (overflow:hidden, overflow-x:auto) then contain the content correctly. */
#view-area { min-width: 0; }

/* ── Sidebar nav ── */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--c-muted);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background .15s, color .15s;
}

.nav-item:hover { background: var(--c-border); color: var(--c-text); }
.nav-item.active { background: var(--c-brand-light); color: var(--c-brand); box-shadow: inset 3px 0 0 var(--c-brand); }
.nav-item .icon { font-size: 16px; flex-shrink: 0; }

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--c-subtle);
  padding: 16px 14px 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--c-border);
}

.nav-group-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-brand);
  background: var(--c-border);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  margin: 16px 0 2px;
}
.nav-group-label:first-child { margin-top: 4px; }

.btn-back-home {
  display: block;
  width: 100%;
  padding: 8px 14px;
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--c-muted);
  background: none;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  transition: background .15s, color .15s;
}
.btn-back-home:hover { background: var(--c-border); color: var(--c-text); }

/* ── Sidebar collapse toggle ── */
.nav-section-row {
  display: flex;
  align-items: center;
}
.nav-section-row .nav-section-label {
  flex: 1;
  border-bottom: none;  /* border lives on the row now */
  padding-bottom: 8px;
  margin-bottom: 0;
}
.nav-section-row {
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 4px;
  padding-bottom: 0;
}

.sidebar-collapse-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  background: none;
  cursor: pointer;
  color: var(--c-muted);
  font-size: 13px;
  line-height: 1;
  margin-right: 14px;
  margin-bottom: 8px;
  transition: background .15s, color .15s;
}
.sidebar-collapse-toggle:hover { background: var(--c-border); color: var(--c-text); }

/* Collapsed state: narrow sidebar, icon flips, nav content hidden */
.main-content.sidebar-collapsed {
  grid-template-columns: 44px 1fr;
}
.main-content.sidebar-collapsed .sidebar-nav > *:not(.nav-section-row) {
  display: none;
}
.main-content.sidebar-collapsed .nav-section-row .nav-section-label {
  display: none;
}
.main-content.sidebar-collapsed .nav-section-row {
  border-bottom: none;
  justify-content: center;
  padding: 4px 0;
}
.main-content.sidebar-collapsed .sidebar-collapse-toggle {
  margin-right: 0;
  margin-bottom: 0;
  /* flip ‹‹ to ›› */
  transform: rotate(180deg);
}

/* When desktop sidebar is collapsed, drop attribution below the content (mirrors mobile behaviour) */
#app-screen:has(.main-content.sidebar-collapsed) .bottom-left {
  position: static;
  bottom: auto;
  left: auto;
  z-index: auto;
  padding: 16px;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.mobile-nav-toggle { display: none; }

/* ── Panel / Card ── */
.panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}

.panel-header {
  padding: 20px 24px 0;
}

.panel-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--c-text);
}


.panel-subtitle {
  font-size: 13px;
  color: var(--c-muted);
  margin-top: 4px;
}

.panel-body { padding: 20px 24px 24px; }

.panel-divider {
  border: none;
  border-top: 1px solid var(--c-border);
  margin: 0;
}

/* ── Form elements ── */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: 6px;
}

.label-hint {
  font-weight: 400;
  color: var(--c-muted);
  margin-left: 6px;
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c-muted);
  color: var(--c-bg, #fff);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  margin-left: 5px;
  cursor: default;
  position: relative;
  vertical-align: middle;
  flex-shrink: 0;
}

.info-icon::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f1f5f9;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
  white-space: normal;
  width: 220px;
  padding: 6px 8px;
  border-radius: 5px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.info-icon:hover::after {
  opacity: 1;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 14px;
  color: var(--c-text);
  background: var(--c-surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

select {
  padding-right: 2.5rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--c-border-focus);
  box-shadow: 0 0 0 3px rgba(53,94,59,.12);
}

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

.input-row { display: flex; gap: 8px; }
.input-row input, .input-row select { flex: 1; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s, transform .1s;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary  { background: var(--c-brand); color: #fff; }
.btn-primary:hover:not(:disabled)  { background: var(--c-brand-dark); }

.btn-secondary {
  background: var(--c-surface);
  color: var(--c-text);
  border: 1px solid var(--c-border);
}
.btn-secondary:hover:not(:disabled) { background: #f3f4f6; border-color: #d1d5db; }

.btn-danger   { background: var(--c-danger); color: #fff; }
.btn-danger:hover:not(:disabled)   { background: #b91c1c; }

.btn-ghost {
  background: none;
  color: var(--c-muted);
  padding: 6px 10px;
}
.btn-ghost:hover:not(:disabled) { background: var(--c-border); color: var(--c-text); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 2px 7px; font-size: 11px; font-weight: 500; border-radius: 4px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 600;
}
.badge-ok     { background: var(--c-ok-bg);     color: var(--c-ok); }
.badge-warn   { background: var(--c-warn-bg);   color: var(--c-warn); }
.badge-danger { background: var(--c-danger-bg); color: var(--c-danger); }
.badge-info   { background: var(--c-info-bg);   color: var(--c-info); }
.badge-muted  { background: var(--c-border);    color: var(--c-muted); }
.badge-beta   { background: #f3e8ff;            color: #7c3aed; }

/* ── Alert banners ── */
.alert {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 12px;
}
.alert-icon { flex-shrink: 0; font-size: 15px; margin-top: 1px; }
.alert-ok     { background: var(--c-ok-bg);     color: var(--c-ok);     border: 1px solid #a7f3d0; border-left: 3px solid var(--c-ok); }
.alert-warn   { background: var(--c-warn-bg);   color: var(--c-warn);   border: 1px solid #fcd34d; border-left: 3px solid var(--c-warn); }
.alert-danger { background: var(--c-danger-bg); color: var(--c-danger); border: 1px solid #fca5a5; border-left: 3px solid var(--c-danger); }
.alert-info   { background: var(--c-info-bg);   color: var(--c-info);   border: 1px solid #93c5fd; border-left: 3px solid var(--c-info); }

/* ── Progress bar ── */
.progress-wrap {
  background: var(--c-border);
  border-radius: 2px;
  height: 5px;
  overflow: hidden;
  margin-top: 10px;
}

.progress-bar {
  height: 100%;
  background: var(--c-brand);
  border-radius: 2px;
  transition: width .3s ease;
}

@keyframes progress-bar-loading {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}
.progress-bar-loading {
  width: 40% !important;
  transition: none;
  animation: progress-bar-loading 1.4s ease-in-out infinite;
}

/* ── Filter block ── */
.filter-block {
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  background: var(--c-surface);
}
.filter-block-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text);
  margin: 0 0 8px;
}
.filter-radios { display: flex; flex-direction: column; gap: 6px; }
.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 400;
  color: var(--c-text);
  margin-bottom: 0;
  cursor: pointer;
}
.radio-label input[type="radio"] { margin: 0; cursor: pointer; }

.filter-dynamic-row { display: flex; gap: 8px; align-items: center; }
.filter-dynamic-row input, .filter-dynamic-row select { width: auto; }

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--c-muted);
  margin-top: 6px;
}

/* ── File drop zone ── */
.dropzone {
  border: 2px dashed var(--c-border);
  border-radius: var(--r-md);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--c-brand);
  background: var(--c-brand-light);
}
.dropzone-icon { font-size: 32px; display: block; margin-bottom: 10px; }
.dropzone-label { font-weight: 600; color: var(--c-text); }
.dropzone-hint  { font-size: 12px; color: var(--c-muted); margin-top: 4px; }

/* File-selected state */
.dropzone.has-file {
  border-style: solid;
  border-color: var(--c-brand);
  background: var(--c-brand-light);
}
.dropzone.has-file .dropzone-label {
  font-size: 13px;
  word-break: break-all;
}
.dropzone-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  color: var(--c-muted);
}
.dropzone-remove:hover { background: var(--c-bg-hover); color: var(--c-danger); }

/* ── Field mapping table ── */
.mapping-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.mapping-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-muted);
  padding: 8px 12px;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  text-align: left;
}

.mapping-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}

.mapping-table tr:last-child td { border-bottom: none; }
.mapping-table select { font-size: 13px; padding: 6px 2.5rem 6px 8px; }

.col-tag {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--c-text);
}

/* ── Results table ── */
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.results-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-muted);
  padding: 8px 12px;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  text-align: left;
}
.results-table td { padding: 8px 12px; border-bottom: 1px solid var(--c-border); }
.results-table tr:last-child td { border-bottom: none; }

/* ── Home screen ── */
.home-shell {
  display: flex;
  justify-content: center;
  padding: 48px 24px;
}

.home-content {
  width: 100%;
  max-width: 860px;
}

.home-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--c-text);
  letter-spacing: -.5px;
}

.home-subtitle {
  font-size: 14px;
  color: var(--c-muted);
  margin-top: 6px;
  margin-bottom: 32px;
}

/* ── Home sections ── */
.home-section {
  margin-bottom: 32px;
}
.home-section:last-child {
  margin-bottom: 0;
}
.home-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
}
.home-section-desc {
  font-size: 13px;
  color: var(--c-muted);
  margin-bottom: 16px;
}

/* ── Tool cards ── */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.tool-card {
  position: relative;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-left: 3px solid var(--c-brand);
  border-radius: var(--r-lg);
  padding: 24px;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  transition: border-color .15s, background .15s, box-shadow .15s;
}

.tool-card:hover {
  border-color: var(--c-brand);
  background: var(--c-brand-light);
  box-shadow: 0 4px 12px rgba(0,0,0,.09);
}

.tool-card-soon {
  opacity: .5;
  cursor: not-allowed;
}

.tool-card-soon:hover {
  border-color: var(--c-brand);
  border-left-color: var(--c-brand);
  background: var(--c-brand-light);
  box-shadow: 0 4px 12px rgba(0,0,0,.09);
}

/* WIP badge — inline chip on tool card name */
.tool-card-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 4px;
}
.tool-card-badge-wip {
  background: var(--c-warn-bg);
  color: var(--c-warn);
  border: 1px solid var(--c-warn);
}

/* Scrollable checkbox list — used by team filter and reusable for future modules */
.checkbox-scroll-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 6px 0;
}
.checkbox-scroll-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.checkbox-scroll-list label:hover {
  background: var(--c-brand-light);
}

.tool-card-icon {
  position: absolute;
  top: 24px;
  right: 24px;
  font-size: 24px;
  line-height: 1;
}

.tool-card-footer {
  margin-top: 12px;
}

.tool-card-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 28px;
}

.tool-card-desc {
  font-size: 13px;
  color: var(--c-muted);
  line-height: 1.5;
}

/* ── Connect modal ── */
.auth-shell {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.5);
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.auth-card {
  position: relative;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 440px;
  padding: 40px;
}

.auth-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--c-muted);
  padding: 4px 6px;
  border-radius: var(--r-sm);
  line-height: 1;
}
.auth-close:hover { background: var(--c-border); color: var(--c-text); }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: var(--c-muted);
  font-size: var(--fs-sm);
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-border);
}

/* ── Connection status (topbar) ── */
.conn-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--c-muted);
}
.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.conn-dot--connected    { background: var(--c-ok);   box-shadow: 0 0 0 2px var(--c-ok-bg); }
.conn-dot--disconnected { background: var(--c-warn); box-shadow: 0 0 0 2px var(--c-warn-bg); }
.conn-space-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--c-brand-light);
  color: var(--c-brand);
  border: 1px solid #b5d4b9;
  user-select: none;
}

/* ── Token warning banner (tool view) ── */
#token-warning-banner {
  max-width: 1440px;
  margin: 16px auto 0;
  padding-left: 24px;
  padding-right: 24px;
}

.token-warning {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  margin-bottom: 16px;
  background: var(--c-warn-bg);
  border: 1px solid #fcd34d;
  border-radius: var(--r-sm);
  color: var(--c-warn);
  font-size: 13px;
}
.token-warning .btn-link {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-warn);
  text-decoration: underline;
  padding: 0;
  font-family: var(--font);
}
.token-warning .btn-link:hover { color: var(--c-text); }

.auth-logo {
  font-size: 22px;
  font-weight: 800;
  color: var(--c-brand);
  margin-bottom: 8px;
  letter-spacing: -.5px;
}

.auth-tagline {
  font-size: 13px;
  color: var(--c-muted);
  margin-bottom: 28px;
}

/* ── Utilities ── */
.hidden   { display: none !important; }
.mt-4     { margin-top: 4px; }
.mt-8     { margin-top: 8px; }
.mt-12    { margin-top: 12px; }
.mt-16    { margin-top: 16px; }
.mt-20    { margin-top: 20px; }
.mb-16    { margin-bottom: 16px; }
.gap-8    { gap: 8px; }
.flex     { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-sm  { font-size: 13px; }
.text-muted { color: var(--c-muted); }
.text-danger { color: var(--c-danger); }
.text-info   { color: var(--c-info); }
.text-ok    { color: var(--c-ok); }
.font-mono { font-family: ui-monospace, monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Checkbox ── */
.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--c-muted);
}
.checkbox-row input[type="checkbox"] { width: auto; accent-color: var(--c-brand); cursor: pointer; margin: 0; flex-shrink: 0; }

/* ── Scrollable result list ── */
.result-scroll {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
}

/* ── Live import log ── */
.live-log {
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  overflow: hidden;
}

.live-log-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  font-size: 12px;
  font-weight: 600;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.live-log-counts { font-weight: 400; color: var(--c-subtle); }

.live-log-scroll {
  max-height: 240px;
  overflow-y: auto;
  background: #0f172a;
  padding: 8px 0;
  scroll-behavior: smooth;
}

.log-entry {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 3px 14px;
  font-family: ui-monospace, "Cascadia Code", "Fira Code", monospace;
  font-size: 12px;
  line-height: 1.6;
}

.log-entry .log-ts {
  flex-shrink: 0;
  color: #475569;
  font-size: 11px;
}

.log-entry .log-msg { flex: 1; }
.log-entry .log-detail { color: #475569; font-size: 11px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.log-entry.success .log-msg { color: #34d399; }
.log-entry.error   .log-msg { color: #f87171; }
.log-entry.warn    .log-msg { color: #fbbf24; }
.log-entry.info    .log-msg { color: #93c5fd; }

/* ── Entities: template list ────────────────────────────── */
.entities-template-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.entities-template-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  font-size: 14px;
}

.entities-template-name {
  color: var(--c-text);
  font-weight: 500;
}

/* ── Entities: import file picker grid ─────────────────── */
.ent-file-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.ent-export-check-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px 16px;
}

.ent-export-check-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  color: var(--c-text);
}

.ent-file-tile {
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
  overflow: hidden;
  transition: border-color .15s;
}

.ent-file-tile.has-file {
  border-color: var(--c-brand);
}

.ent-tile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-bg);
}

.ent-tile-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text);
}

.ent-tile-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--c-muted);
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
}
.ent-tile-remove:hover { color: var(--c-danger); background: var(--c-danger-bg); }

.ent-tile-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 12px;
  cursor: pointer;
  min-height: 80px;
  transition: background .15s;
}
.ent-tile-drop:hover, .ent-tile-drop.drag-over {
  background: var(--c-brand-light);
}

.ent-tile-icon { font-size: 20px; }

.ent-tile-status {
  font-size: 11px;
  color: var(--c-muted);
  text-align: center;
  word-break: break-all;
  max-width: 100%;
}

/* ── Entities: mapping tabs ─────────────────────────────── */
.ent-tab-bar {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--c-border);
  padding-bottom: 0;
}

.ent-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--c-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  transition: color .15s, border-color .15s;
}
.ent-tab-btn:hover { color: var(--c-text); }
.ent-tab-btn.active { color: var(--c-brand); border-bottom-color: var(--c-brand); }

.ent-tab-pill {
  font-size: 11px;
  font-weight: 400;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  color: var(--c-muted);
}
.ent-tab-pill.pill-ok    { background: var(--c-ok-bg);    color: var(--c-ok);    border-color: var(--c-ok); }
.ent-tab-pill.pill-error { background: var(--c-danger-bg); color: var(--c-danger); border-color: var(--c-danger); }

/* ── Entities: mapping table extras ────────────────────── */
.mapping-group-row td {
  padding: 10px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--c-muted);
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
}

.mapping-table td .badge.badge-danger {
  font-size: 10px;
  padding: 1px 5px;
  margin-left: 5px;
}

.badge-required {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--c-danger-bg);
  color: var(--c-danger);
  border: 1px solid var(--c-danger);
  vertical-align: middle;
}

.ent-type-hint {
  font-size: 11px;
  color: var(--c-muted);
  margin-left: 4px;
}

/* ── Entities: options grid ─────────────────────────────── */
.ent-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* ── Entities: delete tile column picker ────────────────── */
.ent-del-col-pick {
  padding: 6px 10px 8px;
  border-top: 1px solid var(--c-border);
  background: var(--c-bg);
}

.ent-del-col-pick .ent-del-col-label {
  font-size: 11px;
  color: var(--c-muted);
  display: block;
  margin-bottom: 4px;
}

.ent-del-col-pick select {
  width: 100%;
  font-size: 12px;
  padding: 3px 6px;
}

@media (max-width: 640px) {
  .ent-file-grid    { grid-template-columns: repeat(2, 1fr); }
  .ent-options-grid { grid-template-columns: 1fr; }
}

/* ── Mobile layout: stack sidebar above content ─────────── */
@media (max-width: 768px) {
  body { overflow-x: hidden; }

  .topbar {
    padding: 0 16px;
    gap: 8px;
  }
  .topbar-breadcrumb { display: none; }
  .topbar-right      { gap: 6px; }
  .dc-btn            { padding: 4px 8px; font-size: 11px; }
  .conn-label        { display: none; }
  .conn-space-chip   { display: none; }

  .main-content {
    grid-template-columns: 1fr;
    padding: 12px 16px 24px;
    gap: 16px;
  }

  .panel-body { overflow-x: auto; }

  /* sidebar-nav is just a pass-through block; grid goes on the wrapper divs */
  .sidebar-nav { display: block; }

  /* Collapsed by default — toggle button reveals the active sidebar */
  .sidebar-nav > div { display: none; }

  .sidebar-nav.mobile-nav-open > div:not(.hidden) {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    margin-top: 4px;
  }

  .mobile-nav-toggle {
    -webkit-appearance: none;
    appearance: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--c-text);
    cursor: pointer;
    gap: 8px;
    font-family: var(--font);
  }

  .mobile-nav-toggle:hover { background: var(--c-bg-hover); }

  .mobile-nav-chevron {
    font-style: normal;
    transition: transform 0.15s;
    flex-shrink: 0;
  }

  .sidebar-nav.mobile-nav-open .mobile-nav-chevron { transform: rotate(180deg); }

  .nav-section-label { display: none; }
  /* Collapse toggle not needed on mobile — mobile nav toggle handles it */
  .sidebar-collapse-toggle { display: none; }
  /* Ensure collapsed class doesn't apply the narrow grid on mobile */
  .main-content.sidebar-collapsed { grid-template-columns: 1fr; }
  /* Desktop collapsed rules hide all sidebar children (specificity 0,4,0) — match it to restore mobile nav elements */
  .main-content.sidebar-collapsed .sidebar-nav > .mobile-nav-toggle { display: flex; }
  .main-content.sidebar-collapsed .sidebar-nav > .btn-back-home { display: block; }
  .main-content.sidebar-collapsed .sidebar-nav.mobile-nav-open > div:not(.hidden) {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    margin-top: 4px;
  }

  .nav-group-label {
    margin: 8px 0 2px;
    font-size: 10px;
  }

  .nav-item {
    width: auto;
    white-space: normal;
    font-size: 13px;
  }

}

/* ── Entities: validation error panels ──────────────────── */
.ent-error-panel {
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  overflow: hidden;
}

.ent-error-panel-title {
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text);
}

/* ── Feedback widget ── */
.bottom-left {
  position: fixed;
  bottom: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  z-index: 200;
}

.feedback-widget {
  display: flex;
  gap: 8px;
}

.feedback-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  background: var(--c-brand);
  color: #fff;
  box-shadow: 0 1px 4px rgba(53,94,59,0.25);
}

.feedback-btn:hover {
  background: var(--c-brand-dark);
  box-shadow: 0 2px 8px rgba(53,94,59,0.35);
}

.feedback-btn--ghost {
  background: var(--c-surface);
  color: var(--c-muted);
  box-shadow: 0 1px 3px rgba(15,23,42,0.1);
  border: 1px solid var(--c-border);
}

.feedback-btn--ghost:hover {
  background: var(--c-bg);
  color: var(--c-text);
  box-shadow: 0 2px 6px rgba(15,23,42,0.12);
}

/* ── Attribution ── */
.attribution {
  font-size: 11px;
  color: var(--c-subtle);
  margin: 0;
}

.attribution a {
  color: var(--c-subtle);
  text-decoration: none;
}

.attribution a:hover {
  color: var(--c-muted);
  text-decoration: underline;
}

/* footer override must come after the .bottom-left base rule to win source order */
@media (max-width: 768px) {
  .bottom-left {
    position: static;
    bottom: auto;
    left: auto;
    z-index: auto;
    padding: 16px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
  }
}

/* ── Team Membership diff preview ── */

.tm-diff-add       { color: var(--c-ok);     }
.tm-diff-remove    { color: var(--c-danger);  }
.tm-diff-unchanged { color: var(--c-muted);   }

.tm-diff-summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 14px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  font-size: 13px;
}

.tm-diff-legend {
  display: flex;
  gap: 20px;
  font-size: 12px;
}

.tm-diff-team-block {
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  margin-bottom: 6px;
  overflow: hidden;
}

.tm-diff-team-block > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 500;
  background: var(--c-surface);
  list-style: none;
}
.tm-diff-team-block > summary::-webkit-details-marker { display: none; }
.tm-diff-team-block > summary::before { content: '▶'; margin-right: 8px; font-size: 10px; color: var(--c-muted); transition: transform .15s; }
.tm-diff-team-block[open] > summary::before { transform: rotate(90deg); }
.tm-diff-team-block > summary:hover { background: var(--c-bg); }

.tm-diff-team-unchanged > summary { color: var(--c-muted); }

.tm-diff-badges { display: flex; gap: 8px; font-size: 12px; font-weight: 600; }
.tm-diff-team-name { flex: 1; }

.tm-diff-member-rows {
  padding: 8px 14px 10px 32px;
  font-size: 13px;
  line-height: 1.8;
  border-top: 1px solid var(--c-border);
  background: var(--c-bg);
}

/* Format preview snippet */
.tm-format-preview { font-size: 12px; }
.tm-format-snippet {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: 11px;
  font-family: ui-monospace, "Cascadia Code", "Fira Code", monospace;
  color: var(--c-muted);
  white-space: pre;
  overflow-x: auto;
}

/* Format preview table */
.tm-preview-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-muted);
  margin-bottom: 4px;
  opacity: .7;
}
.tm-preview-wrap {
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  overflow: hidden;
  margin-top: 6px;
}
.tm-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.tm-preview-table th {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--c-muted);
  padding: 5px 10px;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  text-align: left;
  white-space: nowrap;
}
.tm-preview-table th.col-team {
  font-family: ui-monospace, "Cascadia Code", "Fira Code", monospace;
  font-size: 10px;
  letter-spacing: 0;
  font-weight: 500;
}
.tm-preview-table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--c-border);
  color: var(--c-muted);
  white-space: nowrap;
}
.tm-preview-table tr:last-child td { border-bottom: none; }
.tm-preview-table .col-check {
  text-align: center;
  color: var(--c-ok);
  font-size: 13px;
}

/* ══════════════════════════════════════════════════════════
   Members & Teams Management module
   ══════════════════════════════════════════════════════════ */

/* Toolbar */
.mtm-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}
.mtm-search-wrap { flex: 1; }
.mtm-search-wrap input {
  width: 100%;
  max-width: 360px;
}

/* Team list grid */
.mtm-team-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

/* Team card */
.mtm-team-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.mtm-team-card:hover {
  border-color: var(--c-border-focus);
}
.mtm-team-card.mtm-drop-target {
  border-color: var(--c-brand);
  box-shadow: 0 0 0 2px var(--c-brand-light);
}

/* Card header */
.mtm-card-header { margin-bottom: 12px; }
.mtm-card-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.mtm-card-name {
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  border-bottom: 1px dashed transparent;
}
.mtm-card-name:hover { border-bottom-color: var(--c-muted); }
.mtm-card-handle {
  font-size: 12px;
  color: var(--c-muted);
  cursor: pointer;
  border-bottom: 1px dashed transparent;
}
.mtm-card-handle:hover { border-bottom-color: var(--c-muted); }
.mtm-card-count { font-size: 11px; }
.mtm-card-desc {
  font-size: 12px;
  color: var(--c-muted);
  margin-top: 4px;
  cursor: pointer;
  border-bottom: 1px dashed transparent;
  line-height: 1.4;
}
.mtm-card-desc:hover { border-bottom-color: var(--c-muted); }

/* Inline edit input */
.mtm-inline-input {
  font-family: var(--font);
  font-size: inherit;
  font-weight: inherit;
  color: var(--c-text);
  border: 1px solid var(--c-brand);
  border-radius: var(--r-sm);
  padding: 1px 4px;
  background: var(--c-brand-light);
  outline: none;
  width: 100%;
}
.mtm-inline-textarea {
  font-family: var(--font);
  font-size: inherit;
  color: var(--c-text);
  border: 1px solid var(--c-brand);
  border-radius: var(--r-sm);
  padding: 4px 6px;
  background: var(--c-brand-light);
  outline: none;
  width: 100%;
  resize: vertical;
  line-height: 1.4;
}

/* Member list inside card */
.mtm-member-list {
  flex: 1;
  min-height: 48px;
  max-height: 240px;
  overflow-y: auto;
  margin-bottom: 8px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 2px 0;
}

/* Member row */
.mtm-member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  border-radius: var(--r-sm);
  cursor: grab;
  transition: background 0.1s;
  font-size: 13px;
  user-select: none;
  -webkit-user-select: none;
}
.mtm-member-row:hover {
  background: var(--c-info-bg);
}
.mtm-member-row.mtm-highlight {
  background: #fef9c3;
}
.mtm-member-row.mtm-dragging {
  opacity: 0.4;
}

.mtm-member-info {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.mtm-member-name { font-weight: 600; }
.mtm-member-email { font-weight: 400; color: var(--c-muted); }

.mtm-member-remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--c-muted);
  padding: 0 4px;
  border-radius: var(--r-sm);
  opacity: 0;
  transition: opacity 0.1s, color 0.1s;
}
.mtm-member-row:hover .mtm-member-remove { opacity: 1; }
.mtm-member-remove:hover { color: var(--c-danger); }

/* How-to-use expandable */
.howto {
  margin-top: 8px;
  font-size: 13px;
  color: var(--c-muted);
}
.howto[open] {
  margin-bottom: 12px;
}
.howto summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  color: var(--c-brand);
  list-style: none;
}
.howto summary::before { content: '▸ '; font-size: 20px; vertical-align: -2px; margin-right: 2px; }
.howto[open] summary::before { content: '▾ '; font-size: 20px; vertical-align: -2px; margin-right: 2px; }
.howto ul {
  margin: 8px 0 0;
  padding-left: 18px;
  line-height: 1.7;
}
.howto kbd {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 11px;
  font-family: inherit;
}

/* Card footer */
.mtm-card-footer {
  border-top: 1px solid var(--c-border);
  padding-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.mtm-btn-delete {
  background: var(--c-danger-bg);
  color: var(--c-danger);
  border: 1px solid #fca5a5;
  font-size: 12px;
}
.mtm-btn-delete:hover {
  background: var(--c-danger);
  color: #fff;
}

/* ── Add Member Modal ── */
.mtm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.mtm-modal {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-modal);
  width: 560px;
  max-width: 92vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.mtm-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--c-border);
}
.mtm-modal-title { font-size: 15px; font-weight: 600; }
.mtm-modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--c-muted);
  padding: 0 4px;
}
.mtm-modal-close:hover { color: var(--c-text); }
.mtm-modal-body {
  padding: 16px 20px;
  overflow-y: auto;
}
.mtm-modal-body input {
  width: 100%;
  margin-bottom: 12px;
}

/* Add member button (green, mirrors delete button style) */
.mtm-btn-add {
  background: var(--c-ok-bg);
  color: var(--c-ok);
  border: 1px solid #86efac;
  font-size: 12px;
}
.mtm-btn-add:hover {
  background: var(--c-ok);
  color: #fff;
}

/* Add member search results */
.mtm-add-results {
  max-height: 400px;
  overflow-y: auto;
}
.mtm-add-role-section { margin-bottom: 4px; }
.mtm-add-role-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 2px;
  position: sticky;
  top: 0;
  background: var(--c-surface);
  z-index: 1;
  cursor: pointer;
  user-select: none;
}
.mtm-add-role-header:hover { background: var(--c-bg); }
.mtm-add-chevron {
  font-size: 20px;
  color: var(--c-muted);
  width: 20px;
  text-align: center;
  line-height: 1;
}
.mtm-add-sep {
  color: var(--c-subtle);
  margin: 0 4px;
}
.mtm-add-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 6px 8px 34px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 13px;
}
.mtm-add-result-row:hover { background: var(--c-bg); }
.mtm-add-name { font-weight: 500; }
.mtm-add-email { font-size: 12px; color: var(--c-muted); text-align: right; }

/* ── Members & Teams: mobile layout ─────────────────────── */
@media (max-width: 768px) {
  /* Single-column team cards, no horizontal bleed */
  .mtm-team-list {
    grid-template-columns: 1fr;
  }
  .mtm-team-card {
    min-width: 0;
    overflow: hidden;
  }

  /* Contain member list overflow on both axes */
  .mtm-member-list {
    overflow-x: hidden;
  }

  /* Toolbar: stack search above buttons */
  .mtm-toolbar {
    flex-wrap: wrap;
  }
  .mtm-search-wrap {
    flex-basis: 100%;
  }
  .mtm-search-wrap input {
    max-width: 100%;
  }

  /* Always show the remove button on touch (no hover) */
  .mtm-member-remove {
    opacity: 1;
  }

  /* Modal: contain horizontal overflow, shrink results list */
  .mtm-modal-body {
    overflow-x: hidden;
  }
  .mtm-add-results {
    max-height: 40vh;
    overflow-x: hidden;
  }
  .mtm-add-result-row {
    overflow: hidden;
  }
  .mtm-add-email {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 40%;
  }
}

/* ── Shared confirm / alert dialog ──────────────────────── */
.app-dialog-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.app-dialog {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  box-shadow: 0 8px 30px rgba(0,0,0,.18);
  max-width: 400px; width: 90%;
  padding: 24px;
}
.app-dialog-icon { font-size: 22px; margin-right: 10px; flex-shrink: 0; }
.app-dialog-body { display: flex; align-items: flex-start; }
.app-dialog-msg { font-size: 14px; line-height: 1.5; color: var(--c-text); margin: 0; }
.app-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ── Report Issue modal ── */
.ri-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 9998;
}
.ri-modal {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-modal);
  width: 520px;
  max-width: 92vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.ri-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--c-border);
}
.ri-title { font-size: 15px; font-weight: 600; margin: 0; }
.ri-close {
  background: none; border: none;
  font-size: 20px; cursor: pointer;
  color: var(--c-muted); padding: 0 4px;
}
.ri-close:hover { color: var(--c-text); }
.ri-body {
  padding: 16px 20px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ri-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text);
  margin-top: 4px;
}
.ri-optional { font-weight: 400; color: var(--c-muted); }
.ri-required { color: var(--c-danger); }
.ri-input {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  font-family: var(--font);
  color: var(--c-text);
  background: var(--c-surface);
}
.ri-input:focus {
  outline: none;
  border-color: var(--c-border-focus);
  box-shadow: 0 0 0 2px rgba(116,184,126,.2);
}
select.ri-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.ri-textarea { resize: vertical; min-height: 56px; }
.ri-consent-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--c-muted);
  margin-top: 8px;
  line-height: 1.4;
}
.ri-consent-label input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; }
.ri-consent-label a { color: var(--c-brand); }
.ri-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}
.ri-status {
  margin-right: auto;
  font-size: 13px;
}
.ri-status--ok { color: var(--c-ok); }
.ri-status--error { color: var(--c-danger); }

/* ── Notes Merge: group preview cards ───────────────────── */

/* Table always has a scroll container so it never blows out the panel */
.nm-group-table-wrap { overflow-x: auto; }

/* Summary bar items */
.nm-group-label    { white-space: nowrap; flex-shrink: 0; }
.nm-group-count    { color: var(--c-muted); font-weight: 400; white-space: nowrap; flex-shrink: 0; }
.nm-group-title    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; font-weight: 400; flex: 1; }
.nm-group-customer { color: var(--c-muted); font-weight: 400; font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.nm-group-spacer   { flex: 0; }  /* not needed now that title takes flex:1 */
.nm-group-hint     { font-size: 11px; color: var(--c-muted); font-weight: 400; white-space: nowrap; flex-shrink: 0; }

@media (max-width: 768px) {
  /* Hide non-essential summary labels so the row doesn't overflow */
  .nm-group-customer { display: none; }
  .nm-group-hint     { display: none; }
}

/* ── Notes Merge: compare modal layout ──────────────────── */

/* Group row: needs min-width:0 so the label flex child can truncate */
.nm-cmp-group-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.nm-cmp-group-label {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.nm-cmp-controls-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 11px;
  flex-wrap: wrap;
  row-gap: 4px;
}

.nm-cmp-nav-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Split body: grid-template-rows:1fr gives the single row a definite height so
   overflow-y:auto on each panel actually works. Without it, rows size to content
   and the panels never scroll — they just overflow the modal. */
.nm-split-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#nm-split-left,
#dc-split-left {
  padding: 18px;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--c-border);
  min-width: 0;
}

#nm-split-right,
#dc-split-right {
  padding: 18px;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  position: relative;
}

/* Stack panels at 768px — at narrower widths each 50% column is too cramped
   for note detail rows to render comfortably side by side. */
@media (max-width: 768px) {
  .nm-split-body {
    grid-template-columns: 1fr;
    grid-template-rows: none;   /* rows auto-size when stacked */
    overflow-y: auto;
    overflow-x: hidden;
  }
  #nm-split-left,
  #dc-split-left {
    border-right: none;
    border-bottom: 1px solid var(--c-border);
    overflow-y: visible;        /* stacked: whole body scrolls, not each panel */
    overflow-x: hidden;
  }
  #nm-split-right,
  #dc-split-right {
    overflow-y: visible;
    overflow-x: hidden;
  }
  .nm-cmp-nav-controls { margin-left: 0; }
}

/* === Utility: visually disable a control (opacity + ignore clicks) ===
   Toggle this class on labels/wrappers instead of mutating inline styles. */
.is-disabled-ctl {
  opacity: 0.4;
  pointer-events: none;
}
