:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --border: #dce5ef;
  --text: #1f2937;
  --muted: #5f6b7a;
  --accent: #0063d1;
  --new: #b45309;
  --warn: #b91c1c;
  --topbar-height: 88px;
}

* { box-sizing: border-box; }
.hidden { display: none !important; }
body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 5% 0%, #deebff, #f4f7fb 42%);
}

.connect-splash {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}
.splash-card {
  width: min(560px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.4rem 1.4rem 1.25rem;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.12);
}
.splash-card h1 { margin: 0; }
.splash-card p {
  margin: 0.55rem 0 1rem;
  color: var(--muted);
}
.splash-error {
  margin: 0 0 1rem;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font-size: 0.92rem;
}
.splash-connect-btn {
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 0.68rem 1rem;
  border-radius: 8px;
  cursor: pointer;
}
.splash-connect-btn:disabled { opacity: 0.65; cursor: wait; }

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: 0.4rem 1rem 0.35rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 120;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06);
}

.topbar-subtitle-wrap {
  grid-column: 1;
  justify-self: start;
}
.topbar-brand {
  grid-column: 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
h1 { margin: 0; font-size: 1.5rem; }
.brand-logo-frame {
  width: 250px;
  max-width: min(52vw, 250px);
  height: 48px;
  overflow: hidden;
  display: flex;
  align-items: center;
}
.brand-logo {
  display: block;
  width: 250px;
  height: auto;
  margin-top: -16px;
  margin-bottom: -16px;
}
.subtitle { margin: 0.12rem 0 0; color: var(--muted); }

.controls {
  grid-column: 3;
  justify-self: end;
}
.controls button {
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 0.65rem 0.95rem;
  border-radius: 8px;
  cursor: pointer;
}
.controls button:disabled { opacity: 0.65; cursor: wait; }
.controls .secondary {
  background: #eef2ff;
  color: #1e3a8a;
  border: 1px solid #c7d2fe;
}
.controls .secondary:disabled {
  opacity: 1;
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
  cursor: default;
}

.meta {
  margin: 1rem 1.2rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.view-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}
.view-btn {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  border-radius: 8px;
  padding: 0.34rem 0.62rem;
  font-weight: 600;
  cursor: pointer;
}
.view-btn.active {
  border-color: #bfdbfe;
  background: #e0edff;
  color: #1e3a8a;
}
.view-btn.secondary {
  background: #fff;
}
.view-btn.icon {
  width: 2rem;
  min-width: 2rem;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
}

#statusLine { font-weight: 600; }
#syncLine { margin-top: 0.45rem; color: var(--muted); }
#syncDetails { margin-top: 0.35rem; }
.sync-details {
  display: inline-block;
  color: #334155;
  font-size: 0.9rem;
}
.sync-details summary {
  cursor: pointer;
  color: #475569;
  user-select: none;
}
.sync-details-list {
  margin: 0.35rem 0 0;
  padding-left: 1rem;
}
.sync-details-list li {
  margin: 0.15rem 0;
}
.sync-removed-key {
  font-weight: 700;
  color: #0f172a;
}
.sync-removed-status {
  color: #64748b;
}
.user-context-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
}
.user-context-current {
  font-weight: 600;
  color: #334155;
}
.user-context-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  color: #334155;
}
.user-context-switch select {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.28rem 0.45rem;
  min-width: 220px;
  background: #fff;
}
#manageTeamBtn {
  margin-left: 0.2rem;
}
.user-switch-loading {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: #475569;
}

.table-wrap {
  position: relative;
  margin: 1rem 1.2rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: visible;
  background: var(--surface);
}
.table-overlay {
  position: absolute;
  inset: 0;
  z-index: 160;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: clamp(48px, 14vh, 132px);
  border-radius: inherit;
  background: rgba(248, 250, 252, 0.72);
  backdrop-filter: blur(1.5px);
}
.table-overlay.transition-lock {
  background: rgba(241, 245, 249, 0.82);
}
.table-overlay-card {
  position: sticky;
  top: calc(var(--topbar-height) + 12px);
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  font-size: 0.9rem;
  font-weight: 600;
}
.table-overlay-card .spinner {
  width: 1rem;
  height: 1rem;
  border-width: 2px;
}
.table-scroll {
  overflow-x: visible;
  overflow-y: visible;
  border-radius: 10px;
}

table {
  width: 100%;
  min-width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}
