:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d9e1ee;
  --accent: #2b6de0;
  --head: #eef3fb;
  --tab: #eef3fb;
  --tab-active: #2b6de0;
  --tab-active-text: #ffffff;
  --line: #8fb0e8;
  --node-bg: #ffffff;
  --node-border: #7fa5e6;
  --node-shadow: 0 1px 0 rgba(43, 109, 224, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font: 14px/1.45 Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.wrap {
  max-width: 1840px;
  margin: 0 auto;
  padding: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 6px 18px rgba(16, 24, 40, 0.06);
  overflow: hidden;
}

.top {
  padding: 14px 18px 14px;
  border-bottom: 1px solid var(--border);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: nowrap;
  margin-bottom: 14px;
}

.topbar-split {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: nowrap;
}

.top-left {
  flex: 1 1 auto;
  min-width: 0;
}

.top-right {
  flex: 0 0 auto;
  min-width: 430px;
  display: flex;
  justify-content: flex-end;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 38px;
  align-items: flex-start;
  flex: 1 1 auto;
}

.legend-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

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

.tabs-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.tabs-wrap-rows {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tabs-row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.tab-btn {
  border: 1px solid var(--border);
  background: var(--tab);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--tab-active);
  color: var(--tab-active-text);
  border-color: var(--tab-active);
}

.menu-note {
  display: none;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  text-align: right;
  white-space: nowrap;
}

.controls {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px 220px 44px;
  gap: 12px;
  align-items: flex-start;
}

#linkingControls {
  display: none;
  grid-template-columns: minmax(240px, 1fr) 220px 180px 220px 44px;
}

#textsControls {
  display: none;
  grid-template-columns: minmax(240px, 1fr) 220px 44px 170px;
}

#placementsControls {
  display: none;
  grid-template-columns: minmax(240px, 1fr) 220px 44px;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  background: white;
}

textarea {
  min-height: 74px;
  resize: vertical;
}

.search-input-wrap {
  position: relative;
  width: 100%;
}

.search-input-wrap input {
  padding-right: 42px;
}

.search-clear {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font: 18px/1 Arial, Helvetica, sans-serif;
  padding: 0;
}

.search-clear:hover {
  background: #eef3fb;
  color: #1f2937;
}

.search-input-wrap.has-value .search-clear {
  display: inline-flex;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 240px);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1250px;
}

#linkingTable,
#textsTable {
  min-width: 1250px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--head);
  border-bottom: 1px solid var(--border);
  padding: 12px 10px;
  text-align: left;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

tbody td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  background-clip: padding-box;
}

tbody tr:hover td {
  background: #fafcff;
}

.num {
  text-align: center;
  white-space: nowrap;
}

.breadcrumbs a,
td a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumbs a:hover,
td a:hover {
  text-decoration: underline;
}

.related-links {
  display: grid;
  gap: 6px;
}

.related-links a {
  display: inline-block;
}

.status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
}

.status-edit {
  cursor: pointer;
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.status-edit-arrow {
  opacity: 0.55;
  font-size: 10px;
}

.status-menu {
  position: fixed;
  z-index: 1000;
  display: grid;
  gap: 6px;
  min-width: 230px;
  max-height: 330px;
  overflow: auto;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.16);
}

.status-menu button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0;
  cursor: pointer;
}

.status-menu .status {
  width: 100%;
}

.st-green {
  background: #e8f7ec;
  color: #166534;
  border-color: #b7e2c1;
}

.status-node.st-green {
  background: #e8f7ec;
  color: #166534;
  border-color: #b7e2c1;
}

.st-orange {
  background: #fff7e8;
  color: #9a5b00;
  border-color: #f3dfb3;
}

.status-node.st-orange {
  background: #fff7e8;
  color: #9a5b00;
  border-color: #f3dfb3;
}

.st-yellow {
  background: #fff6dd;
  color: #8a6116;
  border-color: #f2dd9b;
}

.status-node.st-yellow {
  background: #fff6dd;
  color: #8a6116;
  border-color: #f2dd9b;
}

.st-purple {
  background: #f3ebff;
  color: #6d28d9;
  border-color: #dcc7ff;
}

.status-node.st-purple {
  background: #f3ebff;
  color: #6d28d9;
  border-color: #dcc7ff;
}

.st-red {
  background: #ffe8f0;
  color: #b4235b;
  border-color: #f3b7cb;
}

.status-node.st-red {
  background: #ffe8f0;
  color: #b4235b;
  border-color: #f3b7cb;
}

.st-gray {
  background: #f3f4f6;
  color: #6b7280;
  border-color: #e5e7eb;
}

.status-node.st-gray {
  background: #f3f4f6;
  color: #6b7280;
  border-color: #e5e7eb;
}

.st-blue {
  background: #e8f0ff;
  color: #1d4ed8;
  border-color: #bfd0ff;
}

.status-node.st-blue {
  background: #e8f0ff;
  color: #1d4ed8;
  border-color: #bfd0ff;
}

.st-bordeaux {
  background: #f7e7ec;
  color: #8f2d4f;
  border-color: #e7bfd0;
}

.status-node.st-bordeaux {
  background: #f7e7ec;
  color: #8f2d4f;
  border-color: #e7bfd0;
}

.link-type {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
}

.lt-section {
  background: #eef3fb;
  color: #38598c;
  border-color: #d4def1;
}

.lt-related {
  background: #fff7e8;
  color: #9a5b00;
  border-color: #f3dfb3;
}

