@font-face {
  font-family: "Pyidaungsu";
  src: url("assets/fonts/Pyidaungsu-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Pyidaungsu";
  src: url("assets/fonts/Pyidaungsu-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f4f6f1;
  --panel: #ffffff;
  --ink: #1c2522;
  --muted: #65746f;
  --line: #d8ded8;
  --brand: #0b766d;
  --brand-deep: #07524d;
  --accent: #c2412f;
  --warning: #b7791f;
  --soft-brand: #e9f4f0;
  --soft-warning: #fff7e8;
  --shadow: 0 18px 48px rgba(24, 37, 35, 0.14);
  font-family: Pyidaungsu, "Myanmar Text", Inter, ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--ink);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

body.auth-pending .hierarchy-app {
  display: none;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
  background:
    linear-gradient(rgba(248, 250, 248, 0.91), rgba(248, 250, 248, 0.95)),
    repeating-linear-gradient(35deg, transparent 0 38px, rgba(11, 118, 109, 0.07) 39px 40px);
}

.login-form {
  display: grid;
  width: min(420px, 100%);
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-form h1,
.login-form p {
  margin: 0;
}

.login-form h1 {
  font-size: 28px;
  line-height: 1.25;
}

.login-form .intro {
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.6;
}

.login-form label,
.search-control {
  display: grid;
  gap: 7px;
  color: var(--brand-deep);
  font-size: 12px;
  font-weight: 700;
}

.login-form input,
.search-control input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.login-form input:focus,
.search-control input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(11, 118, 109, 0.15);
}

.primary-button,
.secondary-button,
.icon-button {
  min-height: 38px;
  border-radius: 8px;
  font-weight: 700;
}

.primary-button {
  border: 1px solid var(--brand);
  color: #fff;
  background: var(--brand);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.secondary-button {
  padding: 0 12px;
  border: 1px solid var(--line);
  color: var(--brand-deep);
  background: #fff;
}

.secondary-button:hover,
.secondary-button:focus-visible {
  border-color: var(--brand);
  background: var(--soft-brand);
  outline: none;
}

.form-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 12px;
}

.form-status.is-error {
  color: #8a2b20;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--brand);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.hierarchy-app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
}

.topbar {
  z-index: 5;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
}

.brand-block,
.session-block {
  display: flex;
  align-items: center;
}

.brand-block {
  min-width: 0;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: var(--brand-deep);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  font-weight: 850;
}

.brand-block p,
.brand-block h1 {
  margin: 0;
}

.brand-block p {
  color: var(--brand);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 10px;
  font-weight: 800;
}

.brand-block h1 {
  overflow: hidden;
  font-size: 19px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-block {
  flex: 0 0 auto;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.sync-state {
  padding-left: 15px;
  position: relative;
}

.sync-state::before {
  position: absolute;
  top: 50%;
  left: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  content: "";
  transform: translateY(-50%);
}

.sync-state.is-ready::before {
  background: var(--brand);
}

.sync-state.is-error::before {
  background: var(--accent);
}

.workspace {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-columns: 250px minmax(0, 1fr);
}

.workspace.detail-open {
  grid-template-columns: 250px minmax(0, 1fr) minmax(330px, 390px);
}

.rail,
.detail-panel {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: var(--panel);
}

.rail {
  padding: 22px 16px;
  border-right: 1px solid var(--line);
}

.rail-heading h2,
.rail-heading p {
  margin-top: 0;
}

.rail-heading h2 {
  margin-bottom: 8px;
  font-size: 19px;
}

.rail-heading > p:last-child {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.search-control {
  margin-top: 20px;
}

.level-nav {
  display: grid;
  gap: 4px;
  margin-top: 20px;
}

.level-nav button {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  min-height: 42px;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.level-nav button:hover,
.level-nav button:focus-visible {
  background: var(--soft-brand);
  outline: none;
}

.level-number {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  color: var(--brand-deep);
  background: var(--soft-brand);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 10px;
  font-weight: 800;
}

.level-count {
  color: var(--muted);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
}

.legend {
  display: grid;
  gap: 9px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.legend div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-dot.verified {
  background: var(--brand);
}

.legend-dot.unresolved {
  background: var(--warning);
}

.chart-region {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
}

.chart-toolbar {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: #f9faf7;
}

.chart-toolbar h2 {
  margin: 0;
  font-size: 20px;
}

.hierarchy-scroll {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background:
    linear-gradient(rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.72)),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(7, 82, 77, 0.055) 31px 32px),
    repeating-linear-gradient(90deg, transparent 0 31px, rgba(7, 82, 77, 0.055) 31px 32px);
}

.hierarchy-chart {
  display: grid;
  min-width: 1180px;
  gap: 32px;
  padding: 28px 34px 60px;
}

.loading-state,
.empty-result {
  display: grid;
  min-height: 55vh;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.hierarchy-level {
  position: relative;
  display: grid;
  gap: 12px;
  scroll-margin-top: 18px;
}

.hierarchy-level + .hierarchy-level::before {
  position: absolute;
  top: -32px;
  left: 50%;
  width: 1px;
  height: 32px;
  background: #a9b9b3;
  content: "";
}

.level-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.level-heading h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 750;
}

.level-heading::after {
  height: 1px;
  flex: 1;
  background: var(--line);
  content: "";
}

.level-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--columns, 1), minmax(190px, 230px));
  justify-content: center;
  gap: 16px;
}

.level-grid.has-branches::before {
  position: absolute;
  top: -12px;
  right: max(10%, 110px);
  left: max(10%, 110px);
  height: 1px;
  background: #a9b9b3;
  content: "";
}

.leader-card {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 106px;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  padding: 13px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--brand);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 8px 20px rgba(24, 37, 35, 0.08);
  text-align: left;
}

button.leader-card:hover,
button.leader-card:focus-visible,
.leader-card.is-selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(11, 118, 109, 0.14), 0 10px 24px rgba(24, 37, 35, 0.11);
  outline: none;
}