#initsTable.initial-loading thead {
  display: none;
}
th, td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 0.62rem 0.45rem;
  vertical-align: top;
}
.chip-col-cell {
  padding-left: 0.28rem;
  padding-right: 0.28rem;
}
.due-date-col-cell {
  padding-left: 0.1rem;
  padding-right: 0.1rem;
}
thead {
  position: static;
}
th {
  position: sticky;
  position: -webkit-sticky;
  top: var(--topbar-height);
  background: #f8fbff;
  cursor: default;
  user-select: none;
  z-index: 130;
  box-shadow: 0 1px 0 #dce5ef;
}
th.filtered-col {
  background: #eaf2ff;
}
th.filtered-col .col-label {
  color: #1e3a8a;
  font-weight: 700;
}
th.sortable-col {
  cursor: pointer;
}
th.dragging-col {
  opacity: 0.65;
}
.col-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  max-width: calc(100% - 12px);
}
.col-label {
  display: inline-block;
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.columns-control-th {
  text-align: center;
}
.columns-control-th .col-title-wrap {
  width: 100%;
  justify-content: center;
}
.columns-header-btn {
  width: 1.3rem;
  height: 1.3rem;
  border: 1px solid #bfcde1;
  background: #eff3fa;
  color: #334155;
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.columns-header-btn:hover {
  border-color: #93c5fd;
  background: #e0edff;
  color: #1e3a8a;
}
.col-filter-btn {
  flex: 0 0 auto;
  width: 1.2rem;
  height: 1.2rem;
  border: 1px solid #cbd5e1;
  background: #eff3fa;
  color: #64748b;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.col-filter-btn:hover {
  background: #eef2ff;
  border-color: #93c5fd;
}
.col-filter-btn.active {
  color: #1e3a8a;
  border-color: #93c5fd;
  background: #dbeafe;
}
.col-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 10px;
  height: 100%;
  cursor: col-resize;
  opacity: 0;
  transition: opacity 120ms ease;
}
th:hover .col-resize-handle {
  opacity: 1;
}
.col-resize-handle::before {
  content: "";
  position: absolute;
  right: 4px;
  top: 22%;
  width: 2px;
  height: 56%;
  border-radius: 2px;
  background: #94a3b8;
}

tr.new-row { background: #fff7ed; }
tr.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 1rem 0.6rem;
}
.status-cell {
  white-space: nowrap;
}
.status-chip {
  display: inline-block;
  border-radius: 5px;
  padding: 0.09rem 0.36rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.status-chip-primary {
  background: #dbeafe;
  color: #0b4fb3;
}
.status-chip-neutral {
  background: #e2e8f0;
  color: #475569;
}
.status-chip-success {
  background: #dcfce7;
  color: #0f766e;
}
.badge {
  display: inline-block;
  border-radius: 999px;
  font-size: 0.75rem;
  padding: 0.12rem 0.5rem;
  margin-left: 0.35rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge.new { color: var(--new); border-color: #fed7aa; background: #fff7ed; }
.badge.warn { color: var(--warn); border-color: #fecaca; background: #fef2f2; }

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.productset-wrap {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
}
.editable-cell-trigger {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  padding: 0.1rem;
  cursor: pointer;
}
.summary-edit-trigger {
  min-height: 1.65rem;
  font-size: 1.04rem;
}
.editable-cell-trigger:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}
.editable-cell-trigger:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 1px;
}
.summary-inline-input {
  width: 100%;
  border: 1px solid #93c5fd;
  border-radius: 7px;
  padding: 0.22rem 3.2rem 0.22rem 0.36rem;
  font: inherit;
  font-size: 1.04rem;
  color: inherit;
  background: #fff;
}
.summary-inline-input:focus {
  outline: 2px solid #bfdbfe;
  outline-offset: 1px;
}
.summary-inline-wrap {
  position: relative;
}
.summary-inline-actions {
  position: absolute;
  top: 50%;
  right: 0.3rem;
  transform: translateY(-50%);
  display: inline-flex;
  gap: 0.25rem;
}
.summary-inline-action-btn {
  width: 1.35rem;
  height: 1.3rem;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  border-radius: 6px;
  font-size: 0.86rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.summary-inline-action-btn:hover {
  background: #eef2ff;
}
.summary-inline-action-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}
.pill {
  border: 1px solid;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.4;
}
.alert-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  position: relative;
  border-radius: 999px;
  font-size: 0.8rem;
  color: #374151;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  cursor: default;
  margin-top: 0.1rem;
  font-weight: 700;
}
.alert-icon-epic-missing {
  color: #92400e;
  background: #fef3c7;
  border-color: #fcd34d;
}
.alert-icon-product-missing {
  color: #9f1239;
  background: #ffe4e6;
  border-color: #fecdd3;
}
.alert-icon:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 50;
  left: 50%;
  top: calc(100% + 6px);
  transform: translateX(-50%);
  min-width: 260px;
  max-width: 420px;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #0f172a;
  color: #f8fafc;
  font-size: 0.74rem;
  line-height: 1.35;
  white-space: pre-line;
  pointer-events: none;
}

.drag-handle {
  display: inline-block;
  padding: 0.06rem 0.35rem;
  margin-right: 0.35rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: grab;
}
tr.dragging { opacity: 0.55; }
tr.row-drop-confirm td {
  animation: row-drop-confirm 1.5s ease-out;
}
@keyframes row-drop-confirm {
  0% { background: #dcfce7; }
  55% { background: #eefcf3; }
  100% { background: transparent; }
}
.muted { color: var(--muted); }

.inline-editor {
  position: absolute;
  z-index: 80;
  width: min(420px, calc(100vw - 16px));
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.25);
  padding: 0.55rem;
}

.column-filter-menu {
  position: absolute;
  z-index: 200;
  width: min(320px, calc(100vw - 16px));
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.25);
  padding: 0.55rem;
}
.column-selector-menu {
  position: absolute;
  z-index: 200;
  width: min(260px, calc(100vw - 16px));
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.25);
  padding: 0.55rem;
}
.column-filter-menu.wide {
  width: min(420px, calc(100vw - 16px));
}
.column-filter-title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.45rem;
}
.column-filter-mode {
  display: inline-flex;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}
