@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Instrument+Sans:wght@600;700&display=swap');

:root {
  --bg: #0c0f12;
  --surface: #151a21;
  --border: #2a3340;
  --text: #e8ecf1;
  --muted: #8b98a8;
  --accent: #3dd6c3;
  --accent-dim: #2a9d8f;
  --danger: #f07178;
  --radius: 12px;
  --font: 'DM Sans', system-ui, sans-serif;
  --font-display: 'Instrument Sans', var(--font);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

body.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(61, 214, 195, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 50%, rgba(42, 157, 143, 0.08), transparent),
    var(--bg);
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.shell {
  width: 100%;
  max-width: 420px;
}

.brand {
  text-align: center;
  margin-bottom: 2rem;
}

.brand h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

input[type='email'],
input[type='password'],
input[type='text'] {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  margin-bottom: 1rem;
}
input:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(61, 214, 195, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.btn:active {
  transform: scale(0.99);
}

.btn-primary {
  background: linear-gradient(165deg, var(--accent), var(--accent-dim));
  color: #0c0f12;
}
.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  width: auto;
  padding: 0.45rem 0.85rem;
  font-size: 0.9rem;
}
.btn-ghost:hover {
  color: var(--text);
  border-color: var(--muted);
}

.form-footer {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.msg {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.msg-error {
  background: rgba(240, 113, 120, 0.12);
  border: 1px solid rgba(240, 113, 120, 0.35);
  color: #ffb4b8;
}
.msg-ok {
  background: rgba(61, 214, 195, 0.1);
  border: 1px solid rgba(61, 214, 195, 0.3);
  color: var(--accent);
}

.hidden {
  display: none !important;
}

/* Dashboard shell */
body.app-page {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.app-header h1 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0;
  font-weight: 700;
}

.app-header .user-pill {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.app-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.placeholder-panel {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  text-align: center;
  color: var(--muted);
}

.placeholder-panel strong {
  display: block;
  color: var(--text);
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.profile-grid {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 2rem;
  text-align: left;
}

.profile-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 1rem;
  font-size: 0.95rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.profile-row span:first-child {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-admin {
  background: rgba(61, 214, 195, 0.15);
  color: var(--accent);
}
.badge-caller {
  background: rgba(139, 152, 168, 0.15);
  color: var(--muted);
}
.badge-moderator {
  background: rgba(147, 112, 219, 0.18);
  color: #c4b5fd;
}
.badge-teamleader {
  background: rgba(251, 191, 36, 0.15);
  color: #fcd34d;
}

.badge-access-disabled {
  background: rgba(251, 146, 60, 0.22);
  color: #fdba74;
}

.badge-access-archived {
  background: rgba(148, 163, 184, 0.22);
  color: #cbd5e1;
}

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.35rem 0;
  font-size: 0.9rem;
  cursor: pointer;
}

.checkbox-field input {
  margin-top: 0.2rem;
}

.status-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
}
.status-online {
  background: rgba(61, 214, 195, 0.15);
  color: var(--accent);
}
.status-offline {
  background: rgba(139, 152, 168, 0.12);
  color: var(--muted);
}

@media (max-width: 520px) {
  .profile-row {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}

/* —— Admin: sidebar layout (viewport locked; only stage scrolls) —— */
body.app-page.admin-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

body.app-page.admin-page .app-header {
  flex-shrink: 0;
}

body.app-page.admin-page > #load.app-main,
body.app-page.admin-page > #admin-root {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-width: none;
  margin: 0;
  padding: 0;
}

body.app-page.admin-page > #load.app-main {
  padding: 2rem;
  overflow-y: auto;
}

body.app-page.admin-page #admin-root .admin-shell {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.admin-shell {
  display: flex;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.admin-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-sidebar-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0 1rem 0.75rem;
  margin: 0;
}

.admin-nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.65rem 1.25rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: color 0.15s, background 0.15s;
}

.admin-nav-btn:hover {
  color: var(--text);
  background: rgba(61, 214, 195, 0.06);
}

.admin-nav-btn.is-active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(61, 214, 195, 0.1);
}