.leader-card::before {
  position: absolute;
  top: -15px;
  left: 50%;
  width: 1px;
  height: 12px;
  background: #a9b9b3;
  content: "";
}

.hierarchy-level:first-child .leader-card::before {
  display: none;
}

.leader-card.unresolved {
  border-top-color: var(--warning);
  color: var(--muted);
  background: var(--soft-warning);
  box-shadow: none;
}

.leader-photo,
.leader-fallback {
  width: 54px;
  height: 62px;
  border-radius: 5px;
}

.leader-photo {
  object-fit: cover;
  background: #e8ece8;
}

.leader-fallback {
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--brand-deep);
  font-size: 19px;
  font-weight: 800;
}

.unresolved .leader-fallback {
  color: #7a5312;
  background: #f4dfb8;
}

.leader-copy {
  min-width: 0;
}

.leader-rank,
.leader-position,
.leader-name {
  display: block;
  overflow-wrap: anywhere;
}

.leader-rank {
  margin: 0 0 3px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
}

.leader-name {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.35;
}

.leader-position {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.detail-panel {
  border-left: 1px solid var(--line);
}

.detail-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
}

.detail-header h2 {
  margin: 0;
  font-size: 20px;
}

.icon-button {
  display: grid;
  width: 38px;
  min-height: 38px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  font-size: 24px;
  line-height: 1;
}

.detail-content {
  padding: 20px 18px 30px;
}

.profile-summary {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.profile-photo,
.profile-fallback {
  width: 76px;
  height: 88px;
  border-radius: 6px;
}

.profile-photo {
  object-fit: cover;
  background: #e8ece8;
}

.profile-fallback {
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--brand-deep);
  font-size: 23px;
  font-weight: 800;
}

.profile-summary h3,
.profile-summary p {
  margin: 0;
}

.profile-summary h3 {
  font-size: 21px;
  line-height: 1.4;
}

.profile-summary p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.profile-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--line);
}

.profile-meta div {
  min-width: 0;
  padding: 10px;
  background: #fff;
}

.profile-meta dt {
  color: var(--muted);
  font-size: 10px;
}

.profile-meta dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 700;
}

.timeline-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.timeline-heading h3 {
  margin: 0;
  font-size: 16px;
}

.count-pill {
  min-width: 25px;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--brand-deep);
  background: var(--soft-brand);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.career-timeline {
  display: grid;
  gap: 0;
  margin-top: 14px;
}

.career-item {
  position: relative;
  padding: 0 0 18px 20px;
  border-left: 1px solid #b7c7c0;
}

.career-item:last-child {
  border-left-color: transparent;
}

.career-item::before {
  position: absolute;
  top: 3px;
  left: -5px;
  width: 9px;
  height: 9px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
  content: "";
}

.career-item.is-past::before {
  background: #9ba8a3;
  box-shadow: 0 0 0 1px #9ba8a3;
}

.career-item h4,
.career-item p {
  margin: 0;
}

.career-item h4 {
  font-size: 13px;
  line-height: 1.45;
}

.career-item p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.career-status {
  display: inline-block;
  margin-top: 7px;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--brand-deep);
  background: var(--soft-brand);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.career-status.past {
  color: #5e6864;
  background: #edf0ed;
}

@media (max-width: 1180px) {
  .workspace.detail-open {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .workspace.detail-open .detail-panel {
    position: absolute;
    z-index: 10;
    top: 72px;
    right: 0;
    bottom: 0;
    width: min(390px, calc(100vw - 40px));
    box-shadow: -18px 0 40px rgba(24, 37, 35, 0.14);
  }

  .workspace {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .hierarchy-chart {
    min-width: 1050px;
  }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .hierarchy-app {
    min-height: 100vh;
    height: auto;
  }

  .topbar {
    align-items: flex-start;
    padding: 10px 12px;
  }

  .brand-mark,
  .sync-state,
  .session-name {
    display: none;
  }

  .brand-block h1 {
    font-size: 16px;
    white-space: normal;
  }

  .workspace,
  .workspace.detail-open {
    display: block;
  }

  .rail {
    padding: 16px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .rail-heading,
  .legend,
  .level-nav {
    display: none;
  }

  .search-control {
    margin-top: 0;
  }

  .chart-toolbar {
    min-height: 68px;
    padding: 10px 12px;
  }

  .chart-toolbar h2 {
    font-size: 17px;
  }

  #fit-chart {
    display: none;
  }

  .hierarchy-scroll {
    overflow: visible;
  }

  .hierarchy-chart {
    min-width: 0;
    gap: 22px;
    padding: 18px 12px 40px;
  }

  .hierarchy-level + .hierarchy-level::before,
  .level-grid.has-branches::before,
  .leader-card::before {
    display: none;
  }

  .level-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .leader-card {
    width: 100%;
    min-height: 96px;
  }

  .workspace.detail-open .detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    box-shadow: none;
  }
}