.map-wrap {
  overflow: auto;
  max-height: calc(100vh - 210px);
  padding: 20px 18px 24px;
  background: #fafcff;
}

.mindmap {
  min-width: 1500px;
  padding: 4px 12px 20px;
}

.map-root {
  display: flex;
  justify-content: center;
  position: relative;
  margin-bottom: 28px;
}

.root-node {
  display: inline-flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10px 22px;
  border: 2px solid #4f7fd6;
  border-radius: 4px;
  background: var(--node-bg);
  color: #2f4c79;
  font-weight: 700;
  text-decoration: none;
  min-width: 110px;
  box-shadow: var(--node-shadow);
  position: relative;
}

.root-node:hover {
  text-decoration: underline;
}

.root-node::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 1px;
  height: 18px;
  background: var(--line);
  transform: translateX(-50%);
}

.branches {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 34px;
  position: relative;
  padding-top: 22px;
  --line-start: 24px;
  --line-end: calc(100% - 24px);
}

.branches::before {
  content: "";
  position: absolute;
  left: var(--line-start);
  right: auto;
  width: calc(var(--line-end) - var(--line-start));
  top: 0;
  border-top: 1px solid var(--line);
}

.branch {
  position: relative;
  min-width: 210px;
  flex: 0 0 auto;
}

.branch-top-line {
  position: absolute;
  top: -23px;
  left: 50%;
  width: 1px;
  height: 23px;
  background: var(--line);
  transform: translateX(-50%);
}

.branch-head {
  margin-bottom: 10px;
  text-align: left;
}

.tree {
  list-style: none;
  margin: 0;
  padding-left: 22px;
}

.tree li {
  position: relative;
  padding-left: 16px;
  margin: 8px 0;
}

.tree li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 17px;
  width: 14px;
  border-top: 1px solid var(--line);
}

.tree li::after {
  content: "";
  position: absolute;
  left: 0;
  top: -8px;
  bottom: -8px;
  border-left: 1px solid var(--line);
}

.tree li:last-child::after {
  bottom: 17px;
}

.tree-item {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  position: relative;
  z-index: 1;
}

.top-item {
  min-height: 30px;
}

.toggle-btn,
.toggle-placeholder {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: inline-flex;
  align-items: flex-start;
  justify-content: center;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
}

.toggle-btn {
  border: 1px solid #b8c8ea;
  background: #fff;
  color: #3e5f98;
  cursor: pointer;
  padding: 0;
}

.toggle-btn:hover {
  background: #eef4ff;
}

.toggle-placeholder {
  border: 1px solid transparent;
}

.node {
  display: inline-block;
  background: var(--node-bg);
  border: 2px solid var(--node-border);
  border-radius: 3px;
  padding: 5px 10px;
  color: #2e4b79;
  text-decoration: none;
  box-shadow: var(--node-shadow);
  position: relative;
  max-width: 320px;
  line-height: 1.3;
}

.node:hover {
  text-decoration: underline;
}

.node-l1 {
  font-weight: 700;
}

.node-l2,
.node-l3,
.node-l4,
.node-l5 {
  font-size: 13px;
}

.node-leaf {
  background: #fcfdff;
}

.collapsed > .tree {
  display: none;
}

.collapsed > .tree-item .toggle-btn,
.branch.collapsed .branch-head .toggle-btn {
  font-size: 0;
}

.collapsed > .tree-item .toggle-btn::before,
.branch.collapsed .branch-head .toggle-btn::before {
  content: "+";
  font-size: 12px;
  line-height: 1;
}