.admin-nav-group {
  margin: 0.35rem 0 0.5rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.admin-nav-group--collapsible {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.admin-nav-parent {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.admin-nav-parent:hover {
  color: var(--text);
  background: rgba(61, 214, 195, 0.06);
}

.admin-nav-group.has-active-child .admin-nav-parent {
  color: var(--text);
}

.admin-nav-chevron {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  position: relative;
  opacity: 0.75;
}

.admin-nav-chevron::before {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 0.35rem;
  height: 0.35rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.18s ease;
}

.admin-nav-group.is-expanded .admin-nav-chevron::before {
  transform: rotate(45deg);
}

.admin-nav-submenu:not([hidden]) {
  display: flex;
  flex-direction: column;
}

.admin-nav-btn--sub {
  padding-left: 1.65rem;
  font-size: 0.88rem;
  font-weight: 500;
}

.admin-stage {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 1.5rem 2rem 2.5rem;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.app-page.admin-page .admin-stage {
  overscroll-behavior: contain;
}

.admin-panel {
  display: none;
  max-width: 1100px;
}

.admin-panel.is-visible {
  display: block;
}

#panel-users.admin-panel {
  max-width: none;
  width: 100%;
  box-sizing: border-box;
}

#panel-teams.admin-panel {
  max-width: none;
  width: 100%;
  box-sizing: border-box;
}

#panel-data-management.admin-panel,
#panel-agents-management.admin-panel,
#panel-dialer-management.admin-panel,
#panel-reports.admin-panel,
#panel-floor-map.admin-panel {
  max-width: none;
  width: 100%;
  box-sizing: border-box;
}

.floor-map-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  margin-bottom: 0.85rem;
}

.floor-map-head h2 {
  margin: 0;
}

.floor-map-scope-hint {
  flex: 1;
  min-width: min(100%, 16rem);
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--muted);
}

.floor-map-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.65rem;
}

.floor-map-tool-btn {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  cursor: pointer;
}

.floor-map-tool-btn:hover {
  border-color: rgba(61, 214, 195, 0.45);
}

.floor-map-zoom-pct {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  min-width: 3rem;
  text-align: center;
}

.floor-map-reset-btn {
  font-size: 0.85rem;
}

.floor-map-viewport {
  position: relative;
  overflow: hidden;
  min-height: min(70vh, 780px);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  cursor: grab;
  touch-action: none;
}

.floor-map-viewport.is-panning {
  cursor: grabbing;
}

.floor-map-pan-zoom {
  transform-origin: center center;
  will-change: transform;
  display: inline-block;
  min-width: 100%;
  box-sizing: border-box;
}

.floor-map-board {
  min-width: min(100%, 720px);
}

.floor-map-board .teams-map-canvas {
  min-height: min(52vh, 560px);
}

.teams-map-canvas--floor-only {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
}

.teams-map-canvas--floor-only .teams-map-mindmap-main {
  min-width: 0;
  overflow: visible;
}

.teams-mods-scroll--floor {
  overflow: visible !important;
  max-height: none !important;
  min-height: min(48vh, 520px);
  border: none !important;
  background: transparent !important;
  padding: 0.5rem 0.35rem 1rem !important;
}

.team-map-caller-drop--monitor {
  cursor: default;
  border-style: solid;
  border-color: rgba(0, 0, 0, 0.1);
}

.team-map-tl-card--monitor {
  cursor: default;
}

.admin-section-nav-slot:empty {
  display: none;
}

.admin-section-nav-slot:not(:empty) {
  margin-bottom: 1rem;
}

.admin-placeholder-panel {
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  background: rgba(0, 0, 0, 0.08);
  color: var(--muted);
  font-size: 0.95rem;
}

.admin-placeholder-panel p {
  margin: 0;
}

.admin-panel h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 1rem;
  letter-spacing: -0.02em;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  padding: 0.65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.2);
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table td.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  color: var(--muted);
}

.admin-table .empty-row td {
  color: var(--muted);
  text-align: center;
  padding: 2rem;
}

.admin-add-user {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  max-width: 520px;
}

.admin-add-user h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 1rem;
}

.admin-add-user .field {
  margin-bottom: 0.85rem;
}

