:root {
  --bg: #0f1419;
  --bg-elevated: #171d25;
  --bg-soft: #1e2630;
  --border: #2a3441;
  --text: #e8eef6;
  --muted: #8b9aab;
  --accent: #3d9cf0;
  --accent-soft: rgba(61, 156, 240, 0.16);
  --danger: #e85d5d;
  --design: #5b8def;
  --eng: #3ecf8e;
  --product: #f0b429;
  --ops: #c084fc;
  --other: #94a3b8;
  --floor: #1a222c;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

#app {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100%;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 16px;
  background:
    linear-gradient(180deg, rgba(61, 156, 240, 0.06), transparent 180px),
    var(--bg-elevated);
  border-right: 1px solid var(--border);
  overflow: auto;
  z-index: 2;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 4px 8px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background:
    linear-gradient(135deg, #3d9cf0 0%, #1e5f9e 55%, #0f3a66 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 10px 8px 8px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 3px;
  border-top-width: 6px;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.panel {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.tool:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: #3a4656;
}

.tool.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #b8dbff;
}

.tool-icon {
  font-size: 1rem;
  line-height: 1;
  opacity: 0.9;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form.hidden,
.hidden {
  display: none !important;
}

.form label,
#employee-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.form input,
.form select,
#employee-form input,
#employee-form select {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

.form input:focus,
.form select:focus,
#employee-form input:focus,
#employee-form select:focus {
  outline: 2px solid rgba(61, 156, 240, 0.35);
  border-color: var(--accent);
}

.employee-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
}

.employee-list:empty::after {
  content: "Пока никого нет";
  color: var(--muted);
  font-size: 0.85rem;
}

.employee-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.employee-item:hover,
.employee-item.active {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #0b1220;
  flex-shrink: 0;
}

.employee-meta {
  min-width: 0;
}

.employee-meta strong {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.employee-meta span {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
  background: transparent;
  text-align: center;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.04);
}

.btn.primary {
  background: var(--accent);
  border-color: #2f8adf;
  color: #061018;
  font-weight: 600;
}

.btn.primary:hover {
  filter: brightness(1.05);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.02);
}

.file-btn {
  display: grid;
  place-items: center;
}

.viewport-wrap {
  position: relative;
  min-width: 0;
  background:
    radial-gradient(1200px 600px at 70% 20%, rgba(61, 156, 240, 0.08), transparent 60%),
    var(--bg);
}

#viewport {
  width: 100%;
  height: 100%;
  touch-action: none;
}

.hud {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 3;
}

.hud-left,
.hud-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.hud-right {
  pointer-events: auto;
}

.chip {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(15, 20, 25, 0.78);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  font-size: 0.8rem;
  font-weight: 500;
}

.chip.muted {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(15, 20, 25, 0.78);
  backdrop-filter: blur(10px);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
}

.icon-btn:hover {
  border-color: var(--accent);
  color: #b8dbff;
}

.help {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(15, 20, 25, 0.78);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
}

.tooltip {
  position: absolute;
  z-index: 4;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 20, 25, 0.92);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  pointer-events: none;
  min-width: 140px;
  max-width: 220px;
}

.tooltip strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.tooltip span {
  color: var(--muted);
  font-size: 0.78rem;
}

dialog {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0;
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow);
  width: min(360px, calc(100vw - 32px));
}

dialog::backdrop {
  background: rgba(4, 8, 14, 0.65);
  backdrop-filter: blur(4px);
}

#employee-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
}

#employee-form h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

@media (max-width: 900px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    max-height: 42vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .help {
    white-space: normal;
    text-align: center;
    max-width: calc(100% - 24px);
  }
}