.comment-edit {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.comment-input {
  min-height: 36px;
  padding: 8px 10px;
}

.primary-btn,
.secondary-btn,
.small-btn {
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  white-space: nowrap;
}

.primary-btn {
  padding: 10px 14px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.secondary-btn {
  padding: 10px 14px;
  background: #eef3fb;
  color: var(--text);
}

.small-btn {
  padding: 7px 10px;
  background: #eef3fb;
  color: var(--text);
  line-height: 1.2;
}

.danger-btn {
  background: #ffe8f0;
  border-color: #f3b7cb;
  color: #b4235b;
}

.actions-cell {
  white-space: nowrap;
  vertical-align: middle;
}

.actions-cell .small-btn + .small-btn {
  margin-left: 8px;
}

.row-saved {
  animation: rowSaved 1.4s ease-out;
}

@keyframes rowSaved {
  0% { background: #e8f7ec; }
  100% { background: transparent; }
}

.row-saved td {
  animation: rowSavedCell 1.4s ease-out;
}

@keyframes rowSavedCell {
  0% { background: #e8f7ec; }
  100% { background: transparent; }
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1100;
  display: none;
  padding: 10px 14px;
  border-radius: 12px;
  background: #1f2937;
  color: #fff;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.22);
}

.toast.show {
  display: block;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.35);
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(820px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 20px 55px rgba(16, 24, 40, 0.24);
}

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

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

#textTaskForm {
  padding: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid label {
  display: grid;
  gap: 6px;
}

.form-grid label span {
  font-weight: 700;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.url-change-block {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #f8fafc;
}

.url-change-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.url-change-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin-bottom: 10px;
}

.url-change-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.url-change-row input {
  width: 100%;
}

#textTaskPlacementUrl[readonly] {
  background: #f8fafc;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 16px;
}

.placeholder {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: #ffffff;
  color: var(--muted);
}

.footer {
  padding: 10px 20px 16px;
  color: var(--muted);
  font-size: 12px;
}

.hidden-row {
  display: none;
}

@media (max-width: 1300px) {
  .topbar,
  .topbar-split {
    flex-direction: column;
    align-items: stretch;
  }

  .top-right {
    min-width: 0;
    width: 100%;
    justify-content: flex-start;
  }

  .tabs-wrap,
  .tabs-wrap-rows {
    align-items: flex-start;
  }

  .tabs,
  .tabs-row {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

@media (max-width: 1100px) {
  .controls,
  #linkingControls,
  #textsControls,
  #placementsControls {
    grid-template-columns: 1fr;
  }

  .comment-edit {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

.entity-form {
  padding: 18px;
}

.copy-field {
  display: inline-block;
  width: 100%;
  max-width: 360px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  line-height: 1.35;
  text-align: left;
  cursor: copy;
  white-space: normal;
}

.copy-field:hover {
  text-decoration: underline;
}

.copy-field.copied {
  color: #166534;
  font-weight: 700;
}

.copy-field-long {
  max-width: 520px;
}

#placementsTable {
  min-width: 1700px;
}

#placementsTable .actions-cell {
  min-width: 108px;
}

#placementsTable td {
  vertical-align: top;
}

/* auth v12 */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #f5f7fb;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--border, #d9e1ee);
  border-radius: 18px;
  box-shadow: 0 6px 18px rgba(16, 24, 40, 0.06);
  padding: 24px;
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.auth-note {
  color: var(--muted, #6b7280);
  margin-bottom: 18px;
}

.auth-card label {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  font-weight: 700;
}

.auth-submit {
  width: 100%;
  border: 1px solid var(--accent, #2b6de0);
  background: var(--accent, #2b6de0);
  color: #fff;
  border-radius: 10px;
  padding: 11px 14px;
  font-weight: 700;
  cursor: pointer;
}

.auth-error {
  background: #ffe8f0;
  color: #b4235b;
  border: 1px solid #f3b7cb;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.user-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
  color: var(--muted, #6b7280);
  font-size: 13px;
  padding: 10px 18px 0;
}

.user-bar a {
  color: var(--accent, #2b6de0);
  text-decoration: none;
  font-weight: 700;
}

.user-bar a:hover {
  text-decoration: underline;
}


/* v14 filters */
.filter-reset {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #eef3fb;
  color: #6b7280;
  cursor: pointer;
  font: 20px/1 Arial, Helvetica, sans-serif;
  font-weight: 700;
}

.filter-reset:hover {
  background: #e2ebf8;
  color: #1f2937;
}

#statusLegend .status {
  cursor: pointer;
  user-select: none;
}

#statusLegend .status:hover {
  filter: brightness(0.97);
  transform: translateY(-1px);
}

#statusLegend .status.legend-active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* v14 admin */
.admin-card {
  padding: 18px;
}

.admin-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.admin-head h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.admin-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-table-wrap {
  max-height: calc(100vh - 180px);
}

.admin-table {
  min-width: 900px;
}

.admin-row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-form-card {
  max-width: 720px;
  margin: 0 auto;
}

.admin-form {
  display: grid;
  gap: 14px;
}

.admin-form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.check-line {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.check-line input {
  width: auto;
}

.project-access-list {
  display: grid;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fafcff;
}

.form-block-title {
  font-weight: 700;
  margin-top: 4px;
}

.form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.form-error {
  background: #ffe8f0;
  color: #b4235b;
  border: 1px solid #f3b7cb;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

/* v16 admin navigation */
.admin-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 0 0 16px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
  background: transparent;
}

.admin-nav-link:hover {
  background: #f4f7fc;
  color: var(--text);
  text-decoration: none;
}

.admin-nav-link.is-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.admin-nav-link.is-disabled {
  opacity: 0.45;
  cursor: default;
}

.admin-nav-link.is-disabled:hover {
  background: transparent;
  color: var(--muted);
}

.admin-userbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-user {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.logout-btn {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid #f3b7cb;
  border-radius: 10px;
  background: #fff5f8;
  color: #b4235b;
  font-weight: 700;
  text-decoration: none;
}

.logout-btn:hover {
  background: #ffe8f0;
  text-decoration: none;
}

.admin-head-main {
  margin-bottom: 14px;
}

.admin-overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}

.admin-metric-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8fbff;
  padding: 16px;
}

.admin-metric-value {
  font-size: 28px;
  line-height: 1;
  font-weight: 800;
  color: var(--text);
}

.admin-metric-label {
  margin-top: 6px;
  color: var(--muted);
  font-weight: 700;
}

.admin-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 20px;
}

@media (max-width: 820px) {
  .admin-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-userbar {
    justify-content: flex-start;
  }

  .admin-overview-grid {
    grid-template-columns: 1fr;
  }
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 8px 14px;
}

.status-admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 12px;
}

.status-admin-grid label {
  margin: 0;
}

.status-admin-grid textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
}

.status-help {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fbff;
  padding: 10px 12px;
}

.status-help summary {
  cursor: pointer;
  font-weight: 700;
}

.status-help pre {
  white-space: pre-wrap;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 820px) {
  .checkbox-grid,
  .status-admin-grid {
    grid-template-columns: 1fr;
  }
}

/* v19 admin user settings */
.admin-setting-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
}
.muted-label {
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}
.admin-status-summary {
  display: grid;
  gap: 5px;
  min-width: 360px;
  font-size: 12px;
}
.admin-status-summary-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  align-items: start;
}
.status-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.status-choice-card {
  border: 1px solid #d7e0ee;
  border-radius: 16px;
  background: #f8fbff;
  padding: 14px;
}
.status-choice-head {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 10px;
}
.status-choice-head span {
  color: #64748b;
  font-size: 12px;
}
.status-choice-list {
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}
.status-choice-item {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 7px 9px;
}
@media (max-width: 1100px) {
  .status-choice-grid {
    grid-template-columns: 1fr;
  }
  .admin-status-summary {
    min-width: 260px;
  }
}

/* Users table: fix extra divider under action buttons */
.users-table td,
.users-table th {
  vertical-align: top;
}

.users-table tbody tr td {
  border-bottom: 1px solid #d9e2ef;
}

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

.users-table .actions-cell,
.users-table .actions,
.users-table .row-actions,
.users-table .table-actions {
  border: 0 !important;
  box-shadow: none !important;
  background: transparent;
}

.users-table .actions-cell {
  white-space: nowrap;
}

.users-table .row-actions,
.users-table .table-actions,
.users-table .actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
  padding: 0;
  margin: 0;
}