.admin-add-user label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.admin-add-user input,
.admin-add-user select {
  width: 100%;
  max-width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.admin-add-user .hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.admin-add-user .btn-add {
  margin-top: 0.25rem;
  width: auto;
  min-width: 140px;
}

.admin-add-user .msg {
  margin-top: 0.75rem;
  margin-bottom: 0;
}

@media (max-width: 720px) {
  body.app-page.admin-page #admin-root .admin-shell {
    flex-direction: column;
    min-height: 0;
  }

  .admin-sidebar {
    width: 100%;
    flex-shrink: 0;
    max-height: min(40vh, 220px);
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.75rem;
    align-content: flex-start;
    overflow-y: auto;
  }

  .admin-sidebar-title {
    width: 100%;
    padding-bottom: 0.35rem;
  }

  .admin-nav-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0;
    margin: 0;
    padding: 0.35rem 0 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }

  .admin-nav-parent {
    width: 100%;
    border-left: none;
    border-bottom: 3px solid transparent;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
  }

  .admin-nav-submenu:not([hidden]) {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.15rem 0 0.4rem;
  }

  .admin-nav-btn--sub {
    flex: 1;
    min-width: 100px;
    padding-left: 0.75rem;
  }

  .admin-nav-btn {
    flex: 1;
    min-width: 120px;
    border-left: none;
    border-bottom: 3px solid transparent;
    text-align: center;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
  }

  .admin-nav-btn.is-active {
    border-left: none;
    border-bottom-color: var(--accent);
  }

  body.app-page.admin-page .admin-stage {
    flex: 1;
    min-height: 0;
    padding: 1.25rem 1rem 2rem;
  }
}

/* —— Users management —— */
.users-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  margin-bottom: 1.25rem;
}

.users-panel-titles {
  flex: 1;
  min-width: min(100%, 280px);
}

.users-panel-head h2 {
  margin: 0;
}

.users-filters-stack {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.users-filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.users-access-filter-tabs .users-filter-btn.is-active {
  border-color: rgba(148, 163, 184, 0.45);
  background: rgba(148, 163, 184, 0.08);
}

.users-filter-btn {
  padding: 0.4rem 0.85rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.users-filter-btn:hover {
  color: var(--text);
  border-color: rgba(61, 214, 195, 0.35);
}

.users-filter-btn.is-active {
  color: var(--text);
  border-color: rgba(61, 214, 195, 0.55);
  background: rgba(61, 214, 195, 0.1);
}

.td-actions-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}

.btn-row-access {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.28rem 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(251, 146, 60, 0.45);
  background: rgba(251, 146, 60, 0.08);
  color: #fdba74;
  cursor: pointer;
  white-space: nowrap;
}

.btn-row-access:hover {
  background: rgba(251, 146, 60, 0.16);
}

.btn-row-access-archive {
  border-color: rgba(148, 163, 184, 0.45);
  background: rgba(148, 163, 184, 0.1);
  color: #cbd5e1;
}

.btn-row-access-archive:hover {
  background: rgba(148, 163, 184, 0.18);
}

.users-panel-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.45;
  max-width: 52ch;
}

.users-code {
  color: var(--accent);
  font-size: 0.85em;
}

.btn-add-user {
  width: auto;
  min-width: 8.5rem;
  padding: 0.65rem 1.15rem;
  flex-shrink: 0;
}

.users-banner {
  margin-bottom: 1rem;
}

.users-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.users-card-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.users-count {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.users-table-inner {
  border: none;
  border-radius: 0;
}

.admin-table .th-actions,
.admin-table .td-actions {
  text-align: right;
  vertical-align: middle;
  min-width: 11rem;
  max-width: 16rem;
}

.btn-table-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.75rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(61, 214, 195, 0.1);
  border: 1px solid rgba(61, 214, 195, 0.35);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-table-edit:hover {
  background: rgba(61, 214, 195, 0.18);
  border-color: var(--accent-dim);
}

.table-action-muted {
  font-size: 0.85rem;
  color: var(--muted);
}

/* —— Modals —— */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(6, 8, 10, 0.72);
  backdrop-filter: blur(6px);
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-sheet {
  width: 100%;
  max-width: 440px;
  max-height: min(90vh, 640px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.45);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.modal-close {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.modal-body {
  padding: 1.1rem 1.25rem 1.25rem;
}

.modal-body .field {
  margin-bottom: 0.9rem;
}

.modal-body label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.modal-body input[type='email'],
.modal-body input[type='password'],
.modal-body input[type='text'],
.modal-body select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  margin-bottom: 0;
}

.modal-body select {
  cursor: pointer;
}

.modal-body input:focus,
.modal-body select:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(61, 214, 195, 0.15);
}

.modal-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 1rem;
  line-height: 1.45;
}

