:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --line: #d8e0ea;
  --text: #18212b;
  --muted: #5b6a79;
  --accent: #0a7d68;
  --accent-soft: #daf5ef;
  --org-card-width: 220px;
  --org-card-height: 96px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(180deg, #edf3fb 0%, #f8fbff 100%);
  color: var(--text);
}

.topbar {
  background: #073b4c;
  color: #fff;
  padding: 1rem 1.5rem;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.menu-inline {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.menu-link {
  color: #fff;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  font-size: 0.92rem;
  background: transparent;
}

.menu-link:hover {
  background: rgba(255, 255, 255, 0.12);
}

.menu-inline button.menu-link {
  cursor: pointer;
}

.topbar h1 {
  margin: 0;
  font-size: 1.4rem;
}

.layout {
  padding: 1rem;
  display: grid;
  gap: 1rem;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 6px 24px rgba(9, 37, 64, 0.06);
}

.panel h2 {
  margin: 0 0 0.8rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.8rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.92rem;
}

input,
select,
button {
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid #c9d5e4;
  font: inherit;
}

button {
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.95);
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

button.secondary {
  background: #6a7c90;
}

button.danger {
  background: #b4232f;
}

.message {
  margin-top: 0.6rem;
  min-height: 1.2rem;
  color: var(--muted);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.8rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.55rem;
  border-bottom: 1px solid #e4eaf2;
  text-align: left;
  font-size: 0.9rem;
}

.agent-row {
  cursor: pointer;
}

.agent-row:hover {
  background: #f3f8ff;
}

.agent-row:focus-visible {
  outline: 2px solid #157a9b;
  outline-offset: -2px;
}

.thumb {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid #d7dee8;
  background: #eef4fc;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0;
}

.org-root {
  overflow-x: auto;
  padding-bottom: 0.6rem;
  position: relative;
}

.org-canvas {
  position: relative;
  display: inline-block;
  min-width: 100%;
}

.org-lines {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 1;
}

.org-level {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: flex-start;
  gap: 0.9rem;
  margin: 0.6rem 0;
  width: max-content;
}

.org-branch {
  width: max-content;
  min-width: var(--org-card-width);
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.org-node {
  width: var(--org-card-width);
  height: var(--org-card-height);
  text-align: left;
  background: #fff;
  color: inherit;
  border: 1px solid #c8d8ea;
  border-radius: 10px;
  padding: 0.45rem;
  box-shadow: 0 5px 14px rgba(15, 34, 52, 0.08);
  overflow: hidden;
  position: relative;
}

.org-node:hover {
  background: #f7fbff;
}

.org-branch[data-tooltip]::after,
.org-branch[data-tooltip]::before {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.1s ease 0s, visibility 0s linear 0.1s;
  pointer-events: none;
}

.org-branch[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  white-space: pre;
  width: max-content;
  max-width: 90vw;
  height: 72px;
  background: #fff68ddf;
  color: #00007f;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.8;
  display: flex;
  align-items: center;
  box-shadow: 0 8px 18px rgba(15, 34, 52, 0.25);
  z-index: 5;
}

.org-branch[data-tooltip]::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #0f2234;
  z-index: 5;
}

.org-branch[data-tooltip-active="true"]::after,
.org-branch[data-tooltip-active="true"]::before {
  opacity: 1;
  visibility: visible;
  transition-delay: 2s;
}

.org-layout {
  display: flex;
  height: 100%;
  align-items: stretch;
}

.org-photo-wrap {
  flex: 0 0 25%;
  max-width: 25%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.org-thumb {
  width: 100%;
  max-width: 44px;
  aspect-ratio: 1 / 1;
  height: auto;
  border-radius: 6px;
}

.org-body {
  flex: 0 0 75%;
  min-width: 0;
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  align-items: center;
  padding-left: 0.35rem;
}

.org-poste {
  font-weight: 700;
  font-size: 0.74rem;
  line-height: 1.2;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: calc(2 * 1.2em);
}

.org-structure {
  color: #2d4a67;
  font-weight: 600;
  padding: 0.1rem 0;
  font-size: 0.68rem;
  line-height: 1.2;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: calc(2 * 1.2em);
}

.org-name {
  font-weight: 600;
  font-size: 0.72rem;
  line-height: 1.2;
  margin-top: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.org-toggle {
  position: absolute;
  left: 50%;
  transform:translatex(-50%);
  bottom: 0px;
  width: 22px;
  height: 12px;
  border-radius: 6px 6px 0px 0px;
  background: #d6d6d67f;
  color: #0000007f;
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 6px;
  text-align: center;
  box-shadow: 0 4px 10px rgba(10, 125, 104, 0.25);
  border: 1px solid #c8d8ea7f;
  pointer-events: none;
}

.children-container {
  margin-top: 0.9rem;
  padding-top: 12px;
  position: relative;
  display: block;
  width: max-content;
}

.children-container[hidden] {
  display: none !important;
}

@media (max-width: 720px) {
  .org-branch {
    min-width: var(--org-card-width);
  }
}