/* Fix users table actions cell divider */
.admin-table td.admin-row-actions {
  display: table-cell !important;
  vertical-align: top;
  white-space: nowrap;
  border-bottom: 1px solid #d9e2ef !important;
}

.admin-table tbody tr:last-child td.admin-row-actions {
  border-bottom: none !important;
}

.admin-table td.admin-row-actions .secondary-btn {
  display: inline-flex;
  margin-right: 8px;
}

.admin-table td.admin-row-actions .secondary-btn:last-child {
  margin-right: 0;
}
/* v21 project user bar moved to left top area */
.project-userbar {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  align-items: center;
  color: var(--muted, #6b7280);
  font-size: 13px;
  margin: 0 0 10px;
}

.project-userbar a {
  color: var(--accent, #2b6de0);
  text-decoration: none;
  font-weight: 700;
}

.project-userbar a:hover {
  text-decoration: underline;
}

/* v21 admin statuses */
.admin-inline-form {
  max-width: 520px;
  margin: 0 0 16px;
}

.admin-inline-form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.statuses-admin-table td,
.statuses-admin-table th {
  vertical-align: top;
}

.statuses-admin-table .status {
  display: inline-flex;
  white-space: nowrap;
}

.is-inactive-row {
  opacity: 0.62;
}

.status-usage-total {
  font-weight: 800;
  color: var(--text);
}

.status-usage-detail {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.primary-btn,
.secondary-btn.small-btn,
.secondary-btn {
  text-decoration: none;
}

/* v22 overview and inline link editing */
.overview-table td {
  vertical-align: top;
}

.compact-comment {
  display: grid;
  gap: 6px;
  min-width: 220px;
}

.compact-comment textarea {
  min-height: 56px;
  resize: vertical;
}

.quick-status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 220px;
}

.quick-status-btn {
  border: 0;
  cursor: pointer;
  font-size: 12px;
}

.link-edit-cell {
  white-space: nowrap;
}

.link-edit-cell .small-btn {
  margin-left: 6px;
}

/* v23 sortable table headers */
th.sortable-th {
  cursor: pointer;
  user-select: none;
  position: relative;
}

th.sortable-th::after {
  content: "↕";
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  color: #94a3b8;
}

th.sortable-th.sort-asc::after {
  content: "↑";
  color: #2563eb;
}

th.sortable-th.sort-desc::after {
  content: "↓";
  color: #2563eb;
}

.muted {
  color: #94a3b8;
}

/* v24: comment thread in overview */
.comment-thread {
  min-width: 260px;
  max-width: 360px;
}

.comment-thread-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 135px;
  overflow: auto;
  padding-right: 2px;
  margin-bottom: 8px;
}

.comment-message {
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.comment-message-status {
  background: #f4f7ff;
}

.comment-message-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 3px;
}

.comment-message-text {
  font-size: 13px;
  line-height: 1.35;
  color: var(--text);
  word-break: break-word;
}

.comment-compose {
  display: flex;
  gap: 6px;
  align-items: center;
}

.comment-compose .comment-input {
  min-height: 32px;
  height: 32px;
  resize: none;
}

.comment-empty {
  font-size: 12px;
  padding: 6px 0;
}

/* v25: improved comment thread */
.comment-thread-head {
  min-height: 18px;
  margin-bottom: 3px;
}

.comment-new-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  background: #dbeafe;
  color: #1d4ed8;
}

.comment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 5px;
}

.comment-action {
  border: 0;
  background: transparent;
  color: #2563eb;
  font-size: 11px;
  padding: 0;
  cursor: pointer;
}

.comment-action:hover {
  text-decoration: underline;
}

.comment-message-deleted {
  background: #f8fafc;
  color: #94a3b8;
}

.comment-message-deleted .comment-message-text {
  color: #94a3b8;
  font-style: italic;
}

.comment-edited {
  margin-top: 3px;
  font-size: 11px;
  color: #94a3b8;
}

.comment-reply-ref,
.comment-reply-target {
  border-left: 3px solid #dbeafe;
  padding-left: 7px;
  font-size: 11px;
  color: #64748b;
  margin-bottom: 5px;
}

.comment-reply-target {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 6px;
}