.modal-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.65rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.btn-modal-primary,
.btn-modal-secondary {
  width: auto;
  min-width: 6.5rem;
}

.btn-modal-secondary {
  width: auto;
}

.add-dialer-preview {
  margin: -0.25rem 0 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.add-user-success .modal-hint {
  margin-top: 0;
}

.cred-dl {
  margin: 0 0 1rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  font-size: 0.9rem;
}

.cred-dl dt {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cred-dl dd {
  margin: 0;
  word-break: break-word;
}

.cred-pw-note {
  color: var(--muted);
  font-size: 0.88rem;
}

.modal-foot.cred-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 0.65rem;
}

/* —— Teams tab: list + map —— */
.teams-panel-wrap {
  margin-top: 0.5rem;
}

.teams-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.teams-view-btn {
  padding: 0.4rem 0.95rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.teams-view-btn:hover {
  color: var(--text);
  border-color: rgba(61, 214, 195, 0.35);
}

.teams-view-btn.is-active {
  color: var(--text);
  border-color: rgba(61, 214, 195, 0.55);
  background: rgba(61, 214, 195, 0.1);
}

.teams-view-panel.hidden {
  display: none;
}

.teams-map-hint {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
}

.teams-map-board {
  min-height: 120px;
}

/* Moderator columns: horizontal strip + bidirectional scroll (List + Map) */
.teams-mods-scroll {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.08);
  padding: 0.65rem 0.75rem;
  max-height: min(78vh, 52rem);
  min-height: 12rem;
}

.teams-mods-scroll--list {
  margin-top: 0.15rem;
}

.teams-mods-scroll--map {
  margin: 0;
  min-height: 14rem;
  max-height: min(78vh, 56rem);
}

/* Inside map canvas: no second box border (canvas already frames the area) */
.teams-map-canvas .teams-mods-scroll--map {
  border: none;
  background: transparent;
  padding: 0.35rem 0.25rem 0.65rem 0.5rem;
}

/* Mind map canvas: dotted background + unassigned rail + main tree */
.teams-map-canvas {
  display: grid;
  grid-template-columns: minmax(210px, 280px) 1fr;
  gap: 1.25rem;
  align-items: start;
  padding: 1rem 1.1rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background-color: rgba(0, 0, 0, 0.12);
  background-image: radial-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 14px 14px;
}

@media (max-width: 900px) {
  .teams-map-canvas {
    grid-template-columns: 1fr;
  }
}

.teams-map-unassigned {
  position: sticky;
  top: 0.5rem;
  padding: 0.85rem 0.95rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}

.teams-map-unassigned-heading {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.teams-map-unassigned-heading:not(:first-child) {
  margin-top: 1rem;
}

.teams-map-unassigned-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mm-unassigned-empty {
  margin: 0;
  font-size: 0.85rem;
}

.mm-unassigned-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.92);
  color: #1a1a1f;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  font-size: 0.85rem;
}

.mm-unassigned-card .status-pill {
  font-size: 0.7rem;
}

.mm-unassigned-kind {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(0, 0, 0, 0.45);
}

.mm-unassigned-name {
  font-weight: 600;
  color: #111;
  word-break: break-word;
}

.mm-unassigned-card--tl[draggable="true"] {
  cursor: grab;
}

.mm-unassigned-card--caller[draggable="true"] {
  cursor: grab;
}

.teams-map-mindmap-main {
  min-width: 0;
  min-height: 0;
}

.teams-map-mindmap-inner {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  align-items: stretch;
}