.column-filter-mode-btn {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #1e293b;
  border-radius: 7px;
  padding: 0.26rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.column-filter-mode-btn.active {
  border-color: #93c5fd;
  background: #e0edff;
  color: #1e3a8a;
}
.column-filter-quick-btn {
  display: block;
  width: 100%;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
  border-radius: 7px;
  padding: 0.45rem 0.55rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 0.1rem;
  text-align: left;
}
.column-filter-options {
  max-height: 300px;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.35rem 0.45rem;
}
.column-filter-empty {
  font-size: 0.82rem;
  color: #64748b;
  padding: 0.2rem 0.1rem;
}
.column-filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  margin-top: 0.55rem;
}
.inline-editor.inline-editor-wide {
  width: min(560px, calc(100vw - 16px));
}
.inline-editor-title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.45rem;
}
.inline-editor-options {
  max-height: 320px;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.35rem 0.45rem;
}
.inline-editor.inline-editor-wide .inline-editor-options {
  max-height: 420px;
}
.inline-editor-loading,
.inline-editor-error {
  color: #334155;
  font-size: 0.88rem;
  padding: 0.25rem 0.15rem;
}
.inline-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  margin-top: 0.55rem;
}
.inline-btn {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  font-weight: 600;
  border-radius: 7px;
  padding: 0.32rem 0.62rem;
  cursor: pointer;
}
.inline-btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.row-menu {
  position: relative;
}
.assigned-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  max-width: 100%;
}
.assigned-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #dbe4f1;
  flex: 0 0 18px;
}
.assigned-name {
  display: inline-block;
  white-space: nowrap;
}
.row-menu.disabled .row-menu-trigger {
  opacity: 0.45;
  cursor: not-allowed;
}
.row-menu-trigger {
  list-style: none;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 7px;
  width: 1.75rem;
  height: 1.55rem;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.row-menu-trigger::-webkit-details-marker {
  display: none;
}
.row-menu-list {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 260px;
  max-width: min(360px, calc(100vw - 20px));
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
  padding: 0.25rem;
  z-index: 200;
}
.row-menu-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #64748b;
  padding: 0.22rem 0.4rem 0.14rem;
}
.row-menu-divider {
  border-top: 1px solid #e2e8f0;
  margin: 0.24rem 0;
}
.row-menu-loading,
.row-menu-empty {
  font-size: 0.78rem;
  color: #475569;
  padding: 0.35rem 0.42rem;
}
.row-menu-item {
  display: block;
  width: 100%;
  min-width: 0;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 6px;
  padding: 0.34rem 0.4rem;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: normal;
}
.row-menu-item:hover {
  background: #eef2ff;
}
.row-menu-item.loading {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
}
.row-menu-item.loading::before {
  content: "";
  width: 0.76rem;
  height: 0.76rem;
  border: 2px solid #cbd5e1;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}
.row-menu-item:disabled {
  opacity: 0.72;
  cursor: wait;
}

.hle-dialog-body {
  width: min(860px, 95vw);
  max-height: 82vh;
  overflow: auto;
}
.hle-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.hle-dialog-header h3 {
  margin: 0;
}
.hle-dialog-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.hle-point {
  margin: 0;
  min-width: 0;
}
.hle-point-name {
  font-size: 0.83rem;
  color: #334155;
}
.hle-point-value {
  font-weight: 700;
}
.hle-point-updated {
  font-size: 0.81rem;
  color: #475569;
}
.hle-epic {
  border: 1px solid #dbe5f1;
  border-radius: 10px;
  padding: 0.7rem;
  margin-bottom: 0.65rem;
}
.hle-epic-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
  font-weight: 600;
}
.hle-epic .hle-point-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}
.hle-updated.stale {
  color: #b91c1c;
  font-weight: 700;
}
.stale-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.95rem;
  height: 0.95rem;
  margin-left: 0.2rem;
  border-radius: 999px;
  font-size: 0.72rem;
  color: #9f1239;
  background: #ffe4e6;
  border: 1px solid #fecdd3;
  position: relative;
  cursor: default;
}
.stale-icon:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 70;
  left: 50%;
  top: calc(100% + 6px);
  transform: translateX(-50%);
  white-space: nowrap;
  border-radius: 7px;
  padding: 0.33rem 0.42rem;
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #cbd5e1;
  font-size: 0.72rem;
  font-weight: 500;
}
.key-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: nowrap;
}
.key-link {
  color: #0f4c9a;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}
.key-link:hover { text-decoration: underline; }
.rsd-keys-wrap {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.2rem;
}
.rsd-key-entry {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.rsd-sep {
  color: #64748b;
  margin-right: 0.05rem;
}
.mini-copy-btn {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f8fafc;
  color: #334155;
  width: 1.45rem;
  height: 1.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}
.key-wrap:hover .mini-copy-btn,
.key-wrap:focus-within .mini-copy-btn,
.rsd-key-entry:hover .mini-copy-btn,
.rsd-key-entry:focus-within .mini-copy-btn {
  opacity: 1;
  pointer-events: auto;
}
.mini-copy-btn:hover { background: #eef2f7; }
.mini-copy-btn.copied {
  color: #0f766e;
  border-color: #99f6e4;
  background: #f0fdfa;
}
.req-date-edit-btn {
  border: 1px dashed #93c5fd;
  background: #eff6ff;
  color: #1e3a8a;
  border-radius: 7px;
  padding: 0.14rem 0.35rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.req-date-edit-btn:hover {
  background: #dbeafe;
}
.req-date-edit-btn.missing {
  border-style: solid;
  border-color: #cbd5e1;
  background: #f8fafc;
  color: #334155;
}
.req-status-dropdown {
  position: relative;
  display: inline-block;
}
.init-status-dropdown {
  position: relative;
  display: inline-block;
}
.init-status-trigger {
  list-style: none;
  display: inline-flex;
  align-items: center;
  position: relative;
  cursor: pointer;
  max-width: 100%;
  min-width: 0;
}
.init-status-trigger::-webkit-details-marker {
  display: none;
}
.init-status-trigger .status-chip {
  display: inline-flex;
  align-items: center;
  padding-right: 1.2rem;
  max-width: calc(100% - 0.1rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.init-status-caret {
  position: absolute;
  right: 0.2rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 5px;
  border: 1px solid #b7c7de;
  background: #f8fafc;
  color: #334155;
  font-size: 0.62rem;
}
.req-status-trigger {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  border: 1px solid #b7c7de;
  background: #e2e8f0;
  color: #334155;
  border-radius: 7px;
  padding: 0.06rem 0.2rem 0.06rem 0.3rem;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.15;
  cursor: pointer;
  max-width: 100%;
  min-width: 0;
}
.req-status-trigger::-webkit-details-marker {
  display: none;
}
.req-status-text {
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.req-status-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 5px;
  border: 1px solid #b7c7de;
  background: #f8fafc;
  font-size: 0.68rem;
}
.req-status-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 260px;
  max-width: min(360px, calc(100vw - 20px));
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
  padding: 0.25rem;
  z-index: 200;
}

#hleDialog {
  border: 1px solid var(--border);
  border-radius: 12px;
}
#hleDialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.option-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.25rem 0;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.8rem;
}
.dialog-actions button {
  border: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 8px;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
}

#lowDepDialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(760px, 95vw);
}
#lowDepDialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}
.lowdep-form {
  padding: 0.3rem 0.4rem;
}
.lowdep-form h3 {
  margin: 0.2rem 0 0.6rem;
}
.lowdep-form h4 {
  margin: 0 0 0.35rem;
}
.lowdep-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}
.lowdep-options {
  max-height: 240px;
  overflow: auto;
  border: 1px solid #dbe5f1;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
}
.lowdep-input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.7rem;
}
.lowdep-input-row input {
  width: 90px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0.3rem 0.45rem;
}

#teamDialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(540px, 95vw);
}
#teamDialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}
.team-form {
  padding: 0.3rem 0.4rem;
}
.team-form h3 {
  margin: 0.2rem 0 0.6rem;
}
.team-options {
  max-height: 260px;
  overflow: auto;
  border: 1px solid #dbe5f1;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
}
.team-search-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}
#teamMemberSearchInput {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.42rem 0.5rem;
}
.team-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.2rem 0;
  border-bottom: 1px solid #eef2f7;
}
.team-result-row:last-child {
  border-bottom: 0;
}
.team-result-text {
  font-size: 0.92rem;
  color: #1f2937;
}
.team-selected {
  margin-top: 0.35rem;
  min-height: 44px;
  max-height: 180px;
  overflow: auto;
  border: 1px solid #dbe5f1;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
}
.team-selected-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.2rem 0;
  border-bottom: 1px solid #eef2f7;
}
.team-selected-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.team-selected-permission {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #334155;
  font-size: 0.84rem;
  white-space: nowrap;
}
.team-selected-chip:last-child {
  border-bottom: 0;
}
.team-member-option {
  margin: 0.35rem 0;
}
.team-member-disabled {
  opacity: 0.65;
}

#reqDateDialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(340px, 92vw);
}
#reqDateDialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}
.reqdate-form {
  padding: 0.35rem 0.45rem;
}
.reqdate-form h3 {
  margin: 0.2rem 0 0.7rem;
}
#reqDateInput {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.42rem 0.5rem;
}
.reqdate-saving {
  margin-top: 0.45rem;
  font-size: 0.84rem;
  color: #334155;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.spinner {
  width: 0.86rem;
  height: 0.86rem;
  border: 2px solid #cbd5e1;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.undo-toast {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 140;
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 0.42rem;
  max-width: min(94vw, 220px);
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 0.34rem 0.48rem;
  box-shadow: 0 14px 28px rgba(2, 6, 23, 0.35);
  pointer-events: auto;
  transition: padding 180ms ease, gap 180ms ease, max-width 220ms ease, box-shadow 180ms ease;
}
.undo-toast.is-expanded {
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.7rem;
  max-width: min(96vw, 760px);
  padding: 0.55rem 0.72rem;
  box-shadow: 0 18px 34px rgba(2, 6, 23, 0.38);
}
.undo-toast.inactive {
  opacity: 0.88;
}
.undo-toast-details {
  display: inline-flex;
  flex-direction: column;
  gap: 0.16rem;
  width: 0;
  max-width: 0;
  max-height: 0;
  min-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: none;
  pointer-events: none;
  transition: width 220ms ease, max-width 220ms ease, max-height 200ms ease, opacity 170ms ease;
}
.undo-toast.is-expanded .undo-toast-details {
  width: min(72vw, 640px);
  max-width: min(72vw, 640px);
  max-height: 120px;
  opacity: 1;
  pointer-events: auto;
}
.undo-toast-preview {
  display: inline-flex;
  flex-direction: column;
  gap: 0.12rem;
}
.undo-preview-line {
  font-size: 0.76rem;
  color: #dbeafe;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.undo-toast-countdown {
  font-size: 0.8rem;
  color: #cbd5e1;
}
.undo-toast button {
  pointer-events: auto;
  border: 1px solid #93c5fd;
  background: #1d4ed8;
  color: #fff;
  border-radius: 7px;
  padding: 0.24rem 0.6rem;
  font-weight: 700;
  cursor: pointer;
}
#redoReorderBtn {
  border-color: #94a3b8;
  background: #334155;
}
.undo-toast button:disabled {
  opacity: 0.7;
  cursor: default;
}
.undo-toast button.busy:disabled {
  cursor: wait;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
    justify-items: start;
    gap: 0.5rem;
  }
  .topbar-subtitle-wrap {
    grid-column: 1;
    order: 2;
  }
  .topbar-brand {
    grid-column: 1;
    align-items: flex-start;
    order: 1;
  }
  .controls {
    grid-column: 1;
    justify-self: start;
    order: 3;
  }
  .user-context-switch {
    align-items: flex-start;
    flex-direction: column;
  }
  .user-context-switch select {
    min-width: 260px;
    max-width: 84vw;
  }
  .lowdep-grid { grid-template-columns: 1fr; }
  .hle-epic .hle-point-row { grid-template-columns: 1fr; }
  .undo-toast {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    justify-content: center;
  }
  .undo-toast.is-expanded .undo-toast-details {
    width: min(90vw, 640px);
    max-width: min(90vw, 640px);
    max-height: 160px;
  }
}