.comment-reply-cancel {
  border: 0;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

/* v27: comments compact compose */
.comment-reply-target[hidden] {
  display: none !important;
}

.comment-reply-target:not([hidden]) {
  display: flex;
}

.comment-compose .comment-input {
  width: 100%;
}


/* v29: compact overview comments layout */
.overview-table .comment-thread {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}

.overview-table .comment-thread-head {
  min-height: 0;
  margin: 0 0 4px;
}

.overview-table .comment-thread-list {
  max-height: none;
  overflow: visible;
  margin-bottom: 6px;
  padding-right: 0;
}

.overview-table .comment-thread-list:empty {
  display: none;
  margin: 0;
}

.overview-table .comment-compose {
  margin-top: 0;
}

.overview-table .comment-input {
  height: 32px;
  min-height: 32px;
}

/* v30: comment unread badge and compact scroll */
.overview-table .comment-thread {
  position: relative;
}

.overview-table .comment-thread-list {
  max-height: 135px !important;
  overflow: auto !important;
  margin-bottom: 6px;
  padding-right: 2px;
}

.overview-table .comment-thread-list:empty {
  display: none;
  margin: 0;
}

.overview-table .comment-new-badge {
  position: absolute;
  top: 0;
  right: -8px;
  z-index: 2;
  transform: translateX(100%);
}


/* v33: overview filters and admin delete buttons */
#overviewControls {
  grid-template-columns: minmax(240px, 1fr) 220px 44px;
}

.inline-delete-form {
  display: inline-flex;
  margin: 0;
  padding: 0;
}

.danger-btn {
  border: 1px solid #fecdd3;
  background: #fff1f2;
  color: #be123c;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.danger-btn:hover {
  background: #ffe4e6;
  border-color: #fda4af;
}

.admin-table td.admin-row-actions {
  display: table-cell !important;
  vertical-align: top;
  white-space: nowrap;
  border-bottom: 1px solid #d9e2ef !important;
}

.admin-table td.admin-row-actions .inline-delete-form,
.admin-table td.admin-row-actions .secondary-btn,
.admin-table td.admin-row-actions .danger-btn {
  display: inline-flex;
  align-items: center;
  margin-right: 8px;
}

.admin-table td.admin-row-actions .inline-delete-form .danger-btn {
  margin-right: 0;
}

/* v34: project userbar moved between legend and tabs */
.project-userbar-tabs {
  justify-content: flex-end;
  margin: 0 0 8px;
  width: 100%;
}

.project-userbar-project {
  color: var(--text);
  font-weight: 700;
}

.top-right .tabs-wrap {
  width: 100%;
}

/* v35: project header userbar between status counters and tabs */
.top-mid {
  flex: 0 1 360px;
  min-width: 260px;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  padding-top: 2px;
}

.top-mid .project-userbar-tabs {
  width: auto;
  margin: 0;
  justify-content: flex-end;
  white-space: nowrap;
}

.top-mid .project-userbar-project {
  color: var(--text);
  font-weight: 800;
}

.top-mid a.project-userbar-project {
  color: var(--text);
  text-decoration: none;
}

.top-mid a.project-userbar-project:hover {
  color: var(--accent);
  text-decoration: underline;
}

@media (max-width: 1180px) {
  .topbar-split {
    flex-wrap: wrap;
  }
  .top-mid {
    order: 2;
    flex: 1 1 100%;
    justify-content: flex-start;
  }
  .top-right {
    order: 3;
  }
}

/* v36: stable two-row-like project header and compact userbar */
.topbar-split {
  gap: 16px;
}

.top-left {
  flex: 1 1 auto;
  min-width: 680px;
}

.top-mid {
  flex: 0 0 260px;
  min-width: 220px;
  justify-content: center;
}

.top-right {
  flex: 0 0 360px;
  min-width: 340px;
}

.project-userbar-tabs {
  font-size: 13px;
  gap: 8px;
  justify-content: center;
}

.legend-rows {
  width: 100%;
}

.legend-row {
  flex-wrap: wrap;
}

@media (max-width: 1500px) {
  .topbar-split {
    flex-wrap: wrap;
  }
  .top-left {
    flex: 1 1 100%;
    min-width: 0;
    order: 1;
  }
  .top-mid {
    flex: 1 1 auto;
    justify-content: flex-start;
    order: 2;
  }
  .top-right {
    flex: 0 0 auto;
    justify-content: flex-end;
    order: 2;
  }
}

/* v39: import layout, status filters, overview width, dropdown up */
.import-admin-card {
  width: 100%;
}

.import-mode-tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0 18px;
}

.active-soft {
  background: #eaf1ff !important;
  border-color: #bfd0ff !important;
  color: #1d4ed8 !important;
}

.admin-section-card {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  margin-top: 14px;
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.manual-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin: 10px 0 14px;
}

.manual-checks label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.manual-extra-fields {
  margin-top: 10px;
}

.status-admin-filters {
  display: grid;
  grid-template-columns: minmax(260px, 520px) minmax(190px, 260px);
  gap: 14px;
  align-items: end;
}

.status-admin-filters label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

.status-menu {
  max-height: 330px;
}

.overview-table th:nth-child(1),
.overview-table td:nth-child(1) {
  width: 24%;
}

.overview-table th:nth-child(2),
.overview-table td:nth-child(2) {
  width: 31%;
}

.overview-table th:nth-child(3),
.overview-table td:nth-child(3) {
  width: 14%;
}