.teams-map-mindmap-inner.teams-map-mindmap-inner--columns {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 1.25rem 1.5rem;
  width: max-content;
  min-width: 100%;
  box-sizing: border-box;
  padding-bottom: 0.35rem;
}

.teams-map-mindmap-inner--columns .mm-mod-tree.team-map-mod-card {
  flex: 0 0 auto;
  /* Wide enough for multiple TL columns side by side; outer scroll handles overflow */
  width: max-content;
  max-width: min(64rem, calc(100vw - 5rem));
  min-width: min(20rem, calc(100vw - 10rem));
  box-sizing: border-box;
}

/* Downward mind map: moderator (root) → SVG → team leader columns */
.mm-mod-tree.team-map-mod-card {
  max-width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  padding: 1rem 1.1rem 1.25rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.mm-mod-tree.team-map-mod-card.drag-over {
  border-color: rgba(61, 214, 195, 0.55);
  box-shadow: 0 0 0 2px rgba(61, 214, 195, 0.15);
}

.mm-mod-root.mm-node--root {
  margin: 0 auto 0.25rem;
  max-width: 22rem;
  text-align: center;
  padding: 0.85rem 1.15rem;
  border-radius: 12px;
  background: linear-gradient(165deg, #25252c 0%, #18181c 100%);
  color: #f5f5f7;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.mm-node-eyebrow {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 0.35rem;
}

.mm-mod-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
}

.mm-mod-meta {
  margin: 0;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.55);
}

.mm-tree-connector {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  line-height: 0;
}

.mm-tree-svg {
  display: block;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.mm-tl-branches {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: flex-start;
  gap: 1.25rem 1.5rem;
  margin-top: 0.15rem;
  overflow-x: auto;
  overflow-y: visible;
  max-width: 100%;
  padding-bottom: 0.35rem;
  -webkit-overflow-scrolling: touch;
}

.mm-tl-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
  width: min(18rem, 85vw);
  min-width: 11.5rem;
  max-width: 18rem;
}

.mm-tl-column--empty {
  flex: 1 1 auto;
  min-width: min(100%, 20rem);
  max-width: 100%;
  text-align: center;
  padding: 0.5rem;
}

.team-map-tl-card.mm-tl-card {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 0.6rem 0.7rem;
  background: rgba(255, 255, 255, 0.94);
  color: #1a1a1f;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.1);
  cursor: grab;
}

.team-map-tl-card.mm-tl-card[draggable="false"] {
  cursor: default;
}

.team-map-tl-card.is-dragging {
  opacity: 0.55;
}

.team-map-tl-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.65rem;
  margin-bottom: 0.45rem;
}

.team-map-tl-name {
  font-weight: 600;
  font-size: 0.92rem;
}

.team-map-caller-drop {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  min-height: 2rem;
  padding: 0.35rem;
  border-radius: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.mm-tl-card .team-map-caller-drop {
  border-color: rgba(0, 0, 0, 0.12);
  background: rgba(0, 0, 0, 0.03);
}

.team-map-caller-drop.drag-over {
  border-color: rgba(61, 214, 195, 0.55);
  background: rgba(61, 214, 195, 0.08);
}

.team-map-caller-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  cursor: grab;
}

.mm-tl-card .team-map-caller-chip {
  border-color: rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.85);
  color: #1a1a1f;
}

.team-map-caller-chip[draggable="false"] {
  cursor: default;
}

.team-map-caller-chip.is-dragging {
  opacity: 0.55;
}

.team-map-chip-name {
  font-weight: 500;
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-map-no-agents {
  font-size: 0.82rem;
}

.teams-tree {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.teams-tree.teams-tree--columns {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 1rem 1.25rem;
  width: max-content;
  min-width: 100%;
  box-sizing: border-box;
}

.teams-tree--columns .team-block {
  flex: 0 0 auto;
  width: min(24rem, calc(100vw - 8rem));
  min-width: min(18rem, calc(100vw - 10rem));
  max-width: 28rem;
  margin: 0;
}

.teams-tree--columns > .teams-empty {
  flex: 1 1 auto;
  min-width: min(100%, 24rem);
  width: 100%;
  max-width: none;
  text-align: center;
  padding: 2rem 1rem;
  box-sizing: border-box;
}

.teams-empty {
  color: var(--muted);
  margin: 0;
  padding: 1rem 0;
}

.team-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem 1.15rem 1.15rem;
}

.team-block-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
  letter-spacing: -0.02em;
}

