:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background: #fff;
  color: #17262d;
  --muted: #52656e;
  --border: #d7e0e3;
  --line: #a5b5ba;
  --teal: #087a6b;
  --teal-hover: #065a50;
  --teal-soft: #dff4ef;
  --error: #a32d31;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
h1, h2, h3, p, dl { margin: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .7; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
[data-icon] { display: inline-flex; flex: none; }
[data-icon] svg { display: block; width: 20px; height: 20px; }
.masthead {
  min-height: 80px;
  padding: 14px clamp(18px, 3.2vw, 50px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 16px; }
.brand-icon { color: var(--teal); border-right: 1px solid var(--line); padding-right: 16px; }
.brand-icon svg { width: 32px; height: 32px; }
.brand h1 { font-size: clamp(20px, 2.5vw, 31px); letter-spacing: .01em; }
.masthead-actions {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
}
.button {
  min-height: 41px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  color: #263941;
  font-weight: 650;
  line-height: 1.35;
}
.button:hover { background: #f3f7f6; }
.button-primary { background: var(--teal); color: white; border-color: var(--teal); }
.button-primary:hover { background: var(--teal-hover); }
.button-text { border-color: transparent; }
.button-icon { min-width: 40px; padding: 8px; border-color: transparent; }
.button-danger { color: var(--error); }
.menu-toggle { padding-inline: 8px; }
.menu-toggle > [data-icon] { color: var(--teal); }
.chevron {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: -3px 3px 0;
  transform: rotate(45deg);
  border-right: 1.8px solid currentColor;
  border-bottom: 1.8px solid currentColor;
}
.account-menu {
  position: absolute;
  z-index: 2;
  min-width: 165px;
  right: 0;
  top: calc(100% + 8px);
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  box-shadow: 0 8px 24px #173b3619;
}
.menu-username { padding: 8px 10px; color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.account-menu button {
  width: 100%;
  padding: 9px 10px;
  background: none;
  border: 0;
  border-radius: 6px;
  color: inherit;
  text-align: start;
}
.account-menu button:hover { background: #f3f7f6; }

.page-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.page-state > .button { margin: 12px auto 0; }
.login-page {
  min-height: calc(100vh - 80px);
  display: grid;
  align-items: start;
  justify-items: center;
  padding: clamp(28px, 9vh, 100px) 16px;
  background-color: #f5faf8;
}
.login-card {
  width: min(100%, 440px);
  padding: clamp(24px, 5vw, 42px);
  border-radius: 14px;
  border: 1px solid var(--border);
  background: white;
}
.login-icon {
  padding: 12px;
  color: var(--teal);
  background: var(--teal-soft);
  border-radius: 10px;
}
.login-icon svg { width: 28px; height: 28px; }
.login-card h2 { margin: 16px 0 22px; font-size: 27px; }
.field-label { display: block; margin: 15px 0 6px; font-weight: 650; }
input, select {
  width: 100%;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 8px 11px;
  background: white;
}
input::placeholder { color: #5d7079; }
.login-submit { width: 100%; margin-top: 23px; }
.form-error { color: var(--error); margin-top: 12px; overflow-wrap: anywhere; }
.add-rank { padding-inline: 0; color: var(--teal); }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(292px, 1fr);
  min-height: calc(100vh - 80px);
}
.workspace.without-tree { display: block; }
.workspace.without-tree .details-panel { max-width: 680px; margin-inline: auto; border: 0; }
.tree-panel, .details-panel { padding: clamp(20px, 3.2vw, 50px); }
.details-panel { border-left: 1px solid var(--border); min-width: 0; }
.tree-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 27px;
}
.tree-toolbar h2, .details-panel h2 {
  font-size: clamp(23px, 2.2vw, 32px);
  overflow-wrap: anywhere;
}
.search-field {
  width: min(46%, 330px);
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  padding-inline-start: 10px;
}
.search-field:focus-within { outline: 2px solid var(--teal); outline-offset: 2px; }
.search-field input { border: 0; padding-inline-start: 0; outline: none; color: #17262d; }
.tree-message { margin: 0 0 12px; color: var(--muted); }
.tree-scroll { overflow-x: auto; padding: 4px 3px 12px; }
.account-tree, .account-tree ul { margin: 0; padding: 0; list-style: none; }
.account-tree { min-width: max-content; }
.account-tree ul { margin-inline-start: 16px; }
.tree-node { position: relative; margin: 0; padding: 0; }
.tree-node > .tree-row {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 49px;
  gap: 10px;
  padding: 4px 12px 4px 0;
  border-radius: 8px;
  cursor: pointer;
}
.tree-node > .tree-row:hover { background: #f0f7f5; }
.tree-node[aria-selected="true"] > .tree-row { background: var(--teal-soft); }
.tree-node:focus-visible { outline: none; }
.tree-node:focus-visible > .tree-row { outline: 2px solid var(--teal); outline-offset: 1px; }
.account-tree ul > .tree-node { padding-inline-start: 18px; }
.account-tree ul > .tree-node::before,
.account-tree ul > .tree-node::after {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  height: 100%;
  border-left: 1px solid var(--line);
  pointer-events: none;
}
.account-tree ul > .tree-node::after { top: 24px; height: 0; width: 18px; border-top: 1px solid var(--line); }
.account-tree ul > .tree-node:last-child::before { height: 25px; border-radius: 0 0 0 5px; }
.tree-disclosure {
  width: 32px;
  height: 39px;
  display: grid;
  place-items: center;
  color: #263941;
  flex: none;
}
.tree-disclosure .chevron { transform: rotate(-45deg); margin: 0; }
.tree-node[aria-expanded="true"] > .tree-row .chevron { transform: rotate(45deg); margin-top: -4px; }
.tree-node-icon { color: var(--teal); }
.tree-node-icon svg { width: 24px; height: 24px; }
.tree-description { display: flex; align-items: baseline; gap: 8px; }
.tree-name { font-weight: 710; }
.tree-role, .tree-inactive { color: var(--muted); font-size: .875rem; }
.tree-inactive { margin-inline-start: 3px; }

.details-fields { margin-block: 26px; border-top: 1px solid var(--border); }
.details-item {
  display: grid;
  grid-template-columns: 5.6rem minmax(0, 1fr);
  gap: 14px;
  align-items: baseline;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.details-item dt { color: var(--muted); font-weight: 600; }
.details-item dd { margin: 0; overflow-wrap: anywhere; }
.details-actions { display: grid; gap: 10px; }
.details-actions .button { justify-content: center; min-height: 44px; }
.notice {
  position: fixed;
  inset: auto 18px 18px auto;
  z-index: 4;
  max-width: min(32rem, calc(100% - 36px));
  border: 1px solid #b2dfd4;
  border-radius: 9px;
  background: #f0fbf7;
  box-shadow: 0 8px 30px #173b3619;
  color: #143d35;
  padding: 12px 15px;
}
.notice.is-error { color: var(--error); border-color: #e9cacf; background: #fff8f8; }

dialog {
  width: min(460px, calc(100% - 24px));
  max-height: calc(100% - 30px);
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 60px #152c2b35;
  color: inherit;
}
dialog::backdrop { background: #102a33aa; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.dialog-heading h2 { font-size: 22px; }
.dialog-description { color: var(--muted); line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 21px; flex-wrap: wrap; }
.secret-fields { margin-block: 14px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: #f9fbfa; }
.secret-fields .details-item:last-child { border-bottom: 0; }
.secret-fields code { font-size: 1rem; user-select: all; overflow-wrap: anywhere; }
.copy-status { color: var(--muted); margin-top: 12px; }

@media (max-width: 800px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .details-panel { border-left: 0; border-top: 1px solid var(--border); }
  .masthead-actions { gap: 4px; }
}
@media (max-width: 490px) {
  .masthead { flex-wrap: wrap; }
  .masthead-actions { margin-inline-start: auto; flex-wrap: wrap; }
  .masthead-actions > .button { padding-inline: 7px; }
  .tree-toolbar { gap: 10px; }
  .tree-panel, .details-panel { padding-inline: 14px; }
  .tree-row { gap: 6px !important; }
  .account-tree ul { margin-inline-start: 11px; }
  .account-tree ul > .tree-node { padding-inline-start: 12px; }
  .account-tree ul > .tree-node::after { width: 12px; }
}