.overview-table th:nth-child(4),
.overview-table td:nth-child(4) {
  width: 31%;
}

.overview-table .comment-thread {
  max-width: none;
  width: 100%;
}

@media (max-width: 980px) {
  .form-grid.three,
  .status-admin-filters {
    grid-template-columns: 1fr;
  }
}


/* v40: project user line and dark theme */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--tab);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

.theme-toggle:hover {
  background: #e8f0ff;
  border-color: #bfd0ff;
}

.top-mid .project-userbar-project,
.top-mid a.project-userbar-project,
.project-userbar-project {
  color: var(--accent) !important;
  font-weight: 700 !important;
  text-decoration: none;
}

.top-mid .project-userbar-project:hover,
.top-mid a.project-userbar-project:hover,
.project-userbar-project:hover {
  text-decoration: underline;
}

.project-userbar-name,
.project-userbar-role-text {
  color: var(--muted);
  font-weight: 400;
}

.project-userbar-role {
  color: var(--accent) !important;
  font-weight: 700;
  text-decoration: none;
}

.project-userbar-role:hover {
  text-decoration: underline;
}

.project-userbar-logout {
  color: #be123c !important;
  font-weight: 700;
  text-decoration: none;
}

.project-userbar-logout:hover {
  text-decoration: underline;
}

.status-admin-summary {
  color: var(--muted);
  font-size: 13px;
  margin: -4px 0 12px;
}

html[data-theme="dark"] {
  --bg: #0f172a;
  --card: #111827;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #334155;
  --accent: #60a5fa;
  --head: #1f2937;
  --tab: #1f2937;
  --tab-active: #2563eb;
  --tab-active-text: #ffffff;
  --line: #475569;
  --node-bg: #111827;
  --node-border: #475569;
  --node-shadow: none;
}

html[data-theme="dark"] body {
  background: var(--bg);
  color: var(--text);
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .admin-metric-card,
html[data-theme="dark"] .form-card,
html[data-theme="dark"] .status-menu,
html[data-theme="dark"] .comment-message {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
  box-shadow: none;
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #0b1220;
  color: var(--text);
  border-color: var(--border);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #64748b;
}

html[data-theme="dark"] thead th,
html[data-theme="dark"] .admin-table th {
  background: var(--head);
  color: var(--text);
  border-color: var(--border);
}

html[data-theme="dark"] tbody td,
html[data-theme="dark"] .admin-table td {
  border-color: var(--border);
}

html[data-theme="dark"] tbody tr:hover td {
  background: #142033;
}

html[data-theme="dark"] .secondary-btn,
html[data-theme="dark"] .small-btn,
html[data-theme="dark"] .tab-btn,
html[data-theme="dark"] .admin-nav-link,
html[data-theme="dark"] .theme-toggle {
  background: #1f2937;
  color: var(--text);
  border-color: var(--border);
}

html[data-theme="dark"] .tab-btn.active,
html[data-theme="dark"] .admin-nav-link.is-active,
html[data-theme="dark"] .primary-btn {
  background: var(--tab-active);
  color: #fff;
  border-color: var(--tab-active);
}

html[data-theme="dark"] .admin-nav-link:hover,
html[data-theme="dark"] .secondary-btn:hover,
html[data-theme="dark"] .small-btn:hover,
html[data-theme="dark"] .theme-toggle:hover {
  background: #273449;
}

html[data-theme="dark"] .logout-btn,
html[data-theme="dark"] .danger-btn {
  background: #3b1420;
  color: #fda4af;
  border-color: #7f1d1d;
}

html[data-theme="dark"] .map-wrap,
html[data-theme="dark"] .comment-message-status {
  background: #0b1220;
}

html[data-theme="dark"] .st-green { background: #0f3321; color: #86efac; border-color: #166534; }
html[data-theme="dark"] .st-orange { background: #3b2607; color: #fbbf24; border-color: #92400e; }
html[data-theme="dark"] .st-yellow { background: #3a2d08; color: #fde68a; border-color: #a16207; }
html[data-theme="dark"] .st-purple { background: #2e174f; color: #d8b4fe; border-color: #7e22ce; }
html[data-theme="dark"] .st-red { background: #3b1021; color: #f9a8d4; border-color: #9d174d; }
html[data-theme="dark"] .st-gray { background: #1f2937; color: #cbd5e1; border-color: #475569; }
html[data-theme="dark"] .st-blue { background: #102044; color: #93c5fd; border-color: #1d4ed8; }
html[data-theme="dark"] .st-bordeaux { background: #3a1020; color: #f0abc5; border-color: #7f1d1d; }

/* v41: compact status legend and project user line */
.topbar-split {
  align-items: flex-start;
  column-gap: 18px;
}

.top-left {
  flex: 1 1 0;
  min-width: 0;
}

.top-mid {
  flex: 0 0 auto;
  min-width: 0;
}

.top-right {
  flex: 0 0 auto;
  min-width: 360px;
}

#statusLegend.legend-rows {
  gap: 7px;
}

#statusLegend .legend-row {
  flex-wrap: nowrap;
  gap: 7px;
  max-width: 100%;
}

#statusLegend .status {
  white-space: nowrap;
}

.project-userbar-tabs .theme-toggle {
  order: -1;
  margin-right: 2px;
}

/* v41: status admin table should not be clipped; page scrolls normally */
.statuses-admin-page .admin-table-wrap {
  max-height: none !important;
  overflow: visible !important;
}

.statuses-admin-page .admin-table {
  width: 100%;
}

@media (max-width: 1500px) {
  #statusLegend .legend-row {
    flex-wrap: wrap;
  }
}


/* v42: compact user line without role; admin theme toggle */
.project-userbar-sep {
  color: var(--muted);
  margin: 0 2px;
}

.project-userbar-userlink,
.admin-user {
  color: var(--accent) !important;
  text-decoration: none;
  font-weight: 600;
}

.project-userbar-userlink:hover,
.admin-user:hover {
  text-decoration: underline;
}

.top-mid .project-userbar-project,
.top-mid a.project-userbar-project,
.project-userbar-project {
  font-weight: 600 !important;
}

.admin-userbar {
  gap: 10px;
}

.admin-userbar .theme-toggle {
  flex: 0 0 auto;
}

html[data-theme="dark"] .admin-user {
  color: var(--accent) !important;
}

/* v45: align text filters, avoid horizontal scroll in overview, backup page */
#textsControls {
  grid-template-columns: minmax(240px, 1fr) 220px 44px !important;
}

#overviewTab .table-wrap {
  overflow-x: hidden !important;
}

#overviewTable,
.overview-table {
  min-width: 0 !important;
  table-layout: fixed;
}

.overview-table th:nth-child(1),
.overview-table td:nth-child(1) {
  width: 24%;
}

.overview-table th:nth-child(2),
.overview-table td:nth-child(2) {
  width: 28%;
}

.overview-table th:nth-child(3),
.overview-table td:nth-child(3) {
  width: 12%;
}

.overview-table th:nth-child(4),
.overview-table td:nth-child(4) {
  width: 36%;
}

.overview-table td,
.overview-table th {
  overflow-wrap: anywhere;
}

.backup-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.backup-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--soft-bg);
  display: grid;
  gap: 4px;
}

.backup-item span {
  color: var(--muted);
  font-size: 13px;
}

.code-block {
  white-space: pre-wrap;
  overflow: auto;
  background: var(--soft-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  font-size: 13px;
}

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

/* v46 backup page */
.admin-actions-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 14px;
}
.backup-actions form,
.inline-form {
  display: inline-flex;
  margin: 0;
}
.import-alert {
  border-radius: 12px;
  padding: 10px 12px;
  margin: 12px 0;
  font-size: 14px;
}
.import-alert.success {
  background: #e9f8ed;
  color: #126426;
  border: 1px solid #b9e4c2;
}
.import-alert.error {
  background: #fff0f2;
  color: #9f1239;
  border: 1px solid #fecdd3;
}
.backup-table code {
  font-size: 12px;
  white-space: normal;
  word-break: break-all;
}
body.dark .import-alert.success {
  background: rgba(22, 101, 52, 0.18);
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.35);
}
body.dark .import-alert.error {
  background: rgba(159, 18, 57, 0.18);
  color: #fecdd3;
  border-color: rgba(244, 63, 94, 0.35);
}