.team-block-meta {
  margin: 0 0 0.85rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.team-leader-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.team-leader-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.team-leader-row:last-child {
  border-bottom: none;
}

.team-leader-row.muted {
  color: var(--muted);
  font-size: 0.9rem;
  border: none;
}

.team-leader-name {
  font-weight: 600;
  min-width: 10rem;
  flex: 1;
}

.team-leader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.btn-tl-action {
  padding: 0.35rem 0.75rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(61, 214, 195, 0.1);
  border: 1px solid rgba(61, 214, 195, 0.35);
  border-radius: 8px;
  cursor: pointer;
}

.btn-tl-action:hover {
  background: rgba(61, 214, 195, 0.18);
}

.btn-tl-danger {
  color: #ffb4b8;
  border-color: rgba(240, 113, 120, 0.45);
  background: rgba(240, 113, 120, 0.1);
}

.btn-tl-danger:hover {
  background: rgba(240, 113, 120, 0.2);
}

.btn-add-tl-row {
  display: inline-flex;
  margin-top: 0.65rem;
  padding: 0.45rem 0.9rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(61, 214, 195, 0.08);
  border: 1px dashed var(--accent-dim);
  border-radius: 8px;
  cursor: pointer;
  width: auto;
}

.btn-add-tl-row:hover {
  background: rgba(61, 214, 195, 0.14);
}

/* Teams tree: moderator → team leaders → agents */
.team-tl-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.team-no-tl {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

.team-tl-branch {
  padding: 0.35rem 0 0.5rem;
}

.team-tl-branch-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  margin-bottom: 0.5rem;
}

.team-tl-branch-title {
  flex: 1;
  min-width: 12rem;
  line-height: 1.35;
}

.team-tl-label {
  display: inline;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 0.35rem;
}

.team-tl-leader-name {
  font-size: 1rem;
  font-weight: 700;
}

.team-tl-branch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.team-agent-list {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0.15rem 0 0.35rem 0.5rem;
  border-left: 2px solid rgba(61, 214, 195, 0.25);
}

.team-agent-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.65rem;
  padding: 0.28rem 0;
  font-size: 0.9rem;
}

.team-agent-row.team-agent-empty {
  color: var(--muted);
  font-style: italic;
}

.team-agent-dash {
  color: var(--muted);
  user-select: none;
}

.team-agent-name {
  font-weight: 500;
  min-width: 6rem;
}

.team-agent-row .status-pill {
  font-size: 0.72rem;
  padding: 0.12rem 0.45rem;
}

.btn-agent-edit {
  padding: 0.2rem 0.55rem;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: 1px solid rgba(61, 214, 195, 0.35);
  border-radius: 6px;
  cursor: pointer;
  margin-left: auto;
}

.btn-agent-edit:hover {
  background: rgba(61, 214, 195, 0.12);
}

.btn-add-agent {
  display: inline-flex;
  align-self: flex-start;
  margin: 0.15rem 0 0.65rem;
  padding: 0.35rem 0.75rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(61, 214, 195, 0.06);
  border: 1px solid rgba(61, 214, 195, 0.3);
  border-radius: 8px;
  cursor: pointer;
}

.btn-add-agent:hover {
  background: rgba(61, 214, 195, 0.12);
}

.team-tl-sep {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 0.35rem 0 0.85rem;
}

.modal-sheet-wide {
  max-width: 560px;
  max-height: min(90vh, 720px);
}

.modal-table-wrap {
  max-height: 240px;
  overflow: auto;
  margin-bottom: 1rem;
}

.modal-assign-caller-block {
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.field-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem;
}

.field-inline label {
  width: 100%;
}

.field-inline select {
  flex: 1;
  min-width: 200px;
  margin-bottom: 0;
}

.field-inline .btn {
  width: auto;
}