/* v51 admin system summary */
.admin-system-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.admin-metric-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}
.section-head-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.system-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.system-summary-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: var(--soft-bg);
  display: grid;
  gap: 6px;
  min-height: 96px;
}
.system-summary-item span {
  color: var(--muted);
  font-size: 13px;
}
.system-summary-item b {
  font-size: 18px;
}
.system-summary-item small {
  color: var(--muted);
  overflow-wrap: anywhere;
}
.admin-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
@media (max-width: 1100px) {
  .admin-system-grid,
  .system-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 700px) {
  .admin-system-grid,
  .system-summary-grid {
    grid-template-columns: 1fr;
  }
  .section-head-row {
    display: grid;
  }
}

/* v54 backup restore/check */
.import-alert.warning {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
}
.code-block code { white-space: pre-wrap; }

/* v55 UX improvements */
.deadline-overdue {
  color: #b42318;
  font-weight: 700;
}

.breadcrumbs-cell {
  color: var(--muted-text, #667085);
}

#placementsTable .breadcrumbs-cell {
  min-width: 340px;
  max-width: 560px;
  white-space: normal;
  overflow: visible;
  text-overflow: initial;
  line-height: 1.45;
}

#placementsTable .breadcrumbs-cell a {
  display: inline;
}

#placementsTable .copy-field-long {
  max-width: 360px;
}

.select-col {
  width: 42px;
  min-width: 42px;
  text-align: center;
  white-space: nowrap;
}

.bulk-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8fafc;
  margin-bottom: 12px;
}

.bulk-panel-title {
  font-weight: 700;
  margin-right: 6px;
  padding-bottom: 9px;
}

.bulk-panel label {
  display: grid;
  gap: 4px;
  min-width: 160px;
}

.bulk-panel label span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

.bulk-panel input,
.bulk-panel select {
  min-height: 34px;
}

.map-wrap {
  cursor: grab;
  user-select: none;
}

.map-wrap.is-dragging {
  cursor: grabbing;
}

.map-wrap a,
.map-wrap button {
  user-select: text;
}


html[data-theme="dark"] .bulk-panel {
  background: #111827;
}

.texts-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}


.texts-footer > div:first-child {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
}

.bulk-panel-footer {
  align-items: center;
}

.bulk-panel-footer .bulk-panel-title {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
}

.bulk-panel-footer input {
  box-sizing: border-box;
}

.bulk-panel-footer {
  margin-bottom: 0;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 0;
  gap: 8px;
  justify-content: flex-end;
}

.bulk-panel-footer .bulk-panel-title {
  padding-bottom: 0;
  margin-right: 4px;
  font-weight: 600;
  white-space: nowrap;
}

.bulk-panel-footer input {
  min-height: 34px;
  width: 150px;
}

.bulk-panel-footer .primary-btn {
  min-height: 34px;
  padding: 8px 14px;
}

@media (max-width: 900px) {
  .texts-footer {
    align-items: flex-start;
  }
  .bulk-panel-footer {
    justify-content: flex-start;
  }
}



/* v57: project switcher on project pages */
.project-switcher {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.project-switcher-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.project-switcher-select {
  width: 88px;
  min-width: 88px;
  max-width: 112px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--tab);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  padding: 0 22px 0 9px;
}

.project-switcher-select:focus {
  outline: 2px solid rgba(43, 109, 224, 0.18);
  border-color: var(--accent);
}

.project-userbar-projects-link {
  color: var(--accent) !important;
  font-weight: 600;
  text-decoration: none;
}

.project-userbar-projects-link:hover {
  text-decoration: underline;
}

@media (max-width: 980px) {
  .project-switcher {
    flex-wrap: wrap;
  }

  .project-switcher-select {
    width: 84px;
    min-width: 84px;
    max-width: 104px;
  }
}

@media (max-width: 760px) {
  .url-change-row {
    grid-template-columns: 1fr;
  }
}

html[data-theme="dark"] .url-change-block {
  background: rgba(255, 255, 255, 0.03);
}

html[data-theme="dark"] #textTaskPlacementUrl[readonly] {
  background: rgba(255, 255, 255, 0.04);
}

/* v57.4: cleaner project menu tree */
.map-wrap {
  background: #f8fbff;
}

.map-root {
  margin-bottom: 22px;
}

.root-node {
  border-radius: 8px;
}

.root-node::after,
.branches::before,
.branch-top-line {
  display: none !important;
}

.branches {
  padding-top: 10px;
  gap: 38px;
}

.tree {
  padding-left: 18px;
}

.tree li {
  padding-left: 14px;
  margin: 9px 0;
}

.tree li::before {
  width: 12px;
  top: 17px;
  border-top-color: rgba(113, 141, 184, 0.34);
}

.tree li::after {
  top: -5px;
  bottom: -5px;
  border-left-color: rgba(113, 141, 184, 0.28);
}

.tree li:last-child::after {
  bottom: 17px;
}

.node {
  border-width: 1px;
  border-radius: 6px;
  box-shadow: none;
}

.toggle-btn {
  border-color: rgba(113, 141, 184, 0.45);
  color: #5c78a8;
}

/* v57.4: custom project switcher dropdown */
.project-switcher-dropdown {
  position: relative;
  display: inline-block;
  width: 92px;
}

.project-switcher-button {
  width: 92px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--tab);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 0 9px 0 10px;
}

.project-switcher-button:focus {
  outline: 2px solid rgba(43, 109, 224, 0.18);
  border-color: var(--accent);
}

.project-switcher-current {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-switcher-arrow {
  flex: 0 0 auto;
  font-size: 10px;
  color: var(--muted);
}

.project-switcher-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 80;
  display: none;
  min-width: 100%;
  width: 104px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.16);
}

.project-switcher-dropdown.is-open .project-switcher-menu {
  display: grid;
  gap: 2px;
}

.project-switcher-option {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  padding: 7px 8px;
  text-align: left;
}

.project-switcher-option:hover,
.project-switcher-option.is-active {
  background: #edf4ff;
  color: var(--accent);
}

.project-switcher-divider {
  width: 100%;
  height: 1px;
  margin: 4px 0;
  background: var(--border);
  opacity: 0.75;
}

.project-switcher-admin-option {
  font-weight: 500;
}

html[data-theme="dark"] .map-wrap {
  background: #0b1220;
}

html[data-theme="dark"] .tree li::before {
  border-top-color: rgba(148, 163, 184, 0.28);
}

html[data-theme="dark"] .tree li::after {
  border-left-color: rgba(148, 163, 184, 0.22);
}

html[data-theme="dark"] .project-switcher-menu {
  background: #111827;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .project-switcher-option:hover,
html[data-theme="dark"] .project-switcher-option.is-active {
  background: #1f2937;
  color: var(--accent);
}

/* v57.4: theme applies to login page too */
html[data-theme="dark"] .auth-page {
  background: var(--bg);
  color: var(--text);
}

html[data-theme="dark"] .auth-card {
  background: var(--card);
  border-color: var(--border);
  color: var(--text);
  box-shadow: none;
}

html[data-theme="dark"] .auth-note {
  color: var(--muted);
}

html[data-theme="dark"] .auth-error {
  background: #3b1021;
  color: #f9a8d4;
  border-color: #9d174d;
}

@media (max-width: 980px) {
  .project-switcher-dropdown,
  .project-switcher-button {
    width: 88px;
  }

  .project-switcher-menu {
    width: 100px;
  }
}

/* v57.5: overview, breadcrumbs and linking tabs should use page scroll, not inner table scroll */
#overviewTab > .table-wrap,
#tableTab > .table-wrap,
#linkingTab > .table-wrap {
  max-height: none !important;
  overflow-y: visible !important;
}

#overviewTab > .table-wrap {
  overflow-x: hidden !important;
}

#tableTab > .table-wrap,
#linkingTab > .table-wrap {
  overflow-x: auto;
}
